|
@@ -55,39 +55,32 @@ from (SELECT t1.promnum,
|
|
|
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)) )
|
|
|
- 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
|
|
|
- where siteid = $siteid$
|
|
|
- and sa_saleareaid in(select sa_saleareaid from sa_promotion_salearea where sa_promotionid=t1.sa_promotionid)
|
|
|
- union all
|
|
|
- select t2.sa_saleareaid
|
|
|
- from salearea t1
|
|
|
- inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid =$siteid$
|
|
|
-)
|
|
|
-select sa_saleareaid
|
|
|
-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
|
|
|
- where siteid = $siteid$
|
|
|
- and sa_saleareaid in(select sa_saleareaid from sa_promotion_salearea where sa_promotionid=t1.sa_promotionid)
|
|
|
- union all
|
|
|
- select t2.sa_saleareaid
|
|
|
- from salearea t1
|
|
|
- inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid =$siteid$
|
|
|
-)
|
|
|
-select sa_saleareaid
|
|
|
-from salearea)))
|
|
|
- AND not exists(select 1
|
|
|
+ and if(t2.islimit=1,t2.saledamount<t2.limitamount,1=1)) ),
|
|
|
+ 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$))
|
|
|
+ AND if(NOT EXISTS ( SELECT * FROM sa_promotion_salearea WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid),
|
|
|
+ NOT EXISTS ( SELECT * FROM sa_promotion_salearea WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid ),
|
|
|
+ t1.sa_promotionid in(select sa_promotionid from sa_promotion_salearea where sa_saleareaid in(WITH recursive salearea AS (
|
|
|
+ SELECT
|
|
|
+ sa_saleareaid,parentid
|
|
|
+ FROM
|
|
|
+ sa_salearea
|
|
|
+ WHERE
|
|
|
+ siteid = $siteid$
|
|
|
+ AND sa_saleareaid IN ( SELECT sa_saleareaid FROM sys_enterprise_tradefield WHERE sys_enterpriseid = $sys_enterpriseid$ ) UNION ALL
|
|
|
+ SELECT
|
|
|
+ t2.sa_saleareaid,t2.parentid
|
|
|
+ FROM
|
|
|
+ salearea t1
|
|
|
+ INNER JOIN sa_salearea t2 ON t1.parentid = t2.sa_saleareaid
|
|
|
+ AND t2.siteid = $siteid$
|
|
|
+ ) SELECT
|
|
|
+ sa_saleareaid
|
|
|
+ FROM
|
|
|
+ salearea))
|
|
|
+ )
|
|
|
) t
|
|
|
where $where$
|