|
|
@@ -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();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|