Explorar o código

促销商品添加默认图片

hu %!s(int64=3) %!d(string=hai) anos
pai
achega
edb3496f5d
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      src/custom/restcontroller/sale/promotion/promotion.java

+ 8 - 1
src/custom/restcontroller/sale/promotion/promotion.java

@@ -114,13 +114,20 @@ public class promotion extends Controller {
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
 
         ArrayList ids = rows.toArrayList("itemid", new ArrayList<>());
+        //默认商品图片
+        Rows defaultImageRows = getAttachmentUrl("system", (long) 1, "defaultImage");
         // 附件
         RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
         //商品领域
         RowsMap tradefieldRowsMap = beans.Item.Item.getTradefieldRowsMap(this, ids);
 
         for (Row row : rows) {
-            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("tradefield", tradefieldRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
         }