浏览代码

商城中增加商品是否参加活动标识

hu 1 年之前
父节点
当前提交
ab345cd5b6

+ 3 - 3
src/custom/restcontroller/sale/favorites/SQL/查询收藏商品列表.sql

@@ -1,7 +1,7 @@
 SELECT t2.*,
-       t1.qty,
-       t1.width,
-       t1.length,
+       t1.qty favoritesqty,
+       t1.width favoriteswidth,
+       t1.length favoriteslength,
        t3.unitname,
        t8.caliber,
        t8.pressure,

+ 4 - 0
src/custom/restcontroller/sale/itemgroup/SQL/查询商品所在有效活动.sql

@@ -0,0 +1,4 @@
+select t1.sa_promotionid,t1.promname from sa_promotion t1
+     inner join sa_promotion_items t2 on t1.sa_promotionid=t2.sa_promotionid and t1.siteid=t2.siteid
+     inner join plm_item t3 on t2.itemid=t3.itemid and t2.siteid=t3.siteid
+     where t1.sa_promotionid in $sa_promotionids$ and t3.itemno=$itemno$ and t1.siteid=$siteid$

+ 44 - 0
src/custom/restcontroller/sale/itemgroup/itemgroup.java

@@ -20,6 +20,7 @@ import common.data.SQLFactory;
 
 import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
+import restcontroller.sale.promotion.promotion;
 
 import java.math.BigDecimal;
 import java.util.*;
@@ -939,6 +940,49 @@ public class itemgroup extends Controller {
         sqlFactory.addParameter("siteid", siteid);
         Rows itemrows = dbConnect.runSqlQuery(sqlFactory.getSQL());
         for (Row row : itemrows) {
+
+            //判断商品是否参与活动:当前经销商参与的有效的活动
+            SQLFactory activitysqlFactory = new SQLFactory(new promotion(new JSONObject()), "促销方案列表查询");
+            activitysqlFactory.addParameter("siteid", siteid);
+            activitysqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
+            activitysqlFactory.addParameter_SQL("where", "1=1");
+            Rows activityrows = dbConnect.runSqlQuery(activitysqlFactory);
+
+            SQLFactory sqlFactory1 = new SQLFactory(new promotion(new JSONObject()), "促销订单金额合计查询");
+            sqlFactory1.addParameter("siteid", siteid);
+            sqlFactory1.addParameter("sys_enterpriseid", sys_enterpriseid);
+            Rows sumAmountRows =  dbConnect.runSqlQuery(sqlFactory1.getSQL());
+            RowsMap sumAmountRowsMap = sumAmountRows.toRowsMap("sa_promotionid");
+
+            SQLFactory sqlFactory2 = new SQLFactory(new promotion(new JSONObject()), "促销方案列表查询(触发的促销方案)");
+            sqlFactory2.addParameter("siteid", siteid);
+            sqlFactory2.addParameter("sys_enterpriseid", sys_enterpriseid);
+            Rows openPromotionsRows =  dbConnect.runSqlQuery(sqlFactory2.getSQL());
+            RowsMap openPromotionsRowsMap = openPromotionsRows.toRowsMap("sa_promotionid");
+
+            ListIterator<Row> iterator = activityrows.listIterator();
+            while (iterator.hasNext()) {
+                Row  activityrow = iterator.next();
+                if(activityrow.getLong("sa_openpromotionid")!=0){
+                    if(sumAmountRowsMap.containsKey(activityrow.getString("sa_promotionid"))){
+                        BigDecimal sumamount = sumAmountRowsMap.get(activityrow.getString("sa_promotionid")).get(0).getBigDecimal("sumamount");
+                        if(sumamount.compareTo(activityrow.getBigDecimal("openamount"))>=0){
+                            if(openPromotionsRowsMap.containsKey(activityrow.getString("sa_openpromotionid"))){
+                                iterator.add(openPromotionsRowsMap.get(activityrow.getString("sa_openpromotionid")).get(0));
+                            }
+                        }
+                    }
+                }
+            }
+
+            SQLFactory promotionsqlFactory = new SQLFactory(this, "查询商品所在有效活动", pageSize, pageNumber, pageSorting);
+            promotionsqlFactory.addParameter("itemno", itemno);
+            promotionsqlFactory.addParameter_in("sa_promotionids", activityrows.toArray("sa_promotionid"));
+            promotionsqlFactory.addParameter("siteid", siteid);
+            Rows promotionrows = dbConnect.runSqlQuery(promotionsqlFactory.getSQL());
+
+            row.put("canuseactivity",promotionrows);
+
             ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, row.getLong("itemid"));
             row.put("oldprice", itemPrice.getPrice());
             if (sys_enterpriseid > 0 || (usertype == 21 || usertype == 22)) {