Explorar el Código

促销方案业务端查询添加默认图片

hu hace 3 años
padre
commit
7776ed68b9
Se han modificado 1 ficheros con 8 adiciones y 1 borrados
  1. 8 1
      src/custom/restcontroller/sale/promotion/promotion.java

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

@@ -42,9 +42,12 @@ public class promotion extends Controller {
         sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
         sqlFactory.addParameter_SQL("where", where);
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
+        //默认商品图片
+        Rows defaultImageRows = getAttachmentUrl("system", (long) 1, "defaultImage");
         //附件
         ArrayList<Long> ids = rows.toArrayList("sa_promotionid", new ArrayList<>());
         RowsMap attRowsMap = getAttachmentUrl("sa_promotion", ids);
+
         SQLFactory sqlFactory1 = new SQLFactory(this, "促销订单金额合计查询");
         sqlFactory1.addParameter("siteid", siteid);
         sqlFactory1.addParameter("sys_enterpriseid", sys_enterpriseid);
@@ -57,7 +60,11 @@ public class promotion extends Controller {
         Rows openPromotionsRows =  dbConnect.runSqlQuery(sqlFactory2.getSQL());
         RowsMap openPromotionsRowsMap = openPromotionsRows.toRowsMap("sa_promotionid");
         for (Row row : rows) {
-            row.put("attinfos", attRowsMap.getOrDefault(row.getString("sa_promotionid"), new Rows()));
+            if ((attRowsMap.getOrDefault(row.getString("sa_promotionid"), new Rows())).isEmpty()) {
+                row.put("attinfos", defaultImageRows);
+            } else {
+                row.put("attinfos", attRowsMap.getOrDefault(row.getString("sa_promotionid"), new Rows()));
+            }
             if (!StringUtils.isBlank(row.getString("tradefield"))) {
                 row.put("tradefield", JSONArray.parseArray(row.getString("tradefield")));
             } else {