浏览代码

促销方案商品上下架及修改返点比例添加操作日志

hu 1 年之前
父节点
当前提交
0aa6eb76d5

+ 4 - 1
src/custom/restcontroller/webmanage/sale/promotion/promotion.java

@@ -64,7 +64,7 @@ public class promotion extends Controller {
             sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "新增", "促销方案新增成功").getSQL());
         } else {
             Rows rows = dbConnect
-                    .runSqlQuery("SELECT status,authmethod from sa_promotion WHERE sa_promotionid = " + sa_promotionid);
+                    .runSqlQuery("SELECT status,authmethod,rebateratio from sa_promotion WHERE sa_promotionid = " + sa_promotionid);
             if (rows.isNotEmpty()) {
                 if (rows.get(0).getString("status").equals("新建")) {
                     sqlFactory = new SQLFactory(this, "促销方案更新");
@@ -75,6 +75,9 @@ public class promotion extends Controller {
                         }
                         sqlList.add("delete from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
                     }
+                    if (rebateratio.compareTo(rows.get(0).getBigDecimal("rebateratio")) != 0) {
+                        sqlList.add(DataContrlLog.createLog(this, "sa_promotion", sa_promotionid, "促销方案由返点比例:" + rows.get(0).getBigDecimal("rebateratio") + "修改为返点比例:" + rebateratio, "促销方案修改返点比例").getSQL());
+                    }
                 } else {
                     return getErrReturnObject().setErrMsg("非新建状态下无法编辑").toString();
                 }

+ 13 - 1
src/custom/restcontroller/webmanage/sale/promotion/promotionItems.java

@@ -204,6 +204,7 @@ public class promotionItems extends Controller {
     @API(title = "促销方案商品上下架", apiversion = R.ID20230927135803.v1.class)
     @CACHEING_CLEAN(apiClass = {promotionItems.class, promotion.class,restcontroller.sale.promotion.promotion.class})
     public String release() throws YosException {
+        ArrayList<String> sqlList = new ArrayList<>();
         JSONArray sa_promotion_itemsids = content.getJSONArray("sa_promotion_itemsids");
         boolean isonsale = content.getBooleanValue("isonsale");
         List<Long> list = sa_promotion_itemsids.toJavaList(Long.class);
@@ -218,11 +219,22 @@ public class promotionItems extends Controller {
         }
         sqlFactoryupdate.addParameter("siteid", siteid);
         sqlFactoryupdate.addParameter_in("sa_promotion_itemsids", stringArray);
-        dbConnect.runSqlUpdate(sqlFactoryupdate);
+        sqlList.add(sqlFactoryupdate.getSQL());
 //        //发送消息
 //        for (String id : stringArray) {
 //            sendMsg(Long.parseLong(id));
 //        }
+        String sql = "select t1.itemid,t1.orderminqty,t1.orderaddqty,t1.itemname,t2.sa_promotionid from plm_item t1 inner join sa_promotion_items t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.siteid='" + siteid + "' and t2.sa_promotion_itemsid in " + sa_promotion_itemsids;
+        sql = sql.replace("[", "(").replace("]", ")");
+        Rows itemrows = dbConnect.runSqlQuery(sql);
+        for (Row row :itemrows){
+            if(isonsale){
+                sqlList.add(DataContrlLog.createLog(this, "sa_promotion", row.getLong("sa_promotionid"), "促销方案商品【"+row.getString("itemname")+"】由"+username+"上架", "促销方案商品上下架").getSQL());
+            }else{
+                sqlList.add(DataContrlLog.createLog(this, "sa_promotion", row.getLong("sa_promotionid"), "促销方案商品【"+row.getString("itemname")+"】由"+username+"下架" , "促销方案商品上下架").getSQL());
+            }
+        }
+        dbConnect.runSqlUpdate(sqlList);
         return getSucReturnObject().toString();
     }