소스 검색

促销商品添加默认图片

hu 3 년 전
부모
커밋
edb3496f5d
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  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()));
         }