Browse Source

促销订单新增是判断限量

hu 3 năm trước cách đây
mục cha
commit
f5df14ffee

+ 19 - 2
src/custom/restcontroller/webmanage/sale/order/OrderItems.java

@@ -88,6 +88,24 @@ public class OrderItems extends Controller {
                     }
                 }
             }
+            //商品信息
+            Row itemRow = getItemRow(itemid);
+            Rows promotionitems =dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='"+siteid+"' and sa_promotionid="+sa_promotionid);
+            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("itemid");
+            if(type.equals("促销订单")){
+                if(promotionitemsRowsMap.containsKey(itemid)){
+                    if(promotionitemsRowsMap.get(itemid).isNotEmpty()){
+                        BigDecimal saledqty =promotionitemsRowsMap.get(itemid).get(0).getBigDecimal("saledqty");
+                        BigDecimal groupqty =promotionitemsRowsMap.get(itemid).get(0).getBigDecimal("groupqty");
+                        boolean islimit =promotionitemsRowsMap.get(itemid).get(0).getBoolean("islimit");
+                        if(islimit){
+                            if(groupqty.compareTo(saledqty.add(qty))<0){
+                                return getErrReturnObject().setErrMsg(itemRow.getString("itemno")+"商品数量已超过促销活动的限定数量【"+groupqty.subtract(saledqty)+"】,无法新建").toString();
+                            }
+                        }
+            }
+                }
+            }
 
             BigDecimal price1=new BigDecimal(0);
             SQLFactory sqlFactory = new SQLFactory(this, "订单商品明细_新增");
@@ -111,8 +129,7 @@ public class OrderItems extends Controller {
             sqlFactory.addParameter("rowno", 1);
             sqlFactory.addParameter("itemid", itemid);
             sqlFactory.addParameter("remarks", item.getStringValue("remarks"));
-            //商品信息
-            Row itemRow = getItemRow(itemid);
+
             BigDecimal conversionrate = itemRow.getBigDecimal("conversionrate");
             if (conversionrate.compareTo(BigDecimal.ZERO) <= 0) {
                 conversionrate = BigDecimal.valueOf(1);