Quellcode durchsuchen

促销方案授权范围bug修复

郭齐峰 vor 3 Jahren
Ursprung
Commit
198b5f603b

+ 111 - 49
src/custom/restcontroller/sale/promotion/SQL/促销方案列表查询.sql

@@ -1,49 +1,111 @@
-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.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 (
-		t1.sa_promotionid IN ( SELECT sa_promotionid FROM sa_promotion_auth WHERE sys_enterpriseid = $sys_enterpriseid$ ) 
-	OR NOT EXISTS ( SELECT * FROM sa_promotion_auth WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid )) 
-	AND $where$
+select t.*
+from (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 = 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')
+        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 sa_promotion_auth t2
+                     where t1.siteid = t2.siteid
+                       and t1.sa_promotionid = t2.sa_promotionid
+                       and t2.sys_enterpriseid = $sys_enterpriseid$)
+              OR NOT EXISTS(SELECT *
+                            FROM sa_promotion_auth
+                            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 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
+where $where$

+ 1 - 1
src/custom/restcontroller/webmanage/sale/promotion/promotion.java

@@ -343,7 +343,7 @@ public class promotion extends Controller {
     }
     }
 
 
     @API(title = "切换授权方式", apiversion = R.ID20230509100504.v1.class)
     @API(title = "切换授权方式", apiversion = R.ID20230509100504.v1.class)
-    @CACHEING_CLEAN(apiversions = {R.ID20221230144703.v1.class})
+    @CACHEING_CLEAN(apiversions = {R.ID20221230144703.v1.class, R.ID20220103140003.v1.class})
     public String updateAuthMethod() throws YosException {
     public String updateAuthMethod() throws YosException {
         Long sa_promotionid = content.getLong("sa_promotionid");
         Long sa_promotionid = content.getLong("sa_promotionid");
         Rows rows = dbConnect.runSqlQuery("select sa_promotionid,status,authmethod from sa_promotion where sa_promotionid ='" + sa_promotionid + "' and  siteid='" + siteid + "'");
         Rows rows = dbConnect.runSqlQuery("select sa_promotionid,status,authmethod from sa_promotion where sa_promotionid ='" + sa_promotionid + "' and  siteid='" + siteid + "'");