hu 2 лет назад
Родитель
Сommit
9e57c43675

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

@@ -5249,6 +5249,14 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20230918155003 {
+        public static class v1 {
+        }
+    }
+    public static class ID20230918155103 {
+        public static class v1 {
+        }
+    }
 
 
 }

+ 2 - 0
src/custom/restcontroller/sale/itemgroup/SQL/商品组列表查询.sql

@@ -2,6 +2,8 @@ SELECT
 	t1.sa_itemgroupid,
 	t2.itemid,
 	t1.sa_brandid,
+	t1.ispriorityshow,
+  t1.istopping,
 	t1.changeby,
 	t1.createby,
 	t1.changedate,

+ 2 - 0
src/custom/restcontroller/sale/itemgroup/SQL/商品组详情查询.sql

@@ -2,6 +2,8 @@ SELECT
 	t1.sa_itemgroupid,
 	t2.itemid,
 	t1.sa_brandid,
+  t1.ispriorityshow,
+  t1.istopping,
 	t1.changeby,
 	t1.createby,
 	t1.changedate,

+ 10 - 4
src/custom/restcontroller/sale/itemgroup/itemgroup.java

@@ -236,7 +236,6 @@ public class itemgroup extends Controller {
         }
 
         ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
-
         /**
          * 查询商品明细
          */
@@ -261,6 +260,9 @@ public class itemgroup extends Controller {
         RowsMap coverRowsMap = getAttachmentUrl("plm_item", ids, "cover");
         // 附件
         RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
+        // 附件
+        RowsMap itemgroupRowsMap = getAttachmentUrl("sa_itemgroup", itemgroupids);
+
 
         Rows rowsitemclass = dbConnect.runSqlQuery(
                 " select  t7.itemclassname,t6.itemid,t8.brandname,t7.itemclassfullname from sa_itemsaleclass t6 inner JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='"
@@ -281,10 +283,14 @@ public class itemgroup extends Controller {
                 row.put("cover", coverRows.get(0).getString("url"));
             }
 
-            if ((attRowsMap.getOrDefault(row.getString("itemid"), new Rows())).isEmpty()) {
-                row.put("attinfos", defaultImageRows);
+            if ((itemgroupRowsMap.getOrDefault(row.getString("sa_itemgroupid"), new Rows())).isNotEmpty()) {
+                row.put("attinfos", itemgroupRowsMap.getOrDefault(row.getString("sa_itemgroupid"), new Rows()));
             } else {
-                row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+                if ((attRowsMap.getOrDefault(row.getString("itemid"), new Rows())).isEmpty()) {
+                    row.put("attinfos", defaultImageRows);
+                } else {
+                    row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+                }
             }
             row.put("itemclass", itemclassRowsMap.get(row.getString("itemid")));
         }

+ 1 - 0
src/custom/restcontroller/webmanage/sale/itemgroup/SQL/商品组优先展示.sql

@@ -0,0 +1 @@
+update sa_itemgroup set ispriorityshow=1 where sa_itemgroupid in $sa_itemgroupids$ and siteid=$siteid$

+ 2 - 0
src/custom/restcontroller/webmanage/sale/itemgroup/SQL/商品组列表查询.sql

@@ -8,6 +8,8 @@ SELECT t1.sa_itemgroupid,
        t3.brandname,
        t1.groupnum,
        t1.itemno,
+       t1.ispriorityshow,
+       t1.istopping,
        t2.itemname,
        t1.groupname,
        t1.tradefield,

+ 1 - 0
src/custom/restcontroller/webmanage/sale/itemgroup/SQL/商品组取消优先展示.sql

@@ -0,0 +1 @@
+update sa_itemgroup set ispriorityshow=0 where sa_itemgroupid in $sa_itemgroupids$ and siteid=$siteid$

+ 1 - 0
src/custom/restcontroller/webmanage/sale/itemgroup/SQL/商品组取消置顶.sql

@@ -0,0 +1 @@
+update sa_itemgroup set istopping=0 where sa_itemgroupid in $sa_itemgroupids$ and siteid=$siteid$

+ 1 - 0
src/custom/restcontroller/webmanage/sale/itemgroup/SQL/商品组置顶.sql

@@ -0,0 +1 @@
+update sa_itemgroup set istopping=1 where sa_itemgroupid in $sa_itemgroupids$ and siteid=$siteid$

+ 2 - 0
src/custom/restcontroller/webmanage/sale/itemgroup/SQL/商品组详情查询.sql

@@ -8,6 +8,8 @@ SELECT t1.sa_itemgroupid,
        t3.brandname,
        t1.groupnum,
        t1.itemno,
+       t1.ispriorityshow,
+       t1.istopping,
        t2.itemname,
        t1.groupname,
        t1.tradefield,

+ 81 - 6
src/custom/restcontroller/webmanage/sale/itemgroup/itemgroup.java

@@ -174,6 +174,8 @@ public class itemgroup extends Controller {
         RowsMap coverRowsMap = getAttachmentUrl("plm_item", ids, "cover");
         //附件
         RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
+        // 附件
+        RowsMap itemgroupRowsMap = getAttachmentUrl("sa_itemgroup",  rows.toArrayList("sa_itemgroupid", new ArrayList<Long>()));
 
         Rows rowsitemclass = dbConnect.runSqlQuery(
                 " select  t7.itemclassname,t6.itemid,t8.brandname from sa_itemsaleclass t6 inner JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='"
@@ -192,6 +194,7 @@ public class itemgroup extends Controller {
                 row.put("cover", coverRows.get(0).getString("url"));
             }
 
+            row.put("itemgroupinfos", itemgroupRowsMap.getOrDefault(row.getString("sa_itemgroupid"), new Rows()));
             row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
             row.put("itemclass", itemclassRowsMap.get(row.getString("itemid")));
         }
@@ -210,11 +213,37 @@ public class itemgroup extends Controller {
         Rows rowsitemclass = dbConnect.runSqlQuery(
                 " select  t7.itemclassname,t6.itemid,t8.brandname from sa_itemsaleclass t6 inner JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='"
                         + siteid + "'");
+
+        ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
+
+        //默认商品图片
+        Rows defaultImageRows = getAttachmentUrl("system", (long) 1, "defaultImage");
+        //封面cover
+        RowsMap coverRowsMap = getAttachmentUrl("plm_item", ids, "cover");
+        //附件
+        RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
+        // 附件
+        RowsMap itemgroupRowsMap = getAttachmentUrl("sa_itemgroup",  rows.toArrayList("sa_itemgroupid", new ArrayList<Long>()));
+
         RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
-        if (!rows.isEmpty()) {
-            ArrayList<String> list = DataTag.queryTag(this, "sa_itemgroup", rows.get(0).getLong("sa_itemgroupid"), false);
-            rows.get(0).put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
-            rows.get(0).put("itemclass", itemclassRowsMap.get(rows.get(0).getString("itemid")));
+        for (Row row :rows) {
+            ArrayList<String> list = DataTag.queryTag(this, "sa_itemgroup",row.getLong("sa_itemgroupid"), false);
+            row.put("tag1", JSONArray.parseArray(JSON.toJSONString(list)));
+            row.put("itemclass", itemclassRowsMap.get(row.getString("itemid")));
+
+            Rows coverRows = coverRowsMap.get(row.getString("itemid"));
+            if (coverRows.isEmpty()) {
+                if (!defaultImageRows.isEmpty()) {
+                    row.put("cover", defaultImageRows.get(0).getString("url"));
+                } else {
+                    row.put("cover", "");
+                }
+            } else {
+                row.put("cover", coverRows.get(0).getString("url"));
+            }
+
+            row.put("itemgroupinfos", itemgroupRowsMap.getOrDefault(row.getString("sa_itemgroupid"), new Rows()));
+            row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
         }
         return getSucReturnObject().setData(rows.size() > 0 ? rows.get(0) : new Row()).toString();
     }
@@ -225,7 +254,7 @@ public class itemgroup extends Controller {
      * @return
      */
     @API(title = "商品组上架", apiversion = R.ID20220923143603.v1.class)
-    @CACHEING_CLEAN(cms = {@cm(clazz = itemgroup.class, method = {"queryItemgroup", "queryItemgroupMain"})})
+    @CACHEING_CLEAN(apiClass = {itemgroup.class, restcontroller.sale.itemgroup.itemgroup.class})
     public String release() throws YosException {
         JSONArray sa_itemgroupids = content.getJSONArray("sa_itemgroupids");
         String[] s = {"sa_itemgroupids"};
@@ -271,6 +300,52 @@ public class itemgroup extends Controller {
         return getSucReturnObject().toString();
     }
 
+    /**
+     * 商品组设置置顶
+     *
+     * @return
+     */
+    @API(title = "商品组设置置顶", apiversion = R.ID20230918155003.v1.class)
+    @CACHEING_CLEAN(apiClass = {itemgroup.class, restcontroller.sale.itemgroup.itemgroup.class})
+    public String isTopping() throws YosException {
+        JSONArray sa_itemgroupids = content.getJSONArray("sa_itemgroupids");
+        boolean isTopping =content.getBooleanValue("isTopping");
+        List<Long> list = sa_itemgroupids.toJavaList(Long.class);
+        Long[] stringArray = list.toArray(new Long[0]);
+        SQLFactory sqlFactoryupdate = new SQLFactory(this, "商品组取消置顶");
+        if(isTopping){
+             sqlFactoryupdate = new SQLFactory(this, "商品组置顶");
+        }
+        sqlFactoryupdate.addParameter("siteid", siteid);
+        sqlFactoryupdate.addParameter_in("sa_itemgroupids", stringArray);
+        dbConnect.runSqlUpdate(sqlFactoryupdate);
+
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 商品组设置优先展示
+     *
+     * @return
+     */
+    @API(title = "商品组设置优先展示", apiversion = R.ID20230918155103.v1.class)
+    @CACHEING_CLEAN(apiClass = {itemgroup.class, restcontroller.sale.itemgroup.itemgroup.class})
+    public String isPriorityshow() throws YosException {
+        JSONArray sa_itemgroupids = content.getJSONArray("sa_itemgroupids");
+        List<Long> list = sa_itemgroupids.toJavaList(Long.class);
+        boolean isPriorityshow =content.getBooleanValue("isPriorityshow");
+        Long[] stringArray = list.toArray(new Long[0]);
+        SQLFactory sqlFactoryupdate = new SQLFactory(this, "商品组取消优先展示");
+        if(isPriorityshow){
+            sqlFactoryupdate = new SQLFactory(this, "商品组优先展示");
+        }
+        sqlFactoryupdate.addParameter("siteid", siteid);
+        sqlFactoryupdate.addParameter_in("sa_itemgroupids", stringArray);
+        dbConnect.runSqlUpdate(sqlFactoryupdate);
+
+        return getSucReturnObject().toString();
+    }
+
 
     /**
      * 商品组下架
@@ -278,7 +353,7 @@ public class itemgroup extends Controller {
      * @return
      */
     @API(title = "下架", apiversion = R.ID20220923143703.v1.class)
-    @CACHEING_CLEAN(cms = {@cm(clazz = itemgroup.class, method = {"queryItemgroup", "queryItemgroupMain"})})
+    @CACHEING_CLEAN(apiClass = {itemgroup.class, restcontroller.sale.itemgroup.itemgroup.class})
     public String undercarriage() throws YosException {
         JSONArray sa_itemgroupids = content.getJSONArray("sa_itemgroupids");
         String[] s = {"sa_itemgroupids"};