Browse Source

商品管理新增调整

eganwu 1 year ago
parent
commit
2b4c85aabd

+ 25 - 0
src/custom/restcontroller/R.java

@@ -6239,6 +6239,31 @@ public class R {
         }
     }
 
+    public static class ID20240429152502 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240429152602 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240429152702 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240429152802 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240429152902 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 87 - 0
src/custom/restcontroller/webmanage/saletool/custorder/CustOrder.java

@@ -0,0 +1,87 @@
+package restcontroller.webmanage.saletool.custorder;
+
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.data.InsertSQL;
+import common.data.Row;
+import common.data.Rows;
+import common.data.SQLFactory;
+import restcontroller.R;
+
+
+/**
+ * C端订单
+ */
+
+public class CustOrder extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public CustOrder(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    @API(title = "(C端)订单新增或编辑", apiversion = R.ID20240429152502.v1.class)
+    public String insertOrUpdate() throws YosException {
+
+        Long sa_custorderid = content.getLongValue("sa_custorderid");
+        Long sa_fadid = content.getLongValue("sa_fadid");
+
+        Rows fadRows = dbConnect.runSqlQuery("SELECT * from sa_fad WHERE sa_fadid=" + sa_fadid + " and siteid='" + siteid + "'");
+        if (fadRows.isEmpty()) {
+            return getErrReturnObject().setErrMsg("商品不存在").toString();
+        }
+        Row fadRow = fadRows.get(0);
+
+        if (sa_custorderid <= 0) {
+            sa_custorderid = createTableID("sa_custorder");
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_custorder");
+            insertSQL.setUniqueid(sa_custorderid);
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("", "");
+            insertSQL.insert();
+
+
+            insertSQL = SQLFactory.createInsertSQL(this, "sa_custorderitems");
+            insertSQL.setUniqueid(createTableID("sa_custorderitems"));
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("sa_custorderid", sa_custorderid);
+            insertSQL.setValue("sa_fadid", content.getLongValue("sa_fadid"));
+            insertSQL.setValue("pricetype", content.getLongValue("sa_fadid"));
+            insertSQL.insert();
+
+            content.put("sa_custorderid", sa_custorderid);
+        } else {
+
+        }
+
+
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "(C端)订单详情", apiversion = R.ID20240429152602.v1.class)
+    public String detail() {
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "(C端)订单删除", apiversion = R.ID20240429152702.v1.class)
+    public String delete() {
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "(C端)订单更新订单日志", apiversion = R.ID20240429152802.v1.class)
+    public String updateRemarks() {
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "(C端)订单列表", apiversion = R.ID20240429152902.v1.class)
+    public String list() {
+        return getSucReturnObject().toString();
+    }
+
+
+}

+ 30 - 17
src/custom/restcontroller/webmanage/saletool/fad/FadGoods.java

@@ -29,14 +29,19 @@ public class FadGoods extends Controller {
 
     String sa_fad = "sa_fad";
 
-    @API(title = "品新增或编辑", apiversion = R.ID20240428154102.v1.class)
+    @API(title = "品新增或编辑", apiversion = R.ID20240428154102.v1.class)
     public String insertOrUpdate() throws YosException {
         Long sa_fadid = content.getLongValue("sa_fadid");
-        int isonsale = content.getIntValue("isonsale");
+        boolean canadjust = content.getBooleanValue("canadjust");
         String tag = content.getStringValue("tag");
         Long parentid = 0L;
+        if (content.containsKey("sys_enterpriseid") && content.getLongValue("sys_enterpriseid") != 0) {
+            sys_enterpriseid = content.getLongValue("sys_enterpriseid");
+        }
 
         ArrayList<String> listSQL = new ArrayList<>();
+        ArrayList<Long> sa_fadids = new ArrayList<>();
+
         Rows fadRows = dbConnect.runSqlQuery("SELECT * from sa_fad WHERE sa_fadid=" + sa_fadid + " and siteid='" + siteid + "'");
         if (sa_fadid <= 0 || fadRows.isEmpty()) {
             sa_fadid = createTableID(sa_fad);
@@ -45,22 +50,31 @@ public class FadGoods extends Controller {
             content.put("sa_fadid", sa_fadid);
         } else {
 
-            boolean canadjust = fadRows.get(0).getBoolean("canadjust");
+            boolean temp_canadjust = fadRows.get(0).getBoolean("canadjust");
             long temp_sys_enterpriseid = fadRows.get(0).getLong("sys_enterpriseid");
             //允许经销商调整,数据是总部的,修改方为总部
-            if (canadjust && temp_sys_enterpriseid == 0 && sys_enterpriseid == 0) {
+            if (temp_canadjust && temp_sys_enterpriseid == 0 && sys_enterpriseid == 0) {
                 UpdateSQL sqlFactory = FadHelper.getFadUpdateSQL(this, sa_fadid);
                 listSQL.add(sqlFactory.getSQL());
                 //更新parentid为sa_fadid的数据
                 Rows rows = dbConnect.runSqlQuery("SELECT sa_fadid from sa_fad WHERE parentid=" + sa_fadid + " and siteid='" + siteid + "'");
-                for (Row row : rows) {
-                    sqlFactory = FadHelper.getFadUpdateSQL(this, row.getLong("sa_fadid"));
-                    listSQL.add(sqlFactory.getSQL());
+                //修改项为禁止经销商修改
+                if (!canadjust) {
+                    DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sa_fad");
+                    deleteSQL.setSiteid(siteid);
+                    deleteSQL.setWhere("parentid", sa_fadid);
+                    deleteSQL.delete();
+                } else {
+                    sa_fadids = rows.toArrayList("sa_fadid", new ArrayList<>());
+                    for (Row row : rows) {
+                        sqlFactory = FadHelper.getFadUpdateSQL(this, row.getLong("sa_fadid"));
+                        listSQL.add(sqlFactory.getSQL());
+                    }
                 }
 
             }
             //允许经销商调整,数据是总部的,修改方为经销商
-            else if (canadjust && temp_sys_enterpriseid == 0 && sys_enterpriseid > 0) {
+            else if (temp_canadjust && temp_sys_enterpriseid == 0 && sys_enterpriseid > 0) {
                 parentid = sa_fadid;
                 sa_fadid = createTableID(sa_fad);
                 InsertSQL sqlFactory = FadHelper.getFadInsertSQL(this, sa_fadid, parentid);
@@ -74,18 +88,17 @@ public class FadGoods extends Controller {
 
         }
 
+        sa_fadids.add(sa_fadid);
+        for (Long id : sa_fadids) {
+            listSQL.add(FadHelper.getIsOnSalesUpdateSQL(this, id).getSQL());
+        }
         //上下架
-        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, sa_fad);
-        updateSQL.setSiteid(siteid);
-        updateSQL.setWhere("sa_fadid", sa_fadid);
-        updateSQL.setValue("isonsale", isonsale);
-        updateSQL.setValue("onsaledate", isonsale == 1 ? Time.getDateTime_Str() : "null");
-        updateSQL.setValue("onsaleby", isonsale == 1 ? username : "null");
-        listSQL.add(updateSQL.getSQL());
         dbConnect.runSqlUpdate(listSQL);
 
-        DataTag.deleteTag(this, "sa_fad", sa_fadid);
-        DataTag.createSystemTag(this, "sa_fad", sa_fadid, tag);
+        for (Long id : sa_fadids) {
+            DataTag.deleteTag(this, "sa_fad", id);
+            DataTag.createSystemTag(this, "sa_fad", id, tag);
+        }
 
 
         return detail();

+ 14 - 2
src/custom/restcontroller/webmanage/saletool/fad/FadHelper.java

@@ -1,6 +1,7 @@
 package restcontroller.webmanage.saletool.fad;
 
 import beans.parameter.Parameter;
+import beans.time.Time;
 import common.BaseClass;
 import common.Controller;
 import common.YosException;
@@ -23,7 +24,7 @@ public class FadHelper extends BaseClass {
         }
     }
 
-    public static InsertSQL getFadInsertSQL(Controller controller, Long sa_fadid,Long parentid) throws YosException {
+    public static InsertSQL getFadInsertSQL(Controller controller, Long sa_fadid, Long parentid) throws YosException {
         InsertSQL sqlFactory = SQLFactory.createInsertSQL(controller, "sa_fad");
         sqlFactory.setSiteid(controller.siteid);
         sqlFactory.setUniqueid(sa_fadid);
@@ -44,7 +45,7 @@ public class FadHelper extends BaseClass {
         sqlFactory.setValue("sequence", controller.content.getLongValue("sequence"));
         sqlFactory.setValue("content", controller.content.getStringValue("contentstr", true));
         sqlFactory.setValue("classid", 2);
-        sqlFactory.setValue("parentid",parentid);
+        sqlFactory.setValue("parentid", parentid);
         sqlFactory.setValue("canadjust", controller.content.getLongValue("canadjust"));
         sqlFactory.setValue("sys_enterpriseid", controller.sys_enterpriseid);
         return sqlFactory;
@@ -74,4 +75,15 @@ public class FadHelper extends BaseClass {
         return sqlFactory;
     }
 
+    public static UpdateSQL getIsOnSalesUpdateSQL(Controller controller, long sa_fadid) throws YosException {
+        int isonsale = controller.content.getIntValue("isonsale");
+        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(controller, "sa_fad");
+        updateSQL.setSiteid(controller.siteid);
+        updateSQL.setWhere("sa_fadid", sa_fadid);
+        updateSQL.setValue("isonsale", isonsale);
+        updateSQL.setValue("onsaledate", isonsale == 1 ? Time.getDateTime_Str() : "null");
+        updateSQL.setValue("onsaleby", isonsale == 1 ? controller.username : "null");
+        return updateSQL;
+    }
+
 }