Просмотр исходного кода

促销方案可购金额扣减小于0时置为0

hu 6 месяцев назад
Родитель
Сommit
22a95d149f
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      src/custom/restcontroller/webmanage/sale/order/Order.java

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

@@ -2321,7 +2321,7 @@ public class Order extends Controller {
                 Rows promotion = dbConnect.runSqlQuery("select * from sa_promotion where siteid='" + siteid + "'and  sa_promotionid=" + sa_promotionid);
                 if (islimit) {
                     if (promotion.isNotEmpty()) {
-                        sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
+                        sqlList.add("update sa_promotion_auth set saledamount=GREATEST(saledamount-" + amount + ",0) where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
                     }
 
                 }
@@ -3624,7 +3624,7 @@ public class Order extends Controller {
                 JSONObject cashbillPay = Accountbalance.createCashbillPay2(this, sys_enterpriseid, orderaccountclassinfo.getLongValue("sa_accountclassid"), entity, true);
                 sqlList.addAll(cashbillPay.getJSONArray("sqlList").toJavaList(String.class));
                 sa_cashbillidList.add(cashbillPay.getLong("sa_cashbillid"));
-                sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + totalprice + " where sa_promotion_authid=" + sa_promotion_authid);
+                sqlList.add("update sa_promotion_auth set saledamount=GREATEST(saledamount-" + totalprice + ",0) where sa_promotion_authid=" + sa_promotion_authid);
             } else if (amount_orderaccount.compareTo(totalprice) < 0) {
                 System.out.println("222");
                 CashbillEntity entity = new CashbillEntity();
@@ -3640,7 +3640,7 @@ public class Order extends Controller {
                 sqlList.addAll(cashbillPay.getJSONArray("sqlList").toJavaList(String.class));
                 sa_cashbillidList.add(cashbillPay.getLong("sa_cashbillid"));
 
-                sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + amount_orderaccount + " where sa_promotion_authid=" + sa_promotion_authid);
+                sqlList.add("update sa_promotion_auth set saledamount=GREATEST(saledamount-" + amount_orderaccount + ",0) where sa_promotion_authid=" + sa_promotion_authid);
 
                 CashbillEntity promotionentity = new CashbillEntity();
                 promotionentity.setAmount((totalprice.subtract(amount_orderaccount)).negate());