Browse Source

购物车返回isselect:true

eganwu 1 year ago
parent
commit
ff48c383a5
1 changed files with 29 additions and 28 deletions
  1. 29 28
      src/custom/restcontroller/sale/shoppingcart/ShoppingCart.java

+ 29 - 28
src/custom/restcontroller/sale/shoppingcart/ShoppingCart.java

@@ -41,16 +41,16 @@ public class ShoppingCart extends Controller {
         BigDecimal width = content.getBigDecimal("width");
         String itemno = content.getString("itemno");
         String tradefield = content.getStringValue("tradefield");
-        long sa_promotionid =content.getLongValue("sa_promotionid");
-        long sa_promotion_itemsid =content.getLongValue("sa_promotion_itemsid");
+        long sa_promotionid = content.getLongValue("sa_promotionid");
+        long sa_promotion_itemsid = content.getLongValue("sa_promotion_itemsid");
         SQLFactory sqlFactory = new SQLFactory(this, "购物车新增");
         Long sa_shoppingcartid = 0L;
         Rows rows = dbConnect.runSqlQuery("SELECT sa_shoppingcartid FROM sa_shoppingcart WHERE siteid = '" + siteid +
                 "' AND sa_brandid = " + sa_brandid +
-                " and length="+length+" and width="+width+" AND itemid = " + itemid +
+                " and length=" + length + " and width=" + width + " AND itemid = " + itemid +
                 " AND sys_enterpriseid = " + sys_enterpriseid +
                 " AND tradefield = '" + tradefield +
-                "' AND itemno = '" + itemno + "' and sa_promotionid="+sa_promotionid);
+                "' AND itemno = '" + itemno + "' and sa_promotionid=" + sa_promotionid);
         if (rows.isNotEmpty()) {
             sa_shoppingcartid = rows.get(0).getLong("sa_shoppingcartid");
         }
@@ -91,12 +91,12 @@ public class ShoppingCart extends Controller {
     @API(title = "(批量新增)", apiversion = R.ID20231024110003.v1.class)
     @CACHEING_CLEAN(apiversions = {R.ID20220924095302.class})
     public String insert() throws YosException {
-        JSONArray items =content.getJSONArray("items");
+        JSONArray items = content.getJSONArray("items");
         ArrayList<String> sqlList = new ArrayList<>();
-         //System.out.println(111111);
-        for (Object object:items) {
+        //System.out.println(111111);
+        for (Object object : items) {
             //System.out.println(object.toString());
-            JSONObject item = (JSONObject)object;
+            JSONObject item = (JSONObject) object;
             Long sa_brandid = item.getLongValue("sa_brandid");
             Long itemid = item.getLong("itemid");
             BigDecimal qty = item.getBigDecimal("qty");
@@ -104,22 +104,21 @@ public class ShoppingCart extends Controller {
             BigDecimal width = item.getBigDecimal("width");
             String itemno = item.getString("itemno");
             String tradefield = item.getStringValue("tradefield");
-            long sa_promotionid =item.getLongValue("sa_promotionid");
-            long sa_promotion_itemsid =item.getLongValue("sa_promotion_itemsid");
+            long sa_promotionid = item.getLongValue("sa_promotionid");
+            long sa_promotion_itemsid = item.getLongValue("sa_promotion_itemsid");
             SQLFactory sqlFactory = new SQLFactory(this, "购物车新增");
             Long sa_shoppingcartid = 0L;
             Rows rows = dbConnect.runSqlQuery("SELECT sa_shoppingcartid FROM sa_shoppingcart WHERE siteid = '" + siteid +
                     "' AND sa_brandid = " + sa_brandid +
-                    " and length="+length+" and width="+width+" AND itemid = " + itemid +
+                    " and length=" + length + " and width=" + width + " AND itemid = " + itemid +
                     " AND sys_enterpriseid = " + sys_enterpriseid +
                     " AND tradefield = '" + tradefield +
-                    "' AND itemno = '" + itemno + "' and sa_promotionid="+sa_promotionid);
+                    "' AND itemno = '" + itemno + "' and sa_promotionid=" + sa_promotionid);
             if (rows.isNotEmpty()) {
                 sa_shoppingcartid = rows.get(0).getLong("sa_shoppingcartid");
             }
 
 
-
             if (sa_shoppingcartid <= 0) {
                 sa_shoppingcartid = createTableID("sa_shoppingcart");
                 sqlList.add(DataContrlLog.createLog(this, "sa_shoppingcart", sa_shoppingcartid, "新增", "购物车新增" + sa_shoppingcartid).getSQL());
@@ -154,7 +153,7 @@ public class ShoppingCart extends Controller {
     @CACHEING_CLEAN(apiversions = {R.ID20220924095302.class})
     public String updateQty() throws YosException {
         Long sa_shoppingcartid = content.getLong("sa_shoppingcartid");
-        BigDecimal qty = content.getBigDecimalValue("qty",1);
+        BigDecimal qty = content.getBigDecimalValue("qty", 1);
         BigDecimal length = content.getBigDecimalValue("length");
         BigDecimal width = content.getBigDecimalValue("width");
         ArrayList<String> sqlList = new ArrayList<>();
@@ -240,8 +239,8 @@ public class ShoppingCart extends Controller {
         //商品领域
         RowsMap tradefieldRowsMap = beans.Item.Item.getTradefieldRowsMap(this, ids);
 
-        Rows promotionItemsRows = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='"+siteid+"' and sa_promotionid="+content.getLongValue("sa_promotionid"));
-        RowsMap promotionItemsRowsMap =promotionItemsRows.toRowsMap("itemid");
+        Rows promotionItemsRows = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + content.getLongValue("sa_promotionid"));
+        RowsMap promotionItemsRowsMap = promotionItemsRows.toRowsMap("itemid");
 
         Rows sizecustomizedschemes = dbConnect.runSqlQuery("select * from sa_sizecustomizedscheme where siteid='" + siteid + "' ");
         RowsMap sizecustomizedschemesRowsMap = sizecustomizedschemes.toRowsMap("sa_sizecustomizedschemeid");
@@ -257,25 +256,25 @@ public class ShoppingCart extends Controller {
             }
             try {
                 ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, row.getLong("itemid"));
-                row.put("oldprice",  istool == 0 ?itemPrice.getContractprice():itemPrice.getMarketprice());
-                if(content.getLongValue("sa_promotionid")>0){
+                row.put("oldprice", istool == 0 ? itemPrice.getContractprice() : itemPrice.getMarketprice());
+                if (content.getLongValue("sa_promotionid") > 0) {
 
-                    if(promotionItemsRowsMap.containsKey(row.getString("itemid"))){
-                        if(promotionItemsRowsMap.get(row.getString("itemid")).isNotEmpty()){
-                            row.put("orderminqty",promotionItemsRowsMap.get(row.getString("itemid")).get(0).getBigDecimal("orderminqty"));
-                            row.put("orderaddqty",promotionItemsRowsMap.get(row.getString("itemid")).get(0).getBigDecimal("orderaddqty"));
+                    if (promotionItemsRowsMap.containsKey(row.getString("itemid"))) {
+                        if (promotionItemsRowsMap.get(row.getString("itemid")).isNotEmpty()) {
+                            row.put("orderminqty", promotionItemsRowsMap.get(row.getString("itemid")).get(0).getBigDecimal("orderminqty"));
+                            row.put("orderaddqty", promotionItemsRowsMap.get(row.getString("itemid")).get(0).getBigDecimal("orderaddqty"));
                         }
 
                     }
-                    if(row.getBoolean("iscustomsize") && row.getLong("pricingmetod")==1){
+                    if (row.getBoolean("iscustomsize") && row.getLong("pricingmetod") == 1) {
                         row.put("gradeprice", itemPrice.getPromotionPrice(content.getLongValue("sa_promotionid")).multiply(row.getBigDecimal("length").multiply(row.getBigDecimal("width")).divide(new BigDecimal("1000000"), 4, BigDecimal.ROUND_HALF_UP)));
-                    }else{
+                    } else {
                         row.put("gradeprice", itemPrice.getPromotionPrice(content.getLongValue("sa_promotionid")));
                     }
-                }else{
-                    if(row.getBoolean("iscustomsize") && row.getLong("pricingmetod")==1){
+                } else {
+                    if (row.getBoolean("iscustomsize") && row.getLong("pricingmetod") == 1) {
                         row.put("gradeprice", itemPrice.getContractprice().multiply(row.getBigDecimal("length").multiply(row.getBigDecimal("width")).divide(new BigDecimal("1000000"), 4, BigDecimal.ROUND_HALF_UP)));
-                    }else{
+                    } else {
                         row.put("gradeprice", itemPrice.getContractprice());
                     }
                 }
@@ -372,6 +371,8 @@ public class ShoppingCart extends Controller {
             } else {
                 row.put("cheekschemedetails", new JSONArray());
             }
+
+            row.put("isselect", true);
         }
 //        if (isExport) {
 //            //去除不需要导出项
@@ -407,7 +408,7 @@ public class ShoppingCart extends Controller {
     @API(title = "购物车数量", apiversion = R.ID20220927093202.v1.class)
     public String getNum() throws YosException {
 
-        Rows rows = dbConnect.runSqlQuery("SELECT COUNT(0) num FROM sa_shoppingcart t1 WHERE t1.sys_enterpriseid=" + sys_enterpriseid + " AND t1.siteid= '" + siteid + "' and  t1.sa_promotionid="+content.getLongValue("sa_promotionid"));
+        Rows rows = dbConnect.runSqlQuery("SELECT COUNT(0) num FROM sa_shoppingcart t1 WHERE t1.sys_enterpriseid=" + sys_enterpriseid + " AND t1.siteid= '" + siteid + "' and  t1.sa_promotionid=" + content.getLongValue("sa_promotionid"));
 
 
         return getSucReturnObject().setData(rows.get(0)).toString();