Browse Source

促销方案商品列表修改为最新查询方式

hu 2 years ago
parent
commit
9918566141

+ 51 - 7
src/custom/restcontroller/webmanage/sale/promotion/promotionItems.java

@@ -212,13 +212,17 @@ public class promotionItems extends Controller {
         }
         Long sa_promotionid = content.getLong("sa_promotionid");
         Long sa_promotion_itemgroupid = content.getLong("sa_promotion_itemgroupid");
-        SQLFactory sqlFactory = new SQLFactory(this, "促销方案商品查询", pageSize, pageNumber, pageSorting);
-        sqlFactory.addParameter_SQL("where", where);
-        sqlFactory.addParameter("sa_promotionid", sa_promotionid);
-        sqlFactory.addParameter("sa_promotion_itemgroupid", sa_promotion_itemgroupid);
-        sqlFactory.addParameter("siteid", siteid);
-        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
-
+//        SQLFactory sqlFactory = new SQLFactory(this, "促销方案商品查询", pageSize, pageNumber, pageSorting);
+//        sqlFactory.addParameter_SQL("where", where);
+//        sqlFactory.addParameter("sa_promotionid", sa_promotionid);
+//        sqlFactory.addParameter("sa_promotion_itemgroupid", sa_promotion_itemgroupid);
+//        sqlFactory.addParameter("siteid", siteid);
+//        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+//
+        QuerySQL querySQL = queryPromotionItemList(where.toString(),sa_promotionid,sa_promotion_itemgroupid);
+        querySQL.setPage(pageSize, pageNumber);
+        querySQL.setOrderBy(pageSorting);
+        Rows rows = querySQL.query();
         ArrayList ids = rows.toArrayList("itemid", new ArrayList<>());
         // 附件
         RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
@@ -229,6 +233,46 @@ public class promotionItems extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
+    //查询发货单列表
+    public QuerySQL queryPromotionItemList(String where,long sa_promotionid,long sa_promotion_itemgroupid) throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_promotion_items");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.itemid = t2.itemid and t1.siteid = t2.siteid",
+                "itemno", "itemname","spec","model");
+        querySQL.addJoinTable(JOINTYPE.left, "plm_unit", "t3", "t2.unitid = t3.unitid and t2.siteid = t3.siteid", "unitname");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t4", "t1.sa_promotionid = t4.sa_promotionid and t1.itemid = t4.itemid and t1.siteid = t4.siteid and t4.pricegrade = 1");
+        querySQL.addQueryFields("oldprice1", "ifnull(t4.oldprice, 0)");
+        querySQL.addQueryFields("price1", "ifnull(t4.price, 0)");
+        querySQL.addQueryFields("sa_promotion_itempriceid1", "ifnull(t4.sa_promotion_itempriceid, 0)");
+
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t5", "t1.sa_promotionid = t5.sa_promotionid and t1.itemid = t5.itemid and t1.siteid = t5.siteid and t5.pricegrade = 2");
+        querySQL.addQueryFields("oldprice2", "ifnull(t5.oldprice, 0)");
+        querySQL.addQueryFields("price2", "ifnull(t5.price, 0)");
+        querySQL.addQueryFields("sa_promotion_itempriceid2", "ifnull(t5.sa_promotion_itempriceid, 0)");
+
+
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t6", "t1.sa_promotionid = t6.sa_promotionid and t1.itemid = t6.itemid and t1.siteid = t6.siteid and t6.pricegrade = 3");
+        querySQL.addQueryFields("oldprice3", "ifnull(t6.oldprice, 0)");
+        querySQL.addQueryFields("price3", "ifnull(t6.price, 0)");
+        querySQL.addQueryFields("sa_promotion_itempriceid3", "ifnull(t6.sa_promotion_itempriceid, 0)");
+
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t7", "t1.sa_promotionid = t7.sa_promotionid and t1.itemid = t7.itemid and t1.siteid = t7.siteid and t7.pricegrade = 4");
+        querySQL.addQueryFields("oldprice4", "ifnull(t7.oldprice, 0)");
+        querySQL.addQueryFields("price4", "ifnull(t7.price, 0)");
+        querySQL.addQueryFields("sa_promotion_itempriceid4", "ifnull(t7.sa_promotion_itempriceid, 0)");
+
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t8", "t1.sa_promotionid = t8.sa_promotionid and t1.itemid = t8.itemid and t1.siteid = t8.siteid and t8.pricegrade = 5");
+        querySQL.addQueryFields("oldprice5", "ifnull(t8.oldprice, 0)");
+        querySQL.addQueryFields("price5", "ifnull(t8.price, 0)");
+        querySQL.addQueryFields("sa_promotion_itempriceid5", "ifnull(t8.sa_promotion_itempriceid, 0)");
+
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t1.sa_promotionid",sa_promotionid);
+        querySQL.setWhere("t1.sa_promotion_itemgroupid",sa_promotion_itemgroupid);
+        querySQL.setWhere(where);
+        return querySQL;
+    }
+
     @API(title = "删除明细", apiversion = R.ID20230102142603.v1.class)
     @CACHEING_CLEAN(apiversions = {R.ID20230102142503.v1.class, R.ID20230102144603.v1.class,
             R.ID20230102163103.v1.class})