Преглед изворни кода

热门商品:添加热门商品,删除热门商品,获取热门商品列表

吴志根 пре 3 година
родитељ
комит
903b62b8af

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

@@ -0,0 +1,12 @@
+SELECT t2.tagents_productid,
+       t2.tagentsid,
+       t2.fintroduction,
+       t2.fprodname,
+       t2.fprodclassname,
+       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$

+ 66 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/products/products.java

@@ -102,4 +102,70 @@ public class products extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
+    /**
+     * 添加热门商品
+     *
+     * @return
+     * @throws P2Exception
+     */
+    public String addHotProducts() throws P2Exception {
+
+        String tagentsid = content.getString("tagentsid");
+        String tagents_productid = content.getString("tagents_productid");
+        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();
+        }
+
+    }
+
+    /**
+     * 删除热门商品
+     *
+     * @return
+     */
+    public String deleteHotProducts() {
+        String texcellenproductsid = content.getString("texcellenproductsid");
+
+        String sql = "DELETE FROM texcellenproducts WHERE texcellenproductid = '" + texcellenproductsid + "'";
+
+        String response = dbConnect.runSqlUpdate(sql);
+        if (response.equals("true")) {
+            return getSucReturnObject().toString();
+        } else {
+            return getErrReturnObject().toString();
+        }
+
+    }
+
+
+    /**
+     * 获取热门商品列表
+     *
+     * @return
+     */
+    public String getHotAgentsList() {
+
+        SQLFactory prodlistSql = new SQLFactory(this, "热门商品列表", pageSize, pageNumber, "t1.frownum");
+        prodlistSql.addParameter("siteid", siteid);
+
+        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")));
+        }
+        return getSucReturnObject().setDataByPaging(rows).saveToDataPool(10).toString();
+
+    }
+
 }