|
|
@@ -24,308 +24,331 @@ import restcontroller.R;
|
|
|
@API(title = "促销方案")
|
|
|
public class promotion extends Controller {
|
|
|
|
|
|
- public promotion(JSONObject arg0) throws YosException {
|
|
|
- super(arg0);
|
|
|
- // TODO Auto-generated constructor stub
|
|
|
- }
|
|
|
-
|
|
|
- @API(title = "促销方案新增更新", apiversion = R.ID20221230144503.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = { R.ID20221230144703.v1.class, R.ID20221230144803.v1.class,R.ID20220103140003.v1.class})
|
|
|
- public String insertormodify_promotion() throws YosException {
|
|
|
- ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- // 表名
|
|
|
- String tableName = "sa_promotion";
|
|
|
- Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
- Long sa_accountclassid = content.getLong("sa_accountclassid");
|
|
|
- Long sa_brandid = content.getLong("sa_brandid");
|
|
|
- String promname = content.getStringValue("promname");
|
|
|
- String remarks = content.getStringValue("remarks");
|
|
|
- String type = content.getStringValue("type");
|
|
|
- //String tradefield = content.getStringValue("tradefield");
|
|
|
- JSONArray tradefield =content.getJSONArray("tradefield");
|
|
|
- BigDecimal orderminqty = content.getBigDecimal("orderminqty");
|
|
|
- BigDecimal orderaddqty = content.getBigDecimal("orderaddqty");
|
|
|
- BigDecimal orderminamount = content.getBigDecimal("orderminamount");
|
|
|
- String begdate = content.getStringValue("begdate");
|
|
|
- String enddate = content.getStringValue("enddate");
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "促销方案新增");
|
|
|
-
|
|
|
- if (sa_promotionid <= 0 || dbConnect
|
|
|
- .runSqlQuery("select sa_promotionid from sa_promotion where sa_promotionid=" + sa_promotionid)
|
|
|
- .isEmpty()) {
|
|
|
- sa_promotionid = createTableID(tableName);
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "新增", "促销方案新增成功").getSQL());
|
|
|
- } else {
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("SELECT status from sa_promotion WHERE sa_promotionid = " + sa_promotionid);
|
|
|
- if (rows.isNotEmpty()) {
|
|
|
- if (rows.get(0).getString("status").equals("新建")) {
|
|
|
- sqlFactory = new SQLFactory(this, "促销方案更新");
|
|
|
- sqlList.add(
|
|
|
- DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "更新", "促销方案更新成功").getSQL());
|
|
|
- } else {
|
|
|
- return getErrReturnObject().setErrMsg("非新建状态下无法编辑").toString();
|
|
|
- }
|
|
|
- } else {
|
|
|
- return getErrReturnObject().setErrMsg("该促销方案不存在").toString();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("userid", userid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- sqlFactory.addParameter("sa_promotionid", sa_promotionid);
|
|
|
- // 促销方案号createBillCode("promotionbillno")
|
|
|
- sqlFactory.addParameter("promnum",createBillCode("promotionbill"));
|
|
|
- sqlFactory.addParameter("promname", promname);
|
|
|
- sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
|
|
|
- sqlFactory.addParameter("sa_brandid", sa_brandid);
|
|
|
- sqlFactory.addParameter("type", type);
|
|
|
- sqlFactory.addParameter("tradefield", tradefield.toJSONString());
|
|
|
- sqlFactory.addParameter("orderminqty", orderminqty);
|
|
|
- sqlFactory.addParameter("orderaddqty", orderaddqty);
|
|
|
- sqlFactory.addParameter("orderminamount", orderminamount);
|
|
|
- sqlFactory.addParameter("sa_openpromotionid", content.getIntValue("sa_openpromotionid"));
|
|
|
- sqlFactory.addParameter("openamount", content.getBigDecimalValue("openamount"));
|
|
|
- sqlFactory.addParameter("isrelevancepromotion", content.getLongValue("isrelevancepromotion"));
|
|
|
-
|
|
|
- sqlFactory.addParameter("begdate", begdate);
|
|
|
- sqlFactory.addParameter("enddate", enddate);
|
|
|
- // 备注说明
|
|
|
- sqlFactory.addParameter("remarks", remarks);
|
|
|
- sqlList.add(sqlFactory.getSQL());
|
|
|
- dbConnect.runSqlUpdate(sqlList);
|
|
|
-
|
|
|
- content.put("sa_promotionid", sa_promotionid);
|
|
|
-
|
|
|
- return querypromotionMain();
|
|
|
- }
|
|
|
- @API(title = "促销方案详情", apiversion = R.ID20221230144703.v1.class)
|
|
|
- @CACHEING
|
|
|
- public String querypromotionMain() throws YosException {
|
|
|
- Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "促销方案详情查询");
|
|
|
- sqlFactory.addParameter("sa_promotionid", sa_promotionid);
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
- Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
- //附件
|
|
|
+ public promotion(JSONObject arg0) throws YosException {
|
|
|
+ super(arg0);
|
|
|
+ // TODO Auto-generated constructor stub
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "促销方案新增更新", apiversion = R.ID20221230144503.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20221230144703.v1.class, R.ID20221230144803.v1.class, R.ID20220103140003.v1.class})
|
|
|
+ public String insertormodify_promotion() throws YosException {
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ // 表名
|
|
|
+ String tableName = "sa_promotion";
|
|
|
+ Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
+ Long sa_accountclassid = content.getLong("sa_accountclassid");
|
|
|
+ Long sa_brandid = content.getLong("sa_brandid");
|
|
|
+ String promname = content.getStringValue("promname");
|
|
|
+ String remarks = content.getStringValue("remarks");
|
|
|
+ String type = content.getStringValue("type");
|
|
|
+ //String tradefield = content.getStringValue("tradefield");
|
|
|
+ JSONArray tradefield = content.getJSONArray("tradefield");
|
|
|
+ BigDecimal orderminqty = content.getBigDecimal("orderminqty");
|
|
|
+ BigDecimal orderaddqty = content.getBigDecimal("orderaddqty");
|
|
|
+ BigDecimal orderminamount = content.getBigDecimal("orderminamount");
|
|
|
+ String begdate = content.getStringValue("begdate");
|
|
|
+ String enddate = content.getStringValue("enddate");
|
|
|
+ Long authmethod = content.getLongValue("authmethod");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "促销方案新增");
|
|
|
+
|
|
|
+ if (sa_promotionid <= 0 || dbConnect
|
|
|
+ .runSqlQuery("select sa_promotionid from sa_promotion where sa_promotionid=" + sa_promotionid)
|
|
|
+ .isEmpty()) {
|
|
|
+ sa_promotionid = createTableID(tableName);
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "新增", "促销方案新增成功").getSQL());
|
|
|
+ } else {
|
|
|
+ Rows rows = dbConnect
|
|
|
+ .runSqlQuery("SELECT status from sa_promotion WHERE sa_promotionid = " + sa_promotionid);
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ if (rows.get(0).getString("status").equals("新建")) {
|
|
|
+ sqlFactory = new SQLFactory(this, "促销方案更新");
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "更新", "促销方案更新成功").getSQL());
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("非新建状态下无法编辑").toString();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("该促销方案不存在").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter("userid", userid);
|
|
|
+ sqlFactory.addParameter("username", username);
|
|
|
+ sqlFactory.addParameter("sa_promotionid", sa_promotionid);
|
|
|
+ // 促销方案号createBillCode("promotionbillno")
|
|
|
+ sqlFactory.addParameter("promnum", createBillCode("promotionbill"));
|
|
|
+ sqlFactory.addParameter("promname", promname);
|
|
|
+ sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
|
|
|
+ sqlFactory.addParameter("sa_brandid", sa_brandid);
|
|
|
+ sqlFactory.addParameter("type", type);
|
|
|
+ sqlFactory.addParameter("tradefield", tradefield.toJSONString());
|
|
|
+ sqlFactory.addParameter("orderminqty", orderminqty);
|
|
|
+ sqlFactory.addParameter("orderaddqty", orderaddqty);
|
|
|
+ sqlFactory.addParameter("orderminamount", orderminamount);
|
|
|
+ sqlFactory.addParameter("sa_openpromotionid", content.getIntValue("sa_openpromotionid"));
|
|
|
+ sqlFactory.addParameter("openamount", content.getBigDecimalValue("openamount"));
|
|
|
+ sqlFactory.addParameter("isrelevancepromotion", content.getLongValue("isrelevancepromotion"));
|
|
|
+
|
|
|
+ sqlFactory.addParameter("begdate", begdate);
|
|
|
+ sqlFactory.addParameter("enddate", enddate);
|
|
|
+ sqlFactory.addParameter("authmethod", authmethod);
|
|
|
+ // 备注说明
|
|
|
+ sqlFactory.addParameter("remarks", remarks);
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+ content.put("sa_promotionid", sa_promotionid);
|
|
|
+
|
|
|
+ return querypromotionMain();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "促销方案详情", apiversion = R.ID20221230144703.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String querypromotionMain() throws YosException {
|
|
|
+ Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "促销方案详情查询");
|
|
|
+ sqlFactory.addParameter("sa_promotionid", sa_promotionid);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
+ //附件
|
|
|
ArrayList<Long> ids = rows.toArrayList("sa_promotionid", new ArrayList<>());
|
|
|
RowsMap attRowsMap = getAttachmentUrl("sa_promotion", ids);
|
|
|
- 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());
|
|
|
- }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
return getSucReturnObject().setData(row).toString();
|
|
|
- }
|
|
|
-
|
|
|
- @API(title = "查询促销方案列表", apiversion = R.ID20221230144803.v1.class)
|
|
|
- @CACHEING
|
|
|
- public String querypromotionList() 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.promnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t1.promname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append(")");
|
|
|
- }
|
|
|
- if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
- where.append(" and t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
- }
|
|
|
- }
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "促销方案列表查询", pageSize, pageNumber, pageSorting);
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter_SQL("where", where);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
- //附件
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "查询促销方案列表", apiversion = R.ID20221230144803.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String querypromotionList() 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.promnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.promname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
+ where.append(" and t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "促销方案列表查询", pageSize, pageNumber, pageSorting);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ 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());
|
|
|
- }
|
|
|
+ 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 {
|
|
|
-
|
|
|
- ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- JSONArray sa_promotionids = content.getJSONArray("sa_promotionids");
|
|
|
- BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_promotionids.size());
|
|
|
- for (Object o : sa_promotionids) {
|
|
|
- long sa_promotionid = Long.parseLong(o.toString());
|
|
|
- Rows RowsStatus = dbConnect.runSqlQuery("select sa_promotionid,status from sa_promotion where siteid='"
|
|
|
- + siteid + "' and sa_promotionid='" + sa_promotionid + "'");
|
|
|
-
|
|
|
- if (RowsStatus.isNotEmpty()) {
|
|
|
- if (!RowsStatus.get(0).getString("status").equals("新建")) {
|
|
|
- batchDeleteErr.addErr(sa_promotionid, "非新建状态的促销方案无法删除");
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- sqlList.add("delete from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
|
|
|
- sqlList.add(
|
|
|
- "delete from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
|
|
|
- sqlList.add("delete from sa_promotion_itemgroup where siteid='" + siteid + "' and sa_promotionid="
|
|
|
- + sa_promotionid);
|
|
|
- sqlList.add("delete from sa_promotion_itemprice where siteid='" + siteid + "' and sa_promotionid="
|
|
|
- + sa_promotionid);
|
|
|
- sqlList.add("delete from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid="
|
|
|
- + sa_promotionid);
|
|
|
- dbConnect.runSqlUpdate(sqlList);
|
|
|
- }
|
|
|
- return batchDeleteErr.getReturnObject().toString();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @API(title = "审核", apiversion = R.ID20221230145003.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = { R.ID20221230144703.v1.class, R.ID20221230144803.v1.class, R.ID20220103140003.v1.class })
|
|
|
- public String check() throws YosException {
|
|
|
- Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
-
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_promotionid,status,promnum,promname from sa_promotion where sa_promotionid ='"
|
|
|
- + sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
- if (rows.isEmpty()) {
|
|
|
- return getErrReturnObject().setErrMsg("该促销方案不存在").toString();
|
|
|
- } else {
|
|
|
- if (!rows.get(0).getString("status").equals("新建")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("promnum") + "】的促销方案为非新建状态,无法审核")
|
|
|
- .toString();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ArrayList<String> sqlList = new ArrayList<>();
|
|
|
-
|
|
|
- SQLFactory sqlFactoryupdate = new SQLFactory(this, "促销方案审核");
|
|
|
- sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
- sqlFactoryupdate.addParameter("sa_promotionid", sa_promotionid);
|
|
|
- sqlFactoryupdate.addParameter("checkby", username);
|
|
|
- sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "审核", "促销方案审核成功").getSQL());
|
|
|
- dbConnect.runSqlUpdate(sqlList);
|
|
|
- return getSucReturnObject().toString();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @API(title = "反审核", apiversion = R.ID20221230145103.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = { R.ID20221230144703.v1.class, R.ID20221230144803.v1.class,R.ID20220103140003.v1.class })
|
|
|
- public String uncheck() throws YosException {
|
|
|
- Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
-
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_promotionid,status,promnum,promname from sa_promotion where sa_promotionid ='"
|
|
|
- + sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
- if (rows.isEmpty()) {
|
|
|
- return getErrReturnObject().setErrMsg("该促销方案不存在").toString();
|
|
|
- } else {
|
|
|
- if (!rows.get(0).getString("status").equals("审核")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("promnum") + "】的促销方案为非审核状态,无法反审核")
|
|
|
- .toString();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ArrayList<String> sqlList = new ArrayList<>();
|
|
|
-
|
|
|
- SQLFactory sqlFactoryupdate = new SQLFactory(this, "促销方案反审核");
|
|
|
- sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
- sqlFactoryupdate.addParameter("sa_promotionid", sa_promotionid);
|
|
|
- sqlFactoryupdate.addParameter("checkby", username);
|
|
|
- sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "反审核", "促销方案反审核成功").getSQL());
|
|
|
- dbConnect.runSqlUpdate(sqlList);
|
|
|
- return getSucReturnObject().toString();
|
|
|
- }
|
|
|
-
|
|
|
- @API(title = "发布反发布", apiversion = R.ID20221230145203.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = { R.ID20221230144703.v1.class, R.ID20221230144803.v1.class , R.ID20220103140003.v1.class })
|
|
|
- public String recheck() throws YosException {
|
|
|
- Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
- boolean isrecheck = content.getBooleanValue("isrecheck");
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_promotionid,status,promnum from sa_promotion where sa_promotionid ='"
|
|
|
- + sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
- for (Row row : rows) {
|
|
|
- if (isrecheck) {
|
|
|
- if (!row.getString("status").equals("审核")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("promnum") + "】的促销方案为非审核状态,无法发布")
|
|
|
- .toString();
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!row.getString("status").equals("发布")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("promnum") + "】的促销方案为非发布状态,无法反发布")
|
|
|
- .toString();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- SQLFactory sqlFactoryupdate;
|
|
|
- if (isrecheck) {
|
|
|
- sqlFactoryupdate = new SQLFactory(this, "促销方案发布");
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "发布", "促销方案发布成功").getSQL());
|
|
|
- } else {
|
|
|
- sqlFactoryupdate = new SQLFactory(this, "促销方案反发布");
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "反发布", "促销方案反发布成功").getSQL());
|
|
|
- }
|
|
|
- sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
- sqlFactoryupdate.addParameter("sa_promotionid", sa_promotionid);
|
|
|
- sqlFactoryupdate.addParameter("sendby", username);
|
|
|
- sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
-
|
|
|
- dbConnect.runSqlUpdate(sqlList);
|
|
|
- return getSucReturnObject().toString();
|
|
|
- }
|
|
|
- @API(title = "关闭反关闭", apiversion = R.ID20230102095403.v1.class)
|
|
|
- @CACHEING_CLEAN(apiversions = { R.ID20221230144703.v1.class, R.ID20221230144803.v1.class , R.ID20220103140003.v1.class})
|
|
|
- public String close() throws YosException {
|
|
|
- Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
- boolean isclose = content.getBooleanValue("isclose");
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select sa_promotionid,status,promnum from sa_promotion where sa_promotionid ='"
|
|
|
- + sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
- for (Row row : rows) {
|
|
|
- if (isclose) {
|
|
|
- if (!row.getString("status").equals("发布")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("promnum") + "】的促销方案为非发布状态,无法关闭")
|
|
|
- .toString();
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!row.getString("status").equals("关闭")) {
|
|
|
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("promnum") + "】的促销方案为非关闭状态,无法反关闭")
|
|
|
- .toString();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- SQLFactory sqlFactoryupdate;
|
|
|
- if (isclose) {
|
|
|
- sqlFactoryupdate = new SQLFactory(this, "促销方案关闭");
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "关闭", "促销方案关闭成功").getSQL());
|
|
|
- } else {
|
|
|
- sqlFactoryupdate = new SQLFactory(this, "促销方案反关闭");
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "反关闭", "促销方案反关闭成功").getSQL());
|
|
|
- }
|
|
|
- sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
- sqlFactoryupdate.addParameter("sa_promotionid", sa_promotionid);
|
|
|
- sqlFactoryupdate.addParameter("closeby", username);
|
|
|
- sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
-
|
|
|
- dbConnect.runSqlUpdate(sqlList);
|
|
|
- return getSucReturnObject().toString();
|
|
|
- }
|
|
|
+
|
|
|
+ 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 {
|
|
|
+
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ JSONArray sa_promotionids = content.getJSONArray("sa_promotionids");
|
|
|
+ BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_promotionids.size());
|
|
|
+ for (Object o : sa_promotionids) {
|
|
|
+ long sa_promotionid = Long.parseLong(o.toString());
|
|
|
+ Rows RowsStatus = dbConnect.runSqlQuery("select sa_promotionid,status from sa_promotion where siteid='"
|
|
|
+ + siteid + "' and sa_promotionid='" + sa_promotionid + "'");
|
|
|
+
|
|
|
+ if (RowsStatus.isNotEmpty()) {
|
|
|
+ if (!RowsStatus.get(0).getString("status").equals("新建")) {
|
|
|
+ batchDeleteErr.addErr(sa_promotionid, "非新建状态的促销方案无法删除");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sqlList.add("delete from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
|
|
|
+ sqlList.add(
|
|
|
+ "delete from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
|
|
|
+ sqlList.add("delete from sa_promotion_itemgroup where siteid='" + siteid + "' and sa_promotionid="
|
|
|
+ + sa_promotionid);
|
|
|
+ sqlList.add("delete from sa_promotion_itemprice where siteid='" + siteid + "' and sa_promotionid="
|
|
|
+ + sa_promotionid);
|
|
|
+ sqlList.add("delete from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid="
|
|
|
+ + sa_promotionid);
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ }
|
|
|
+ return batchDeleteErr.getReturnObject().toString();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "审核", apiversion = R.ID20221230145003.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20221230144703.v1.class, R.ID20221230144803.v1.class, R.ID20220103140003.v1.class})
|
|
|
+ public String check() throws YosException {
|
|
|
+ Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
+
|
|
|
+ Rows rows = dbConnect
|
|
|
+ .runSqlQuery("select sa_promotionid,status,promnum,promname from sa_promotion where sa_promotionid ='"
|
|
|
+ + sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("该促销方案不存在").toString();
|
|
|
+ } else {
|
|
|
+ if (!rows.get(0).getString("status").equals("新建")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("promnum") + "】的促销方案为非新建状态,无法审核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+
|
|
|
+ SQLFactory sqlFactoryupdate = new SQLFactory(this, "促销方案审核");
|
|
|
+ sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
+ sqlFactoryupdate.addParameter("sa_promotionid", sa_promotionid);
|
|
|
+ sqlFactoryupdate.addParameter("checkby", username);
|
|
|
+ sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "审核", "促销方案审核成功").getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "反审核", apiversion = R.ID20221230145103.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20221230144703.v1.class, R.ID20221230144803.v1.class, R.ID20220103140003.v1.class})
|
|
|
+ public String uncheck() throws YosException {
|
|
|
+ Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
+
|
|
|
+ Rows rows = dbConnect
|
|
|
+ .runSqlQuery("select sa_promotionid,status,promnum,promname from sa_promotion where sa_promotionid ='"
|
|
|
+ + sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("该促销方案不存在").toString();
|
|
|
+ } else {
|
|
|
+ if (!rows.get(0).getString("status").equals("审核")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("promnum") + "】的促销方案为非审核状态,无法反审核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+
|
|
|
+ SQLFactory sqlFactoryupdate = new SQLFactory(this, "促销方案反审核");
|
|
|
+ sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
+ sqlFactoryupdate.addParameter("sa_promotionid", sa_promotionid);
|
|
|
+ sqlFactoryupdate.addParameter("checkby", username);
|
|
|
+ sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "反审核", "促销方案反审核成功").getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "发布反发布", apiversion = R.ID20221230145203.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20221230144703.v1.class, R.ID20221230144803.v1.class, R.ID20220103140003.v1.class})
|
|
|
+ public String recheck() throws YosException {
|
|
|
+ Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
+ boolean isrecheck = content.getBooleanValue("isrecheck");
|
|
|
+ Rows rows = dbConnect
|
|
|
+ .runSqlQuery("select sa_promotionid,status,promnum from sa_promotion where sa_promotionid ='"
|
|
|
+ + sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
+ for (Row row : rows) {
|
|
|
+ if (isrecheck) {
|
|
|
+ if (!row.getString("status").equals("审核")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("promnum") + "】的促销方案为非审核状态,无法发布")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!row.getString("status").equals("发布")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("promnum") + "】的促销方案为非发布状态,无法反发布")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ SQLFactory sqlFactoryupdate;
|
|
|
+ if (isrecheck) {
|
|
|
+ sqlFactoryupdate = new SQLFactory(this, "促销方案发布");
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "发布", "促销方案发布成功").getSQL());
|
|
|
+ } else {
|
|
|
+ sqlFactoryupdate = new SQLFactory(this, "促销方案反发布");
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "反发布", "促销方案反发布成功").getSQL());
|
|
|
+ }
|
|
|
+ sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
+ sqlFactoryupdate.addParameter("sa_promotionid", sa_promotionid);
|
|
|
+ sqlFactoryupdate.addParameter("sendby", username);
|
|
|
+ sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "关闭反关闭", apiversion = R.ID20230102095403.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20221230144703.v1.class, R.ID20221230144803.v1.class, R.ID20220103140003.v1.class})
|
|
|
+ public String close() throws YosException {
|
|
|
+ Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
+ boolean isclose = content.getBooleanValue("isclose");
|
|
|
+ Rows rows = dbConnect
|
|
|
+ .runSqlQuery("select sa_promotionid,status,promnum from sa_promotion where sa_promotionid ='"
|
|
|
+ + sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
+ for (Row row : rows) {
|
|
|
+ if (isclose) {
|
|
|
+ if (!row.getString("status").equals("发布")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("promnum") + "】的促销方案为非发布状态,无法关闭")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!row.getString("status").equals("关闭")) {
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("promnum") + "】的促销方案为非关闭状态,无法反关闭")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ SQLFactory sqlFactoryupdate;
|
|
|
+ if (isclose) {
|
|
|
+ sqlFactoryupdate = new SQLFactory(this, "促销方案关闭");
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "关闭", "促销方案关闭成功").getSQL());
|
|
|
+ } else {
|
|
|
+ sqlFactoryupdate = new SQLFactory(this, "促销方案反关闭");
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "反关闭", "促销方案反关闭成功").getSQL());
|
|
|
+ }
|
|
|
+ sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
+ sqlFactoryupdate.addParameter("sa_promotionid", sa_promotionid);
|
|
|
+ sqlFactoryupdate.addParameter("closeby", username);
|
|
|
+ sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "切换授权方式", apiversion = R.ID20230509100504.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiversions = {R.ID20221230144703.v1.class})
|
|
|
+ public String updateAuthMethod() throws YosException {
|
|
|
+ Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select sa_promotionid,status,authmethod from sa_promotion where sa_promotionid ='" + sa_promotionid + "' and siteid='" + siteid + "'");
|
|
|
+ if (rows.isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("无效促销方案").toString();
|
|
|
+ }
|
|
|
+ if (!rows.get(0).getString("status").equals("新建")) {
|
|
|
+ return getErrReturnObject().setErrMsg("非新建状态不能修改授权方式").toString();
|
|
|
+ }
|
|
|
+ if (rows.get(0).getLong("authmethod") == 0) {
|
|
|
+ dbConnect.runSqlUpdate("update sa_promotion set authmethod=1 where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
|
|
|
+ } else {
|
|
|
+ dbConnect.runSqlUpdate("update sa_promotion set authmethod=0 where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
|
|
|
+ }
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
}
|