吴志根 4 лет назад
Родитель
Сommit
870ebe19fc

+ 12 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tagentauth/SQL/经销商授权列表.sql

@@ -0,0 +1,12 @@
+SELECT t1.tagentauthid,
+       t1.tagentsid,
+       t1.fauthtype,
+       t2.fagentname,
+       t2.faddress,
+       t2.fcontact,
+       t2.fphonenumber,
+       t2.wechat_depid
+FROM tagentauth t1
+         LEFT JOIN tagents t2
+                   ON t1.tagentsid = t2.tagentsid
+ORDER BY t1.createdate DESC

+ 113 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tagentauth/tagentauth.java

@@ -0,0 +1,113 @@
+package com.cnd3b.restcontroller.enterprise.tagentauth;
+
+import com.alibaba.fastjson.JSONObject;
+import com.cnd3b.common.Controller;
+import com.cnd3b.common.data.Rows;
+import com.cnd3b.common.data.SQLFactory;
+import p2.common.parse.S;
+import p2.pao.PaoRemote;
+import p2.pao.PaoSetRemote;
+import p2.util.P2Exception;
+
+public class tagentauth extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public tagentauth(JSONObject content) {
+        super(content);
+    }
+
+    /**
+     * 新增经销商授权体系
+     *
+     * @return
+     */
+    public String inseretTagentauth() throws P2Exception {
+        //经销商id
+        String tagentsid = content.getString("tagentsid");
+        //体系类型
+        String fauthtype = content.getString("fauthtype");
+        if (tagentsid == null || tagentsid.equals("")) {
+            return getErrReturnObject().setErrMsg("经销商id为空").toString();
+        }
+        if (fauthtype == null || fauthtype.equals("")) {
+            return getErrReturnObject().setErrMsg("体系类型不能为空").toString();
+        }
+        //新增
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagentauth");
+        PaoRemote paoRemote = paoSetRemote.addAtEnd();
+        paoRemote.setValue("tagentsid", tagentsid, 11L);
+        paoRemote.setValue("fauthtype", fauthtype, 11L);
+        paoSetRemote.save();
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 更新经销商授权体系
+     *
+     * @return
+     */
+    public String updateTagentauth() throws P2Exception {
+        //经销商体系id
+        String tagentauthid = content.getString("tagentauthid");
+        //经销商id
+        String tagentsid = content.getString("tagentsid");
+        //体系类型
+        String fauthtype = content.getString("fauthtype");
+        if (tagentsid == null || tagentsid.equals("")) {
+            return getErrReturnObject().setErrMsg("经销商id为空").toString();
+        }
+        if (fauthtype == null || fauthtype.equals("")) {
+            return getErrReturnObject().setErrMsg("体系类型不能为空").toString();
+        }
+        if (fauthtype == null || fauthtype.equals("")) {
+            return getErrReturnObject().setErrMsg("体系类型不能为空").toString();
+        }
+        //更新体系
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagentauth", "tagentauthid = '" + tagentauthid + "'");
+        if (!paoSetRemote.isEmpty()) {
+            PaoRemote paoRemote = paoSetRemote.getPao(0);
+            paoRemote.setValue("tagentsid", tagentsid, 11L);
+            paoRemote.setValue("fauthtype", fauthtype, 11L);
+            paoSetRemote.save();
+        } else {
+            return getErrReturnObject().setErrMsg("未找到更新的数据").toString();
+        }
+
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 删除经销商授权体系
+     *
+     * @return
+     */
+    public String deleteTagentauth() throws P2Exception {
+        String tagentauthid = content.getString("tagentauthid");
+        if (tagentauthid == null || tagentauthid.equals("")) {
+            return getErrReturnObject().setErrMsg("id为空").toString();
+        }
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagentauth", "tagentauthid = '" + tagentauthid + "'");
+        if (!paoSetRemote.isEmpty()) {
+            PaoRemote paoRemote = paoSetRemote.getPao(0);
+            paoRemote.delete();
+            paoSetRemote.save();
+        } else {
+            return getErrReturnObject().setErrMsg("删除失败").toString();
+        }
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 查询经销商授权体系列表
+     *
+     * @return
+     */
+    public String selectTagentauthList() {
+        SQLFactory sqlFactory = new SQLFactory(this, "经销商授权列表");
+        Rows rows = sqlFactory.runSqlQuery();
+        return getSucReturnObject().setData(rows).toString();
+    }
+}

+ 4 - 11
src/dsb/com/cnd3b/restcontroller/enterprise/tagents/SQL/经销商档案列表.sql

@@ -1,16 +1,9 @@
-SELECT t1.fagentname,
-       t1.faddress,
-       t1.tagentsid,
+SELECT t1.tagentsid,
        t1.createdate,
-       t1.wechat_agentid,
-       t1.fcounty,
-       t1.tsalerid,
-       t1.fagentnum,
-       t1.wechat_corpid,
+       t1.fagentname,
+       t1.faddress,
        t1.fcontact,
        t1.fphonenumber,
-       t1.fcity,
-       t1.wechat_corp_name,
-       t1.fprovince
+       t1.wechat_depid
 FROM tagents t1
 ORDER BY t1.createdate desc

+ 1 - 131
src/dsb/com/cnd3b/restcontroller/enterprise/tagents/tagents.java

@@ -4,10 +4,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.SQLFactory;
-import com.cnd3b.utility.wechatdock.WechatDock_Enterprise;
-import p2.pao.PaoRemote;
-import p2.pao.PaoSetRemote;
-import p2.util.P2Exception;
 
 public class tagents extends Controller {
     /**
@@ -21,139 +17,13 @@ public class tagents extends Controller {
 
 
     /**
-     * 新增下游企业(经销商档案)
-     *
-     * @return
-     */
-    public String insertTagents() throws P2Exception {
-        //经销商编号
-        String fagentnum = content.getString("fagentnum");
-        //经销商名称
-        String fagentname = content.getString("fagentname");
-        //联系人
-        String fcontact = content.getString("fcontact");
-        //联系方式
-        String fphonenumber = content.getString("fphonenumber");
-        //省
-        String fprovince = content.getString("fprovince");
-        //市
-        String fcity = content.getString("fcity");
-        //县
-        String fcounty = content.getString("fcounty");
-        //地址
-        String faddress = content.getString("faddress");
-        //所属业务员ID
-        String tsalerid = content.getString("tsalerid");
-        //下游企业corpid
-        String wechat_corpid = content.getString("wechat_corpid");
-        //下游企业名称
-        String wechat_corp_name = content.getString("wechat_corp_name");
-        //下游企业应用id
-        String wechat_agentid = content.getString("wechat_agentid");
-
-        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagents");
-        PaoRemote paoRemote = paoSetRemote.addAtEnd();
-        paoRemote.setValue("fagentnum", fagentnum, 11L);
-        paoRemote.setValue("fagentname", fagentname, 11L);
-        paoRemote.setValue("fcontact", fcontact, 11L);
-        paoRemote.setValue("fphonenumber", fphonenumber, 11L);
-        paoRemote.setValue("fprovince", fprovince, 11L);
-        paoRemote.setValue("fcity", fcity, 11L);
-        paoRemote.setValue("fcounty", fcounty, 11L);
-        paoRemote.setValue("faddress", faddress, 11L);
-        paoRemote.setValue("tsalerid", tsalerid, 11L);
-        paoRemote.setValue("siteid", "JIUSHENG");
-        paoRemote.setValue("createby", username, 11L);
-        paoRemote.setValue("wechat_corpid", wechat_corpid, 11L);
-        paoRemote.setValue("wechat_corp_name", wechat_corp_name, 11L);
-        paoRemote.setValue("wechat_agentid", wechat_agentid, 11L);
-        paoSetRemote.save();
-
-        return getSucReturnObject().toString();
-    }
-
-    /**
-     * 更新下游企业(经销商档案)
-     *
-     * @return
-     */
-    public String updateTagents() throws P2Exception {
-        String tagentsid = content.getString("tagentsid");
-        //经销商编号
-        String fagentnum = content.getString("fagentnum");
-        //经销商名称
-        String fagentname = content.getString("fagentname");
-        //联系人
-        String fcontact = content.getString("fcontact");
-        //联系方式
-        String fphonenumber = content.getString("fphonenumber");
-        //省
-        String fprovince = content.getString("fprovince");
-        //市
-        String fcity = content.getString("fcity");
-        //县
-        String fcounty = content.getString("fcounty");
-        //地址
-        String faddress = content.getString("faddress");
-        //所属业务员ID
-        String tsalerid = content.getString("tsalerid");
-        //下游企业corpid
-        String wechat_corpid = content.getString("wechat_corpid");
-        //下游企业名称
-        String wechat_corp_name = content.getString("wechat_corp_name");
-        //下游企业应用id
-        String wechat_agentid = content.getString("wechat_agentid");
-
-        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagents", "tagentsid = '" + tagentsid + "'");
-        if (!paoSetRemote.isEmpty()) {
-            PaoRemote paoRemote = paoSetRemote.getPao(0);
-            paoRemote.setValue("fagentnum", fagentnum, 11L);
-            paoRemote.setValue("fagentname", fagentname, 11L);
-            paoRemote.setValue("fcontact", fcontact, 11L);
-            paoRemote.setValue("fphonenumber", fphonenumber, 11L);
-            paoRemote.setValue("fprovince", fprovince, 11L);
-            paoRemote.setValue("fcity", fcity, 11L);
-            paoRemote.setValue("fcounty", fcounty, 11L);
-            paoRemote.setValue("faddress", faddress, 11L);
-            paoRemote.setValue("tsalerid", tsalerid, 11L);
-            paoRemote.setValue("siteid", "JIUSHENG");
-            paoRemote.setValue("createby", username, 11L);
-            paoRemote.setValue("wechat_corpid", wechat_corpid, 11L);
-            paoRemote.setValue("wechat_corp_name", wechat_corp_name, 11L);
-            paoRemote.setValue("wechat_agentid", wechat_agentid, 11L);
-            paoSetRemote.save();
-        }
-        return getSucReturnObject().toString();
-    }
-
-    /**
-     * 删除下游企业(经销商档案)
-     *
-     * @return
-     */
-    public String deleteTagents() throws P2Exception {
-        String tagentsid = content.getString("tagentsid");
-        if (tagentsid == null || tagentsid.equals("")) {
-            return getErrReturnObject().setErrMsg("经销商id为空").toString();
-        }
-        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tagents", "tagentsid = '" + tagentsid + "'");
-        if (!paoSetRemote.isEmpty()) {
-            PaoRemote paoRemote = paoSetRemote.getPao(0);
-            paoRemote.delete();
-            paoSetRemote.save();
-        }
-        return getSucReturnObject().toString();
-    }
-
-    /**
-     * 查询下游企业(经销商档案)列表
+     * 查询经销商列表
      *
      * @return
      */
     public String selectTagentsList() {
 
         SQLFactory sqlFactory = new SQLFactory(this, "经销商档案列表");
-        sqlFactory.addParameter("siteid", siteid);
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
 
         return getSucReturnObject().setData(rows).toString();

+ 6 - 0
src/dsb/com/cnd3b/restcontroller/enterprise/tdepartment/SQL/部门列表.sql

@@ -0,0 +1,6 @@
+SELECT t1.wechat_depid,
+       t1.wechat_parendeptid,
+       t1.tdepartmentid,
+       t1.wechat_depname
+FROM tdepartment t1
+ORDER BY t1.createdate desc

+ 7 - 69
src/dsb/com/cnd3b/restcontroller/enterprise/tdepartment/tdepartment.java

@@ -2,10 +2,9 @@ package com.cnd3b.restcontroller.enterprise.tdepartment;
 
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
-import com.cnd3b.utility.wechatdock.WechatDock_Enterprise;
-import p2.pao.PaoRemote;
-import p2.pao.PaoSetRemote;
-import p2.util.P2Exception;
+import com.cnd3b.common.data.Rows;
+import com.cnd3b.common.data.SQLFactory;
+
 
 public class tdepartment extends Controller {
     /**
@@ -17,59 +16,6 @@ public class tdepartment extends Controller {
         super(content);
     }
 
-    /**
-     * 新增部门
-     *
-     * @return
-     */
-    public String insertTdepartment() throws P2Exception {
-        //下游企业ID、经销商ID
-        String tagentsid = content.getString("tagentsid");
-        //企业微信部门ID
-        String wechat_departmentid = content.getString("wechat_departmentid");
-        ;
-        //父部门id。根部门为1。
-        String wechat_departmentparentid = "1";
-        //在父部门中的次序值。order值大的排序靠前。值范围是[0, 2^32)。
-        String wechat_order = content.getString("wechat_order");
-        //部门名称
-        String wechat_name = content.getString("wechat_name");
-
-
-        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tdepartment");
-        PaoRemote paoRemote = paoSetRemote.addAtEnd();
-        paoRemote.setValue("tagentsid", tagentsid, 11L);
-        paoRemote.setValue("wechat_departmentid", wechat_departmentid, 11L);
-        paoRemote.setValue("wechat_departmentparentid", wechat_departmentparentid, 11L);
-        paoRemote.setValue("wechat_order", wechat_order, 11L);
-        paoRemote.setValue("wechat_name", wechat_name, 11L);
-        paoRemote.setValue("createby", username, 11L);
-        paoSetRemote.save();
-
-        JSONObject object = new JSONObject();
-
-
-        return getSucReturnObject().setData(object).toString();
-
-    }
-
-    /**
-     * 更新部门
-     *
-     * @return
-     */
-    public String updateTdepartment() {
-        return "";
-    }
-
-    /**
-     * 删除部门
-     *
-     * @return
-     */
-    public String deleteTdepartment() {
-        return "";
-    }
 
     /**
      * 查询部门列表
@@ -77,18 +23,10 @@ public class tdepartment extends Controller {
      * @return
      */
     public String selectTdepartmentList() {
-        return "";
+        SQLFactory sqlFactory = new SQLFactory(this, "部门列表");
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setData(rows).toString();
     }
 
-    /**
-     * 获取微信下游企业信息
-     *
-     * @return
-     */
-    public String getWeChatDepartmentList() {
-//        int agentid = content.getIntValue("agentid");
-//        String corpid = content.getString("corpid");
-//        return getSucReturnObject().setData(WechatDock_Enterprise.getDepartmentList(agentid, corpid)).toString();
-        return "";
-    }
+
 }