Browse Source

新增订单添加时数量为0的提示

eganwu 1 year ago
parent
commit
6865f35bb6

+ 6 - 2
src/custom/restcontroller/webmanage/sale/order/OrderItemsHelper.java

@@ -340,10 +340,15 @@ public class OrderItemsHelper extends BaseClass {
     public void compareQty(String type, RowsMap itemRowsMap, JSONObject item, Row itemRow, Rows promotionitems) throws YosException {
         BigDecimal qty = item.getBigDecimalValue("qty");
         String itemid = item.getString("itemid");
+        Rows itemRows = itemRowsMap.getOrDefault(itemid, new Rows());
+        if(qty.compareTo(BigDecimal.ZERO)==0){
+            throw new YosException(false, "品号为" + itemRows.get(0).getString("itemno") + "的商品的添加数量为0,不允许添加");
+        }
+
         if (!type.equals("促销订单")) {
             if (!type.equals("特殊订单")) {
                 if (itemRowsMap.containsKey(itemid)) {
-                    Rows itemRows = itemRowsMap.getOrDefault(itemid, new Rows());
+
                     if (itemRows.isNotEmpty()) {
                         BigDecimal orderaddqty = itemRows.get(0).getBigDecimal("orderaddqty");
                         BigDecimal orderminqty = itemRows.get(0).getBigDecimal("orderminqty");
@@ -355,7 +360,6 @@ public class OrderItemsHelper extends BaseClass {
                     }
                 }
             } else {
-                Rows itemRows = itemRowsMap.getOrDefault(itemid, new Rows());
                 if (qty.compareTo(BigDecimal.ZERO) <= 0) {
                     throw new YosException(false, "品号为" + itemRows.get(0).getString("itemno") + "的商品数量必须大于0");
                 }