浏览代码

效果图关联单品

eganwu 1 年之前
父节点
当前提交
1802ff45a5

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

@@ -6155,6 +6155,27 @@ public class R {
         }
     }
 
+    public static class ID20240419135702 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240419135802 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240419135902 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240419136002 {
+        public static class v1 {
+        }
+    }
+
+
 }
 
 

+ 114 - 0
src/custom/restcontroller/webmanage/saletool/sharematerial/Renderings.java

@@ -1,6 +1,7 @@
 package restcontroller.webmanage.saletool.sharematerial;
 
 import beans.attachment.Attachment;
+import beans.itemclass.ItemClass;
 import beans.parameter.Parameter;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -238,4 +239,117 @@ public class Renderings extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
+
+    @API(title = "选择单品列表",apiversion = R.ID20240419135702.v1.class)
+    public String chooseFadList() 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 t1.spec like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+
+        Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_fad"
+                , "sa_fadid", "name", "model", "spec", "price", "onsaledate");
+        querySQL.setTableAlias("t1");
+
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere(where.toString());
+        querySQL.setWhere("not exists(select 1 from  sat_sharematerial_link where sat_sharematerialid=" + sat_sharematerialid + " and sa_fadid=t1.sa_fadid and siteid='" + siteid + "'  )");
+        querySQL.setOrderBy(pageSorting);
+        querySQL.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 Rows = RowsMap.getOrDefault(row.getString("sa_fadid"), new Rows());
+            row.put("attinfos", Rows);
+            row.putIfAbsent("onsaledate", "");
+        }
+
+
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "关联单品列表",apiversion = R.ID20240419135802.v1.class)
+    public String relateFadList() 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 t1.spec like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+
+        Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_fad"
+                , "sa_fadid", "name", "model", "spec", "price", "onsaledate");
+        querySQL.addJoinTable(JOINTYPE.inner,"sat_sharematerial_link","t2","t2.sa_fadid=t1.sa_fadid","sat_sharematerial_linkid");
+        querySQL.setTableAlias("t1");
+        querySQL.setWhere("t2.sat_sharematerialid",sat_sharematerialid);
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere(where.toString());
+        querySQL.setOrderBy(pageSorting);
+        querySQL.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 Rows = RowsMap.getOrDefault(row.getString("sa_fadid"), new Rows());
+            row.put("attinfos", Rows);
+            row.putIfAbsent("onsaledate", "");
+        }
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "关联单品",apiversion = R.ID20240419135902.v1.class)
+    public String relateFad() throws YosException {
+        Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
+        JSONArray sa_fadids = content.getJSONArray("sa_fadids");
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+        for (Object obj : sa_fadids) {
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_sharematerial_link");
+            insertSQL.setSiteid(siteid);
+            insertSQL.setUniqueid(createTableID("sat_sharematerial_link"));
+            insertSQL.setValue("sa_fadid", obj);
+            insertSQL.setValue("sat_sharematerialid", sat_sharematerialid);
+            sqlList.add(insertSQL.getSQL());
+        }
+
+
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "删除单品",apiversion = R.ID20240419136002.v1.class)
+    public String deleteFad() throws YosException {
+        JSONArray sat_sharematerial_linkids = content.getJSONArray("sat_sharematerial_linkids");
+
+        DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_sharematerial_link");
+        deleteSQL.setSiteid(siteid);
+        deleteSQL.setWhere("sat_sharematerial_linkid", sat_sharematerial_linkids);
+        deleteSQL.delete();
+        return getSucReturnObject().toString();
+    }
 }