Prechádzať zdrojové kódy

促销方案优化(增加判断限购金额)

hu 2 rokov pred
rodič
commit
7a4803f400

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

@@ -51,7 +51,8 @@ from (SELECT t1.promnum,
                      from sa_promotion_auth t2
                      where t1.siteid = t2.siteid
                        and t1.sa_promotionid = t2.sa_promotionid
-                       and t2.sys_enterpriseid = $sys_enterpriseid$)
+                       and t2.sys_enterpriseid = $sys_enterpriseid$
+                       and t2.saledamount<t2.limitamount)
               OR NOT EXISTS(SELECT *
                             FROM sa_promotion_auth
                             WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid))

+ 26 - 0
src/custom/restcontroller/webmanage/sale/order/Order.java

@@ -1237,6 +1237,20 @@ public class Order extends Controller {
                     }
                 }
             }
+
+            //促销订单经销商限购金额判断
+            Rows promotion_auth = dbConnect.runSqlQuery(" select * from sa_promotion_auth where sys_enterpriseid="+sys_enterpriseid+" and sa_promotionid="+sa_promotionid);
+            if(promotion_auth.isNotEmpty()){
+                boolean islimit = promotion_auth.get(0).getBoolean("islimit");
+                BigDecimal limitamount = promotion_auth.get(0).getBigDecimal("limitamount");
+                BigDecimal saledamount = promotion_auth.get(0).getBigDecimal("saledamount");
+                if(islimit){
+                    if(amount.compareTo(limitamount.subtract(saledamount))>0){
+                        return getErrReturnObject().setErrMsg("已超过促销方案限定金额,无法提交").toString();
+                    }
+                    sqlList.add("update sa_promotion_auth set saledamount=saledamount+" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
+                }
+            }
         }
 
 
@@ -1703,6 +1717,18 @@ public class Order extends Controller {
                     }
                 }
             }
+
+            //促销订单经销商限购金额判断
+            Rows promotion_auth = dbConnect.runSqlQuery("select * from sa_promotion_auth where sys_enterpriseid="+sys_enterpriseid+" and sa_promotionid="+row.getLong("sa_promotionid"));
+            if(promotion_auth.isNotEmpty()){
+                boolean islimit = promotion_auth.get(0).getBoolean("islimit");
+                BigDecimal limitamount = promotion_auth.get(0).getBigDecimal("limitamount");
+                BigDecimal saledamount = promotion_auth.get(0).getBigDecimal("saledamount");
+                if(islimit){
+                    sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
+                }
+            }
+
         }
 
         SQLFactory sqlFactory = new SQLFactory(this, "订单_退回");