Преглед изворни кода

标准订单和促销订单提交时如果商品价格发生变化禁止提交

hu пре 2 година
родитељ
комит
eb9ddc50e4

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

@@ -8,6 +8,7 @@ import beans.dataextend.DataExtend;
 import beans.datateam.DataTeam;
 import beans.enterprise.Enterprise;
 import beans.hr.Hr;
+import beans.itemprice.ItemPrice;
 import beans.parameter.Parameter;
 import beans.remind.Remind;
 import beans.uploaderpdata.UploadDataToERP;
@@ -1272,6 +1273,19 @@ public class Order extends Controller {
             if (iteminfos.isNotEmpty()) {
                 return getErrReturnObject().setErrMsg("检测到品号" + iteminfos.get(0).getLong("itemno") + "未上架,请删除后重试").toString();
             }
+        }   //辅助类
+        OrderItemsHelper orderItemsHelper = new OrderItemsHelper(this);
+        if (type.equals("标准订单") || type.equals("促销订单")) {
+            Rows orderiteminfos = dbConnect.runSqlQuery("select t1.* from sa_orderitems t1  where t1.sa_orderid=" + sa_orderid + " and t1.siteid='" + siteid + "'");
+            for (Row row1:orderiteminfos) {
+                ItemPrice itemPrice = ItemPrice.getItemPrice(this, rows.get(0).getLong("sys_enterpriseid"), row1.getLong("itemid"));
+                if(row1.getBigDecimal("saleprice").compareTo(BigDecimal.ZERO)>0){
+                    if(orderItemsHelper.getSalePrice(rows.get(0), itemPrice).compareTo(row1.getBigDecimal("saleprice"))!=0){
+                        return getErrReturnObject().setErrMsg("商品:"+row1.getString("itemno")+"销售价格有更新,请删除后重新添加!").toString();
+                    }
+                }
+
+            }
         }
 
         //通过版本更新订单表头数据

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

@@ -128,14 +128,17 @@ public class OrderItems extends Controller {
 
             BigDecimal defaultprice;
             BigDecimal price;
+            BigDecimal saleprice;
             //价格
             ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, itemid);
             if (!item.containsKey("defaultprice")) {
                 defaultprice = orderItemsHelper.getDefaultprice(itemPrice);
                 price = orderItemsHelper.getPrice(orderRows.get(0), itemPrice, item, itemRowsMap);
+                saleprice= orderItemsHelper.getSalePrice(orderRows.get(0), itemPrice);
             } else {
                 defaultprice = item.getBigDecimalValue("defaultprice");
                 price = item.getBigDecimalValue("price");
+                saleprice= orderItemsHelper.getSalePrice(orderRows.get(0), itemPrice);
                 if (price.compareTo(price1) != 0) {
                     sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单商品【" + itemRow.getString("itemname") + "】由单价:" + price1 + "修改为单价:" + price, "订单修改单价").getSQL());
                 }
@@ -144,9 +147,9 @@ public class OrderItems extends Controller {
                 return getErrReturnObject().setErrMsg("价格不可小于0").toString();
             }
             if (isInsert) {
-                sqlList.add(orderItemsHelper.getInsertSQL(customproperties, sa_orderitemsid, item, itemRow, type, defaultprice, price, itemPrice.getMarketprice()).getSQL());
+                sqlList.add(orderItemsHelper.getInsertSQL(customproperties, sa_orderitemsid, item, itemRow, type, defaultprice, price,saleprice, itemPrice.getMarketprice()).getSQL());
             } else {
-                sqlList.add(orderItemsHelper.getUpdateSQL(sa_orderitemsid, item, itemRow, type, defaultprice, price).getSQL());
+                sqlList.add(orderItemsHelper.getUpdateSQL(sa_orderitemsid, item, itemRow, type, defaultprice, price,saleprice).getSQL());
             }
 
 

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

@@ -165,7 +165,7 @@ public class OrderItemsHelper extends BaseClass {
 
     String sa_orderitems = "sa_orderitems";
 
-    public InsertSQL getInsertSQL(JSONArray customproperties, long sa_orderitemsid, JSONObject item, Row itemRow, String type, BigDecimal defaultprice, BigDecimal price, BigDecimal marketprice) throws YosException {
+    public InsertSQL getInsertSQL(JSONArray customproperties, long sa_orderitemsid, JSONObject item, Row itemRow, String type, BigDecimal defaultprice, BigDecimal price,BigDecimal saleprice, BigDecimal marketprice) throws YosException {
         Long itemid = item.getLong("itemid");
         BigDecimal qty = item.getBigDecimalValue("qty");
 
@@ -236,6 +236,8 @@ public class OrderItemsHelper extends BaseClass {
         }
         //单价,折后价(元),取合同价
         insertSQL.setValue("defaultprice", defaultprice);
+        insertSQL.setValue("saleprice", saleprice);
+
         //金额,折后金额(元)
         insertSQL.setValue("defaultamount", defaultprice.multiply(qty));
         //牌价、市场价(元),标准订单牌价取商品价格,项目订单取合同里的牌价
@@ -244,7 +246,7 @@ public class OrderItemsHelper extends BaseClass {
         return insertSQL;
     }
 
-    public UpdateSQL getUpdateSQL(long sa_orderitemsid, JSONObject item, Row itemRow, String type, BigDecimal defaultprice, BigDecimal price) throws YosException {
+    public UpdateSQL getUpdateSQL(long sa_orderitemsid, JSONObject item, Row itemRow, String type, BigDecimal defaultprice, BigDecimal price,BigDecimal saleprice) throws YosException {
         BigDecimal qty = item.getBigDecimalValue("qty");
 
         UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, sa_orderitems);
@@ -305,7 +307,7 @@ public class OrderItemsHelper extends BaseClass {
         updateSQL.setValue("defaultprice", defaultprice);
         //金额,折后金额(元)
         updateSQL.setValue("defaultamount", defaultprice.multiply(qty));
-
+        updateSQL.setValue("saleprice", saleprice);
 
         updateSQL.setWhere("siteid", controller.siteid);
         updateSQL.setWhere("sa_orderitemsid", sa_orderitemsid);
@@ -348,6 +350,19 @@ public class OrderItemsHelper extends BaseClass {
 
         return price;
     }
+    public BigDecimal getSalePrice(Row orderRow, ItemPrice itemPrice) throws YosException {
+        String type = orderRow.getString("type");
+        Long sa_promotionid = orderRow.getLong("sa_promotionid");
+        BigDecimal price;
+        switch (type) {
+            case "促销订单":
+                price = itemPrice.getPromotionPrice(sa_promotionid);
+                break;
+            default:
+                price = itemPrice.getGraderateprice();
+        }
 
+        return price;
+    }
 
 }