shenjingwei hace 1 mes
padre
commit
a90ceffc58

+ 0 - 394
src/custom/beans/datateam/DataTeam.java

@@ -1,394 +0,0 @@
-package beans.datateam;
-
-import beans.datacontrllog.DataContrlLog;
-import beans.user.User;
-import common.Controller;
-import common.YosException;
-import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
-
-import java.util.ArrayList;
-
-public class DataTeam {
-
-    /**
-     * 数据团队查询
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @throws YosException
-     */
-    public static RowsMap queryTeam(Controller controller, String ownertable, long ownerid) throws YosException {
-        Rows rows = controller.dbConnect.runSqlQuery("select * from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' order by isleader desc,sys_datateamid");
-        for (Row row : rows) {
-            row.put("headpic", controller.getHeadPic(row.getLong("userid")));
-            row.put("username", controller.getUser(row.getLong("userid")).getString("name"));
-        }
-        return rows.toRowsMap("sys_enterpriseid");
-    }
-
-    public static Rows queryTeamRow(Controller controller, String ownertable, long ownerid) throws YosException {
-        Rows rows = controller.dbConnect.runSqlQuery("select * from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' order by isleader desc,sys_datateamid");
-        for (Row row : rows) {
-            row.put("headpic", controller.getHeadPic(row.getLong("userid")));
-            row.put("username", controller.getUser(row.getLong("userid")).getString("name"));
-        }
-        return rows;
-    }
-
-    /**
-     * 判断当前账号是否为数据管理员
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @throws YosException
-     */
-    public static boolean isLeader(Controller controller, String ownertable, long ownerid) throws YosException {
-        return controller.dbConnect.runSqlQuery("select * from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' and userid=" + controller.userid + " and isleader=1").isNotEmpty();
-    }
-
-    /**
-     * 获取数据的负责人
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @throws YosException
-     */
-    public static Rows getLeader(Controller controller, String ownertable, long ownerid) throws YosException {
-        Rows rows = controller.dbConnect.runSqlQuery("select * from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' and isleader=1");
-        for (Row row : rows) {
-            row.put("headpic", controller.getHeadPic(row.getLong("userid")));
-        }
-        return rows;
-    }
-
-    /**
-     * 获取数据的负责人
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @param sys_enterpriseid 0
-     * @throws YosException
-     */
-    public static Rows getLeader(Controller controller, String ownertable, long ownerid, long sys_enterpriseid) throws YosException {
-        Rows rows = controller.dbConnect.runSqlQuery("select * from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' and isleader=1 and sys_enterpriseid=" + sys_enterpriseid);
-        for (Row row : rows) {
-            row.put("headpic", controller.getHeadPic(row.getLong("userid")));
-        }
-        return rows;
-    }
-
-
-    /**
-     * 批量获取数据的负责人
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerids
-     * @return
-     * @throws YosException
-     */
-    public static Rows getLeader(Controller controller, String ownertable, ArrayList<String> ownerids) throws YosException {
-        String str = "select * from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid in " + ownerids + " and isleader=1";
-        if (ownerids.isEmpty()) {
-            str = "select * from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid in ('') and isleader=1";
-        }
-
-        str = str.replace("[", "(").replace("]", ")");
-        Rows rows = controller.dbConnect.runSqlQuery(str);
-        for (Row row : rows) {
-            row.put("headpic", controller.getHeadPic(row.getLong("userid")));
-        }
-        return rows;
-    }
-
-    /**
-     * 为数据添加团队成员
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @param userid     账号id
-     * @throws YosException
-     */
-    public static void createTeam(Controller controller, String ownertable, long ownerid, long userid) throws YosException {
-        controller.dbConnect.runSqlUpdate(createTeamSQL(controller, ownertable, ownerid, userid));
-    }
-
-    /**
-     * 为数据添加团队成员返回sql
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @param userid     账号id
-     * @throws YosException
-     */
-    public static ArrayList<String> createTeamSQL(Controller controller, String ownertable, long ownerid, long userid) throws YosException {
-        if (controller.dbConnect.runSqlQuery("select * from sys_users where userid=" + userid).isEmpty()) {
-            return new ArrayList<>();
-        }
-        SQLFactory sqlFactory = new SQLFactory(new DataTeam(), "数据团队插入");
-        sqlFactory.addParameter("sys_datateamid", controller.createTableID("sys_datateam"));
-        sqlFactory.addParameter("siteid", controller.siteid);
-        sqlFactory.addParameter("userid", userid);
-        sqlFactory.addParameter("ownerid", ownerid);
-        sqlFactory.addParameter("ownertable", ownertable);
-        sqlFactory.addParameter("username", controller.username);
-        sqlFactory.addParameter("changeuserid", controller.userid);
-        sqlFactory.addParameter("editable", 0);
-
-        Row agenthrrow = controller.getEnterpriseHr(userid);
-        Row hrrow = controller.getHr(userid);
-        if (!agenthrrow.isEmpty()) {
-            sqlFactory.addParameter("position", agenthrrow.getString("position"));
-            sqlFactory.addParameter("name", agenthrrow.getString("name"));
-            sqlFactory.addParameter("sys_enterpriseid", agenthrrow.getLong("sys_enterpriseid"));
-        } else if (!hrrow.isEmpty()) {
-            sqlFactory.addParameter("position", hrrow.getString("position"));
-            sqlFactory.addParameter("name", hrrow.getString("name"));
-            sqlFactory.addParameter("sys_enterpriseid", 0);
-        } else {
-            sqlFactory.addParameter("position", "");
-            sqlFactory.addParameter("name", controller.getUser(userid).getString("name"));
-            sqlFactory.addParameter("sys_enterpriseid", 0);
-        }
-
-        sqlFactory.addParameter("isleader", getLeader(controller, ownertable, ownerid, controller.sys_enterpriseid).isEmpty());
-
-        ArrayList<String> sqlist = new ArrayList<>();
-        sqlist.add(sqlFactory.getSQL());
-        return sqlist;
-    }
-
-    /**
-     * 为数据删除团队成员
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @param userid     账号id
-     * @throws YosException
-     */
-    public static void deleteTeam(Controller controller, String ownertable, long ownerid, long userid) throws YosException {
-        controller.dbConnect.runSqlUpdate(deleteTeamSQL(controller, ownertable, ownerid, userid));
-    }
-
-    /**
-     * 为数据删除团队成员
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @param userid     账号id
-     * @throws YosException
-     */
-    public static ArrayList<String> deleteTeamSQL(Controller controller, String ownertable, long ownerid, long userid) throws YosException {
-        ArrayList<String> sqlist = new ArrayList<>();
-        sqlist.add("delete from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' and userid ='" + userid + "' and sys_enterpriseid=" + controller.sys_enterpriseid);
-        return sqlist;
-    }
-
-    /**
-     * 为数据团队设置负责人
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @param userid     账号id
-     * @throws YosException
-     */
-    public static void setTeamLeader(Controller controller, String ownertable, long ownerid, long userid) throws YosException {
-        controller.dbConnect.runSqlUpdate(setTeamLeaderSQL(controller, ownertable, ownerid, userid));
-    }
-
-    /**
-     * 为数据团队设置负责人SQL
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @param userid     账号id
-     * @throws YosException
-     */
-    public static ArrayList<String> setTeamLeaderSQL(Controller controller, String ownertable, long ownerid, long userid) throws YosException {
-        Rows rows = controller.dbConnect.runSqlQuery("select max(leadernum)as leadernum from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' and userid ='" + userid + "' and sys_enterpriseid=" + controller.sys_enterpriseid);
-        long leadernum = 0;
-        if (rows.isNotEmpty()) {
-            leadernum = rows.get(0).getLong("leadernum") + 1;
-        }
-        ArrayList<String> sqllist = new ArrayList<>();
-        sqllist.add("update sys_datateam set isleader=1,leadernum=" + leadernum + ",changeuserid=" + controller.userid + ",changeby='" + controller.username + "',changedate=now() where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' and userid ='" + userid + "' and isleader=0 and sys_enterpriseid=" + controller.sys_enterpriseid);
-        sqllist.add("update sys_datateam set isleader=0,changeuserid=" + controller.userid + ",changeby='" + controller.username + "',changedate=now() where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid='" + ownerid + "' and userid !='" + userid + "' and isleader=1 and sys_enterpriseid=" + controller.sys_enterpriseid);
-        Rows leadrows = controller.dbConnect.runSqlQuery("select userid from sys_datateam where siteid='" + controller.siteid + "' and ownertable='" + ownertable + "' and ownerid=" + ownerid + " and isleader=1 and sys_enterpriseid=" + controller.sys_enterpriseid);
-        if (leadrows.isEmpty()) {
-            sqllist.add(DataContrlLog.createLog(controller, ownertable, ownerid, "设置负责人", "【" + controller.getUser(userid).getString("name") + "】").getSQL());
-        } else if (leadrows.isNotEmpty() && leadrows.get(0).getLong("userid") != userid) {
-            sqllist.add(DataContrlLog.createLog(controller, ownertable, ownerid, "变更负责人", "【" + controller.getUser(leadrows.get(0).getLong("userid")).getString("name") + "】 变更为 【" + controller.getUser(userid).getString("name") + "】").getSQL());
-        }
-        return sqllist;
-    }
-
-    /**
-     * 数据快速过滤
-     *
-     * @param controller
-     * @param ownertable 数据表名
-     * @param alias      数据表别名
-     * @param type       1:我负责的;2:我参与的;3:我下属负责的;4:我下属参与的;5:我创建的
-     * @throws YosException
-     */
-    public static String getDataWhereStr(Controller controller, String ownertable, String alias, int type) throws YosException {
-        String str = " 1=1 ";
-        switch (type) {
-            case 1: {
-                str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=1 and userid=" + controller.userid + " and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                break;
-            }
-            case 2: {
-                str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=0 and userid=" + controller.userid + " and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                break;
-            }
-            case 3: {
-                ArrayList<Long> subUserIds = User.getSubUserIds(controller);
-                if (subUserIds.size() == 0) {
-                    str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=1 and userid in ('') and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                } else {
-                    str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=1 and userid in " + User.getSubUserIds(controller) + " and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-
-                }
-                str = str.replace("[", "(").replace("]", ")");
-                break;
-            }
-            case 4: {
-                ArrayList<Long> subUserIds = User.getSubUserIds(controller);
-                if (subUserIds.size() == 0) {
-                    str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=0 and userid in ('') and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                } else {
-                    str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=0 and userid in " + User.getSubUserIds(controller) + " and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                }
-                str = str.replace("[", "(").replace("]", ")");
-                break;
-            }
-            case 5: {
-                str = alias + ".createuserid=" + controller.userid + " ";
-                break;
-            }
-            default:
-                break;
-        }
-        return str;
-    }
-
-
-
-    /**
-     * 数据快速过滤
-     *
-     * @param controller
-     * @param ownertable 数据表名
-     * @param alias      数据表别名
-     * @param type       1:我负责的;2:我参与的;3:我下属负责的;4:我下属参与的;5:我创建的
-     * @throws YosException
-     */
-    public static String getDataWhereStr(Controller controller, String ownertable, String alias, int type, ArrayList<Long> userids, ArrayList<Long> subUserIds) throws YosException {
-        String str = " 1=1 ";
-
-        switch (type) {
-            case 1: {
-                str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=1 and userid in" + userids + " and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                str = str.replace("[", "(").replace("]", ")");
-                break;
-            }
-            case 2: {
-                str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=0 and userid in" + userids + " and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                str = str.replace("[", "(").replace("]", ")");
-                break;
-            }
-            case 3: {
-                if (subUserIds.size() == 0) {
-                    str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=1 and userid in ('') and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                } else {
-                    str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=1 and userid in " + subUserIds + " and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-
-                }
-                str = str.replace("[", "(").replace("]", ")");
-                break;
-            }
-            case 4: {
-                if (subUserIds.size() == 0) {
-                    str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=0 and userid in ('') and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                } else {
-                    str = " exists(select sys_datateamid from sys_datateam where siteid='" + controller.siteid + "' and isleader=0 and userid in " + subUserIds + " and ownertable='" + ownertable + "' and ownerid=" + alias + "." + controller.getuniquecolumnname(ownertable) + " )";
-                }
-                str = str.replace("[", "(").replace("]", ")");
-                break;
-            }
-            case 5: {
-                str = alias + ".createuserid in" + userids + " ";
-                str = str.replace("[", "(").replace("]", ")");
-                break;
-            }
-            default:
-                break;
-        }
-        return str;
-    }
-
-    /**
-     * 添加我的团队里的所有成员
-     *
-     * @param controller
-     * @param ownertable
-     * @param ownerid
-     * @param userid
-     * @return
-     * @throws YosException
-     */
-    public static ArrayList<String> createTeamMemberSql(Controller controller, String ownertable, long ownerid, long userid) throws YosException {
-        Rows rows = controller.dbConnect.runSqlQuery("select userid,editable from sys_userteam where siteid='" + controller.siteid + "' and createuserid=" + userid + " and userid !=" + userid);
-        ArrayList<String> sqlist = new ArrayList<>();
-        for (Row row : rows) {
-            long downUserid = row.getLong("userid");
-            if (controller.dbConnect.runSqlQuery("select * from sys_users where userid=" + downUserid).isEmpty()) {
-                continue;
-            }
-            SQLFactory sqlFactory = new SQLFactory(new DataTeam(), "数据团队插入");
-            sqlFactory.addParameter("sys_datateamid", controller.createTableID("sys_datateam"));
-            sqlFactory.addParameter("siteid", controller.siteid);
-            sqlFactory.addParameter("userid", downUserid);
-            sqlFactory.addParameter("ownerid", ownerid);
-            sqlFactory.addParameter("ownertable", ownertable);
-            sqlFactory.addParameter("username", controller.username);
-            sqlFactory.addParameter("changeuserid", controller.userid);
-            sqlFactory.addParameter("editable", row.getInteger("editable"));
-
-            Row agenthrrow = controller.getEnterpriseHr(downUserid);
-            Row hrrow = controller.getHr(downUserid);
-            if (!agenthrrow.isEmpty()) {
-                sqlFactory.addParameter("position", agenthrrow.getString("position"));
-                sqlFactory.addParameter("name", agenthrrow.getString("name"));
-                sqlFactory.addParameter("sys_enterpriseid", agenthrrow.getLong("sys_enterpriseid"));
-            } else if (!hrrow.isEmpty()) {
-                sqlFactory.addParameter("position", hrrow.getString("position"));
-                sqlFactory.addParameter("name", hrrow.getString("name"));
-                sqlFactory.addParameter("sys_enterpriseid", 0);
-            } else {
-                sqlFactory.addParameter("position", "");
-                sqlFactory.addParameter("name", controller.getUser(downUserid).getString("name"));
-                sqlFactory.addParameter("sys_enterpriseid", 0);
-            }
-
-            sqlFactory.addParameter("isleader", 0);
-
-            sqlist.add(sqlFactory.getSQL());
-        }
-        return sqlist;
-    }
-}

+ 0 - 16
src/custom/beans/datateam/SQL/数据团队插入.sql

@@ -1,16 +0,0 @@
-insert into sys_datateam(siteid, sys_datateamid, ownerid, ownertable, userid, name, position, isleader, createby,
-                         createdate, changeuserid, changeby, changedate, sys_enterpriseid,editable)
-SELECT $siteid$,
-       $sys_datateamid$,
-       $ownerid$,
-       $ownertable$,
-       $userid$,
-       $name$,
-       $position$,
-       $isleader$,
-       $username$,
-       now(),
-       $changeuserid$,
-       $username$,
-       now(),
-       $sys_enterpriseid$,$editable$ where not exists (select * from sys_datateam where siteid=$siteid$  and ownertable=$ownertable$ and ownerid=$ownerid$ and userid=$userid$)

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

@@ -72,6 +72,21 @@ public class ClientUserInfo extends UserInfo {
         return enterprise_HrRow;
     }
 
+    /**
+     * 获取当前账号的门店ID
+     *
+     * @return
+     * @throws YosException
+     */
+    public Long getStoreID() throws YosException {
+        long sys_enterprise_hrid = getEnterprise_HrRow().getLong("sys_enterprise_hrid");
+        Rows sa_store_hrRows = controller.dbConnect.runSqlQuery("select * from sa_store_hr where siteid='" + getSiteId() + "' and sys_enterpriseid=" + getEnterpriseId() + " and sys_enterprise_hrid=" + sys_enterprise_hrid);
+        if (sa_store_hrRows.isNotEmpty()) {
+            return sa_store_hrRows.getRow(0).getLong("sa_storeid");
+        }
+        return 0L;
+    }
+
     public Row getAgentRow() throws YosException {
         if (agentsRow == null) {
             Rows agentsRows = controller.dbConnect.runSqlQuery("select * from sa_agents where siteid='" + getSiteId() + "' and sys_enterpriseid=" + getEnterpriseId());

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

@@ -7412,6 +7412,41 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2026031410293201 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2026031414243401 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2026031414384501 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2026031414454901 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2026031415462301 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2026031416083401 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2026031416194201 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 7 - 7
src/custom/restcontroller/common/task/task.java

@@ -27,7 +27,7 @@ public class task extends Controller {
         int year = content.getInteger("year");
         int month = content.getInteger("month");
         Rows rows = dbConnect.runSqlQuery("select distinct starttime as taskdate from sys_task where siteid='" + siteid + "' and year(starttime)=" + year + " and month(starttime)=" + month +
-                " and (" + DataTeam.getDataWhereStr(this, "sys_task", "sys_task", 1) + ")");
+                " and (" + DataTeam.getDataWhereStr(this, "sys_task", "sys_task", DataTeam.FilterType.valueOf( 1)) + ")");
         return getSucReturnObject().setData(rows.toJsonArray("taskdate")).toString();
     }
 
@@ -53,13 +53,13 @@ public class task extends Controller {
             }
         }
         if (type == 0) {
-            where = " (" + where + ") and (" + DataTeam.getDataWhereStr(this, "sys_task", "t1", 1)
-                    + " or " + DataTeam.getDataWhereStr(this, "sys_task", "t1", 2)
-                    + " or " + DataTeam.getDataWhereStr(this, "sys_task", "t1", 3)
-                    + " or " + DataTeam.getDataWhereStr(this, "sys_task", "t1", 4)
-                    + " or " + DataTeam.getDataWhereStr(this, "sys_task", "t1", 5) + ")";
+            where = " (" + where + ") and (" + DataTeam.getDataWhereStr(this, "sys_task", "t1", DataTeam.FilterType.valueOf( 1))
+                    + " or " + DataTeam.getDataWhereStr(this, "sys_task", "t1", DataTeam.FilterType.valueOf( 2))
+                    + " or " + DataTeam.getDataWhereStr(this, "sys_task", "t1", DataTeam.FilterType.valueOf( 3))
+                    + " or " + DataTeam.getDataWhereStr(this, "sys_task", "t1", DataTeam.FilterType.valueOf( 4))
+                    + " or " + DataTeam.getDataWhereStr(this, "sys_task", "t1", DataTeam.FilterType.valueOf( 5)) + ")";
         } else {
-            where = " (" + where + ") and (" + DataTeam.getDataWhereStr(this, "sys_task", "t1", type) + ")";
+            where = " (" + where + ") and (" + DataTeam.getDataWhereStr(this, "sys_task", "t1", DataTeam.FilterType.valueOf( type)) + ")";
         }
 //        SQLFactory sqlFactory = new SQLFactory(this, "任务列表查询", pageSize, pageNumber, pageSorting);
 //        sqlFactory.addParameter("siteid", siteid);

+ 1 - 0
src/custom/restcontroller/crm/agent/customer/Customer.java

@@ -91,6 +91,7 @@ public class Customer extends Controller {
             insertSQL.setValue("birthday", birthday.isBlank() ? null : birthday);// 生日
             insertSQL.setValue("remarks", remarks);// 备注
             insertSQL.setValue("source", source);// 客户来源
+            insertSQL.setValue("sa_storeid", userInfo.getStoreID());// 门店ID
             if (sat_orderclueid > 0) {
                 insertSQL.setValue("sourcetable", "sat_orderclue");// 关联数据表
                 insertSQL.setValue("sourceid", sat_orderclueid);// 关联数据id

+ 216 - 50
src/custom/restcontroller/crm/agent/custorder/Custorder.java

@@ -1,13 +1,12 @@
 package restcontroller.crm.agent.custorder;
 
+import beans.datateam.DataTeam;
 import com.alibaba.fastjson2.JSONObject;
 import common.Controller;
 import common.YosException;
 import common.annotation.API;
-import common.data.InsertSQL;
-import common.data.SQLDump;
-import common.data.SQLFactory;
-import common.data.UpdateSQL;
+import common.annotation.Param;
+import common.data.*;
 import restcontroller.R;
 
 @API(title = "美大CRM_经销商_客户订单管理")
@@ -16,61 +15,113 @@ public class Custorder extends Controller {
         super(content);
     }
 
-    @API(title = "美大CRM_经销商_客户订单新增修改", apiversion = R.ID2026031309441701.v1.class)
+    @API(title = "美大CRM_经销商_客户订单列表查询", apiversion = R.ID2026031410293201.v1.class)
+    public String sa_custorder_querylist() throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_custorder", "sa_custorderid", // C端订单ID
+                "siteid", // 站点
+                "billdate", // 开单日期
+                "sa_customersid", // 客户档案ID
+                "sa_storeid", // 门店表ID
+                "ispaid", // 付款状态
+                "amount", // 金额(元)
+                "payamount",//已收款金额
+                "qty", // 数量
+                "remarks", // 备注说明
+                "status", // 状态
+                "sys_enterpriseid", // 合作企业档案ID
+                "sonum", // 订单编号
+                "createby", // 创建人
+                "createdate", // 创建时间
+                "changeby", // 修改人
+                "changedate" // 修改时间
+        ).setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t2", "t1.sa_customersid=t2.sa_customersid", "name", "phonenumber", "address");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_store", "t3", "t1.sa_storeid=t3.sa_storeid", "storeno", "storename");
+
+        querySQL.setWhere("sys_enterpriseid", sys_enterpriseid);
+        if (userInfo.getEnterprise_HrRow().getBoolean("storedatalimit")) {
+            querySQL.setWhere("sa_storeid", userInfo.getStoreID());
+        }
+        if (userInfo.getEnterprise_HrRow().getBoolean("userdatalimit")) {
+            querySQL.setDataTeamLimit(DataTeam.FilterType.MyLeader);
+        }
+        querySQL.setSiteid(siteid);
+        querySQL.setPage(pageSize, pageNumber);
+        Rows rows = querySQL.query();
+
+        RowsMap leaderRowsMap = DataTeam.getLeader(this, "sa_customers", rows.toArrayList("sa_customersid")).toRowsMap("ownerid");
+        for (Row row : rows) {
+            if (leaderRowsMap.containsKey(row.getString("sa_customersid"))) {
+                row.put("leader", leaderRowsMap.get(row.getString("sa_customersid")).get(0).getString("name"));
+            } else {
+                row.put("leader", "");
+            }
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "美大CRM_经销商_客户订单详情查询", apiversion = R.ID2026031414384501.v1.class, params = {@Param(paramname = "sa_custorderid", fieldtype = FieldType.BigInt)})
+    public String sa_custorder_querymain() throws YosException {
+        long sa_custorderid = content.getLongValue("sa_custorderid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_custorder", "sa_custorderid", // C端订单ID
+                "siteid", // 站点
+                "billdate", // 开单日期
+                "sa_customersid", // 客户档案ID
+                "sa_storeid", // 门店表ID
+                "ispaid", // 付款状态
+                "amount", // 金额(元)
+                "payamount",//已收款金额
+                "qty", // 数量
+                "remarks", // 备注说明
+                "status", // 状态
+                "sys_enterpriseid", // 合作企业档案ID
+                "sonum", // 订单编号
+                "createby", // 创建人
+                "createdate", // 创建时间
+                "changeby", // 修改人
+                "changedate" // 修改时间
+        ).setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t2", "t1.sa_customersid=t2.sa_customersid", "name", "phonenumber", "address", "community");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_store", "t3", "t1.sa_storeid=t3.sa_storeid", "storeno", "storename");
+        querySQL.setWhere("sys_enterpriseid", sys_enterpriseid);
+        querySQL.setUniqueid(sa_custorderid);
+        querySQL.setSiteid(siteid);
+        Rows rows = querySQL.query();
+        RowsMap leaderRowsMap = DataTeam.getLeader(this, "sa_customers", rows.toArrayList("sa_customersid")).toRowsMap("ownerid");
+        for (Row row : rows) {
+            if (leaderRowsMap.containsKey(row.getString("sa_customersid"))) {
+                row.put("leader", leaderRowsMap.get(row.getString("sa_customersid")).get(0).getString("name"));
+            } else {
+                row.put("leader", "");
+            }
+        }
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "美大CRM_经销商_客户订单新增修改", apiversion = R.ID2026031309441701.v1.class, params = {@Param(paramname = "sa_custorderid", remarks = "订单ID,修改时必填", fieldtype = FieldType.BigInt, isrequired = false), @Param(paramname = "sa_customersid", remarks = "客户ID,新增时必填", fieldtype = FieldType.BigInt), @Param(paramname = "remarks", remarks = "备注说明", fieldtype = FieldType.Varchar, isrequired = false), @Param(paramname = "billdate", remarks = "开单日期", fieldtype = FieldType.Date, isrequired = false)})
     public String sa_custorder_save() throws YosException {
         long sa_custorderid = content.getLongValue("sa_custorderid");
-        long sa_storeid = content.getLongValue("sa_storeid");// 门店表ID
-        long rec_contactsid = content.getLongValue("rec_contactsid");// 合作企业联系人表ID
-        boolean ispaid = content.getBooleanValue("ispaid");// 付款状态
-        String out_refund_no = content.getStringValue("out_refund_no");// 商户退款单号
-        String wechatpayorder = content.getStringValue("wechatpayorder");// 微信支付订单查询结果
-        boolean deleted = content.getBooleanValue("deleted");// 删除状态
-        String phonenumber = content.getStringValue("phonenumber");// 联系电话
-        String name = content.getStringValue("name");// 客户名称
-        double amount = content.getDoubleValue("amount");// 金额(元)
-        String paytime = content.getStringValue("paytime");// 付费时间
-        String remarks = content.getStringValue("remarks");// 订单日志
-        String paymode = content.getStringValue("paymode");// 付款方式
-        String status = content.getStringValue("status");// 状态
-        long sys_enterpriseid = content.getLongValue("sys_enterpriseid");// 合作企业档案ID
-        String sonum = content.getStringValue("sonum");// 订单编号
+        String remarks = content.getStringValue("remarks");// 备注说明
+        String billdate = content.getStringValue("billdate");// 开单日期
+        Rows sa_custorderRow = SQLFactory.createQuerySQL(this, "sa_custorder", "sa_custorderid").setSiteid(siteid).setUniqueid(sa_custorderid).query();
         SQLDump sqldump = new SQLDump();
-        if (sa_custorderid <= 0 || SQLFactory.createQuerySQL(this, "sa_custorder", "sa_custorderid").setSiteid(siteid).setUniqueid(sa_custorderid).query().isEmpty()) {
+        if (sa_custorderid == 0 || sa_custorderRow.isEmpty()) {
+            long sa_customersid = content.getLong("sa_customersid");//客户ID
             InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_custorder");
+            insertSQL.setValue("sonum", createBillCode("custorder"));// 订单编号
             insertSQL.setValue("siteid", siteid);// 站点
-            insertSQL.setValue("sa_storeid", sa_storeid);// 门店表ID
-            insertSQL.setValue("rec_contactsid", rec_contactsid);// 合作企业联系人表ID
-            insertSQL.setValue("ispaid", ispaid);// 付款状态
-            insertSQL.setValue("out_refund_no", out_refund_no);// 商户退款单号
-            insertSQL.setValue("wechatpayorder", wechatpayorder);// 微信支付订单查询结果
-            insertSQL.setValue("deleted", deleted);// 删除状态
-            insertSQL.setValue("phonenumber", phonenumber);// 联系电话
-            insertSQL.setValue("name", name);// 客户名称
-            insertSQL.setValue("amount", amount);// 金额(元)
-            insertSQL.setValue("paytime", paytime);// 付费时间
-            insertSQL.setValue("remarks", remarks);// 订单日志
-            insertSQL.setValue("paymode", paymode);// 付款方式
-            insertSQL.setValue("status", status);// 状态
+            insertSQL.setValue("sa_storeid", userInfo.getStoreID());// 门店表ID
+            insertSQL.setValue("remarks", remarks);// 备注说明
+            insertSQL.setValue("billdate", billdate);// 开单日期
+            insertSQL.setValue("status", "待出库");// 状态
+            insertSQL.setValue("ispaid", 0);// 付款状态,待付款
             insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);// 合作企业档案ID
-            insertSQL.setValue("sonum", sonum);// 订单编号
+            insertSQL.setValue("sa_customersid", sa_customersid);// 合作企业档案ID
             sqldump.add(insertSQL);
         } else {
             UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_custorder");
-            updateSQL.setValue("sa_storeid", sa_storeid);// 门店表ID
-            updateSQL.setValue("rec_contactsid", rec_contactsid);// 合作企业联系人表ID
-            updateSQL.setValue("ispaid", ispaid);// 付款状态
-            updateSQL.setValue("out_refund_no", out_refund_no);// 商户退款单号
-            updateSQL.setValue("wechatpayorder", wechatpayorder);// 微信支付订单查询结果
-            updateSQL.setValue("deleted", deleted);// 删除状态
-            updateSQL.setValue("phonenumber", phonenumber);// 联系电话
-            updateSQL.setValue("name", name);// 客户名称
-            updateSQL.setValue("amount", amount);// 金额(元)
-            updateSQL.setValue("paytime", paytime);// 付费时间
-            updateSQL.setValue("remarks", remarks);// 订单日志
-            updateSQL.setValue("paymode", paymode);// 付款方式
-            updateSQL.setValue("status", status);// 状态
-            updateSQL.setValue("sys_enterpriseid", sys_enterpriseid);// 合作企业档案ID
-            updateSQL.setValue("sonum", sonum);// 订单编号
+            updateSQL.setValue("remarks", remarks);// 备注说明
+            updateSQL.setValue("billdate", billdate);// 开单日期
             updateSQL.setSiteid(siteid);
             updateSQL.setUniqueid(sa_custorderid);
             sqldump.add(updateSQL);
@@ -79,5 +130,120 @@ public class Custorder extends Controller {
         return getSucReturnObject().toString();
     }
 
+    @API(title = "美大CRM_经销商_客户订单删除", apiversion = R.ID2026031414454901.v1.class, params = {@Param(paramname = "sa_custorderid", fieldtype = FieldType.BigInt)})
+    public String sa_custorder_delete() throws YosException {
+        long sa_custorderid = content.getLongValue("sa_custorderid");
+        SQLDump sqldump = new SQLDump();
+        sqldump.add(SQLFactory.createDeleteSQL(this, "sa_custorder").setUniqueid(sa_custorderid));
+        sqldump.add(SQLFactory.createDeleteSQL(this, "sa_custorderitems").setWhere("sa_custorderid", sa_custorderid));
+        sqldump.commit();
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "美大CRM_经销商_客户订单退单", apiversion = R.ID2026031416194201.v1.class)
+    public String sa_custorder_void() throws YosException {
+        long sa_custorderid = content.getLongValue("sa_custorderid");
+        String voidreason = content.getString("voidreason");
+        SQLFactory.createUpdateSQL(this, "sa_custorder").setValue("status", "已退单").setValue("voidreason", voidreason).setUniqueid(sa_custorderid).update();
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "美大CRM_经销商_客户订单商品明细查询", apiversion = R.ID2026031414243401.v1.class, params = {@Param(paramname = "sa_custorderid", fieldtype = FieldType.BigInt)})
+    public String sa_custorderitems_querylist() throws YosException {
+        long sa_custorderid = content.getLong("sa_custorderid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_custorderitems", "*").setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.unitid=t2.unitid", "unitname");
+        querySQL.setWhere("sa_custorderid", sa_custorderid);
+        querySQL.setSiteid(siteid);
+        querySQL.setPage(pageSize, pageNumber);
+        Rows rows = querySQL.query();
+        return getSucReturnObject().setData(rows).toString();
+    }
 
+    @API(title = "美大CRM_经销商_客户订单商品明细新增修改", apiversion = R.ID2026031415462301.v1.class, params = {@Param(paramname = "sa_custorderid", fieldtype = FieldType.BigInt), @Param(paramname = "sa_custorderitemsid", fieldtype = FieldType.BigInt), @Param(paramname = "sys_enterprise_itemid", remarks = "企业商品ID", fieldtype = FieldType.BigInt), @Param(paramname = "qty", remarks = "数量", fieldtype = FieldType.Decimal), @Param(paramname = "oldprice", remarks = "原价(元)", fieldtype = FieldType.Decimal), @Param(paramname = "discountrate", remarks = "折扣%", fieldtype = FieldType.Decimal), @Param(paramname = "price", remarks = "单价(元)", fieldtype = FieldType.Decimal), @Param(paramname = "amount", remarks = "金额(元)", fieldtype = FieldType.Decimal)})
+    public String sa_custorderitems_save() throws YosException {
+        long sa_custorderid = content.getLong("sa_custorderid");// 订单ID
+        long sa_custorderitemsid = content.getLongValue("sa_custorderitemsid");
+        double qty = content.getDoubleValue("qty");// 数量
+        double price = content.getDoubleValue("price");// 单价(元)
+        double amount = content.getDoubleValue("amount");// 金额(元)
+        double discountrate = content.getDoubleValue("discountrate");// 折扣%
+
+        SQLDump sqldump = new SQLDump();
+        if (sa_custorderitemsid <= 0 || SQLFactory.createQuerySQL(this, "sa_custorderitems", "sa_custorderitemsid").setSiteid(siteid).setUniqueid(sa_custorderitemsid).query().isEmpty()) {
+            long sys_enterprise_itemid = content.getLongValue("sys_enterprise_itemid");// 企业商品档案表ID
+            double oldprice = content.getDoubleValue("oldprice");// 原单价(元)
+
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_custorderitems");
+            insertSQL.setValue("siteid", siteid);// 站点
+            insertSQL.setValue("sa_custorderid", sa_custorderid);// C端订单ID
+            insertSQL.setValue("sys_enterprise_itemid", sys_enterprise_itemid);// 企业商品档案表ID
+            insertSQL.setValue("qty", qty);// 数量
+            insertSQL.setValue("oldprice", oldprice);// 原单价(元)
+            insertSQL.setValue("discountrate", discountrate);// 折扣%
+            insertSQL.setValue("price", price);// 单价(元)
+            insertSQL.setValue("amount", amount);// 金额(元)
+
+            Rows sys_enterprise_itemRows = SQLFactory.createQuerySQL(this, "sys_enterprise_item", "unitid").setWhere("sys_enterprise_itemid", sys_enterprise_itemid).query();
+            if (sys_enterprise_itemRows.isEmpty()) {
+                return getErrReturnObject().setErrMsg("未找到商品档案信息").toString();
+            }
+            long unitid = sys_enterprise_itemRows.get(0).getLong("unitid");
+            String spec = sys_enterprise_itemRows.get(0).getString("spec");
+            String itemno = sys_enterprise_itemRows.get(0).getString("itemno");
+            String model = sys_enterprise_itemRows.get(0).getString("model");
+            String itemname = sys_enterprise_itemRows.get(0).getString("itemname");
+
+            insertSQL.setValue("itemno", itemno);// 商品编号
+            insertSQL.setValue("itemname", itemname);// 产品名称
+            insertSQL.setValue("model", model);// 型号
+            insertSQL.setValue("spec", spec);// 尺寸
+            insertSQL.setValue("unitid", unitid);// 单位
+            sqldump.add(insertSQL);
+        } else {
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_custorderitems");
+            updateSQL.setValue("qty", qty);// 数量
+            updateSQL.setValue("discountrate", discountrate);// 折扣%
+            updateSQL.setValue("price", price);// 单价(元)
+            updateSQL.setValue("amount", amount);// 金额(元)
+            updateSQL.setSiteid(siteid);
+            updateSQL.setWhere("sa_custorderid", sa_custorderid);
+            updateSQL.setUniqueid(sa_custorderitemsid);
+            sqldump.add(updateSQL);
+        }
+        sqldump.commit();
+        updateOrderHeadData(sa_custorderid);
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "美大CRM_经销商_客户订单商品明细删除", apiversion = R.ID2026031416083401.v1.class,
+            params = {
+                    @Param(paramname = "sa_custorderid", fieldtype = FieldType.BigInt),
+                    @Param(paramname = "sa_custorderitemsid", fieldtype = FieldType.BigInt)
+            })
+    public String sa_custorderitems_delete() throws YosException {
+        long sa_custorderid = content.getLongValue("sa_custorderid");
+        long sa_custorderitemsid = content.getLongValue("sa_custorderitemsid");
+        SQLFactory.createDeleteSQL(this, "sa_custorderitems").setWhere("sa_custorderid", sa_custorderid).setUniqueid(sa_custorderitemsid).delete();
+        updateOrderHeadData(sa_custorderid);
+        return getSucReturnObject().toString();
+    }
+
+    /**
+     * 更新订单表头金额数量
+     *
+     * @param sa_custorderid
+     * @throws YosException
+     */
+    public void updateOrderHeadData(long sa_custorderid) throws YosException {
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_custorderitems");
+        querySQL.addQueryFields("qty", "ifnull(sum(qty),0)");
+        querySQL.addQueryFields("amount", "ifnull(sum(amount),0)");
+        Rows rows = querySQL.query();
+        if (rows.isNotEmpty()) {
+            double qty = rows.get(0).getDouble("qty");
+            double amount = rows.get(0).getDouble("amount");
+            SQLFactory.createUpdateSQL(this, "sa_custorder").setValue("qty", qty).setValue("amount", amount).setUniqueid(sa_custorderid).update();
+        }
+    }
 }

+ 15 - 0
src/custom/restcontroller/crm/agent/custorder/doc/sa_custorder_save.json

@@ -0,0 +1,15 @@
+{
+  "request": {
+    "content": {
+      "sa_custorderid": 0,
+      "sa_customersid": 1,
+      "sa_storeid": 1,
+      "remarks": "",
+      "billdate": ""
+    }
+  },
+  "suc": {
+  },
+  "err": {
+  }
+}

+ 7 - 7
src/custom/restcontroller/sale/customer/Customer.java

@@ -537,13 +537,13 @@ public class Customer extends Controller {
         sqlFactory.addParameter_SQL("where", where);
         String where2 = "";
         if (type == 0) {
-            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", 1)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 2)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 3)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 4)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 5);
+            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 1))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 2))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 3))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 4))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 5));
         } else {
-            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", type);
+            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( type));
         }
         sqlFactory.addParameter_SQL("where2", where2);
         String sql = sqlFactory.getSQL();
@@ -759,7 +759,7 @@ public class Customer extends Controller {
         querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t3", " t3.sys_enterpriseid = t1.sys_enterpriseid AND t3.siteid = t1.siteid","enterprisename");
         querySQL.setSiteid(siteid);
         querySQL.setWhere(where.toString());
-        querySQL.setWhere(DataTeam.getDataWhereStr(this, "sa_customers", "t1", 1));
+        querySQL.setDataTeamLimit(DataTeam.FilterType.MyLeader);
         querySQL.setPage(pageSize, pageNumber);
 
         Rows rows = querySQL.query();

+ 7 - 7
src/custom/restcontroller/sale/project/Project.java

@@ -114,13 +114,13 @@ public class Project extends Controller {
 //        sqlFactory.addParameter("username", username);
         String where2;
         if (type == 0) {
-            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", 1)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 2)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 3)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 4)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 5);
+            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 1))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 2))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 3))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 4))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 5));
         } else {
-            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", type);
+            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( type));
         }
 
         sqlFactory.addParameter_SQL("where2", where2);
@@ -394,7 +394,7 @@ public class Project extends Controller {
         querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t2.sys_enterpriseid = t1.sys_enterpriseid AND t2.siteid = t1.siteid", "enterprisename");
         querySQL.setSiteid(siteid);
         querySQL.setWhere(where.toString());
-        querySQL.setWhere(DataTeam.getDataWhereStr(this, "sa_customers", "t1", 1));
+        querySQL.setWhere(DataTeam.getDataWhereStr(this, "sa_customers", "t1", DataTeam.FilterType.valueOf( 1)));
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
 

+ 1 - 1
src/custom/restcontroller/sale/salesforecast/salesforecast.java

@@ -500,7 +500,7 @@ public class salesforecast extends Controller {
         querySQL.setSiteid(siteid);
         querySQL.setWhere("t1.deleted = 0");
         querySQL.setWhere(where);
-        querySQL.setWhere(DataTeam.getDataWhereStr(this, "sa_project", "t1", 1));
+        querySQL.setWhere(DataTeam.getDataWhereStr(this, "sa_project", "t1", DataTeam.FilterType.valueOf(1)));
         querySQL.setWhere("t1.sa_projectid not in (select sa_projectid from sa_salesforecastproject where sa_salesforecastbillid='"+ content.getLong("sa_salesforecastbillid")+"' )");
 
         querySQL.setPage(pageSize, pageNumber);

+ 1 - 1
src/custom/restcontroller/sale/salestarget/project.java

@@ -67,7 +67,7 @@ public class project extends Controller {
         querySQL.setSiteid(siteid);
         querySQL.setWhere("t1.status","跟进中");
         querySQL.setWhere(where.toString());
-        querySQL.setWhere(DataTeam.getDataWhereStr(this, "sa_project", "t1", 1));
+        querySQL.setWhere(DataTeam.getDataWhereStr(this, "sa_project", "t1", DataTeam.FilterType.valueOf( 1)));
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
 

+ 7 - 7
src/custom/restcontroller/webmanage/sale/contract/Contract.java

@@ -489,13 +489,13 @@ public class Contract extends Controller {
 //        sqlFactory.addParameter_SQL("where", where);
         String where2 = "";
         if (type == 0) {
-            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", 1)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 2)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 3)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 4)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 5);
+            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 1))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 2))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 3))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 4))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 5));
         } else {
-            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", type);
+            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( type));
         }
 //        sqlFactory.addParameter_SQL("where2", where2);
 //        String sql = sqlFactory.getSQL();
@@ -1092,7 +1092,7 @@ public class Contract extends Controller {
             //业务员
             if (userInfo.isSaler()) {
                 //选择操作人负责的项目合同(包括经销、直销项目合同)
-                where = " (" + where + ") and (" + DataTeam.getDataWhereStr(this, "sa_contract", "t1", 1) + ")";
+                where = " (" + where + ") and (" + DataTeam.getDataWhereStr(this, "sa_contract", "t1", DataTeam.FilterType.valueOf(1)) + ")";
             } else {
                 //选择操作人参与团队的负责人的名下负责的项目合同(包括经销、直销项目合同)
                 where = " (" + where + ") and (" + getDataWhereStr(this, "sa_contract", "t1") + ")";

+ 1 - 1
src/custom/restcontroller/webmanage/sale/customer/CustomerRelationInfo.java

@@ -106,7 +106,7 @@ public class CustomerRelationInfo extends Controller {
         if (type == 0) {
             sqlFactory.addParameter_SQL("where2", "1=1");
         } else {
-            sqlFactory.addParameter_SQL("where2", DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", type));
+            sqlFactory.addParameter_SQL("where2", DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( type)));
         }
 
 //        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());

+ 2 - 2
src/custom/restcontroller/webmanage/sale/enterprise/enterprise.java

@@ -333,8 +333,8 @@ public class enterprise extends Controller {
         //业务员
         String where2 = "1=1";
         if (!ismanage && usertype == 1) {
-            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", 1)
-                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 3);
+            where2 = DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 1))
+                    + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf( 3));
         }
 //        SQLFactory sqlFactory = new SQLFactory(this, "客户列表", pageSize, pageNumber, pageSorting);
 //        sqlFactory.addParameter_SQL("where", where);

+ 32 - 32
src/custom/restcontroller/webmanage/sale/quotedprice/quotedprice.java

@@ -716,9 +716,9 @@ public class quotedprice extends Controller {
         }
         //System.out.println(sqlFactory.getSQL());
 //        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter",  "sys_site_parameterid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
         querySQL.setTableAlias("t0");
-        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'","*");
+        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'", "*");
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
 
@@ -853,18 +853,18 @@ public class quotedprice extends Controller {
                 where2 = " exists(select sys_datateamid from sys_datateam where siteid='" + siteid + "' and userid in" + userids + " and ownertable='sa_project' and ownerid=t1.sa_projectid)";
                 where2 = where2.replace("[", "(").replace("]", ")");
             } else {
-                where2 = DataTeam.getDataWhereStr(this, tablename, "t1", type, userids, subUserIds);
+                where2 = DataTeam.getDataWhereStr(this, tablename, "t1", userids, subUserIds, DataTeam.FilterType.valueOf(type));
             }
 
         } else {
             if (type == 0) {
-                where2 = DataTeam.getDataWhereStr(this, tablename, "t1", 1)
-                        + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 2)
-                        + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 3)
-                        + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 4)
-                        + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", 5);
+                where2 = DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf(1))
+                        + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf(2))
+                        + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf(3))
+                        + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf(4))
+                        + " or " + DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf(5));
             } else {
-                where2 = DataTeam.getDataWhereStr(this, tablename, "t1", type);
+                where2 = DataTeam.getDataWhereStr(this, tablename, "t1", DataTeam.FilterType.valueOf(type));
             }
         }
 
@@ -872,11 +872,11 @@ public class quotedprice extends Controller {
 
         sqlFactory.addParameter_SQL("where2", where2);
 //        String sql = sqlFactory.getSQL();
-       // System.out.println(sql);
+        // System.out.println(sql);
 //        Rows rows = dbConnect.runSqlQuery(sql);
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter",  "sys_site_parameterid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
         querySQL.setTableAlias("t0");
-        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'","*");
+        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'", "*");
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
         return getSucReturnObject().setData(rows).toString();
@@ -909,9 +909,9 @@ public class quotedprice extends Controller {
         sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
         sqlFactory.addParameter_SQL("where", where);
 //        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter",  "sys_site_parameterid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
         querySQL.setTableAlias("t0");
-        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'","*");
+        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'", "*");
         querySQL.setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
         return getSucReturnObject().setData(rows).toString();
@@ -987,26 +987,26 @@ public class quotedprice extends Controller {
         sqlFactory.addParameter_SQL("where", where);
         String where2 = "";
         if (type == 0) {
-            where2 = DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 1) + " or "
-                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 2) + " or "
-                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 3) + " or "
-                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 4) + " or "
-                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 5);
+            where2 = DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 1)) + " or "
+                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 2)) + " or "
+                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 3)) + " or "
+                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 4)) + " or "
+                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 5));
         } else {
-            where2 = DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", type);
+            where2 = DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( type));
         }
 
         sqlFactory.addParameter_SQL("where2", where2);
 
         sqlFactory.addParameter("siteid", siteid);
 //        Rows rows = dbConnect.runSqlQuery(sqlFactory);
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter",  "sys_site_parameterid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
         querySQL.setTableAlias("t0");
-        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'","*");
+        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'", "*");
         Rows rows;
         if (rowindex > 0) {
             rows = querySQL.query(rowindex);
-        }else{
+        } else {
             querySQL.setPage(pageSize, pageNumber);
             rows = querySQL.query();
         }
@@ -1119,14 +1119,14 @@ public class quotedprice extends Controller {
 
         String where2 = "";
         if (type == 0) {
-            where2 = DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 1) + " or "
-                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 2) + " or "
-                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 3) + " or "
-                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 4) + " or "
-                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", 5);
+            where2 = DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 1)) + " or "
+                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 2)) + " or "
+                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 3)) + " or "
+                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 4)) + " or "
+                    + DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( 5));
             ;
         } else {
-            where2 = DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", type);
+            where2 = DataTeam.getDataWhereStr(this, "sa_quotedprice", "t1", DataTeam.FilterType.valueOf( type));
         }
         sqlFactory.addParameter_SQL("where2", where2);
         sqlFactory.addParameter("siteid", siteid);
@@ -1145,13 +1145,13 @@ public class quotedprice extends Controller {
         sqlFactory.addParameter_SQL("where", where);
 
 //        Rows historyrows = dbConnect.runSqlQuery(sqlFactory);
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter",  "sys_site_parameterid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
         querySQL.setTableAlias("t0");
-        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'","*");
+        querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'", "*");
         Rows historyrows;
         if (rowindex > 0) {
             historyrows = querySQL.query(rowindex);
-        }else{
+        } else {
             querySQL.setPage(pageSize, pageNumber);
             historyrows = querySQL.query();
         }