|
@@ -37,7 +37,6 @@ from (SELECT t1.promnum,
|
|
|
LEFT JOIN sa_accountclass t3 ON t1.sa_accountclassid = t3.sa_accountclassid
|
|
|
AND t1.siteid = t3.siteid
|
|
|
WHERE t1.siteid = $siteid$
|
|
|
- and t1.authmethod = 0
|
|
|
AND t1.STATUS = '发布'
|
|
|
AND DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') >= DATE_FORMAT(t1.begdate, '%Y-%m-%d %H:%i:%s')
|
|
|
AND DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') <= DATE_FORMAT(t1.enddate, '%Y-%m-%d %H:%i:%s')
|
|
@@ -46,7 +45,7 @@ from (SELECT t1.promnum,
|
|
|
where STATUS = '发布'
|
|
|
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 (
|
|
|
+ AND if(t1.authmethod=0,(
|
|
|
exists(select 1
|
|
|
from sa_promotion_auth t2
|
|
|
where t1.siteid = t2.siteid
|
|
@@ -69,57 +68,8 @@ with recursive salearea as (
|
|
|
)
|
|
|
select sa_saleareaid
|
|
|
from salearea))
|
|
|
-OR NOT EXISTS ( SELECT * FROM sa_promotion_salearea WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid ) )
|
|
|
-
|
|
|
- union all
|
|
|
- SELECT t1.promnum,
|
|
|
- t1.sa_promotionid,
|
|
|
- t1.promname,
|
|
|
- t1.remarks,
|
|
|
- t1.type,
|
|
|
- t1.sa_accountclassid,
|
|
|
- t1.sa_brandid,
|
|
|
- t1.tradefield,
|
|
|
- t1.orderminqty,
|
|
|
- t1.orderaddqty,
|
|
|
- t1.orderminamount,
|
|
|
- t1.isrelevancepromotion,
|
|
|
- t1.begdate,
|
|
|
- t1.enddate,
|
|
|
- t1.STATUS,
|
|
|
- t1.createuserid,
|
|
|
- t1.createby,
|
|
|
- t1.createdate,
|
|
|
- t1.checkby,
|
|
|
- t1.checkdate,
|
|
|
- t1.sendby,
|
|
|
- t1.senddate,
|
|
|
- t1.closeby,
|
|
|
- t1.closedate,
|
|
|
- t1.changeuserid,
|
|
|
- t1.changeby,
|
|
|
- t1.changedate,
|
|
|
- t1.sa_openpromotionid,
|
|
|
- t1.openamount,
|
|
|
- t2.brandname,
|
|
|
- t3.accountno,
|
|
|
- t3.accountname
|
|
|
- FROM sa_promotion t1
|
|
|
- LEFT JOIN sa_brand t2 ON t1.sa_brandid = t2.sa_brandid
|
|
|
- AND t1.siteid = t2.siteid
|
|
|
- LEFT JOIN sa_accountclass t3 ON t1.sa_accountclassid = t3.sa_accountclassid
|
|
|
- AND t1.siteid = t3.siteid
|
|
|
- WHERE t1.siteid = $siteid$
|
|
|
- and t1.authmethod = 1
|
|
|
- AND t1.STATUS = '发布'
|
|
|
- AND DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') >= DATE_FORMAT(t1.begdate, '%Y-%m-%d %H:%i:%s')
|
|
|
- AND DATE_FORMAT(now(), '%Y-%m-%d %H:%i:%s') <= DATE_FORMAT(t1.enddate, '%Y-%m-%d %H:%i:%s')
|
|
|
- and t1.sa_promotionid not in (select ifnull(sa_openpromotionid, 0)
|
|
|
- from sa_promotion
|
|
|
- where STATUS = '发布'
|
|
|
- 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 exists(select 1 from sys_enterprise_tradefield where sys_enterpriseid=$sys_enterpriseid$ and sa_saleareaid in(
|
|
|
+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(
|
|
|
with recursive salearea as (
|
|
|
select sa_saleareaid
|
|
|
from sa_salearea
|
|
@@ -131,10 +81,11 @@ with recursive salearea as (
|
|
|
inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid =$siteid$
|
|
|
)
|
|
|
select sa_saleareaid
|
|
|
-from salearea))
|
|
|
+from salearea)) OR NOT EXISTS ( SELECT * FROM sa_promotion_salearea WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid ))
|
|
|
AND not 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$)) t
|
|
|
+ and t2.sys_enterpriseid = $sys_enterpriseid$))
|
|
|
+ ) t
|
|
|
where $where$
|