Explorar o código

新增热门商品相关接口

吴志根 %!s(int64=4) %!d(string=hai) anos
pai
achega
2c19d45617

+ 4 - 9
src/dsb/com/cnd3b/restcontroller/enterprise/products/SQL/热门商品列表.sql

@@ -1,12 +1,7 @@
-SELECT t2.tagents_productid,
-       t2.tagentsid,
-       t2.fintroduction,
-       t2.fprodname,
-       t2.fprodclassname,
+SELECT t1.fname,
+       t1.ftype,
        t1.frownum,
        t1.texcellenproductid
 FROM texcellenproducts as t1
-         LEFT JOIN tagents_product as t2
-                   ON t1.tagents_productid = t2.tagents_productid
-where t2.fisonsale = 1
-  and t2.siteid = $siteid$
+where t1.siteid = $siteid$
+  and t1.ftype like $ftype$

+ 51 - 23
src/dsb/com/cnd3b/restcontroller/enterprise/products/products.java

@@ -103,34 +103,33 @@ public class products extends Controller {
     }
 
     /**
-     * 添加热门商品
+     * 添加热门商品(关注榜)
      *
      * @return
      * @throws P2Exception
      */
     public String addHotProducts() throws P2Exception {
 
-        String tagentsid = content.getString("tagentsid");
-        String tagents_productid = content.getString("tagents_productid");
+        String fname = content.getString("fname");
+        String ftype = content.getString("ftype");
         String frownum = content.getString("frownum");
 
-        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("texcellenproducts", "tagents_productid = '" + tagents_productid + "' OR frownum = '" + frownum + "'", "changedate");
-        if (paoSetRemote.isEmpty()) {
-            PaoRemote paoRemote = paoSetRemote.addAtEnd();
-            paoRemote.setValue("texcellenproductid", paoRemote.getUniqueIDValue(), 11L);
-            paoRemote.setValue("tagentsid", tagentsid);
-            paoRemote.setValue("tagents_productid", tagents_productid);
-            paoRemote.setValue("frownum", frownum);
-            paoSetRemote.save();
-            return getSucReturnObject().toString();
-        } else {
-            return getErrReturnObject().setErrMsg("商品已存在或者当前排序以设置对应商品").toString();
-        }
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("texcellenproducts");
+
+        PaoRemote paoRemote = paoSetRemote.addAtEnd();
+        paoRemote.setValue("texcellenproductid", paoRemote.getUniqueIDValue(), 11L);
+        paoRemote.setValue("fname", fname);
+        paoRemote.setValue("ftype", ftype);
+        paoRemote.setValue("frownum", frownum);
+        paoRemote.setValue("siteid", siteid);
+        paoSetRemote.save();
+        return getSucReturnObject().toString();
+
 
     }
 
     /**
-     * 删除热门商品
+     * 删除热门商品(关注榜)
      *
      * @return
      */
@@ -148,21 +147,50 @@ public class products extends Controller {
 
     }
 
+    /**
+     * 更新热门商品(关注榜)
+     * @return
+     * @throws P2Exception
+     */
+    public String updateHotProducts() throws P2Exception {
+        String texcellenproductid = content.getString("texcellenproductid");
+        String fname = content.getString("fname");
+        String ftype = content.getString("ftype");
+        String frownum = content.getString("frownum");
+
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("texcellenproducts", " texcellenproductid = '" + texcellenproductid + "'");
+        if (!paoSetRemote.isEmpty()) {
+            PaoRemote paoRemote = paoSetRemote.getPao(0);
+            paoRemote.setValue("fname", fname);
+            paoRemote.setValue("ftype", ftype);
+            paoRemote.setValue("siteid", siteid);
+            paoRemote.setValue("frownum", frownum);
+            paoSetRemote.save();
+            return getSucReturnObject().toString();
+        } else {
+            return getErrReturnObject().setErrMsg("未找到对应的数据").toString();
+        }
+
+    }
+
 
     /**
-     * 获取热门商品列表
+     * 获取热门商品列表(关注榜)
      *
      * @return
      */
-    public String getHotAgentsList() {
-
-        SQLFactory prodlistSql = new SQLFactory(this, "热门商品列表", pageSize, pageNumber, "t1.frownum");
+    public String getHotProductsList() {
+        String ftype = content.getString("ftype");
+        if (ftype == null) {
+            ftype = "";
+        }
+        SQLFactory prodlistSql = new SQLFactory(this, "热门商品列表", pageSize, pageNumber, "t1.ftype,t1.frownum");
         prodlistSql.addParameter("siteid", siteid);
-
+        prodlistSql.addParameter("ftype", "%" + ftype + "%");
+        System.err.println(prodlistSql.getSQL());
         Rows rows = prodlistSql.runSqlQuery();
-        RowsMap map = getAttachmentUrl("tagents_product", rows.toArrayList("tagents_productid"));
         for (Row row : rows) {
-            row.put("attinfos", map.get(row.getString("tagents_productid")));
+            row.put("attinfos", getAttachmentUrl("texcellenproducts", row.getString("texcellenproductid")));
         }
         return getSucReturnObject().setDataByPaging(rows).saveToDataPool(10).toString();
 

+ 7 - 0
src/dsb/com/cnd3b/restcontroller/publicmethod/homepage/SQL/新品列表.sql

@@ -0,0 +1,7 @@
+SELECT t1.fname,
+       t1.ftype,
+       t1.frownum,
+       t1.texcellenproductid
+FROM texcellenproducts as t1
+where t1.siteid = $siteid$
+  and t1.ftype like $ftype$

+ 27 - 1
src/dsb/com/cnd3b/restcontroller/publicmethod/homepage/homepage.java

@@ -245,7 +245,7 @@ public class homepage extends Controller {
      *
      * @return
      */
-    public String getHotAgentsList() {
+    public String  getHotAgentsList() {
         SQLFactory agentlistSql = null;
         if (content.containsKey("ftype") && !"".equals(content.getString("ftype"))) {
             String ftype = content.getString("ftype");
@@ -269,4 +269,30 @@ public class homepage extends Controller {
 
     }
 
+    /**
+     * 获取热门商品列表(关注榜)
+     *
+     * @return
+     */
+    public String getHotProductsList() {
+        String ftype = content.getString("ftype");
+        if (ftype == null) {
+            ftype = "";
+        }
+        SQLFactory prodlistSql = new SQLFactory(this, "新品列表", pageSize, pageNumber, "t1.ftype,t1.frownum");
+
+        if(prodlistSql == null){
+            return getErrReturnObject().setErrMsg("prodlistSql is null").toString();
+        }
+        prodlistSql.addParameter("siteid", siteid);
+        prodlistSql.addParameter("ftype", "%" + ftype + "%");
+        System.err.println(prodlistSql.getSQL());
+        Rows rows = dbConnect.runSqlQuery(prodlistSql.getSQL());
+        for (Row row : rows) {
+            row.put("attinfos", getAttachmentUrl("texcellenproducts", row.getString("texcellenproductid")));
+        }
+        return getSucReturnObject().setDataByPaging(rows).toString();
+
+    }
+
 }