Browse Source

商品管理门店商品列表

eganwu 1 year ago
parent
commit
b31a7df149

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

@@ -6264,6 +6264,11 @@ public class R {
         }
     }
 
+    public static class ID20240430094102 {
+        public static class v1 {
+        }
+    }
+
 
 }
 

+ 69 - 0
src/custom/restcontroller/webmanage/saletool/fad/FadGoods.java

@@ -118,6 +118,8 @@ public class FadGoods extends Controller {
 
         QuerySQL querySQ = SQLFactory.createQuerySQL(this, sa_fad)
                 .setTableAlias("t1");
+        querySQ.addJoinTable(JOINTYPE.left, "sys_datacollect", "t2", "t2.siteid=t1.siteid and t2.ownertable='sa_fad' and t2.type=1 and t2.ownerid=t1.sa_fadid and t2.userid='" + userid + "'");
+        querySQ.addQueryFields("iscollect", "CASE WHEN t2.sys_datacollectid>0 THEN 1 ELSE 0 END");
         querySQ.setSiteid(siteid);
         querySQ.setWhere("sa_fadid", sa_fadid);
         Rows rows = querySQ.query();
@@ -282,6 +284,73 @@ public class FadGoods extends Controller {
         }
 
 
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "获取门店商品列表", apiversion = R.ID20240430094102.v1.class)
+    public String getStoreList() throws YosException {
+        /*
+          过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and (");
+                where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.model like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.tag like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+
+            if (whereObject.containsKey("isnew") && !"".equals(whereObject.getString("isnew"))) {
+                where.append(" and (");
+                where.append("t1.isnew ='").append(whereObject.getString("isnew")).append("' ");
+                where.append(")");
+            }
+
+
+            if (whereObject.containsKey("class") && !"".equals(whereObject.getString("class"))) {
+                where.append(" and (");
+                where.append("JSON_CONTAINS(t1.class,'\"" + whereObject.getString("class") + "\"')");
+                where.append(")");
+            }
+
+        }
+
+        ArrayList<Long> sys_enterpriseids = new ArrayList<Long>();
+        Long sys_enterpriseid = content.getLongValue("sys_enterpriseid");
+        sys_enterpriseids.add(sys_enterpriseid);
+        sys_enterpriseids.add(0L);
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, sa_fad,
+                        "sa_fadid", "name",  "pricetype","price","price_deposit", "unitname")
+                .setTableAlias("t1");
+
+        querySQL.addJoinTable(JOINTYPE.left, "sys_datatag", "t2", "t2.ownertable='sa_fad' and t2.ownerid=t1.sa_fadid and t2.siteid=t1.siteid");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("not EXISTS(SELECT 1 from sa_fad WHERE sys_enterpriseid="+sys_enterpriseid+" and parentid=t1.sa_fadid and siteid=t1.siteid)");
+        querySQL.setWhere("sys_enterpriseid", sys_enterpriseids);
+        querySQL.setWhere("classid", 2);
+        querySQL.setWhere("isonsale", 1);
+        querySQL.setWhere(where.toString());
+        querySQL.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
+        Rows rows = querySQL.query();
+
+
+        ArrayList<Long> ids = rows.toArrayList("sa_fadid", new ArrayList<>());
+        // 附件
+        RowsMap RowsMap = getAttachmentUrl(sa_fad, ids);
+        for (Row row : rows) {
+            Rows attRows = RowsMap.getOrDefault(row.getString("sa_fadid"), new Rows());
+            attRows.sortby("sequence", "linksid");
+            row.put("attinfos", attRows);
+            ArrayList<String> tags = DataTag.queryTag(this, "sa_fad", row.getLong("sa_fadid"), true);
+            row.putIfAbsent("tag", StringUtils.join(tags, ","));
+
+        }
+
+
         return getSucReturnObject().setData(rows).toString();
     }
 }