瀏覽代碼

订单表体添加商品增加spec字段

hu 2 年之前
父節點
當前提交
1c7dd043a4

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

@@ -98,10 +98,11 @@ public class OrderItems extends Controller {
 //            SQLFactory sqlFactory = new SQLFactory(this, "订单商品明细_新增");
             Boolean isInsert = true;
             JSONArray customproperties = new JSONArray();
+            String spec="";
             if (sa_orderitemsid <= 0) {
                 //获取定制属性
                 customproperties = orderItemsHelper.getCustomProperties(itemRowsMap, item);
-
+                spec=orderItemsHelper.getCustomSpec(itemRowsMap, item);
                 Rows rows = dbConnect.runSqlQuery("SELECT sa_orderitemsid,price from sa_orderitems WHERE siteid='" + siteid + "' and itemid=" + itemid + " and sa_orderid=" + sa_orderid);
 
                 if (rows.isEmpty()) {
@@ -147,7 +148,7 @@ public class OrderItems extends Controller {
                 return getErrReturnObject().setErrMsg("价格不可小于0").toString();
             }
             if (isInsert) {
-                sqlList.add(orderItemsHelper.getInsertSQL(customproperties, sa_orderitemsid, item, itemRow, type, defaultprice, price,saleprice, itemPrice.getMarketprice()).getSQL());
+                sqlList.add(orderItemsHelper.getInsertSQL(customproperties, sa_orderitemsid, item, itemRow, type, defaultprice, price,saleprice, itemPrice.getMarketprice(),spec).getSQL());
             } else {
                 sqlList.add(orderItemsHelper.getUpdateSQL(sa_orderitemsid, item, itemRow, type, defaultprice, price,saleprice).getSQL());
             }

+ 32 - 1
src/custom/restcontroller/webmanage/sale/order/OrderItemsHelper.java

@@ -127,6 +127,36 @@ public class OrderItemsHelper extends BaseClass {
         return customproperties;
     }
 
+    /**
+     * 获取定制尺寸信息
+     *
+     * @param itemRowsMap
+     * @param item
+     * @return
+     * @throws YosException
+     */
+    public String getCustomSpec(RowsMap itemRowsMap, JSONObject item) throws YosException {
+
+        String spec="";
+        Rows customschemeRows = dbConnect.runSqlQuery("select * from sa_customscheme_items where siteid='" + controller.siteid + "'");
+        RowsMap customschemeRowsMap = customschemeRows.toRowsMap("sa_customschemeid");
+
+        String itemid = item.getString("itemid");
+        if (itemRowsMap.containsKey(itemid)) {
+            if (itemRowsMap.get(itemid).isNotEmpty()) {
+                if (!itemRowsMap.get(itemid).get(0).getBoolean("iscustomsize")) {
+                    spec=itemRowsMap.get(itemid).get(0).getString("spec");
+                } else {
+                    spec=item.getStringValue("length") + "*" + item.getStringValue("width");
+                }
+
+            }
+
+        }
+
+        return spec;
+    }
+
     /**
      * 批量查询商品信息
      *
@@ -165,7 +195,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 saleprice, 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,String spec) throws YosException {
         Long itemid = item.getLong("itemid");
         BigDecimal qty = item.getBigDecimalValue("qty");
 
@@ -186,6 +216,7 @@ public class OrderItemsHelper extends BaseClass {
         insertSQL.setValue("stockno", item.getOrDefault("stockno", "null"));
         insertSQL.setValue("position", item.getOrDefault("position", "null"));
         insertSQL.setValue("batchno", item.getOrDefault("batchno", "null"));
+        insertSQL.setValue("spec",spec);
 
         String deliverydate = item.getStringValue("deliverydate");
         Rows rows = dbConnect.runSqlQuery("SELECT deliverydate,defaultprice from sa_orderitems WHERE sa_orderitemsid =" + sa_orderitemsid);