沈静伟 4 лет назад
Родитель
Сommit
ef78889f3a

+ 11 - 0
src/dsb/com/cnd3b/common/BaseClass.java

@@ -166,6 +166,17 @@ public class BaseClass {
         return paoSetRemote;
     }
 
+    public ArrayList<Object> getP2FieldValues(PaoSetRemote paoSetRemote, String fieldname) throws P2Exception {
+        ArrayList<Object> list = new ArrayList<>();
+        int i = 0;
+        PaoRemote pao = null;
+        while ((pao = paoSetRemote.getPao(i)) != null) {
+            list.add(pao.getDatabaseValue(fieldname));
+            i++;
+        }
+        return list;
+    }
+
 
     public HashMap<String, PaoRemote> getPaoMap(PaoSetRemote paoSetRemote, String keyfieldname) throws P2Exception {
         HashMap<String, PaoRemote> map = new HashMap<>();

+ 2 - 0
src/dsb/com/cnd3b/restcontroller/customer/tagents/SQL/经销商经营类目查询.sql

@@ -0,0 +1,2 @@
+select fprodclassname from tagents_prodclass
+where t1.siteid =$siteid$ and t1.tagentsid=$tagentsid$

+ 13 - 4
src/dsb/com/cnd3b/restcontroller/customer/tagents/tagents.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
 import com.cnd3b.common.D3bException;
+import com.cnd3b.common.data.Row;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.SQLFactory;
 import com.cnd3b.common.data.db.DataPool;
@@ -22,10 +23,17 @@ public class tagents extends Controller {
      * @return
      */
     public String query_enterpriseAgentsMain() {
-        SQLFactory sql = new SQLFactory(this, "¾­ÏúÉÌÖ÷½çÃæ²éѯ");
-        sql.addParameter("siteid", siteid);
-        sql.addParameter("tagentsid", tagentsid);
-        Rows rows = dbConnect.runSqlQuery(sql.getSQL());
+        SQLFactory agentsql = new SQLFactory(this, "¾­ÏúÉÌÖ÷½çÃæ²éѯ");
+        agentsql.addParameter("siteid", siteid);
+        agentsql.addParameter("tagentsid", tagentsid);
+        Rows rows = dbConnect.runSqlQuery(agentsql.getSQL());
+        for (Row row : rows) {
+            SQLFactory saleprodclass = new SQLFactory(this, "¾­ÏúÉ̾­ÓªÀàÄ¿²éѯ");
+            saleprodclass.addParameter("siteid", siteid);
+            saleprodclass.addParameter("tagentsid", tagentsid);
+            Rows prodclassrows = dbConnect.runSqlQuery(saleprodclass.getSQL());
+            row.put("saleprodclass", prodclassrows.toArray("fprodclassname"));
+        }
         return getSucReturnObject().setData(rows).toString();
     }
 
@@ -69,4 +77,5 @@ public class tagents extends Controller {
         }
         return getSucReturnObject().toString();
     }
+
 }

+ 2 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tagents/SQL/经销商经营类目查询.sql

@@ -0,0 +1,2 @@
+select tagents_prodclassid,fprodclassname from tagents_prodclass
+where t1.siteid =$siteid$ and t1.tagentsid=$tagentsid$

+ 28 - 3
src/dsb/com/cnd3b/restcontroller/enterprise/tagents/tagents.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
 import com.cnd3b.common.D3bException;
+import com.cnd3b.common.data.Row;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.SQLFactory;
 import com.cnd3b.common.data.db.DataPool;
@@ -12,6 +13,8 @@ import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
 import p2.util.P2Exception;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 
 public class tagents extends Controller {
@@ -81,10 +84,18 @@ public class tagents extends Controller {
      * @return
      */
     public String query_enterpriseAgentsMain() {
+        tagentsid = content.getLong("tagentsid");
         SQLFactory sql = new SQLFactory(this, "经销商主界面查询");
         sql.addParameter("siteid", siteid);
-        sql.addParameter("tagentsid", content.getString("tagentsid"));
+        sql.addParameter("tagentsid", tagentsid);
         Rows rows = dbConnect.runSqlQuery(sql.getSQL());
+        for (Row row : rows) {
+            SQLFactory prodclass = new SQLFactory(this, "经销商经营类目查询");
+            prodclass.addParameter("siteid", siteid);
+            prodclass.addParameter("tagentsid", tagentsid);
+            Rows prodclassrows = dbConnect.runSqlQuery(prodclass.getSQL());
+            row.put("prodclass", prodclassrows);
+        }
         return getSucReturnObject().setData(rows).toString();
     }
 
@@ -160,8 +171,22 @@ public class tagents extends Controller {
                 Iterator it = changemsgObject.keySet().iterator();
                 while (it.hasNext()) {
                     String key = (String) it.next();
-                    String value = changemsgObject.getString(key);
-                    tagents.setValue(key, value, 11L);
+                    if ("saleprodclass".equals(key)) {
+                        //经营类目修改
+                        JSONArray saleprodclassArray = changemsgObject.getJSONArray("saleprodclass");
+                        PaoSetRemote tagents_prodclassSet = tagents.getPaoSet("$tagents_prodclass", "tagents_prodclass", "tagentsid=" + tagentsid);
+                        tagents_prodclassSet.deleteAll();
+                        for (Object saleprodclassObject : saleprodclassArray) {
+                            String fprodclassname = (String) saleprodclassObject;
+                            PaoRemote saleprodclassPao = tagents_prodclassSet.addAtEnd();
+                            saleprodclassPao.setValue("tagentsid", tagentsid, 11L);
+                            saleprodclassPao.setValue("siteid", siteid, 11L);
+                            saleprodclassPao.setValue("fprodclassname", fprodclassname, 11L);
+                        }
+                    } else {
+                        String value = changemsgObject.getString(key);
+                        tagents.setValue(key, value, 11L);
+                    }
                 }
                 if (ftype.equals("商户认证")) {
                     tagents.setValue("ftype", "普通商户", 11L);