| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- package restcontroller.webmanage.sale.promotion;
- import beans.data.BatchDeleteErr;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import common.Controller;
- import common.YosException;
- import common.annotation.API;
- import common.annotation.CACHEING;
- import common.annotation.CACHEING_CLEAN;
- import common.data.Rows;
- import common.data.SQLFactory;
- import restcontroller.R;
- import java.util.ArrayList;
- public class promotionSalearea extends Controller {
- /**
- * 构造函数
- *
- * @param content
- */
- public promotionSalearea(JSONObject content) throws YosException {
- super(content);
- }
- @API(title = "促销方案授权营销区域新增更新", apiversion = R.ID20230629140803.v1.class)
- @CACHEING_CLEAN(apiClass = {promotionSalearea.class})
- public String insertormodify_promotionSalearea() throws YosException {
- Long sa_promotionid = content.getLong("sa_promotionid");
- JSONArray saleareainfos = content.getJSONArray("saleareainfos");
- ArrayList<String> sqlList = new ArrayList<>();
- int i = 0;
- long[] sa_promotion_saleareaid = createTableID("sa_promotion_salearea", saleareainfos.size());
- for (Object obj : saleareainfos) {
- JSONObject saleareainfo = (JSONObject) obj;
- if (saleareainfo.getLong("sa_promotion_saleareaid") <= 0 || dbConnect.runSqlQuery(
- "select sa_promotion_saleareaid from sa_promotion_salearea where sa_promotion_saleareaid="
- + saleareainfo.getLong("sa_promotion_saleareaid"))
- .isEmpty()) {
- SQLFactory saleFactory = new SQLFactory(this, "促销方案授权营销区域新增");
- saleFactory.addParameter("siteid", siteid);
- saleFactory.addParameter("sa_promotion_saleareaid", sa_promotion_saleareaid[i]);
- saleFactory.addParameter("sa_promotionid", sa_promotionid);
- saleFactory.addParameter("sa_saleareaid", saleareainfo.getLong("sa_saleareaid"));
- sqlList.add(saleFactory.getSQL());
- i++;
- } else {
- SQLFactory saleFactory = new SQLFactory(this, "促销方案授权营销区域更新");
- saleFactory.addParameter("sa_promotion_saleareaid", saleareainfo.getLong("sa_promotion_saleareaid"));
- saleFactory.addParameter("siteid", siteid);
- saleFactory.addParameter("sa_promotionid", sa_promotionid);
- saleFactory.addParameter("sys_enterpriseid", saleareainfo.getLong("sa_saleareaid"));
- sqlList.add(saleFactory.getSQL());
- }
- }
- dbConnect.runSqlUpdate(sqlList);
- return queryPromotionAuthList();
- }
- @API(title = "营销区域列表查询", apiversion = R.ID20230629141403.v1.class)
- @CACHEING
- public String query_saleareaList() throws YosException {
- long sa_promotionid = content.getLong("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.areaname like'%").append(whereObject.getString("condition")).append("%' ");
- where.append(" or t1.areanum like'%").append(whereObject.getString("condition")).append("%' ");
- where.append(")");
- }
- }
- SQLFactory sqlFactory = new SQLFactory(this, "营销区域查询", pageSize, pageNumber, pageSorting);
- sqlFactory.addParameter_SQL("where", where);
- sqlFactory.addParameter("sa_promotionid", sa_promotionid);
- sqlFactory.addParameter("siteid", siteid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "促销方案授权营销区域列表", apiversion = R.ID20230629141503.v1.class)
- @CACHEING
- public String queryPromotionAuthList() 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.areaname like '%").append(whereObject.getString("condition")).append("%' ");
- where.append(")");
- }
- }
- Long sa_promotionid = content.getLong("sa_promotionid");
- SQLFactory sqlFactory = new SQLFactory(this, "促销方案授权营销区域查询", pageSize, pageNumber, pageSorting);
- sqlFactory.addParameter_SQL("where", where);
- sqlFactory.addParameter("sa_promotionid", sa_promotionid);
- sqlFactory.addParameter("siteid", siteid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "删除明细", apiversion = R.ID20230629141603.v1.class)
- @CACHEING_CLEAN(apiClass = {promotionSalearea.class})
- public String deletemx() throws YosException {
- JSONArray sa_promotion_saleareaids = content.getJSONArray("sa_promotion_saleareaids");
- BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_promotion_saleareaids.size());
- for (Object o : sa_promotion_saleareaids) {
- long sa_promotion_saleareaid = Long.parseLong(o.toString());
- ArrayList<String> list = new ArrayList<>();
- SQLFactory deletesql = new SQLFactory("sql:delete from sa_promotion_salearea where siteid='" + siteid
- + "' and sa_promotion_saleareaid=" + sa_promotion_saleareaid);
- list.add(deletesql.getSQL());
- dbConnect.runSqlUpdate(list);
- }
- return batchDeleteErr.getReturnObject().toString();
- }
- }
|