Browse Source

查询授权的经销商列表

eganwu 1 year ago
parent
commit
b0b34e18ff

+ 7 - 0
src/custom/restcontroller/ClientUserInfo.java

@@ -159,6 +159,13 @@ public class ClientUserInfo extends UserInfo {
         return StringUtils.join(areaRows.toArray("areaname"), ",");
     }
 
+    public String getAreaName(Controller controller, Long sys_enterpriseid) throws YosException {
+        Rows areaRows = controller.dbConnect.runSqlQuery("SELECT DISTINCT t1.areaname from sa_salearea t1 " +
+                "INNER JOIN sys_enterprise_tradefield t2 ON t2.sa_saleareaid = t1.sa_saleareaid " +
+                "WHERE t2.sys_enterpriseid=" + sys_enterpriseid + " and t1.siteid='" + controller.siteid + "'");
+        return StringUtils.join(areaRows.toArray("areaname"), ",");
+    }
+
     public String getUserRoleName(Controller controller, Long userid) throws YosException {
         Rows rolenameRows = controller.dbConnect.runSqlQuery("select rolename from sys_userrole t1 " +
                 "inner join sys_role t2 ON t2.roleid=t1.roleid and t2.siteid=t1.siteid " +

+ 13 - 1
src/custom/restcontroller/webmanage/saletool/store/Store.java

@@ -58,15 +58,27 @@ public class Store extends Controller {
                         , "sys_enterpriseid", "enterprisename", "contact", "phonenumber", "province", "city", "county", "address")
                 .setTableAlias("t1");
         querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t2", "t2.sys_enterpriseid=t1.sys_enterpriseid and t2.siteid=t1.siteid"
-                , "agentnum");
+                , "agentnum", "status");
         querySQL.setSiteid(siteid);
         querySQL.setWhere(where.toString());
         querySQL.setWhere("EXISTS(SELECT 1 from sys_enterprise_tradefield WHERE sys_enterpriseid=t1.sys_enterpriseid and sa_saleareaid in " + sa_saleareaids.toString().replace("[", "(").replace("]", ")") + ")");
         querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
         Rows rows = querySQL.query();
+        if(rows.isEmpty()){
+            return getSucReturnObject().setData(rows).toString();
+        }
+
+        ArrayList<Long> ids=rows.toArrayList("sys_enterpriseid",new ArrayList<>());
+        ids.add(-1L);
+
+        RowsMap rowsMap = dbConnect.runSqlQuery("SELECT sys_enterpriseid,count(sys_enterprise_hrid) count from sys_enterprise_hr WHERE siteid='" + siteid + "' and sys_enterpriseid in " + ids.toString().replace("[", "(").replace("]", ")")  + " GROUP by sys_enterpriseid").toRowsMap("sys_enterpriseid");
 
         for (Row row : rows) {
             row.put("detailaddress", row.getString("province") + row.getString("city") + row.getString("county") + row.getString("address"));
+            row.put("areanames", userInfo.getAreaName(this, row.getLong("sys_enterpriseid")));
+            Rows countRows = rowsMap.getOrDefault(row.getString("sys_enterpriseid"), new Rows());
+            row.put("hrcount", countRows.isNotEmpty() ? countRows.get(0).getLong("count") : 0);
+
         }
 
 

+ 3 - 2
src/custom/restcontroller/webmanage/saletool/store/StoreTeam.java

@@ -46,6 +46,7 @@ public class StoreTeam extends Controller {
                         , "sys_enterprise_hrid", "name", "position", "phonenumber", "isleader", "userid")
                 .setTableAlias("t1");
         querySQL.setSiteid(siteid);
+        querySQL.setWhere(where.toString());
         querySQL.setWhere("sys_enterpriseid", sys_enterpriseid);
         querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
         Rows rows = querySQL.query();
@@ -104,7 +105,7 @@ public class StoreTeam extends Controller {
             insertSQL.setValue("name", name);
             insertSQL.setValue("remarks", "");
             insertSQL.setValue("sex", content.getStringValue("sex"));
-            insertSQL.setValue("birthday", content.getStringValue("birthday",true,"null"));
+            insertSQL.setValue("birthday", content.getStringValue("birthday", true, "null"));
             insertSQL.setValue("changeuserid", userid);
             sqlList.add(insertSQL.getSQL());
             content.put("sys_enterprise_hrid", sys_enterprise_hrid);
@@ -117,7 +118,7 @@ public class StoreTeam extends Controller {
             updateSQL.setValue("email", email);
             updateSQL.setValue("phonenumber", phonenumber);
             updateSQL.setValue("sex", content.getStringValue("sex"));
-            updateSQL.setValue("birthday", content.getStringValue("birthday",true,"null"));
+            updateSQL.setValue("birthday", content.getStringValue("birthday", true, "null"));
             sqlList.add(updateSQL.getSQL());
         }