Procházet zdrojové kódy

商品选项查询方式调整

沈静伟 před 3 roky
rodič
revize
2e8508ec95

+ 39 - 7
src/rest/openapi/restcontroller/wechatapp/titem/SQL/商品档案选项查询.sql

@@ -1,13 +1,45 @@
-select distinct 'fvalue1'field,fvalue1 as value from titem where siteid=$siteid$ and isnull(fvalue1,'')!='' and fvalue8=1
+with a as(
+    select
+        t1.fvalue1,
+        t1.fvalue2,
+        t1.fvalue3,
+        t1.fvalue4,
+        t1.fvalue5,
+        t1.fvalue6,
+        t1.fvalue7
+    from titem t1
+    where fvalue8=1
+      and fisonsale = 1
+      and fstatus = 'ÉóºË'
+      and t1.siteid =$siteid$
+      and $where$
+      and (exists ( select * from tagentauthors where fagentnum=$fagentnum$
+                                                  and siteid=t1.siteid
+                                                  and (isnull(fsaleclsnum
+                                                           , '')=isnull(t1.fsaleclsnum
+                                                           , '')
+            or isnull(fitemno
+                   , '')=t1.fitemno))
+        or exists (select * from tagents where fagentnum=$fagentnum$
+                                           and fagentauthors=1
+                                           and siteid=t1.siteid))
+      and exists (select * from tagents_brand where fbrand=t1.fbrand
+                                                and siteid=t1.siteid
+                                                and fagentnum=$fagentnum$)
+      and exists (select * from tagents_field where fieldname=t1.fieldname
+                                                and siteid=t1.siteid
+                                                and fagentnum=$fagentnum$)
+)
+select distinct 'fvalue1'field,fvalue1 as value from a where isnull(fvalue1,'')!=''
 union all
-select distinct 'fvalue2'field,fvalue2 as value from titem where siteid=$siteid$ and isnull(fvalue2,'')!='' and fvalue8=1
+select distinct 'fvalue2'field,fvalue2 as value from a where isnull(fvalue2,'')!=''
 union all
-select distinct 'fvalue3'field,fvalue3 as value from titem where siteid=$siteid$ and isnull(fvalue3,'')!='' and fvalue8=1
+select distinct 'fvalue3'field,fvalue3 as value from a where isnull(fvalue3,'')!=''
 union all
-select distinct 'fvalue4'field,fvalue4 as value from titem where siteid=$siteid$ and isnull(fvalue4,'')!='' and fvalue8=1
+select distinct 'fvalue4'field,fvalue4 as value from a where isnull(fvalue4,'')!=''
 union all
-select distinct 'fvalue5'field,fvalue5 as value from titem where siteid=$siteid$ and isnull(fvalue5,'')!='' and fvalue8=1
+select distinct 'fvalue5'field,fvalue5 as value from a where isnull(fvalue5,'')!=''
 union all
-select distinct 'fvalue6'field,fvalue6 as value from titem where siteid=$siteid$ and isnull(fvalue6,'')!='' and fvalue8=1
+select distinct 'fvalue6'field,fvalue6 as value from a where isnull(fvalue6,'')!=''
 union all
-select distinct 'fvalue7'field,fvalue7 as value from titem where siteid=$siteid$ and isnull(fvalue7,'')!='' and fvalue8=1
+select distinct 'fvalue7'field,fvalue7 as value from a where isnull(fvalue7,'')!=''

+ 80 - 7
src/rest/openapi/restcontroller/wechatapp/titem/Titem.java

@@ -1338,16 +1338,89 @@ public class Titem extends Controller {
     }
 
     public String query_itemvalueclass() {
-        SQLFactory sqlFactory = new SQLFactory(this, "商品档案选项查询");
-        sqlFactory.addParameter("siteid", siteid);
+        DBConnect connect = new DBConnect();
+        /**
+         * 过滤条件设置
+         */
+        String where = " 1=1 ";
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where = where + " and(t1.fitemname like'%" + whereObject.getString("condition") + "%' or t1.fitemno='" + whereObject.getString("condition") + "' or t1.fspec like '%" + whereObject.getString("condition") + "%' or t1.fmodel like'%" + whereObject.getString("condition") + "%')";
+            }
+            if (whereObject.containsKey("fitemno") && !"".equals(whereObject.getString("fitemno"))) {
+                where = where + " and t1.fitemno ='" + whereObject.getString("fitemno") + "'";
+            }
+            if (whereObject.containsKey("fspec") && !"".equals(whereObject.getString("fspec"))) {
+                where = where + " and t1.fspec ='" + whereObject.getString("fspec") + "'";
+            }
+            if (whereObject.containsKey("fsaleclsnum") && !"".equals(whereObject.getString("fsaleclsnum"))) {
+                SQLFactory flongsaleslsFactory = new SQLFactory(this, "营销类别全路径查询");
+                flongsaleslsFactory.addParameter("fsaleclsnum", whereObject.getString("fsaleclsnum"));
+                flongsaleslsFactory.addParameter("siteid", siteid);
+                Rows flongsaleslsRows = connect.runSqlQuery(flongsaleslsFactory.getSQL());
+                if (flongsaleslsRows.isEmpty()) {
+                    where = where + " and 1=2";
+                } else {
+                    //where = where + " and t1.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%'";
+                    where = where + " and exists(select *from titem_saleclsnum where titem_saleclsnum.siteid=t1.siteid and titem_saleclsnum.fitemno=t1.fitemno and titem_saleclsnum.flongsaleclsnum like'" + flongsaleslsRows.get(0).getString("flongsaleslsnum") + "%') ";
+                }
+            }
+            if (whereObject.containsKey("fiscollection") && !"".equals(whereObject.getString("fiscollection"))) {
+                where = where + " and isnull(t4.fiscollection,0) ='" + whereObject.getString("fiscollection") + "'";
+            }
+            if (whereObject.containsKey("fiscustomized") && !"".equals(whereObject.getString("fiscustomized"))) {
+                where = where + " and t1.fiscustomized ='" + whereObject.getString("fiscustomized") + "'";
+            }
+            if (whereObject.containsKey("fiswuliao") && !"".equals(whereObject.getString("fiswuliao"))) {
+                where = where + " and t1.fiswuliao ='" + whereObject.getString("fiswuliao") + "'";
+            }
+            if (whereObject.containsKey("fieldname") && !"".equals(whereObject.getString("fieldname"))) {
+                where = where + " and t1.fieldname ='" + whereObject.getString("fieldname") + "'";
+            }
+            if (whereObject.containsKey("fbrand") && !"".equals(whereObject.getString("fbrand"))) {
+                where = where + " and t1.fbrand ='" + whereObject.getString("fbrand") + "'";
+            }
+            if (whereObject.containsKey("fistool") && !"".equals(whereObject.getString("fistool"))) {
+                where = where + " and t1.fistool ='" + whereObject.getString("fistool") + "'";
+            }
 
-        DBConnect dbConnect = new DBConnect();
-        RowsMap rowsMap = dbConnect.runSqlQuery(sqlFactory.getSQL()).toRowsMap("field");
+            if (whereObject.containsKey("fvalue8") && whereObject.getBoolean("fvalue8")) {
+                //如果是中线碟阀
+                where = where + " and t1.fvalue8=1";
+            }
+            if (whereObject.containsKey("fvalue7") && !"".equals(whereObject.getString("fvalue7"))) {
+                where = where + " and t1.fvalue7 ='" + whereObject.getString("fvalue7") + "'";
+            }
+            if (whereObject.containsKey("fvalue6") && !"".equals(whereObject.getString("fvalue6"))) {
+                where = where + " and t1.fvalue6 ='" + whereObject.getString("fvalue6") + "'";
+            }
+            if (whereObject.containsKey("fvalue5") && !"".equals(whereObject.getString("fvalue5"))) {
+                where = where + " and t1.fvalue5 ='" + whereObject.getString("fvalue5") + "'";
+            }
+            if (whereObject.containsKey("fvalue4") && !"".equals(whereObject.getString("fvalue4"))) {
+                where = where + " and t1.fvalue4 ='" + whereObject.getString("fvalue4") + "'";
+            }
+            if (whereObject.containsKey("fvalue3") && !"".equals(whereObject.getString("fvalue3"))) {
+                where = where + " and t1.fvalue3 ='" + whereObject.getString("fvalue3") + "'";
+            }
+            if (whereObject.containsKey("fvalue2") && !"".equals(whereObject.getString("fvalue2"))) {
+                where = where + " and t1.fvalue2 ='" + whereObject.getString("fvalue2") + "'";
+            }
+            if (whereObject.containsKey("fvalue1") && !"".equals(whereObject.getString("fvalue1"))) {
+                where = where + " and t1.fvalue1 ='" + whereObject.getString("fvalue1") + "'";
+            }
+        }
 
-        JSONObject object = new JSONObject();
+        SQLFactory sqlFactory = new SQLFactory(this, "商品档案选项查询");
+        sqlFactory.addParameter("fagentnum", fagentnum);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter_SQL("where", where);
+        RowsMap rowsMap = connect.runSqlQuery(sqlFactory.getSQL()).toRowsMap("field");
+        JSONObject fieldobject = new JSONObject();
         for (String field : rowsMap.keySet()) {
-            object.put(field, rowsMap.get(field).toJsonArray("value"));
+            fieldobject.put(field, rowsMap.get(field).toJsonArray("value"));
         }
-        return getReturnObject_suc(object, true).toString();
+        return getReturnObject_suc(fieldobject, true).toString();
     }
 }

+ 1 - 1
src/rest/openapi/tools/nuonuo/OpenApi.java

@@ -29,7 +29,7 @@ public class OpenApi {
         // String method = "nuonuo.ElectronInvoice.requestBillingNew";
         // String token = "29a9a279edab1bb28e4cc40pigwd7sls";
         // String content = "填写API私有请求参数, 标准JSON格式";
-        // String url = "https://sdk.nuonuo.com/open/v1/services";// 票据识别请使用https://sdk.nuonuo.com/open/v2/ocr
+        // String urhttps://www.chuanglan.com/control/loginl = "https://sdk.nuonuo.com/open/v1/services";// 票据识别请使用https://sdk.nuonuo.com/open/v2/ocr
         // String appSecret = "SDA63AFA88C6468C";
         //String url = "https://sandbox.nuonuocs.cn/open/v1/services";
         String url = "https://sdk.nuonuo.com/open/v1/services";