Version 15 (modified by grzesiek, 11 years ago) |
---|
Procedura zmiany daty lub godziny wydania gazety
Definicje:
$regularIssueDate - normalna data zamknięcia wydania (2.03.2013 17:00 wt) $changeIssueDate - zmieniona data wydania (1.03.2013 17:00 pon) $nextIssueDate - data kolejnego poprawnego wydania (9.03.2013 17:00 wt)
Należy znaleźć:
1. Ogłoszenia które normalnie wygasną przed 17:00, we wtorek - one nie powinny iść do tego poniedziałkowego wydania
select * from ads where enddate > '$changeIssueDate' and enddate < '$regularIssueDate ' and status = 1 and magazinepromotion > 0
Te ogłoszenia wyłączamy
2. Ogłoszenia które normalnie wygasną przed 17:00 we wtorek ale mają przedłużenia - one powinny pójść
select * from orderitems i join orders o on o.id = i.orderid where productid in ( select id from ads where enddate > '$changeIssueDate' and enddate < '$regularIssueDate' and status = 1 ) and i.startdate >= '$regularIssueDate' and i.magazinepromotion > 0 and o.status <> 4
Należy aktywować przedłużenia, a więc w OrderItems? odpowiednio zmodyfikować start oraz end date i uruchomić na team city task activate.
3. Ogłoszenia, które nie są aktywne w poniedziałek, ale włączą się jeszcze przed 17:00 we wtorek.
select * from orderitems i join orders o on o.id = i.orderid where o.status <> 4 and i.startdate >= '$changeIssueDate' and startdate < '$regularIssueDate' and subscriptionpromotion is null and i.magazinepromotion > 0
Należy aktywować ogłoszenia, a więc w OrderItems? odpowiednio zmodyfikować start oraz end date i uruchomić na team city task activate.
4. Należy pamiętać aby przesunąć zamówienia abonamentowe z poprzedniego tygodnia, tak aby utworzyły się zamówienia bieżące.
5. Ogłoszenia zamieszczone między $changeIssueDate a $regularIssueDate należy przedłużyć.
select * from ads where status = 1 and magazinepromotion > 0 and startdate > $changeIssueDate and startdate < $regularIssueDate
Krótkie wyjaśnienie: zamykamy wydanie w poniedziałek 1 marca o 17:00, klient zamieszcza ogłoszenie 2 marca na jedna emisje (wtorek) o 9:00 (to ogłoszenie wygaśnie 9 marca o 9:00), a powinno pojść do gazety 9 marca 17:00.
DECLARE @regularIssueDate DATETIME SET @regularIssueDate = '2013-12-24 17:00'
DECLARE @changeIssueDate DATETIME SET @changeIssueDate = '2013-12-20 16:00'
declare @ads as table (adid integer) declare @ads2 as table (adid integer, orderitemId integer)
Ogłoszenia które normalnie wygasną przed 17:00 we wtorek ale mają przedłużenia - one powinny pójść
insert into @ads select productid from orderitems i join orders o on o.id = i.orderid where productid in (
select id from ads where enddate > @changeIssueDate and enddate < @regularIssueDate and status = 1
) and i.startdate >= @changeIssueDate and i.startdate < @regularIssueDate and i.magazinepromotion > 0 and o.status <> 4
Ogłoszenia które maja start miedzy zmieniona data wydania a stara 17:00 we wtorek - one powinny pójść
insert into @ads2 select productid, i.id from orderitems i join orders o on o.id = i.orderid where o.status <> 4 and i.startdate >= @changeIssueDate and startdate < @regularIssueDate and subscriptionpromotion is null and i.magazinepromotion > 0
select * from @ads
select * from @ads2
Ogłoszenia które normalnie wygasną przed 17:00, we wtorek - one nie powinny iść do tego poniedziałkowego wydania
select currentorderitem as oi, customerid as cid , * from ads where enddate > @changeIssueDate and enddate < @regularIssueDate and status = 1 and magazinepromotion > 0 and (id not in (select adid from @ads) or id not in (select adid from @ads2)) order by currentorderitem desc
Edycja ogloszen - wstrzymanie ogloszen ktore wygasna przed stara data wydania - wykluczajac przedluzenia i te rozpoczynajace sie miedzy pon a wtorkiem
update ads set status=5 where enddate > @changeIssueDate and enddate < @regularIssueDate and status = 1 and magazinepromotion > 0 and (id not in (select adid from @ads) or id not in (select adid from @ads2))
select * from ads where status=5
update ads set status=1 where status=5