|
@@ -130,6 +130,91 @@ public class promotion extends Controller {
|
|
|
return getSucReturnObject().setData(row).toString();
|
|
return getSucReturnObject().setData(row).toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @API(title = "一键复制促销方案", apiversion = R.ID20230713101303.v1.class)
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {promotion.class, promotionSalearea.class,promotionAuth.class,promotionItems.class, promotionItemPrice.class})
|
|
|
|
|
+ public String copyPromotion() throws YosException {
|
|
|
|
|
+
|
|
|
|
|
+ Long sa_promotionid = content.getLong("sa_promotionid");
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery("SELECT * from sa_promotion WHERE sa_promotionid = " + sa_promotionid + " and siteid = '" + siteid + "'");
|
|
|
|
|
+
|
|
|
|
|
+ if (rows.isEmpty()) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("促销方案不存在").toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ Row row = rows.get(0);
|
|
|
|
|
+
|
|
|
|
|
+ Long sa_promotion_copy = createTableID("sa_promotion");
|
|
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "促销方案新增");
|
|
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
+ sqlFactory.addParameter("sa_promotionid", sa_promotion_copy);
|
|
|
|
|
+ sqlFactory.addParameter("userid", userid);
|
|
|
|
|
+ sqlFactory.addParameter("username", username);
|
|
|
|
|
+ //促销方案名称
|
|
|
|
|
+ sqlFactory.addParameter("promname", row.getString("promname")+"复制");
|
|
|
|
|
+ sqlFactory.addParameter("promnum", createBillCode("promotionbill"));
|
|
|
|
|
+ sqlFactory.addParameter("sa_accountclassid", row.getLong("sa_accountclassid"));
|
|
|
|
|
+ sqlFactory.addParameter("sa_brandid", row.getLong("sa_brandid"));
|
|
|
|
|
+ sqlFactory.addParameter("type", row.getString("type"));
|
|
|
|
|
+ sqlFactory.addParameter("tradefield", row.getString("tradefield"));
|
|
|
|
|
+ sqlFactory.addParameter("orderminqty", row.getString("orderminqty"));
|
|
|
|
|
+ sqlFactory.addParameter("orderaddqty", row.getString("orderaddqty"));
|
|
|
|
|
+ sqlFactory.addParameter("orderminamount", row.getString("orderminamount"));
|
|
|
|
|
+ sqlFactory.addParameter("sa_openpromotionid", row.getString("sa_openpromotionid"));
|
|
|
|
|
+ sqlFactory.addParameter("openamount", row.getBigDecimal("openamount"));
|
|
|
|
|
+ sqlFactory.addParameter("isrelevancepromotion", row.getString("isrelevancepromotion"));
|
|
|
|
|
+
|
|
|
|
|
+ sqlFactory.addParameter("begdate", row.getString("begdate"));
|
|
|
|
|
+ sqlFactory.addParameter("enddate", row.getString("enddate"));
|
|
|
|
|
+ sqlFactory.addParameter("authmethod", row.getString("authmethod"));
|
|
|
|
|
+ // 备注说明
|
|
|
|
|
+ sqlFactory.addParameter("remarks", row.getString("remarks"));
|
|
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
|
|
+
|
|
|
|
|
+ //复制商品
|
|
|
|
|
+ Rows promotionitemsRows = dbConnect.runSqlQuery("SELECT * from sa_promotion_items WHERE sa_promotionid = " + sa_promotionid + " and siteid = '" + siteid + "'");
|
|
|
|
|
+ //复制商品
|
|
|
|
|
+ Rows promotionitemspriceRows = dbConnect.runSqlQuery("SELECT * from sa_promotion_itemprice WHERE sa_promotionid = " + sa_promotionid + " and siteid = '" + siteid + "'");
|
|
|
|
|
+ RowsMap promotionitemspriceRowsMap =promotionitemspriceRows.toRowsMap("sa_promotion_itemsid");
|
|
|
|
|
+
|
|
|
|
|
+ for (Row promotionitemsRow : promotionitemsRows) {
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "促销方案商品新增");
|
|
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
+ long sa_promotion_itemsidcopy =createTableID("sa_promotion_items");
|
|
|
|
|
+ sqlFactory.addParameter("sa_promotion_itemsid", sa_promotion_itemsidcopy);
|
|
|
|
|
+ sqlFactory.addParameter("sa_promotionid", sa_promotion_copy);
|
|
|
|
|
+ sqlFactory.addParameter("sa_promotion_itemgroupid",promotionitemsRow.getLong("sa_promotion_itemgroupid") );
|
|
|
|
|
+ sqlFactory.addParameter("groupqty", promotionitemsRow.getBigDecimal("groupqty"));
|
|
|
|
|
+ sqlFactory.addParameter("itemid", promotionitemsRow.getLong("itemid"));
|
|
|
|
|
+ sqlFactory.addParameter("orderaddqty", promotionitemsRow.getBigDecimal("orderaddqty"));
|
|
|
|
|
+ sqlFactory.addParameter("orderminqty", promotionitemsRow.getBigDecimal("orderminqty"));
|
|
|
|
|
+ sqlFactory.addParameter("islimit", promotionitemsRow.getLong("islimit"));
|
|
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
|
|
+
|
|
|
|
|
+ if(promotionitemspriceRowsMap.containsKey(promotionitemsRow.getString("sa_promotion_itemsid")) && promotionitemspriceRowsMap.get(promotionitemsRow.getString("sa_promotion_itemsid")).isNotEmpty()){
|
|
|
|
|
+ for (Row rowdetail:promotionitemspriceRowsMap.get(promotionitemsRow.getString("sa_promotion_itemsid"))) {
|
|
|
|
|
+ SQLFactory itempriceFactory = new SQLFactory(this, "促销方案商品价格新增");
|
|
|
|
|
+ itempriceFactory.addParameter("siteid", siteid);
|
|
|
|
|
+ itempriceFactory.addParameter("sa_promotion_itempriceid",
|
|
|
|
|
+ createTableID("sa_promotion_itemprice"));
|
|
|
|
|
+ itempriceFactory.addParameter("sa_promotionid", sa_promotion_copy);
|
|
|
|
|
+ itempriceFactory.addParameter("sa_promotion_itemsid",sa_promotion_itemsidcopy);
|
|
|
|
|
+ itempriceFactory.addParameter("itemid", rowdetail.getLong("itemid"));
|
|
|
|
|
+ itempriceFactory.addParameter("pricegrade", rowdetail.getBigDecimal("pricegrade"));
|
|
|
|
|
+ itempriceFactory.addParameter("oldprice", rowdetail.getBigDecimal("oldprice"));
|
|
|
|
|
+ itempriceFactory.addParameter("price", rowdetail.getBigDecimal("price"));
|
|
|
|
|
+ sqlList.add(itempriceFactory.getSQL());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
+ content.put("sa_promotionid", sa_promotion_copy);
|
|
|
|
|
+
|
|
|
|
|
+ return querypromotionMain();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@API(title = "查询促销方案列表", apiversion = R.ID20221230144803.v1.class)
|
|
@API(title = "查询促销方案列表", apiversion = R.ID20221230144803.v1.class)
|
|
|
@CACHEING
|
|
@CACHEING
|
|
|
public String querypromotionList() throws YosException {
|
|
public String querypromotionList() throws YosException {
|