瀏覽代碼

促销管理增加销售排行

hu 1 年之前
父節點
當前提交
8fa6e73b1f

+ 8 - 0
src/custom/restcontroller/R.java

@@ -4816,6 +4816,14 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20231007101703 {
+        public static class v1 {
+        }
+    }
+    public static class ID20231007101803 {
+        public static class v1 {
+        }
+    }
 
 }
 

+ 3 - 0
src/custom/restcontroller/webmanage/sale/promotion/SQL/促销方案销售排行查询(商品).sql

@@ -0,0 +1,3 @@
+select t2.itemno,t2.itemname,t1.qty from (select t1.* from  (select  t2.itemid,sum(if(t1.status='手工关闭',ifnull(t2.deliedqty,0),t2.qty)) qty from sa_order t1
+     inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid where t1.sa_promotionid=$sa_promotionid$ and t1.siteid=$siteid$ and t1.status in('提交','审核','关闭','手工关闭') group by t2.itemid) t1
+) t1 inner join plm_item t2 on t1.itemid=t2.itemid

+ 3 - 0
src/custom/restcontroller/webmanage/sale/promotion/SQL/促销方案销售排行查询(经销商).sql

@@ -0,0 +1,3 @@
+select t2.agentnum,t3.abbreviation,t1.amount from (select t1.* from  (select  t1.sys_enterpriseid,sum(if(t1.status='手工关闭',ifnull(t2.deliedqty,0)*t2.price,t2.amount)) amount from sa_order t1
+     inner join sa_orderitems t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid where t1.sa_promotionid=$sa_promotionid$ and t1.siteid=$siteid$ and t1.status in('提交','审核','关闭','手工关闭') group by t1.sys_enterpriseid) t1
+) t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid inner join sys_enterprise t3 on t1.sys_enterpriseid=t3.sys_enterpriseid

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

@@ -166,6 +166,69 @@ public class promotion extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
+    @API(title = "查询促销方案销售排行(经销商)", apiversion = R.ID20231007101703.v1.class)
+    @CACHEING
+    public String queryAgentSalesRanking() throws YosException {
+        long sa_promotionid =content.getLongValue("sa_promotionid");
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t3.abbreviation like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "促销方案销售排行查询(经销商)", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("sa_promotionid", sa_promotionid);
+        sqlFactory.addParameter_SQL("where", where);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
+    @API(title = "查询促销方案销售排行(商品)", apiversion = R.ID20231007101803.v1.class)
+    @CACHEING
+    public String queryItemSalesRanking() throws YosException {
+        long sa_promotionid =content.getLongValue("sa_promotionid");
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.itemno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.itemname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "促销方案销售排行查询(商品)", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("sa_promotionid", sa_promotionid);
+        sqlFactory.addParameter_SQL("where", where);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+
+
+//        //附件
+//        ArrayList<Long> ids = rows.toArrayList("sa_promotionid", new ArrayList<>());
+//        RowsMap attRowsMap = getAttachmentUrl("sa_promotion", ids);
+//        for (Row row : rows) {
+//            if (!StringUtils.isBlank(row.getString("tradefield"))) {
+//                row.put("tradefield", JSONArray.parseArray(row.getString("tradefield")));
+//            } else {
+//                row.put("tradefield", new JSONArray());
+//            }
+//            row.put("attinfos", attRowsMap.getOrDefault(row.getString("sa_promotionid"), new Rows()));
+//        }
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
     @API(title = "删除", apiversion = R.ID20221230144903.v1.class)
     @CACHEING_CLEAN(apiversions = {R.ID20221230144703.v1.class, R.ID20221230144803.v1.class, R.ID20220103140003.v1.class})
     public String delete() throws YosException {