Browse Source

关注商户:添加,更新,删除,列表

吴志根 3 years ago
parent
commit
4ff626be29

+ 3 - 6
src/dsb/com/cnd3b/restcontroller/enterprise/tagents/SQL/热门商户列表.sql

@@ -1,7 +1,4 @@
-SELECT t2.tagentsid, t2.saleprodclass, t2.fbrand, t2.fagentname, t1.frownum, t1.texcellentagentsid
+SELECT t1.frownum, t1.texcellentagentsid, t1.fname, t1.ftype
 FROM texcellentagents as t1
-         LEFT JOIN tagents as t2
-                   ON t1.tagentsid = t2.tagentsid
-
-where t2.saleprodclass = $saleprodclass$
-  and t2.siteid = $siteid$
+where t1.ftype = $ftype$
+--   and t1.siteid = $siteid$

+ 2 - 5
src/dsb/com/cnd3b/restcontroller/enterprise/tagents/SQL/热门商户列表_全部.sql

@@ -1,6 +1,3 @@
-SELECT t2.tagentsid, t2.saleprodclass, t2.fbrand, t2.fagentname, t1.frownum, t1.texcellentagentsid
+SELECT t1.frownum, t1.texcellentagentsid, t1.fname, t1.ftype
 FROM texcellentagents as t1
-         LEFT JOIN tagents as t2
-                   ON t1.tagentsid = t2.tagentsid
-
-where  t2.siteid = $siteid$
+-- where t1.siteid = $siteid$

+ 43 - 11
src/dsb/com/cnd3b/restcontroller/enterprise/tagents/tagents.java

@@ -322,23 +322,55 @@ public class tagents extends Controller {
      */
     public String addHotAgents() throws P2Exception {
 
-        String tagentsid = content.getString("tagentsid");
+        String fname = content.getString("fname");
+        String ftype = content.getString("ftype");
         String frownum = content.getString("frownum");
 
-        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("texcellentagents", "tagentsid = '" + tagentsid + "' OR frownum = '" + frownum + "'", "changedate");
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("texcellentagents", " ftype = '" + ftype + "' AND frownum = '" + frownum + "'");
         if (paoSetRemote.isEmpty()) {
             PaoRemote paoRemote = paoSetRemote.addAtEnd();
             paoRemote.setValue("texcellentagentsid", paoRemote.getUniqueIDValue(), 11L);
-            paoRemote.setValue("tagentsid", tagentsid);
+            paoRemote.setValue("fname", fname);
+            paoRemote.setValue("ftype", ftype);
             paoRemote.setValue("frownum", frownum);
             paoSetRemote.save();
             return getSucReturnObject().toString();
         } else {
-            return getErrReturnObject().setErrMsg("商户已存在或者当前排序以设置对应商户").toString();
+
+
+            return getErrReturnObject().setErrMsg("当前类型的排序已存在,无法添加").toString();
         }
 
     }
 
+    /**
+     * 更新热门商户
+     *
+     * @return
+     * @throws P2Exception
+     */
+    public String updateHotAgents() throws P2Exception {
+        String texcellentagentsid = content.getString("texcellentagentsid");
+        String fname = content.getString("fname");
+        String ftype = content.getString("ftype");
+        String frownum = content.getString("frownum");
+
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("texcellentagents", " texcellentagentsid = '" + texcellentagentsid + "'");
+        if (!paoSetRemote.isEmpty()) {
+            PaoRemote paoRemote = paoSetRemote.getPao(0);
+
+            paoRemote.setValue("fname", fname);
+            paoRemote.setValue("ftype", ftype);
+            paoRemote.setValue("frownum", frownum);
+            paoSetRemote.save();
+            return getSucReturnObject().toString();
+        } else {
+
+
+            return getErrReturnObject().setErrMsg("未找到对应的数据").toString();
+        }
+    }
+
     /**
      * 删除热门商户
      *
@@ -366,22 +398,22 @@ public class tagents extends Controller {
      */
     public String getHotAgentsList() {
         SQLFactory agentlistSql = null;
-        if (content.containsKey("saleprodclass") && !"".equals(content.getString("saleprodclass"))) {
-            String saleprodclass = content.getString("saleprodclass");
+        if (content.containsKey("ftype") && !"".equals(content.getString("ftype"))) {
+            String ftype = content.getString("ftype");
             agentlistSql = new SQLFactory(this, "热门商户列表", pageSize, pageNumber, "t1.frownum");
-            agentlistSql.addParameter("saleprodclass", saleprodclass);
+            agentlistSql.addParameter("ftype", ftype);
             agentlistSql.addParameter("siteid", siteid);
         } else {
-            agentlistSql = new SQLFactory(this, "热门商户列表_全部", pageSize, pageNumber, "t1.frownum");
+            agentlistSql = new SQLFactory(this, "热门商户列表_全部", pageSize, pageNumber, "t1.ftype,1.frownum");
             agentlistSql.addParameter("siteid", siteid);
         }
 
         System.err.println(agentlistSql.getSQL());
         Rows rows = dbConnect.runSqlQuery(agentlistSql.getSQL());
-        RowsMap map = getAttachmentUrl("tagents", rows.toArrayList("tagentsid"));
+        RowsMap map = getAttachmentUrl("texcellentagents", rows.toArrayList("texcellentagentsid"));
         for (Row row : rows) {
-            row.put("attinfos", map.get(row.getString("tagentsid")));
-            row.put("saleprodclass", JSONArray.parseArray(row.getString("saleprodclass")));
+            row.put("attinfos", map.get(row.getString("texcellentagentsid")));
+
         }
         return getSucReturnObject().setData(rows).saveToDataPool(10).toString();