|
@@ -1,5 +1,6 @@
|
|
|
package restcontroller.sale.promotion;
|
|
|
|
|
|
+import beans.salearea.SaleArea;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import common.Controller;
|
|
@@ -201,4 +202,179 @@ public class promotion extends Controller {
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
+ @API(title = "查询促销方案列表(区域经理)", apiversion = R.ID20231025144003.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String querypromotionList_regionalManager() throws YosException {
|
|
|
+ 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("t.promnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t.promname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t.remarks like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SQLFactory areasqlFactory = new SQLFactory(this, "区域经理查询下属营销区域");
|
|
|
+ areasqlFactory.addParameter("siteid", siteid);
|
|
|
+ areasqlFactory.addParameter("hrid", hrid);
|
|
|
+ Rows arearows = dbConnect.runSqlQuery(areasqlFactory);
|
|
|
+ ArrayList<Long> arrayList =arearows.toArrayList("sa_saleareaid", new ArrayList<Long>());
|
|
|
+ arrayList.addAll(SaleArea.getSubSaleAreaIds(this, arrayList));
|
|
|
+
|
|
|
+
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "促销方案列表查询(区域经理)", pageSize, pageNumber, pageSorting);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter_in("sa_saleareaids", arrayList);
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ //默认商品图片
|
|
|
+ Rows defaultImageRows = getAttachmentUrl("system", (long) 1, "defaultImage");
|
|
|
+ //附件
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sa_promotionid", new ArrayList<>());
|
|
|
+ RowsMap attRowsMap = getAttachmentUrl("sa_promotion", ids);
|
|
|
+
|
|
|
+// SQLFactory sqlFactory1 = new SQLFactory(this, "促销订单金额合计查询");
|
|
|
+// 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(this, "促销方案列表查询(触发的促销方案)");
|
|
|
+// 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 = rows.listIterator();
|
|
|
+// while (iterator.hasNext()) {
|
|
|
+// Row row = iterator.next();
|
|
|
+// if(row.getLong("sa_openpromotionid")!=0){
|
|
|
+// if(sumAmountRowsMap.containsKey(row.getString("sa_promotionid"))){
|
|
|
+// BigDecimal sumamount = sumAmountRowsMap.get(row.getString("sa_promotionid")).get(0).getBigDecimal("sumamount");
|
|
|
+// if(sumamount.compareTo(row.getBigDecimal("openamount"))>=0){
|
|
|
+// if(openPromotionsRowsMap.containsKey(row.getString("sa_openpromotionid"))){
|
|
|
+// iterator.add(openPromotionsRowsMap.get(row.getString("sa_openpromotionid")).get(0));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ //Rows promotionAuthRows = dbConnect.runSqlQuery("select t1.sa_promotionid,ifnull(t1.limitamount,0)-ifnull(t1.saledamount,0) canuseamount from sa_promotion_auth t1 inner join sa_promotion t2 on t1.sa_promotionid=t2.sa_promotionid and t1.siteid=t2.siteid where t1.sys_enterpriseid="+sys_enterpriseid);
|
|
|
+ // RowsMap promotionAuthRowsMap = promotionAuthRows.toRowsMap("sa_promotionid");
|
|
|
+ for (Row row : rows) {
|
|
|
+ if ((attRowsMap.getOrDefault(row.getString("sa_promotionid"), new Rows())).isEmpty()) {
|
|
|
+ row.put("attinfos", defaultImageRows);
|
|
|
+ } else {
|
|
|
+ row.put("attinfos", attRowsMap.getOrDefault(row.getString("sa_promotionid"), new Rows()));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isBlank(row.getString("tradefield"))) {
|
|
|
+ row.put("tradefield", JSONArray.parseArray(row.getString("tradefield")));
|
|
|
+ } else {
|
|
|
+ row.put("tradefield", new JSONArray());
|
|
|
+ }
|
|
|
+
|
|
|
+// if(row.getString("type").equals("返利促销")){
|
|
|
+// if(promotionAuthRowsMap.containsKey(row.getString("sa_promotionid"))){
|
|
|
+// row.put("canuseamount", promotionAuthRowsMap.get(row.getString("sa_promotionid")).get(0).getBigDecimal("canuseamount"));
|
|
|
+// }else {
|
|
|
+// row.put("canuseamount", 0);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else{
|
|
|
+// row.put("canuseamount", 0);
|
|
|
+// }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "促销方案商品列表(区域经理)", apiversion = R.ID20231025144103.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String queryPromotionItemsList_regionalManager() throws YosException {
|
|
|
+ /*
|
|
|
+ * 过滤条件设置
|
|
|
+ */
|
|
|
+ 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("t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.model like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+
|
|
|
+ ArrayList ids = rows.toArrayList("itemid", new ArrayList<>());
|
|
|
+ //默认商品图片
|
|
|
+ Rows defaultImageRows = getAttachmentUrl("system", (long) 1, "defaultImage");
|
|
|
+ // 附件
|
|
|
+ RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
|
|
|
+ //商品领域
|
|
|
+ RowsMap tradefieldRowsMap = beans.Item.Item.getTradefieldRowsMap(this, ids);
|
|
|
+ Rows sizecustomizedschemes=dbConnect.runSqlQuery("select * from sa_sizecustomizedscheme where siteid='"+siteid+"' ");
|
|
|
+ RowsMap sizecustomizedschemesRowsMap=sizecustomizedschemes.toRowsMap("sa_sizecustomizedschemeid");
|
|
|
+ Rows sizeschemedetails=dbConnect.runSqlQuery("select * from sa_sizeschemedetail where siteid='"+siteid+"' ");
|
|
|
+ RowsMap sizeschemedetailsRowsMap=sizeschemedetails.toRowsMap("sa_sizecustomizedschemeid");
|
|
|
+ for (Row row : rows) {
|
|
|
+ if ((attRowsMap.getOrDefault(row.getString("itemid"), new Rows())).isEmpty()) {
|
|
|
+ row.put("attinfos", defaultImageRows);
|
|
|
+ } else {
|
|
|
+ row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
|
|
|
+ }
|
|
|
+
|
|
|
+ row.put("tradefield", tradefieldRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
|
|
|
+
|
|
|
+ if(row.getLong("widthschemeid")!=0){
|
|
|
+ if(sizecustomizedschemesRowsMap.containsKey(row.getString("widthschemeid"))){
|
|
|
+ if(sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).isNotEmpty()){
|
|
|
+ row.put("widthtype",sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).get(0).getString("type"));
|
|
|
+ row.put("widthmin",sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).get(0).getBigDecimal("min"));
|
|
|
+ row.put("widthmax",sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).get(0).getBigDecimal("max"));
|
|
|
+ row.put("widthdecimalplaces",sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).get(0).getBigDecimal("decimalplaces"));
|
|
|
+ if(sizeschemedetailsRowsMap.containsKey(row.getString("widthschemeid"))){
|
|
|
+ row.put("widthschemedetails",sizeschemedetailsRowsMap.get(row.getString("widthschemeid")));
|
|
|
+ }else{
|
|
|
+ row.put("widthschemedetails",new JSONArray());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(row.getLong("lengthschemeid")!=0){
|
|
|
+ if(sizecustomizedschemesRowsMap.containsKey(row.getString("lengthschemeid"))){
|
|
|
+ if(sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).isNotEmpty()){
|
|
|
+ row.put("lengthtype",sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).get(0).getString("type"));
|
|
|
+ row.put("lengthmin",sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).get(0).getBigDecimal("min"));
|
|
|
+ row.put("lengthmax",sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).get(0).getBigDecimal("max"));
|
|
|
+ row.put("lengthdecimalplaces",sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).get(0).getBigDecimal("decimalplaces"));
|
|
|
+ if(sizeschemedetailsRowsMap.containsKey(row.getString("lengthschemeid"))){
|
|
|
+ row.put("lengthschemedetails",sizeschemedetailsRowsMap.get(row.getString("lengthschemeid")));
|
|
|
+ }else{
|
|
|
+ row.put("lengthschemedetails",new JSONArray());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|