Explorar el Código

促销方案商品查询改为查询促销方案所属领域

hu hace 3 años
padre
commit
4c1db88268

+ 5 - 1
src/custom/restcontroller/webmanage/sale/promotion/SQL/商品查询.sql

@@ -11,4 +11,8 @@ SELECT
 FROM
 	plm_item t1
 	 LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
-	where $where$ and t1.siteid=$siteid$ and ifnull(t1.isonsale,0) =1 and t1.itemid not in (select itemid from sa_promotion_items where sa_promotionid=$sa_promotionid$)
+	where $where$ and t1.siteid=$siteid$ and ifnull(t1.isonsale,0) =1 and t1.itemid not in (select itemid from sa_promotion_items where sa_promotionid=$sa_promotionid$)
+	  and t1.itemid in (SELECT itemid
+                    from plm_item_tradefield
+                    WHERE ($where1$)
+                      and siteid = $siteid$)

+ 18 - 0
src/custom/restcontroller/webmanage/sale/promotion/promotionItems.java

@@ -13,6 +13,7 @@ import common.data.Row;
 import common.data.Rows;
 import common.data.RowsMap;
 import common.data.SQLFactory;
+import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
 
 import java.util.ArrayList;
@@ -31,6 +32,7 @@ public class promotionItems extends Controller {
          * 过滤条件设置
          */
         String where = " 1=1 ";
+        String where1 = " 1=1 ";
         if (content.containsKey("where")) {
             JSONObject whereObject = content.getJSONObject("where");
             if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
@@ -41,11 +43,27 @@ public class promotionItems extends Controller {
 
         }
         Long sa_promotionid = content.getLong("sa_promotionid");
+        Rows tradefieldrows =dbConnect.runSqlQuery("select tradefield from sa_promotion where siteid='"+siteid+"' and sa_promotionid="+sa_promotionid);
+        JSONArray tradefield=new JSONArray();
+        if(!tradefieldrows.isEmpty()){
+            if (!StringUtils.isBlank(tradefieldrows.get(0).getString("tradefield"))) {
+                tradefield=JSONArray.parseArray(tradefieldrows.get(0).getString("tradefield"));
+            }
+        }
+        if(tradefield!=null && !tradefield.isEmpty()){
+            for (Object object:tradefield) {
+                String str = String.valueOf(object);
+                where1=where1 +" or tradefield =+'"+str+"' ";
+            }
+        }
+
 //			String hrid = content.getString("hrid");
         SQLFactory sqlFactory = new SQLFactory(this, "商品查询", pageSize, pageNumber, pageSorting);
         sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter_SQL("where1", where1);
         sqlFactory.addParameter("sa_promotionid", sa_promotionid);
         sqlFactory.addParameter("siteid", siteid);
+         System.out.println(sqlFactory.getSQL());
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
 
         // 附件