Kaynağa Gözat

经销商端:促销活动,已售罄的商品禁止加入活动购物车

eganwu 1 yıl önce
ebeveyn
işleme
838b06617c

+ 10 - 2
src/custom/restcontroller/sale/shoppingcart/ShoppingCart.java

@@ -60,6 +60,10 @@ public class ShoppingCart extends Controller {
             return getErrReturnObject().setErrMsg("商品【" + itemno + "】已添加至购物车,不能再次添加。").toString();
         }
 
+        if (sa_promotionid > 0 && dbConnect.runSqlQuery("SELECT 1 from sa_promotion_items WHERE  islimit=1 and groupqty <= saledqty  and  itemid=" + itemid + " and siteid='" + siteid + "' and sa_promotionid='" + sa_promotionid + "'").isNotEmpty()) {
+            return getErrReturnObject().setErrMsg("商品【" + itemno + "】已售罄,不能添加。").toString();
+        }
+
 
         SQLFactory sqlFactory = new SQLFactory(this, "购物车新增");
         Long sa_shoppingcartid = 0L;
@@ -137,6 +141,10 @@ public class ShoppingCart extends Controller {
             colors = colors.equals("0") ? "" : colors;
             material = material.equals("0") ? "" : material;
 
+            if (sa_promotionid > 0 && dbConnect.runSqlQuery("SELECT 1 from sa_promotion_items WHERE  islimit=1 and groupqty <= saledqty  and  itemid=" + itemid + " and siteid='" + siteid + "' and sa_promotionid='" + sa_promotionid + "'").isNotEmpty()) {
+                return getErrReturnObject().setErrMsg("商品【" + itemno + "】已售罄,不能添加。").toString();
+            }
+
             if (dbConnect.runSqlQuery("SELECT * from sa_shoppingcart " +
                     "WHERE ifnull(length,0)=" + length + " and ifnull(width,0)=" + width +
                     " and ifnull(colors,'') ='" + colors + "' and ifnull(cheek,'')='" + cheek + "' and ifnull(material,'')='" + material + "'" +
@@ -333,10 +341,10 @@ public class ShoppingCart extends Controller {
             row = customScheme.setScheme(row, "material");
             row = customScheme.setScheme(row, "color");
             row = customScheme.setScheme(row, "cheek");
-            if (row.getBigDecimal("width").compareTo(BigDecimal.ZERO)==0) {
+            if (row.getBigDecimal("width").compareTo(BigDecimal.ZERO) == 0) {
                 row.replace("width", null);
             }
-            if (row.getBigDecimal("length").compareTo(BigDecimal.ZERO)==0) {
+            if (row.getBigDecimal("length").compareTo(BigDecimal.ZERO) == 0) {
                 row.replace("length", null);
             }
             row.put("isselect", true);