Browse Source

Merge remote-tracking branch 'origin/develop' into develop-green

eganwu 2 years ago
parent
commit
d7fb068cbe

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

@@ -254,6 +254,7 @@ public class Order extends Controller {
         Long istool = content.getLongValue("istool");
         Long sa_brandid = 0L;
         String tradefield = content.getString("tradefield");
+        Long sa_promotionid = content.getLongValue("sa_promotionid");
 
         JSONArray items = content.getJSONArray("items");
         ArrayList<Long> itemidids = new ArrayList();
@@ -263,10 +264,10 @@ public class Order extends Controller {
         //判断是否是同一个品牌的商品
         for (Object obj : items) {
             JSONObject item = (JSONObject) obj;
-            if(type.equals("促销订单")) {
-                orderItemsHelper.checkOffOrderItems("sa_promotion_items", item.getLongValue("itemid"));
-            }else {
-                orderItemsHelper.checkOffOrderItems("plm_item", item.getLongValue("itemid"));
+            if (type.equals("促销订单")) {
+                orderItemsHelper.checkOffOrderItems("sa_promotion_items", item.getLongValue("itemid"),sa_promotionid);
+            } else {
+                orderItemsHelper.checkOffOrderItems("plm_item", item.getLongValue("itemid"),sa_promotionid);
             }
 
             Long temp_sa_brandid = item.getLongValue("sa_brandid");
@@ -1420,7 +1421,7 @@ public class Order extends Controller {
             return getErrReturnObject().setErrMsg("订单表体不存在商品无法提交").toString();
         }
         String type = row.getString("type");
-        if(type.equals("标准订单")||type.equals("促销订单")) {
+        if (type.equals("标准订单") || type.equals("促销订单")) {
             if (dbConnect.runSqlQuery("select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "' and  (price<=0 or amount<=0 or qty<=0)").isNotEmpty()) {
                 return getErrReturnObject().setErrMsg("商品单价或金额禁止小于等于0").toString();
             }
@@ -1433,12 +1434,12 @@ public class Order extends Controller {
 
         //标准订单:提交时商品必须是上架状态,否则不允许提交
         if (type.equals("标准订单")) {
-            orderItemsHelper.checkOffOrderItems(sa_orderid, "plm_item");
+            orderItemsHelper.checkOffOrderItems(sa_orderid, "plm_item", sa_promotionid);
         }
         //促销订单:提交时商品必须是上架状态,并且活动方案中的商品必须也是上架状态,否则不允许提交
         if (type.equals("促销订单")) {
 //            orderItemsHelper.checkOffOrderItems(sa_orderid, "plm_item");
-            orderItemsHelper.checkOffOrderItems(sa_orderid, "sa_promotion_items");
+            orderItemsHelper.checkOffOrderItems(sa_orderid, "sa_promotion_items",sa_promotionid);
         }
 
         if (type.equals("标准订单") || type.equals("促销订单")) {

+ 14 - 5
src/custom/restcontroller/webmanage/sale/order/OrderItemsHelper.java

@@ -267,17 +267,26 @@ public class OrderItemsHelper extends BaseClass {
     }
 
 
-    public void checkOffOrderItems(Long sa_orderid, String tablename) throws YosException {
-        Rows iteminfos = dbConnect.runSqlQuery("select t2.itemid from sa_orderitems t1 inner join " + tablename + " t2 on t1.siteid=t2.siteid and t1.itemid=t2.itemid where t1.sa_orderid="
-                + sa_orderid + " and t1.siteid='" + controller.siteid + "' and t2.isonsale!=1");
+    public void checkOffOrderItems(Long sa_orderid, String tablename, Long sa_promotionid) throws YosException {
+        String sql = "select t2.itemid from sa_orderitems t1 inner join " + tablename + " t2 on t1.siteid=t2.siteid and t1.itemid=t2.itemid where t1.sa_orderid="
+                + sa_orderid + " and t1.siteid='" + controller.siteid + "' and t2.isonsale!=1";
+        if (tablename.equals("sa_promotion_items")) {
+            sql = sql + " and t2.sa_promotionid=" + sa_promotionid;
+        }
+
+        Rows iteminfos = dbConnect.runSqlQuery(sql);
         if (iteminfos.isNotEmpty()) {
             Row itemRow = dbConnect.runSqlQuery(0, "SELECT itemno from plm_item WHERE itemid=" + iteminfos.get(0).getString("itemid"));
             throw new YosException(false, "检测到品号" + itemRow.getString("itemno") + "未上架,请删除后重试");
         }
     }
 
-    public void checkOffOrderItems(String tablename, Long itemid) throws YosException {
-        Rows iteminfos = dbConnect.runSqlQuery("select t1.itemid from " + tablename + " t1  where t1.siteid='" + controller.siteid + "' and t1.isonsale!=1 and t1.itemid=" + itemid);
+    public void checkOffOrderItems(String tablename, Long itemid, Long sa_promotionid) throws YosException {
+        String sql = "select t1.itemid from " + tablename + " t1  where t1.siteid='" + controller.siteid + "' and t1.isonsale!=1 and t1.itemid=" + itemid;
+        if (tablename.equals("sa_promotion_items")) {
+            sql = sql + " and t1.sa_promotionid=" + sa_promotionid;
+        }
+        Rows iteminfos = dbConnect.runSqlQuery(sql);
         if (iteminfos.isNotEmpty()) {
             Row itemRow = dbConnect.runSqlQuery(0, "SELECT itemno from plm_item WHERE itemid=" + iteminfos.get(0).getString("itemid"));
             throw new YosException(false, "检测到品号" + itemRow.getString("itemno") + "未上架,请删除后重试");