| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- package restcontroller.webmanage.sale.order;
- import beans.brand.Brand;
- import beans.itemprice.ItemPrice;
- import com.alibaba.fastjson.JSONObject;
- import common.Controller;
- import common.YosException;
- import common.annotation.API;
- import common.data.Row;
- import common.data.Rows;
- import common.data.RowsMap;
- import common.data.SQLFactory;
- import restcontroller.R;
- import java.util.ArrayList;
- import static beans.order.Order.getOrderRows;
- /**
- * 促销订单相关接口
- */
- public class PromotionOrder extends Controller {
- /**
- * 构造函数
- *
- * @param content
- */
- public PromotionOrder(JSONObject content) throws YosException {
- super(content);
- }
- /**
- * 查询订货企业授权的促销方案列表
- *
- * @return
- */
- @API(title = "查询促销方案列表", apiversion = R.ID20230107182102.v1.class)
- public String selectPromotionList() 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(")");
- }
- }
- if (content.containsKey("sys_enterpriseid")) {
- sys_enterpriseid = content.getLongValue("sys_enterpriseid");
- }
- SQLFactory sqlFactory = new SQLFactory(this, "促销方案列表查询", pageSize, pageNumber, pageSorting);
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
- sqlFactory.addParameter_SQL("where", where);
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "查询促销方案中的商品列表", apiversion = R.ID20230107182302.v1.class)
- public String selectPromotionItemsList() 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("t1.itemno like'%").append(whereObject.getString("condition")).append("%' ");
- where.append("or t1.itemname like'%").append(whereObject.getString("condition")).append("%' ");
- where.append("or t1.model like'%").append(whereObject.getString("condition")).append("%' ");
- where.append("or t1.spec like'%").append(whereObject.getString("condition")).append("%' ");
- where.append(")");
- }
- }
- Long sa_orderid = content.getLong("sa_orderid");
- Rows orderRows = getOrderRows(this,sa_orderid);
- Long sa_promotionid = -1L;
- if (orderRows.isNotEmpty()) {
- sa_promotionid = orderRows.get(0).getLong("sa_promotionid");
- sys_enterpriseid = orderRows.get(0).getLong("sys_enterpriseid");
- }
- // ArrayList<Long> itemids = getOrderItemsList(sa_orderid, sa_promotionid);
- // itemids.add(-1L);
- SQLFactory sqlFactory = new SQLFactory(this, "促销方案商品列表", pageSize, pageNumber, pageSorting);
- sqlFactory.addParameter("siteid", siteid);
- // sqlFactory.addParameter_in("itemid", itemids);
- sqlFactory.addParameter("sa_promotionid", sa_promotionid);
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
- sqlFactory.addParameter_SQL("where", where);
- String sql = sqlFactory.getSQL();
- Rows rows = dbConnect.runSqlQuery(sql);
- ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
- //查询附件
- RowsMap attinfoRowsMap = getAttachmentUrl("plm_item", ids);
- //商品领域
- RowsMap tradefieldRowsMap = beans.Item.Item.getTradefieldRowsMap(this, ids);
- //品牌
- RowsMap brandRowsMap = Brand.getBrandRowsMap(this, ids);
- for (Row row : rows) {
- row.put("attinfos", attinfoRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
- row.put("tradefield", tradefieldRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
- row.put("brand", brandRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
- }
- return getSucReturnObject().setData(rows).toString();
- }
- // public ArrayList<Long> getOrderItemsList(Long sa_orderid, Long sa_promotionid) throws YosException {
- // String sql = "SELECT distinct itemid from sa_promotion_itemprice WHERE sa_promotionid = '" + sa_promotionid + "' and siteid = '" + siteid + "' and itemid not in (SELECT itemid from sa_orderitems WHERE sa_orderid = " + sa_orderid + " and siteid = '" + siteid + "')";
- // Rows rows = dbConnect.runSqlQuery(sql);
- // return rows.toArrayList("itemid", new ArrayList<>());
- // }
- }
|