浏览代码

6C红人服务

eganwu 1 年之前
父节点
当前提交
09c4ec6f1e

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

@@ -6309,6 +6309,15 @@ public class R {
         }
     }
 
+    public static class ID20240511110302 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240511133302 {
+        public static class v1 {
+        }
+    }
 
 }
 

+ 107 - 5
src/custom/restcontroller/webmanage/saletool/sharematerial/LongPicText.java

@@ -13,6 +13,9 @@ import restcontroller.webmanage.saletool.fad.FadHelper;
 
 import java.util.ArrayList;
 
+/**
+ * 长图文
+ */
 public class LongPicText extends Controller {
     /**
      * 构造函数
@@ -50,7 +53,7 @@ public class LongPicText extends Controller {
             insertSQL.setValue("content", content.getStringValue("contentstr"));
             insertSQL.insert();
             content.put("sat_sharematerialid", sat_sharematerialid);
-        }else {
+        } else {
 
 
             UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sat_sharematerial");
@@ -94,7 +97,7 @@ public class LongPicText extends Controller {
         Rows attRows = getAttachmentUrl("sat_sharematerial", sat_sharematerialid);
         detailRow.put("attinfos", attRows);
 
-        detailRow.put("shareurl", FadHelper.getAppletUrl(this, "LongPicShareUrl", "长图文分享小程序链接")  + sat_sharematerialid);
+        detailRow.put("shareurl", FadHelper.getAppletUrl(this, "LongPicShareUrl", "长图文分享小程序链接") + sat_sharematerialid);
         detailRow.put("noshareurl", FadHelper.getAppletUrl(this, "LongPicNoShareUrl", "长图文不分享小程序链接") + sat_sharematerialid);
 
 
@@ -189,7 +192,7 @@ public class LongPicText extends Controller {
             Rows attRows = getAttachmentUrl("sat_sharematerial", row.getLong("sat_sharematerialid"));
             row.put("attinfos", attRows);
 
-            row.put("shareurl", FadHelper.getAppletUrl(this, "LongPicShareUrl", "长图文分享小程序链接")  + row.getLong("sat_sharematerialid"));
+            row.put("shareurl", FadHelper.getAppletUrl(this, "LongPicShareUrl", "长图文分享小程序链接") + row.getLong("sat_sharematerialid"));
             row.put("noshareurl", FadHelper.getAppletUrl(this, "LongPicNoShareUrl", "长图文不分享小程序链接") + row.getLong("sat_sharematerialid"));
         }
 
@@ -197,25 +200,35 @@ public class LongPicText extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "小程序长图文详情", apiversion = R.ID20240408131902.v1.class,accesstoken = false)
+    @API(title = "小程序长图文详情", apiversion = R.ID20240408131902.v1.class, accesstoken = false)
     public String miniAppDetail() throws YosException {
         String ownertable = "sat_sharematerial";
         Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
 
         QuerySQL querySQ = SQLFactory.createQuerySQL(this, "sat_sharematerial"
-                        ,"sat_sharematerialid","sharepagecontrol","type","title","siteid","content","status")
+                        , "sat_sharematerialid", "sharepagecontrol", "type", "title", "siteid", "content", "status")
                 .setTableAlias("t1");
         querySQ.setWhere("sat_sharematerialid", sat_sharematerialid);
         Rows rows = querySQ.query();
         Row detailRow = rows.isNotEmpty() ? rows.get(0) : new Row();
         Rows attRows = getAttachmentUrl("sat_sharematerial", sat_sharematerialid);
         detailRow.put("attinfos", attRows);
+        siteid = detailRow.getString("siteid");
+        if (detailRow.getString("title").equals("6C红人服务")) {
+            initEnterprisePic(sat_sharematerialid);
+        }
+
+
 
         QuerySQL attachmentQuery = SQLFactory.createQuerySQL(this, "sys_attachment_links").setTableAlias("t1");
         attachmentQuery.setSiteid(detailRow.getString("siteid"));
         attachmentQuery.setWhere("ownertable", ownertable);
         attachmentQuery.setWhere("ownerid", sat_sharematerialid);
         attachmentQuery.setWhere("usetype", ownertable);
+        if (detailRow.getString("title").equals("6C红人服务")) {
+            Long sys_enterpriseid = content.getLongValue("sys_enterpriseid");
+            attachmentQuery.setWhere("t1.attachmentid in(SELECT attachmentid from sys_attachment_links WHERE isonsale=1 and siteid='"+siteid+"' and  ownerid='"+sys_enterpriseid+"' and ownertable ='sys_enterpriseid' and usetype='sys_enterprise')");
+        }
         attachmentQuery.setOrderBy("t1.sequence");
         Rows attachmentRows = attachmentQuery.query();
 
@@ -358,4 +371,93 @@ public class LongPicText extends Controller {
 //        return temp;
 //    }
 
+    @API(title = "拉取6C红人服务图片", apiversion = R.ID20240511110302.v1.class)
+    public String getPicList() throws YosException {
+
+        String title = content.getStringValue("title");
+        Rows sharematerialRows = dbConnect.runSqlQuery("SELECT * from sat_sharematerial WHERE classid=2 and title='" + title + "' and siteid='" + siteid + "'");
+        if (sharematerialRows.isEmpty()) {
+            return getSucReturnObject().setData(new Rows()).toString();
+        }
+
+        Long sat_sharematerialid = sharematerialRows.get(0).getLong("sat_sharematerialid");
+
+        initEnterprisePic(sat_sharematerialid);
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_attachment_links").setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("ownertable", "sys_enterprise");
+        querySQL.setWhere("ownerid", sys_enterpriseid);
+        querySQL.setWhere("usetype", "sys_enterprise");
+        querySQL.setOrderBy("t1.sequence");
+        Rows rows = querySQL.query();
+
+        ArrayList<Long> ids = rows.toArrayList("attachmentid", new ArrayList<>());
+
+        RowsMap attRowsMap = Attachment.get(this, ids).toRowsMap("attachmentid");
+
+        for (Row row : rows) {
+            Rows attRows = new Rows();
+            Rows tempAttRows = attRowsMap.getOrDefault(row.getString("attachmentid"), new Rows());
+            for (Row tempAttRow : tempAttRows) {
+                if (tempAttRow.getString("usetype").equals("sys_enterprise")) {
+                    attRows.add(tempAttRow);
+                }
+            }
+            row.put("attinfos", attRows);
+        }
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
+    @API(title = "(6C红人服务)图片是否上架", apiversion = R.ID20240511133302.v1.class)
+    public String isonsale() throws YosException {
+
+        boolean isonsale = content.getBooleanValue("isonsale");
+        JSONArray linksids = content.getJSONArray("linksids");
+
+        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_attachment_links");
+        updateSQL.setValue("isonsale", isonsale);
+        updateSQL.setSiteid(siteid);
+        updateSQL.setWhere("linksid", linksids);
+        updateSQL.update();
+
+        return getSucReturnObject().toString();
+    }
+
+    //拉取最新的图片到对应经销商下(6C红人服务)
+    public void initEnterprisePic(Long sat_sharematerialid) throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_attachment_links").setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("ownertable", "sat_sharematerial");
+        querySQL.setWhere("ownerid", sat_sharematerialid);
+        querySQL.setWhere("usetype", "sat_sharematerial");
+        Rows rows = querySQL.query();
+
+        for (Row row : rows) {
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_attachment_links");
+            insertSQL.setSiteid(siteid);
+            insertSQL.setUniqueid(createTableID("sys_attachment_links"));
+            insertSQL.setValue("attachmentid", row.getLong("attachmentid"));
+            insertSQL.setValue("jumpurl", row.getString("jumpurl"));
+            insertSQL.setValue("sequence", row.getLong("sequence"));
+            insertSQL.setValue("ownerid", sys_enterpriseid);
+            insertSQL.setValue("ownertable", "sys_enterprise");
+            insertSQL.setValue("usetype", "sys_enterprise");
+            insertSQL.setValue("isonsale", 1);
+            insertSQL.setWhere("not exists(select 1 from  sys_attachment_links where attachmentid=" + row.getLong("attachmentid") + " and ownertable='sys_enterprise' and siteid='" + siteid + "' and ownerid=" + sys_enterpriseid + " )");
+            insertSQL.insert();
+        }
+        if(rows.isNotEmpty()) {
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sys_attachment_links");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setWhere("ownertable", "sys_enterprise");
+            deleteSQL.setWhere("ownerid", sys_enterpriseid);
+            deleteSQL.setWhere("usetype", "sys_enterprise");
+            deleteSQL.setWhere("attachmentid not in" + rows.toArrayList("attachmentid").toString().replace("[", "(").replace("]", ")") + "");
+            deleteSQL.delete();
+        }
+    }
+
 }