Ver Fonte

医院关联经销商

wu há 2 meses atrás
pai
commit
6e8cc1f13b

+ 11 - 12
src/custom/beans/proxy/Proxy.java

@@ -13,23 +13,22 @@ public class Proxy extends BaseClass {
 
     //获取当前账号的代理人
     public static ArrayList<Long> getProxyHrids(Controller controller) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sys_hr", "hrid");
-        querySQL.addJoinTable(JOINTYPE.inner, "sys_userteam", "t2", "t2.createuserid=t1.userid and t2.siteid=t1.siteid");
-        querySQL.setTableAlias("t1");
-        querySQL.setWhere("t2.isproxy", 1);
-        querySQL.setWhere("t2.userid", controller.userid);
-        querySQL.setWhere("t2.siteid", controller.siteid);
+        QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sys_userteam", "userid")
+                .setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left,"sys_hr","t2","t2.userid=t1.userid and t2.siteid=t1.siteid","hrid");
+        querySQL.setSiteid(controller.siteid);
+        querySQL.setWhere("t1.isproxy", 1);
+        querySQL.setWhere("t1.createuserid", controller.userid);
         return querySQL.query().toArrayList("hrid", new ArrayList<>());
 
     }
 
     public static ArrayList<Long> getProxyUserids(Controller controller) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sys_hr", "userid");
-        querySQL.addJoinTable(JOINTYPE.inner, "sys_userteam", "t2", "t2.createuserid=t1.userid and t2.siteid=t1.siteid");
-        querySQL.setTableAlias("t1");
-        querySQL.setWhere("t2.isproxy", 1);
-        querySQL.setWhere("t2.userid", controller.userid);
-        querySQL.setWhere("t2.siteid", controller.siteid);
+        QuerySQL querySQL = SQLFactory.createQuerySQL(controller, "sys_userteam", "userid")
+                .setTableAlias("t1");
+        querySQL.setSiteid(controller.siteid);
+        querySQL.setWhere("t1.isproxy", 1);
+        querySQL.setWhere("t1.createuserid", controller.userid);
         return querySQL.query().toArrayList("userid", new ArrayList<>());
 
     }

+ 5 - 0
src/custom/restcontroller/R.java

@@ -7372,6 +7372,11 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025102714042402 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 52 - 0
src/custom/restcontroller/sale/customer/Hospital.java

@@ -845,5 +845,57 @@ public class Hospital extends Controller {
         return getSucReturnObject().toString();
     }
 
+    @API(title = "选择经销商列表", apiversion = R.ID2025102714042402.v1.class)
+    public String chooseAgents() throws YosException {
+        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.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.province like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.city like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.county like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.address like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t3.erpagentnum like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+        where.append(" and t1.status !='作废' ");
+
+        ArrayList<Long> hrids = Proxy.getProxyHrids(this);
+        hrids.add(hrid);
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents",
+                        "sa_agentsid", "sys_enterpriseid", "gmname", "gmphonenumber", "agentnum", "cooperatetype", "remarks", "status", "createdate").
+                setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
+                "enterprisename", "province", "city", "county", "address");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t3", "t1.sys_enterpriseid = t3.ownerid and ownertable = 'sys_enterprise' and t1.siteid = t3.siteid",
+                "erpagentnum");
+        querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise_tradefield", "t4", "t4.sa_agentsid=t1.sa_agentsid and t4.siteid=t1.siteid");
+        querySQL.setWhere("t4.hrid", hrids);
+
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere(where);
+        querySQL.setPage(pageSize, pageNumber);
+        querySQL.setOrderBy("t1.createdate desc");
+        Rows rows = querySQL.query();
+
+        RowsMap areaRowsMap = getAreaRowsMap(rows.toArrayList("sa_agentsid", new ArrayList<>()));
+        RowsMap salerRowsMap = getSalerNameRowsMap(rows.toArrayList("sa_agentsid", new ArrayList<>()));
+        for (Row row : rows) {
+            row.put("p_c_c", row.getString("province") + "-" + row.getString("city") + "-" + row.getString("county"));
+            Rows areaRows = areaRowsMap.getOrDefault(row.getString("sa_agentsid"), new Rows());
+            row.put("areanames", StringUtils.join(areaRows.toArrayList("areaname"), ","));
+            Rows salerRows = salerRowsMap.getOrDefault(row.getString("sa_agentsid"), new Rows());
+            row.put("salernames", StringUtils.join(salerRows.toArrayList("name"), ","));
+            row.putIfAbsent("scale", "");
+            row.putIfAbsent("mainproducts", "");
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+
 
 }