|
@@ -46,16 +46,19 @@ from (SELECT t1.promnum,
|
|
|
AND DATE_FORMAT(now(), '%Y-%m-%d') >= DATE_FORMAT(t1.begdate, '%Y-%m-%d')
|
|
|
AND DATE_FORMAT(now(), '%Y-%m-%d') <= DATE_FORMAT(t1.enddate, '%Y-%m-%d'))
|
|
|
AND if(t1.authmethod=0,(
|
|
|
+ NOT EXISTS(SELECT *
|
|
|
+ FROM sa_promotion_auth
|
|
|
+ WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid)
|
|
|
+ or
|
|
|
exists(select 1
|
|
|
from sa_promotion_auth t2
|
|
|
where t1.siteid = t2.siteid
|
|
|
and t1.sa_promotionid = t2.sa_promotionid
|
|
|
and t2.sys_enterpriseid = $sys_enterpriseid$
|
|
|
- and if(t2.islimit=1,t2.saledamount<t2.limitamount,1=1))
|
|
|
- OR NOT EXISTS(SELECT *
|
|
|
- FROM sa_promotion_auth
|
|
|
- WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid))
|
|
|
- AND (exists(select 1 from sys_enterprise_tradefield where sys_enterpriseid=$sys_enterpriseid$ and sa_saleareaid in(
|
|
|
+ and if(t2.islimit=1,t2.saledamount<t2.limitamount,1=1)) )
|
|
|
+ AND (NOT EXISTS ( SELECT * FROM sa_promotion_salearea WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid )
|
|
|
+ OR
|
|
|
+ exists(select 1 from sys_enterprise_tradefield where sys_enterpriseid=$sys_enterpriseid$ and sa_saleareaid in(
|
|
|
with recursive salearea as (
|
|
|
select sa_saleareaid
|
|
|
from sa_salearea
|
|
@@ -67,9 +70,8 @@ with recursive salearea as (
|
|
|
inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid =$siteid$
|
|
|
)
|
|
|
select sa_saleareaid
|
|
|
-from salearea))
|
|
|
-OR NOT EXISTS ( SELECT * FROM sa_promotion_salearea WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid ) ),
|
|
|
- (exists(select 1 from sys_enterprise_tradefield where sys_enterpriseid=$sys_enterpriseid$ and sa_saleareaid in(
|
|
|
+from salearea)) ),
|
|
|
+ ( NOT EXISTS ( SELECT * FROM sa_promotion_salearea WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid ) or exists(select 1 from sys_enterprise_tradefield where sys_enterpriseid=$sys_enterpriseid$ and sa_saleareaid in(
|
|
|
with recursive salearea as (
|
|
|
select sa_saleareaid
|
|
|
from sa_salearea
|
|
@@ -81,7 +83,7 @@ with recursive salearea as (
|
|
|
inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid =$siteid$
|
|
|
)
|
|
|
select sa_saleareaid
|
|
|
-from salearea)) OR NOT EXISTS ( SELECT * FROM sa_promotion_salearea WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid ))
|
|
|
+from salearea)))
|
|
|
AND not exists(select 1
|
|
|
from sa_promotion_auth t2
|
|
|
where t1.siteid = t2.siteid
|