Sfoglia il codice sorgente

商品档案新增字段

hu 2 anni fa
parent
commit
151f02e4f8

+ 66 - 0
src/custom/beans/itemgroup/Itemgroup.java

@@ -0,0 +1,66 @@
+package beans.itemgroup;
+
+import com.alibaba.fastjson.JSONArray;
+import common.BaseClass;
+import common.Controller;
+import common.YosException;
+import common.data.SQLFactory;
+import java.util.ArrayList;
+
+
+public class Itemgroup extends BaseClass {
+
+
+    /**
+     * 获取增加商品组语句
+     * @param controller
+     * @param itemid
+     * @param itemname
+     * @param itemno
+     * @param tradefields
+     * @param sa_brandid
+     * @return
+     * @throws YosException
+     */
+    public static ArrayList<String> createItemGroupSql(Controller controller, long itemid, String itemname, String itemno, JSONArray tradefields, long sa_brandid) throws YosException {
+
+        ArrayList<String> sqlList = new ArrayList<>();
+        String billcode = controller.createBillCode("itemgroup");
+        long sa_itemgroupid = controller.createTableID("sa_itemgroup");
+        String tradefield="";
+        if(tradefields!=null && !tradefields.isEmpty()){
+            for (Object object:tradefields) {
+                tradefield = tradefield +(String) object + ",";
+            }
+        }
+        if (!tradefield.equals("")) {
+            tradefield = tradefield.substring(0, tradefield.length() - 1);
+        }
+
+        SQLFactory sqlAddFactory = new SQLFactory(new Itemgroup(), "商品组新增");
+        sqlAddFactory.addParameter("sa_itemgroupid", sa_itemgroupid);
+        sqlAddFactory.addParameter("siteid", controller.siteid);
+        sqlAddFactory.addParameter("groupname", itemname);
+        sqlAddFactory.addParameter("itemno", itemno);
+        sqlAddFactory.addParameter("username", controller.username);
+        sqlAddFactory.addParameter("groupnum", billcode);
+        sqlAddFactory.addParameter("tradefield", tradefield);
+        sqlAddFactory.addParameter("sa_brandid", sa_brandid);
+        sqlAddFactory.addParameter("sequence", 1);
+         System.out.println(sqlAddFactory.getSQL());
+        sqlList.add(sqlAddFactory.getSQL());
+
+        SQLFactory saleFactory = new SQLFactory(new Itemgroup(), "商品组商品明细新增");
+        saleFactory.addParameter("siteid", controller.siteid);
+        saleFactory.addParameter("sequence",1);
+        saleFactory.addParameter("sa_itemgroupmxid", controller.createTableID("sa_itemgroupmx"));
+        saleFactory.addParameter("itemno", itemno);
+        saleFactory.addParameter("itemid", itemid);
+        saleFactory.addParameter("sa_itemgroupid", sa_itemgroupid);
+        System.out.println(saleFactory.getSQL());
+        sqlList.add(saleFactory.getSQL());
+
+        return sqlList;
+    }
+
+}

+ 18 - 0
src/custom/beans/itemgroup/SQL/商品组商品明细新增.sql

@@ -0,0 +1,18 @@
+INSERT INTO sa_itemgroupmx (sa_itemgroupmxid, 
+                            siteid,
+                            sequence,
+                            itemno,
+                            itemid,
+                            sa_itemgroupid
+)
+VALUES ($sa_itemgroupmxid$,
+        $siteid$,
+        $sequence$,
+        $itemno$,
+        $itemid$,
+        $sa_itemgroupid$)
+
+
+
+
+

+ 30 - 0
src/custom/beans/itemgroup/SQL/商品组新增.sql

@@ -0,0 +1,30 @@
+INSERT INTO sa_itemgroup (sa_itemgroupid,
+                          siteid,
+                          createby,
+                          createdate,
+                          changeby,
+                          changedate,
+                          groupnum,
+                          tradefield,
+                          itemno,
+                          groupname,
+                          isonsale,
+                          sa_brandid,
+                          sequence)
+VALUES ($sa_itemgroupid$,
+        $siteid$,
+        $username$,
+        CURRENT_TIME,
+        $username$,
+        CURRENT_TIME,
+        $groupnum$,
+        $tradefield$,
+        $itemno$,
+        $groupname$,
+        1,
+        $sa_brandid$, $sequence$)
+
+
+
+
+

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

@@ -4603,6 +4603,35 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20230321153703 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230321153803 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230321153903 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230321154003 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20230321155503 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230321155603 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230321155703 {
+        public static class v1 {
+        }
+    }
 
 }
 

+ 4 - 0
src/custom/restcontroller/webmanage/sale/customscheme/SQL/商品定制方案列表查询.sql

@@ -0,0 +1,4 @@
+SELECT
+    t1.*
+FROM sa_customscheme t1
+	where t1.siteid=$siteid$ and $where$

+ 3 - 0
src/custom/restcontroller/webmanage/sale/customscheme/SQL/商品定制方案新增.sql

@@ -0,0 +1,3 @@
+insert into sa_customscheme (siteid, sa_customschemeid,createuserid,createby, createdate, billno,changeuserid,changeby, changedate,
+                                schemename,remarks)
+values ($siteid$, $sa_customschemeid$,$userid$,$username$, CURRENT_TIME, $billno$,$userid$, $username$, CURRENT_TIME, $schemename$,$remarks$);

+ 5 - 0
src/custom/restcontroller/webmanage/sale/customscheme/SQL/商品定制方案明细列表查询.sql

@@ -0,0 +1,5 @@
+SELECT
+    t1.*
+FROM
+    sa_customscheme_items t1
+where $where$ and t1.siteid=$siteid$ and t1.sa_customschemeid=$sa_customschemeid$

+ 2 - 0
src/custom/restcontroller/webmanage/sale/customscheme/SQL/商品定制方案明细新增.sql

@@ -0,0 +1,2 @@
+insert into sa_customscheme_items (siteid, sa_customscheme_itemsid,sa_customschemeid,value,description)
+values ($siteid$, $sa_customscheme_itemsid$,$sa_customschemeid$,$value$,$description$);

+ 9 - 0
src/custom/restcontroller/webmanage/sale/customscheme/SQL/商品定制方案明细更新.sql

@@ -0,0 +1,9 @@
+UPDATE sa_customscheme_items
+SET 
+    value=$value$,
+    description=$description$
+WHERE sa_customscheme_itemsid = $sa_customscheme_itemsid$
+
+
+
+

+ 12 - 0
src/custom/restcontroller/webmanage/sale/customscheme/SQL/商品定制方案更新.sql

@@ -0,0 +1,12 @@
+UPDATE sa_customscheme
+SET 
+    changeuserid=$userid$,
+    changedate = CURRENT_TIME,
+    changeby = $username$,
+    schemename = $schemename$,
+    remarks=$remarks$
+WHERE sa_customschemeid = $sa_customschemeid$ and siteid=$siteid$
+
+
+
+

+ 5 - 0
src/custom/restcontroller/webmanage/sale/customscheme/SQL/商品定制方案详情查询.sql

@@ -0,0 +1,5 @@
+SELECT
+    t1.*
+FROM
+	sa_customscheme t1
+	where t1.sa_customschemeid=$sa_customschemeid$

+ 142 - 0
src/custom/restcontroller/webmanage/sale/customscheme/customscheme.java

@@ -0,0 +1,142 @@
+package restcontroller.webmanage.sale.customscheme;
+
+import beans.data.BatchDeleteErr;
+import beans.datacontrllog.DataContrlLog;
+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.Row;
+import common.data.Rows;
+import common.data.RowsMap;
+import common.data.SQLFactory;
+import restcontroller.R;
+import restcontroller.sale.item.Item;
+import restcontroller.webmanage.sale.order.Order;
+
+import java.util.ArrayList;
+/**
+ * 商品定制方案
+ */
+@API(title = "商品定制方案")
+public class customscheme extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public customscheme(JSONObject content) throws YosException {
+        super(content);
+    }
+    @API(title = "商品定制方案单新增更新", apiversion = R.ID20230321153703.v1.class)
+    @CACHEING_CLEAN(apiClass = {customscheme.class, Item.class, restcontroller.webmanage.sale.item.Item.class})
+    public String insertormodify_customscheme() throws YosException {
+        ArrayList<String> sqlList = new ArrayList<>();
+        // 表名
+        String tableName = "sa_customscheme";
+        Long sa_customschemeid = content.getLong("sa_customschemeid");
+        String schemename = content.getStringValue("schemename");
+        String remarks = content.getStringValue("remarks");
+
+        SQLFactory sqlFactory = new SQLFactory(this, "商品定制方案新增");
+
+        if (sa_customschemeid <= 0 || dbConnect.runSqlQuery(
+                "select sa_customschemeid from sa_customscheme where sa_customschemeid=" + sa_customschemeid)
+                .isEmpty()) {
+            sa_customschemeid = createTableID(tableName);
+            sqlList.add(
+                    DataContrlLog.createLog(this, "sa_customscheme", sa_customschemeid, "新增", "商品定制方案新增成功").getSQL());
+        } else {
+            Rows rows = dbConnect.runSqlQuery(
+                    "SELECT sa_customschemeid from sa_customscheme WHERE sa_customschemeid = "
+                            + sa_customschemeid);
+            if (rows.isNotEmpty()) {
+                {
+                    sqlFactory = new SQLFactory(this, "商品定制方案更新");
+                    sqlList.add(DataContrlLog.createLog(this, "sa_customscheme", sa_customschemeid, "更新", "商品定制方案更新成功")
+                            .getSQL());
+                }
+            } else {
+                return getErrReturnObject().setErrMsg("该商品定制方案不存在").toString();
+            }
+
+        }
+
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("userid", userid);
+        sqlFactory.addParameter("username", username);
+        sqlFactory.addParameter("sa_customschemeid", sa_customschemeid);
+        //商品定制方案单号createBillCode("customschemebill")
+        sqlFactory.addParameter("billno", "1234567890");
+        sqlFactory.addParameter("schemename", schemename);
+        sqlFactory.addParameter("remarks", remarks);
+        sqlList.add(sqlFactory.getSQL());
+        dbConnect.runSqlUpdate(sqlList);
+
+        content.put("sa_customschemeid", sa_customschemeid);
+
+        return querycustomschemeMain();
+    }
+
+    @API(title = "商品定制方案单详情", apiversion = R.ID20230321153803.v1.class)
+    @CACHEING
+    public String querycustomschemeMain() throws YosException {
+        Long sa_customschemeid = content.getLong("sa_customschemeid");
+        SQLFactory sqlFactory = new SQLFactory(this, "商品定制方案详情查询");
+        sqlFactory.addParameter("sa_customschemeid", sa_customschemeid);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+        Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
+
+        return getSucReturnObject().setData(row).toString();
+    }
+
+    @API(title = "查询商品定制方案单列表", apiversion = R.ID20230321153903.v1.class)
+    @CACHEING
+    public String querycustomschemeList() 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.billno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.schemename like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "商品定制方案列表查询", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter_SQL("where", where);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "删除", apiversion = R.ID20230321154003.v1.class)
+    @CACHEING_CLEAN(apiClass = {customscheme.class})
+    public String delete() throws YosException {
+
+        JSONArray sa_customschemeids = content.getJSONArray("sa_customschemeids");
+        BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_customschemeids.size());
+        for (Object o : sa_customschemeids) {
+            long sa_customschemeid = Long.parseLong(o.toString());
+            Rows RowsStatus = dbConnect
+                    .runSqlQuery("select itemid from plm_item where siteid='" + siteid
+                            + "' and sa_customschemeid='" + sa_customschemeid + "'");
+
+            if (RowsStatus.isNotEmpty()) {
+                batchDeleteErr.addErr(sa_customschemeid, "已在商品档案中使用的定制方案无法删除");
+                continue;
+            }
+
+            dbConnect.runSqlUpdate("delete from sa_customscheme where siteid='" + siteid + "' and sa_customschemeid="
+                    + sa_customschemeid);
+        }
+        return batchDeleteErr.getReturnObject().toString();
+
+    }
+}

+ 172 - 0
src/custom/restcontroller/webmanage/sale/customscheme/customschemeItems.java

@@ -0,0 +1,172 @@
+package restcontroller.webmanage.sale.customscheme;
+
+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.Row;
+import common.data.Rows;
+import common.data.RowsMap;
+import common.data.SQLFactory;
+import org.apache.commons.io.filefilter.FalseFileFilter;
+import restcontroller.R;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+public class customschemeItems  extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public customschemeItems(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    @API(title = "方案选择列表查询", apiversion = R.ID20230105110903.v1.class)
+    @CACHEING
+    public String querySelectSchemeList() throws YosException {
+        /*
+         * 过滤条件设置
+         */
+        Long sa_customschemeid = content.getLong("sa_customschemeid");
+
+        Rows rows = dbConnect.runSqlQuery("select value from sa_customscheme_items where sa_customschemeid="+sa_customschemeid);
+        Rows selectRows = new Rows();
+
+        JSONObject jsonObject1 =new JSONObject();
+        JSONObject jsonObject2 =new JSONObject();
+        JSONObject jsonObject3 =new JSONObject();
+        jsonObject1.put("value", "spec");
+        jsonObject1.put("description", "尺寸");
+        jsonObject2.put("value", "material");
+        jsonObject2.put("description", "基材");
+        jsonObject3.put("value", "color");
+        jsonObject3.put("description", "颜色");
+
+
+        boolean hsacolor =false;
+        boolean hsamaterial =false;
+        boolean hsaspec =false;
+        if(!rows.isEmpty()){
+            for (Row row:rows) {
+               if(row.getString("value").equals("color")){
+                   hsacolor=true;
+               }
+                if(row.getString("value").equals("material")){
+                    hsamaterial=true;
+                }
+                if(row.getString("value").equals("spec")){
+                    hsaspec=true;
+                }
+            }
+        }
+        JSONArray jsonArray = new JSONArray();
+        if(!hsacolor){
+            jsonArray.add(jsonObject3);
+        }
+        if(!hsamaterial){
+            jsonArray.add(jsonObject2);
+        }
+        if(!hsaspec){
+            jsonArray.add(jsonObject1);
+        }
+        return getSucReturnObject().setData(jsonArray).toString();
+    }
+
+    @API(title = "新建或修改商品定制方案明细", apiversion = R.ID20230321155503.v1.class)
+    @CACHEING_CLEAN(apiClass = {customschemeItems.class})
+    public String insertormodify_customschemeItems() throws YosException {
+        Long sa_customschemeid = content.getLong("sa_customschemeid");
+        JSONArray iteminfos = content.getJSONArray("iteminfos");
+        ArrayList<String> sqlList = new ArrayList<>();
+        Rows rowscount = dbConnect.runSqlQuery("select sa_customschemeid from sa_customscheme where sa_customschemeid=" + sa_customschemeid);
+        if (rowscount.isEmpty()) {
+            return getErrReturnObject().setErrMsg("该商品定制方案不存在").toString();
+        }
+        int i = 0;
+        long[] sa_customscheme_itemsid = createTableID("sa_customscheme_items", iteminfos.size());
+
+        for (Object obj : iteminfos) {
+            JSONObject iteminfo = (JSONObject) obj;
+            if (iteminfo.getLong("sa_customscheme_itemsid") <= 0 || dbConnect
+                    .runSqlQuery("select sa_customscheme_itemsid from sa_customscheme_items where sa_customscheme_itemsid="
+                            + iteminfo.getLong("sa_customscheme_itemsid"))
+                    .isEmpty()) {
+                SQLFactory saleFactory = new SQLFactory(this, "商品定制方案明细新增");
+                 System.out.println("1234");
+                saleFactory.addParameter("siteid", siteid);
+                saleFactory.addParameter("sa_customscheme_itemsid", sa_customscheme_itemsid[i]);
+                saleFactory.addParameter("sa_customschemeid", sa_customschemeid);
+                saleFactory.addParameter("value", iteminfo.getStringValue("value"));
+                saleFactory.addParameter("description", iteminfo.getStringValue("description"));
+                sqlList.add(saleFactory.getSQL());
+                i++;
+            } else {
+                SQLFactory saleFactory = new SQLFactory(this, "商品定制方案明细更新");
+                saleFactory.addParameter("siteid", siteid);
+                saleFactory.addParameter("sa_customscheme_itemsid",  iteminfo.getLongValue("sa_customscheme_itemsid"));
+                saleFactory.addParameter("sa_customschemeid", sa_customschemeid);
+                saleFactory.addParameter("value", iteminfo.getStringValue("value"));
+                saleFactory.addParameter("description", iteminfo.getStringValue("description"));
+                sqlList.add(saleFactory.getSQL());
+            }
+
+        }
+        dbConnect.runSqlUpdate(sqlList);
+        return querycustomschemeItemsList();
+    }
+
+    @API(title = "商品定制方案明细明细列表", apiversion = R.ID20230321155603.v1.class)
+    @CACHEING
+    public String querycustomschemeItemsList() 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.value like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.description like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+        Long sa_customschemeid = content.getLong("sa_customschemeid");
+//			String hrid = content.getString("hrid");
+        SQLFactory sqlFactory = new SQLFactory(this, "商品定制方案明细列表查询", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter("sa_customschemeid", sa_customschemeid);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "删除明细", apiversion = R.ID20230321155703.v1.class)
+    @CACHEING_CLEAN(apiClass = {customschemeItems.class})
+    public String deletemx() throws YosException {
+
+        JSONArray sa_customscheme_itemsids = content.getJSONArray("sa_customscheme_itemsids");
+        BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_customscheme_itemsids.size());
+        long sa_customschemeid = 0;
+        for (Object o : sa_customscheme_itemsids) {
+            long sa_customscheme_itemsid = Long.parseLong(o.toString());
+            ArrayList<String> list = new ArrayList<>();
+            SQLFactory deletesql = new SQLFactory("sql:delete from sa_customscheme_items where siteid='" + siteid
+                    + "' and sa_customscheme_itemsid=" + sa_customscheme_itemsid);
+            list.add(deletesql.getSQL());
+
+            dbConnect.runSqlUpdate(list);
+        }
+
+        return batchDeleteErr.getReturnObject().toString();
+    }
+}

+ 43 - 0
src/custom/restcontroller/webmanage/sale/item/Item.java

@@ -4,6 +4,7 @@ import beans.brand.Brand;
 import beans.datacontrllog.DataContrlLog;
 import beans.invbal.Invbal;
 import beans.itemclass.ItemClass;
+import beans.itemgroup.Itemgroup;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import common.Controller;
@@ -38,6 +39,7 @@ public class Item extends Controller {
 
         Long itemid = content.getLong("itemid");
         String itemno = content.getString("itemno");
+        long sa_customschemeid = content.getLong("sa_customschemeid");
         boolean isauxunit = content.getBoolean("isauxunit");
 
         ArrayList<String> sqlList = new ArrayList<>();
@@ -117,6 +119,8 @@ public class Item extends Controller {
         sqlFactory.addParameter("packageqty", content.getStringValue("packageqty"));
         sqlFactory.addParameter("iswoodproducts", content.getStringValue("iswoodproducts"));
 
+        sqlFactory.addParameter("sa_customschemeid", content.getLongValue("sa_customschemeid"));
+
         sqlList.add(sqlFactory.getSQL());
         // 货品档案扩展属性字段表
 
@@ -331,6 +335,17 @@ public class Item extends Controller {
         JSONArray jsonArray = content.getJSONArray("itemids");
         String status = content.getString("status");
 
+        Rows brandRows = dbConnect.runSqlQuery("select sa_brandid from sa_brand where siteid='"+siteid+"'");
+        long sa_brandid=0;
+        if(!brandRows.isEmpty()){
+            sa_brandid=brandRows.get(0).getLong("sa_brandid");
+        }
+        Rows itemRows = dbConnect.runSqlQuery("select itemid,itemno,itemname,sa_customschemeid from plm_item where siteid='"+siteid+"'");
+        RowsMap itemRowsMap = itemRows.toRowsMap("itemid");
+
+        Rows tradefieldRows = dbConnect.runSqlQuery("select itemid,tradefield from plm_item_tradefield where siteid='"+siteid+"'");
+        RowsMap tradefieldRowsMap = tradefieldRows.toRowsMap("itemid");
+
         ArrayList<String> sqlList = new ArrayList<>();
         for (Object obj : jsonArray) {
             int id = (int) obj;
@@ -339,6 +354,34 @@ public class Item extends Controller {
             sqlFactory.addParameter("siteid", siteid);
             sqlFactory.addParameter("username", username);
             sqlFactory.addParameter("status", status.equals("0") ? "新建" : "审核");
+            //审核商品时,自动添加至商品组中
+            if(itemRowsMap.containsKey(String.valueOf(obj))){
+                if(!itemRowsMap.get(String.valueOf(obj)).isEmpty()){
+                    if(itemRowsMap.get(String.valueOf(obj)).get(0).getLong("sa_customschemeid")!=0){
+                        if(status.equals("1")){
+                            Rows rowsCount = dbConnect.runSqlQuery("select count(1) count,min(groupnum) groupnum from (select ifnull(t3.sa_customschemeid,0) count,t1.sa_itemgroupid,t1.groupnum,t1.siteid from sa_itemgroup t1 inner join sa_itemgroupmx t2 on t1.siteid=t2.siteid and t1.sa_itemgroupid=t2.sa_itemgroupid inner join plm_item t3 on t2.itemid=t3.itemid and t2.siteid=t3.siteid group by t1.sa_itemgroupid,t1.groupnum,t1.siteid,ifnull(t3.sa_customschemeid,0))t where t.siteid='"+siteid+"' and t.sa_itemgroupid in (select sa_itemgroupid from sa_itemgroupmx where itemid="+id+")");
+                            if(rowsCount.get(0).getLong("count")>1){
+                                return getErrReturnObject().setErrMsg("该商品存在与商品组"+rowsCount.get(0).getString("groupnum")+",请在商品组删除该商品后进行审核").toString();
+                            }
+                        }
+                    }else{
+                        if(status.equals("0")){
+                            sqlList.add("delete from sa_itemgroup where sa_itemgroupid in(select * from sa_itemgroupmx where itemid="+id+" and siteid='"+siteid+"')");
+                            sqlList.add("delete from sa_itemgroupmx where itemid="+id+" and siteid='"+siteid+"'");
+                        }else {
+                            sqlList.addAll(Itemgroup.createItemGroupSql(this, id,itemRowsMap.get(String.valueOf(obj)).get(0).getString("itemname"), itemRowsMap.get(String.valueOf(obj)).get(0).getString("itemno"),tradefieldRowsMap.get(String.valueOf(obj)).toJsonArray("tradefield"),sa_brandid ));
+                        }
+                    }
+
+
+                }else {
+                    return getErrReturnObject().setErrMsg("商品不存在").toString();
+                }
+
+            }
+
+
+
             sqlList.add(sqlFactory.getSQL());
         }
 

+ 2 - 2
src/custom/restcontroller/webmanage/sale/item/SQL/货品档案新增.sql

@@ -2,9 +2,9 @@ insert into plm_item (siteid, itemid, createby, createdate, changeuserid, change
                       isauxunit, unitgroupid, itemname, isonsale, status, model, spec, orderminqty, orderaddqty,
                       orderminqty_auxunit, orderaddqty_auxunit, remarks, barcode, skucontrol, batchcontrol, grossweight,
                       weight, height, width, length, delivery, istool, marketprice, standards, stockstatus2,
-                      stockstatus1, warrantyday, iswuliao, isservice,color,packageqty,ismodule,iswoodproducts)
+                      stockstatus1, warrantyday, iswuliao, isservice,color,packageqty,ismodule,iswoodproducts,sa_customschemeid)
 values ($siteid$, $itemid$, $username$, CURRENT_TIME, $userid$, $username$, CURRENT_TIME, $itemno$, $unitid$,
         $isauxunit$, $unitgroupid$, $itemname$, $isonsale$, '新建', $model$, $spec$, $orderminqty$, $orderaddqty$,
         $orderminqty_auxunit$, $orderaddqty_auxunit$, $remarks$, $barcode$, $skucontrol$, $batchcontrol$, $grossweight$,
         $weight$, $height$, $width$, $length$, $delivery$, $istool$, $marketprice$, $standards$,
-        $stockstatus2$, $stockstatus1$, $warrantyday$, $iswuliao$, $isservice$,$color$,$packageqty$,$ismodule$,$iswoodproducts$)
+        $stockstatus2$, $stockstatus1$, $warrantyday$, $iswuliao$, $isservice$,$color$,$packageqty$,$ismodule$,$iswoodproducts$,$sa_customschemeid$)

+ 2 - 1
src/custom/restcontroller/webmanage/sale/item/SQL/货品档案更新.sql

@@ -35,7 +35,8 @@ SET changeuserid=$userid$,
     color = $color$,
     packageqty = $packageqty$,
     iswoodproducts=$iswoodproducts$,
-    isservice = $isservice$
+    isservice = $isservice$,
+    sa_customschemeid=$sa_customschemeid$
 WHERE itemid = $itemid$
   and siteid = $siteid$