浏览代码

商品组默认图更新

hu 3 年之前
父节点
当前提交
92416c6e27
共有 1 个文件被更改,包括 12 次插入2 次删除
  1. 12 2
      src/custom/restcontroller/sale/itemgroup/itemgroup.java

+ 12 - 2
src/custom/restcontroller/sale/itemgroup/itemgroup.java

@@ -243,7 +243,11 @@ public class itemgroup extends Controller {
                 row.put("cover", coverRows.get(0).getString("url"));
             }
 
-            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")));
         }
 
@@ -885,6 +889,8 @@ public class itemgroup extends Controller {
 
         ArrayList<Long> ids = itemrows.toArrayList("itemid", new ArrayList<>());
 
+        //默认商品图片
+        Rows defaultImageRows = getAttachmentUrl("system", (long) 1, "defaultImage");
         // 封面cover
         RowsMap coverRowsMap = getAttachmentUrl("plm_item", ids, "cover");
         // 附件
@@ -912,7 +918,11 @@ public class itemgroup extends Controller {
                 row.put("cover", coverRows.get(0).getString("url"));
             }
 
-            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")));
             row.put("tradefield", tradefieldRowsMap.get(row.getString("itemid")));
             row.put("brand", brandRowsMap.get(row.getString("itemid")));