瀏覽代碼

商户主界面附件查询错误修复

沈静伟 4 年之前
父節點
當前提交
4bf4c344b2

+ 2 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/products/SQL/商品列表查询.sql

@@ -0,0 +1,2 @@
+select t1.tagents_productid,t1.fprice, t1.fprodname, t1.fprodnum,t1.fprodclassname,ftag,fisonsale, fintroduction from tagents_product t1
+where t1.siteid=$siteid$ and t1.tagentsid=$tagentsid$ and $where$

+ 4 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/products/SQL/商品详情查询.sql

@@ -0,0 +1,4 @@
+select  tagents_productid, createby, changeby, createdate, changedate,
+ fisonsale, fnotes, foffsaleby, foffsaledate, fonsaleby, fonsaledate, fprice, fprodname, fprodnum
+ , fprodclassname, fintroduction,ftag from tagents_product t1
+ where siteid=$siteid$ and tagentsid=$tagentsid$ and tagents_productid=$tagents_productid$

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

@@ -0,0 +1,96 @@
+package com.cnd3b.restcontroller.enterprise.products;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.cnd3b.common.Controller;
+import com.cnd3b.common.D3BReturnObject_Err;
+import com.cnd3b.common.D3bException;
+import com.cnd3b.common.data.Row;
+import com.cnd3b.common.data.Rows;
+import com.cnd3b.common.data.RowsMap;
+import com.cnd3b.common.data.SQLFactory;
+import p2.pao.PaoRemote;
+import p2.pao.PaoSetRemote;
+import p2.util.P2Exception;
+
+import java.util.ArrayList;
+
+public class products extends Controller {
+
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public products(JSONObject content) {
+        super(content);
+    }
+
+    /**
+     * 商品列表查询
+     *
+     * @return
+     */
+    public String query_productsList() {
+        long tagentsid = content.getLong("tagentsid");
+        /**
+         *排序条件设置
+         */
+        String[] sortfield = {"t1.fprodname"};
+        String sort = getSort(sortfield, "t1.fprodname");
+        /**
+         * 过滤条件设置
+         */
+        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.fprodname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.fprodnum like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.fintroduction like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.ftag like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("fisonsale") && !"".equals(whereObject.getString("fisonsale"))) {
+                if (whereObject.getBooleanValue("fisonsale")) {
+                    where.append(" and t1.fisonsale=1 ");
+                } else {
+                    where.append(" and t1.fisonsale=0 ");
+                }
+            }
+        }
+        SQLFactory sql = new SQLFactory(this, "商品列表查询", pageSize, pageNumber, sort);
+        sql.addParameter("siteid", siteid);
+        sql.addParameter("tagentsid", tagentsid);
+        sql.addParameter_SQL("where", where);
+        Rows rows = dbConnect.runSqlQuery(sql.getSQL());
+        RowsMap tagents_productMap = getAttachmentUrl("tagents_product", rows.toArrayList("tagents_productid"));
+        for (Row row : rows) {
+            row.put("attinfos", tagents_productMap.get(row.getString("tagents_productid")));
+            row.put("ftag", JSONArray.parseArray(row.getString("ftag")));
+        }
+        return getSucReturnObject().setDataByPaging(rows, sortfield).saveToDataPool().toString();
+    }
+
+    /**
+     * 商品详情查询
+     *
+     * @return
+     */
+    public String query_productsMain() {
+        long tagentsid = content.getLong("tagentsid");
+        SQLFactory sql = new SQLFactory(this, "商品详情查询");
+        sql.addParameter("siteid", siteid);
+        sql.addParameter("tagentsid", tagentsid);
+        sql.addParameter("tagents_productid", content.getLong("tagents_productid"));
+        Rows rows = dbConnect.runSqlQuery(sql.getSQL());
+        RowsMap tagents_productMap = getAttachmentUrl("tagents_product", rows.toArrayList("tagents_productid"));
+        for (Row row : rows) {
+            row.put("attinfos", tagents_productMap.get(row.getString("tagents_productid")));
+            row.put("ftag", JSONArray.parseArray(row.getString("ftag")));
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+}