|
|
@@ -1882,10 +1882,20 @@ 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");
|
|
|
+// BigDecimal limitamount = promotion_auth.get(0).getBigDecimal("limitamount");
|
|
|
+// BigDecimal saledamount = promotion_auth.get(0).getBigDecimal("saledamount");
|
|
|
+ long sa_promotionid =promotion_auth.get(0).getLong("sa_promotionid");
|
|
|
+ Rows promotion = dbConnect.runSqlQuery("select * from sa_promotion where siteid='" + siteid + "'and sa_promotionid=" + sa_promotionid);
|
|
|
if (islimit) {
|
|
|
- sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
+ if(promotion.isNotEmpty()){
|
|
|
+ Rows amountrows = dbConnect.runSqlQuery("select sum(amount) amount from sa_cashbill where ownerid='"+sa_orderid+"' and ownertable='sa_order' and sa_accountclassid="+promotion.get(0).getLong("sa_accountclassid")) ;
|
|
|
+ if(amountrows.isNotEmpty()){
|
|
|
+ if(amountrows.get(0).getBigDecimal("amount").compareTo(BigDecimal.ZERO)>0){
|
|
|
+ sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + amountrows.get(0).getBigDecimal("amount") + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|