wu пре 6 месеци
родитељ
комит
ed4f2a5c6e

+ 162 - 378
src/custom/restcontroller/sale/customer/Customer.java

@@ -9,6 +9,7 @@ import beans.hr.Hr;
 import beans.phonebook.PhoneBook;
 import beans.proxy.Proxy;
 import beans.recycle.Recycle;
+import beans.salearea.SaleArea;
 import beans.salesfees.SalesFees;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -51,290 +52,111 @@ public class Customer extends Controller {
             R.ID20220920083901.v1.class})
     public String insertOrUpdate() throws YosException {
         String tablename = "sa_customers";
+        Long sa_customersid = content.getLong("sa_customersid");
+        String type = content.getString("type");
         Long sys_enterpriseid = content.getLong("sys_enterpriseid");
         String enterprisename = content.getString("enterprisename");
-        String telephone = content.getStringValue("telephone");
-        String taxno = content.getStringValue("taxno");
         String address = content.getStringValue("address");
         String province = content.getStringValue("province");
         String city = content.getStringValue("city");
         String county = content.getStringValue("county");
+        Long saler_userid = content.getLongValue("saler_userid");
+        if (userInfo.isSaler()) {
+            saler_userid = userid;
+        }
         ArrayList<String> sqlList = new ArrayList<>();
         //创建企业档案
-        SQLFactory sqlFactory = new SQLFactory(this, "客户企业档案新增");
         if (sys_enterpriseid <= 0) {
             sys_enterpriseid = createTableID("sys_enterprise");
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise");
+            insertSQL.setSiteid(siteid);
+            insertSQL.setUniqueid(sys_enterpriseid);
+            insertSQL.setValue("province", province);
+            insertSQL.setValue("city", city);
+            insertSQL.setValue("county", county);
+            insertSQL.setValue("address", address);
+            insertSQL.setValue("enterprisename", enterprisename);
+            sqlList.add(insertSQL.getSQL());
         } else {
-            sqlFactory = new SQLFactory(this, "客户企业档案更新");
-        }
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("userid", userid);
-        sqlFactory.addParameter("username", username);
-        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-        sqlFactory.addParameter("province", province);
-        sqlFactory.addParameter("city", city);
-        sqlFactory.addParameter("county", county);
-        sqlFactory.addParameter("address", address);
-        sqlFactory.addParameter("enterprisename", enterprisename);
-        sqlFactory.addParameter("abbreviation", content.getStringValue("abbreviation"));
-        sqlFactory.addParameter("taxno", taxno);
-        sqlFactory.addParameter("grade", content.getLongValue("grade") == 0 ? "null" : content.getLongValue("grade"));
-        sqlFactory.addParameter("industry", content.getJSONArray("industry"));
-        sqlFactory.addParameter("contact", content.getStringValue("contact"));
-        sqlFactory.addParameter("phonenumber", telephone);
-        sqlFactory.addParameter("telephone", telephone);
-        sqlList.add(sqlFactory.getSQL());
-
-        Long parentid = content.getLongValue("parentid");
-        long parent_sa_agentsid = 0L;
-        Rows rows = dbConnect.runSqlQuery("SELECT sa_agentsid from sa_agents WHERE sys_enterpriseid in (SELECT sys_enterpriseid from sa_customers  WHERE sa_customersid=" + parentid + ") and siteid='" + siteid + "'");
-        if (rows.isNotEmpty()) {
-            parent_sa_agentsid = rows.get(0).getLong("sa_agentsid");
-            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_agents");
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise");
             updateSQL.setSiteid(siteid);
-            updateSQL.setWhere("sys_enterpriseid", sys_enterpriseid);
-            updateSQL.setValue("parentid", parent_sa_agentsid);
+            updateSQL.setUniqueid(sys_enterpriseid);
+            updateSQL.setValue("province", province);
+            updateSQL.setValue("city", city);
+            updateSQL.setValue("county", county);
+            updateSQL.setValue("address", address);
+            updateSQL.setValue("enterprisename", enterprisename);
             sqlList.add(updateSQL.getSQL());
         }
 
-        //扩展字段
-        String erpagentnum = content.getStringValue("erpagentnum");
-        String sql = "SELECT * from sys_dataextend WHERE ownertable='sys_enterprise' and ownerid=" + sys_enterpriseid + " and siteid = '" + siteid + "'";
-        Rows extendRows = dbConnect.runSqlQuery(sql);
-        Long sys_dataextendid = 0L;
-        if (extendRows.isEmpty()) {
-            sys_dataextendid = createTableID("sys_dataextend");
-            sqlFactory = new SQLFactory(this, "经销商扩展字段新增");
-        } else {
-            sys_dataextendid = extendRows.get(0).getLong("sys_dataextendid");
-            sqlFactory = new SQLFactory(this, "经销商扩展字段更新");
-
-        }
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("username", username);
-        sqlFactory.addParameter("userid", userid);
-        sqlFactory.addParameter("sys_dataextendid", sys_dataextendid);
-        sqlFactory.addParameter("ownerid", sys_enterpriseid);
-        sqlFactory.addParameter("ownertable", "sys_enterprise");
-        sqlFactory.addParameter("erpagentnum", erpagentnum);
-        sqlList.add(sqlFactory.getSQL());
-
-
-        Long sa_customersid = content.getLong("sa_customersid");
-
-        String type = content.getString("type");
-        Long sa_agentsid = content.getLongValue("sa_agentsid");
         boolean isAdd = false;
-        sqlFactory = new SQLFactory(this, "客户新增");
         if (sa_customersid <= 0) {
-            sa_customersid = createTableID(tablename);
-            //数据团队新增
-            sqlList.addAll(DataTeam.createTeamSQL(this, tablename, sa_customersid, userid));
-            sqlList.add(DataTag.createTagSql(this, "sa_customers", sa_customersid, "潜在"));
-            sqlList.addAll(DataTeam.createTeamMemberSql(this, "sa_customers", sa_customersid, userid));
-            //操作记录
-            sqlList.add(DataContrlLog.createLog(this, tablename, sa_customersid, "新增", "客户新增成功").getSQL());
             isAdd = true;
+            Rows stagenameRows = dbConnect.runSqlQuery("SELECT stagename from sa_devstage WHERE siteid='" + siteid + "' order by sequence  LIMIT 1");
+            sa_customersid = createTableID(tablename);
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_customers");
+            insertSQL.setSiteid(siteid);
+            insertSQL.setUniqueid(sa_customersid);
+            insertSQL.setValue("billno", createBillCode("hospital"));
+            insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
+            insertSQL.setValue("name", enterprisename);
+            insertSQL.setValue("type", type);
+            insertSQL.setValue("grade", content.getStringValue("grade"));
+            insertSQL.setValue("host", content.getLongValue("host"));
+            insertSQL.setValue("room", content.getLongValue("room"));
+            insertSQL.setValue("bed", content.getLongValue("bed"));
+            insertSQL.setValue("scale", content.getLongValue("scale"));
+            insertSQL.setValue("sa_saleareaid", content.getLongValue("sa_saleareaid"));
+            insertSQL.setValue("province", province);
+            insertSQL.setValue("city", city);
+            insertSQL.setValue("county", county);
+            insertSQL.setValue("address", address);
+            insertSQL.setValue("stagename", stagenameRows.isNotEmpty() ? stagenameRows.get(0).getString("stagename") : "");
+            sqlList.add(insertSQL.getSQL());
         } else {
-            sqlFactory = new SQLFactory(this, "客户更新");
-            //操作记录
-            sqlList.add(DataContrlLog.createLog(this, tablename, sa_customersid, "更新", "客户更新成功").getSQL());
-        }
-
-        if (siteid.equals("HY")) {
-            sqlFactory.addParameter("reward_point", "[\"订单核销审核\", \"物流单审核\", \"开票审核\"]");
-            sqlFactory.addParameter("reward_rate", 0.00);
-        } else {
-            sqlFactory.addParameter("reward_point", "null");
-            sqlFactory.addParameter("reward_rate", "null");
+            UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_customers");
+            updateSQL.setSiteid(siteid);
+            updateSQL.setUniqueid(sa_customersid);
+            updateSQL.setValue("name", enterprisename);
+            updateSQL.setValue("type", type);
+            updateSQL.setValue("grade", content.getStringValue("grade"));
+            updateSQL.setValue("host", content.getLongValue("host"));
+            updateSQL.setValue("room", content.getLongValue("room"));
+            updateSQL.setValue("bed", content.getLongValue("bed"));
+            updateSQL.setValue("scale", content.getLongValue("scale"));
+            updateSQL.setValue("sa_saleareaid", content.getStringValue("sa_saleareaid"));
+            sqlList.add(updateSQL.getSQL());
         }
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("userid", userid);
-        sqlFactory.addParameter("username", username);
-        sqlFactory.addParameter("sa_customersid", sa_customersid);
-        //上级客户ID
-        sqlFactory.addParameter("parentid", parentid == 0 ? "null" : parentid);
-        //合作企业档案ID
-        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-        //客户类型
-        sqlFactory.addParameter("type", type);
-        //客户池(公海池)ID
-        sqlFactory.addParameter("sa_customerpoolid", 0);
-        //客户来源
-        sqlFactory.addParameter("source", content.getString("source"));
-        sqlFactory.addParameter("customergrade", content.getStringValue("customergrade"));
-        Long ispublic = content.getLongValue("ispublic", 1L);
-        sqlFactory.addParameter("ispublic", ispublic);
-
-        sqlFactory.addParameter("sa_agentsid", sa_agentsid);
-        sqlFactory.addParameter("name", enterprisename);
-        sqlFactory.addParameter("province", province);
-        sqlFactory.addParameter("city", city);
-        sqlFactory.addParameter("county", county);
-        sqlFactory.addParameter("address", address);
-        sqlFactory.addParameter("phonenumber", telephone);
 
-        sqlList.add(sqlFactory.getSQL());
-
-        //操作记录
         if (isAdd) {
-            if (ispublic == 1) {
-                sqlList.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "新建", "新建公海客户" + enterprisename).getSQL());
-            } else {
-                sqlList.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "新建", "新建客户" + enterprisename).getSQL());
-            }
+            //标签
+            sqlList.add(DataTag.createTagSql(this, "sa_customers", sa_customersid, type));
+            //数据团队新增
+            sqlList.addAll(DataTeam.createTeamSQL(this, tablename, sa_customersid, saler_userid));
+            sqlList.add(DataContrlLog.createLog(this, tablename, sa_customersid, "新建", "新建医院成功").getSQL());
+            //标记数据来源
             DataExtend.markDataFrom(this, "sa_customers", sa_customersid);
+        } else {
+            sqlList.add(DataContrlLog.createLog(this, tablename, sa_customersid, "编辑", "编辑医院成功").getSQL());
         }
 
-        Long sjssys_phonebookid = 0L;
-        if (type.equals("设计师")) {
-            if (dbConnect.runSqlQuery("select 1 from sys_enterprise_contacts where siteid='" + siteid + "' and name='" + enterprisename + "' and deleted=0 and workaddress=0 and sys_enterpriseid=" + sys_enterpriseid).isEmpty()) {
-                sjssys_phonebookid = createTableID("sys_phonebook");
-                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_phonebook");
-                insertSQL.setSiteid(siteid);
-                insertSQL.setValue("sys_phonebookid", sjssys_phonebookid);
-                insertSQL.setValue("createuserid", userid);
-                insertSQL.setValue("createby", username);
-                insertSQL.setDateValue("createdate");
-                insertSQL.setValue("changeuserid", userid);
-                insertSQL.setValue("changeby", username);
-                insertSQL.setDateValue("changedate");
-                insertSQL.setValue("userid", userid);
-                insertSQL.setValue("sys_phonebookgroupid", "0");
-                insertSQL.setValue("name", enterprisename);
-                sqlList.add(insertSQL.getSQL());
-                sqlList.add(DataContrlLog.createLog(this, "sys_phonebook", sjssys_phonebookid, "通讯录新增", "通讯录新增:" + enterprisename).getSQL());
-                sqlList.addAll(DataTeam.createTeamSQL(this, "sys_phonebook", sjssys_phonebookid, userid));
-                Long contactsid = createTableID("sys_enterprise_contacts");
-                insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_contacts");
-                insertSQL.setSiteid(siteid);
-                insertSQL.setValue("contactsid", contactsid);
-                insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
-                insertSQL.setValue("sys_phonebookid", sjssys_phonebookid);
-                insertSQL.setValue("createuserid", userid);
-                insertSQL.setValue("createby", username);
-                insertSQL.setDateValue("createdate");
-                insertSQL.setValue("changeuserid", userid);
-                insertSQL.setValue("changeby", username);
-                insertSQL.setDateValue("changedate");
-                insertSQL.setValue("workaddress", 0);
-                sqlList.add(insertSQL.getSQL());
-                sqlList.add(DataContrlLog.createLog(this, "sys_enterprise_contacts", contactsid, "新建联系人", "新建联系人" + enterprisename).getSQL());
-                sqlList.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "新建联系人", "新建联系人" + enterprisename).getSQL());
-            }
-        }
-
-        Long mrsys_phonebookid = 0L;
         //新增时插入财务信息和联系人信息
         if (isAdd) {
-
-            //添加财务信息
-            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_finance");
-            Long sys_enterprise_financeid = createTableID("sys_enterprise_finance");
-            insertSQL.setSiteid(siteid);
-            insertSQL.setValue("sys_enterprise_financeid", sys_enterprise_financeid);
-            insertSQL.setValue("changeuserid", userid);
-            insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
-            insertSQL.setValue("enterprisename", enterprisename);
-            insertSQL.setValue("phonenumber", telephone);
-            insertSQL.setValue("taxno", taxno);
-            insertSQL.setValue("address", address);
-            insertSQL.setValue("isdefault", 1);
-            sqlList.add(insertSQL.getSQL());
-            sqlList.add(DataContrlLog.createLog(this, "sys_enterprise_finance", sys_enterprise_financeid, "新建开票信息", "新建开票信息" + enterprisename).getSQL());
-
             //添加地址
             Long contactsid = createTableID("sys_enterprise_contacts");
-            insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_contacts");
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_contacts");
             insertSQL.setSiteid(siteid);
             insertSQL.setValue("contactsid", contactsid);
             insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
-            insertSQL.setValue("createuserid", userid);
-            insertSQL.setValue("createby", username);
-            insertSQL.setDateValue("createdate");
-            insertSQL.setValue("changeuserid", userid);
-            insertSQL.setValue("changeby", username);
-            insertSQL.setValue("phonenumber", telephone);
             insertSQL.setValue("province", province);
             insertSQL.setValue("city", city);
             insertSQL.setValue("county", county);
             insertSQL.setValue("address", address);
-            insertSQL.setValue("name", content.getStringValue("contact"));
-            insertSQL.setDateValue("changedate");
             insertSQL.setValue("workaddress", 1);
             insertSQL.setValue("isdefault", 1);
             insertSQL.setValue("isprimary", 1);
             sqlList.add(insertSQL.getSQL());
 
-            JSONObject contactsinfo = content.getJSONObject("contactsinfo");
-
-            mrsys_phonebookid = contactsinfo.getLong("sys_phonebookid");
-            String phonenumber = contactsinfo.getStringValue("phonenumber");
-            String name = contactsinfo.getStringValue("name");
-
-            if (mrsys_phonebookid <= 0 || dbConnect.runSqlQuery("select 1 from sys_phonebook where siteid='" + siteid + "' and sys_phonebookid=" + mrsys_phonebookid).isEmpty()) {
-                if (PhoneBook.verifyphonenumber(this, phonenumber, userid, mrsys_phonebookid)) {
-                    return getReturnObject().setCode("0056", new String[0]).toString(); //当前联系方式已存在
-                }
-                mrsys_phonebookid = createTableID("sys_phonebook");
-                insertSQL = SQLFactory.createInsertSQL(this, "sys_phonebook");
-                insertSQL.setSiteid(siteid);
-                insertSQL.setValue("sys_phonebookid", mrsys_phonebookid);
-                insertSQL.setValue("createuserid", userid);
-                insertSQL.setValue("createby", username);
-                insertSQL.setDateValue("createdate");
-                insertSQL.setValue("changeuserid", userid);
-                insertSQL.setValue("changeby", username);
-                insertSQL.setDateValue("changedate");
-                insertSQL.setValue("userid", userid);
-                insertSQL.setValue("sys_phonebookgroupid", "0");
-                insertSQL.setValue("name", name);
-                insertSQL.setValue("phonenumber", phonenumber);
-                sqlList.add(insertSQL.getSQL());
-                sqlList.addAll(DataTeam.createTeamSQL(this, "sys_phonebook", mrsys_phonebookid, userid));
-                sqlList.add(DataContrlLog.createLog(this, "sys_phonebook", mrsys_phonebookid, "通讯录新增", "通讯录新增:" + name).getSQL());
-            } else {
-                Rows leaderWithoutHeadpic = DataTeam.getLeaderWithoutHeadpic(this, "sys_phonebook", mrsys_phonebookid);
-                Long leaderuserid = 0L;
-                if (leaderWithoutHeadpic.isNotEmpty()) {
-                    leaderuserid = leaderWithoutHeadpic.get(0).getLong("userid");
-                }
-                if (PhoneBook.verifyphonenumber(this, phonenumber, leaderuserid, mrsys_phonebookid)) {
-                    return getReturnObject().setCode("0056", new String[0]).toString(); //当前联系方式已存在
-                }
-                UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_phonebook");
-                updateSQL.setSiteid(siteid);
-                updateSQL.setWhere("sys_phonebookid", mrsys_phonebookid);
-                updateSQL.setValue("changeuserid", userid);
-                updateSQL.setValue("changeby", username);
-                updateSQL.setDateValue("changedate");
-                updateSQL.setValue("name", name);
-                updateSQL.setValue("phonenumber", phonenumber);
-                sqlList.add(updateSQL.getSQL());
-                sqlList.add(DataContrlLog.createLog(this, "sys_phonebook", mrsys_phonebookid, "通讯录编辑", "通讯录编辑:" + name).getSQL());
-            }
-
-            contactsid = createTableID("sys_enterprise_contacts");
-            //添加联系人
-            InsertSQL contactsinsert = SQLFactory.createInsertSQL(this, "sys_enterprise_contacts");
-
-            contactsinsert.setValue("sys_enterpriseid", sys_enterpriseid);
-            contactsinsert.setValue("sys_phonebookid", mrsys_phonebookid);
-            contactsinsert.setValue("workaddress", 0);
-            contactsinsert.setValue("createuserid", userid);
-            contactsinsert.setValue("createby", username);
-            contactsinsert.setDateValue("createdate");
-            contactsinsert.setValue("changeuserid", userid);
-            contactsinsert.setValue("changeby", username);
-            contactsinsert.setDateValue("changedate");
-            contactsinsert.setValue("isdefault", 0);
-            contactsinsert.setValue("isprimary", 0);
-            contactsinsert.setValue("iscreate", 1);
-            contactsinsert.setValue("contactsid", contactsid);
-            contactsinsert.setSiteid(siteid);
-            sqlList.add(contactsinsert.getSQL());
-            sqlList.add(DataContrlLog.createLog(this, "sys_enterprise_contacts", contactsid, "新建联系人", "新建联系人" + name).getSQL());
-
         }
         content.put("sa_customersid", sa_customersid);
         String time = userInfo.getDateTime_Str();
@@ -356,11 +178,6 @@ public class Customer extends Controller {
 
         //客户查重
         if (isAdd) {
-            for (Row row : teamRows) {
-                DataTeam.createTeam(this, "sys_phonebook", sjssys_phonebookid, row.getLong("userid"));
-                DataTeam.createTeam(this, "sys_phonebook", mrsys_phonebookid, row.getLong("userid"));
-            }
-
             ArrayList<Long> repeatIds = getRepeatCustomers(this, sa_customersid);
             repeatIds.add(120L);
             for (Object obj : repeatIds) {
@@ -372,17 +189,12 @@ public class Customer extends Controller {
 
             Executor.sendEml_controller(this, "customers_add_my", sa_customersid, extradata);
         } else {
-            if (ispublic == 1) {
-                DataContrlLog.createLog(this, "sa_customers", sa_customersid, "编辑", "编辑公海客户" + enterprisename).insert();
+            String changedValue = getChangedValue(sa_customersid, time);
+            if (StringUtils.isEmpty(changedValue)) {
+                DataContrlLog.createLog(this, "sa_customers", sa_customersid, "编辑", "编辑医院" + enterprisename + "(" + sa_customersid + "),无字段值更新").insert();
             } else {
-                String changedValue=getChangedValue(sa_customersid, time);
-                if(StringUtils.isEmpty(changedValue)){
-                    DataContrlLog.createLog(this, "sa_customers", sa_customersid, "编辑", "编辑客户" + enterprisename+"("+sa_customersid+"),无字段值更新").insert();
-                }else {
-                    DataContrlLog.createLog(this, "sa_customers", sa_customersid, "编辑", "编辑客户" + enterprisename+"("+sa_customersid+");"+changedValue).insert();
-                    Executor.sendEml_controller(this, "customers_update_my", sa_customersid, extradata);
-                }
-
+                DataContrlLog.createLog(this, "sa_customers", sa_customersid, "编辑", "编辑医院" + enterprisename + "(" + sa_customersid + ");" + changedValue).insert();
+                Executor.sendEml_controller(this, "customers_update_my", sa_customersid, extradata);
             }
         }
 
@@ -634,33 +446,51 @@ public class Customer extends Controller {
         sqlFactory.addParameter("sa_customersid", sa_customersid);
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL(false));
 
-        RowsMap leaderRows = DataTeam.getLeader(this, "sa_customers", rows.toArrayList("sa_customersid")).toRowsMap("ownerid");
-        if (rows.isNotEmpty()) {
-            QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_phonebook", "*");
-            querySQL.setTableAlias("t1");
-            querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise_contacts", "t2", "t1.siteid=t2.siteid and t1.sys_phonebookid=t2.sys_phonebookid", "contactsid");
-            querySQL.setWhere("t2.iscreate", 1);
-            querySQL.setWhere("t2.deleted", 0);
-            querySQL.setWhere("t2.workaddress", 0);
-            querySQL.setWhere("t2.sys_enterpriseid", rows.get(0).getLong("sys_enterpriseid"));
-            Rows contacts = querySQL.query();
-            rows.get(0).put("contactsinfo", contacts);
-        }
+        ArrayList<Long> ids = rows.toArrayList("sa_customersid", new ArrayList<>());
 
+        RowsMap leaderRows = DataTeam.getLeader(this, "sa_customers", rows.toArrayList("sa_customersid")).toRowsMap("ownerid");
+        //标签
+        HashMap<Long, ArrayList<String>> tagList = DataTag.queryTag(this, "sa_customers", ids, false);
+        //系统标签
+        HashMap<Long, ArrayList<String>> sysTagList = DataTag.queryTag(this, "sa_customers", ids, true);
         for (Row row : rows) {
+            Long id = row.getLong("sa_customersid");
             row.put("leader", leaderRows.get(row.getString("sa_customersid")));
-            BigDecimal salesfeesamount = SalesFees.getsalefeesamount(this, "sa_customers", sa_customersid);
-            row.put("salesfeesamount", salesfeesamount);
+            if (leaderRows.get(String.valueOf(id)).isNotEmpty()) {
+                row.put("depname", leaderRows.get(String.valueOf(id)).get(0).getString("depname"));
+            }
+            ArrayList<String> tag = tagList.get(id) != null ? tagList.get(id) : new ArrayList<String>();
+            ArrayList<String> sys_tag = sysTagList.get(id) != null ? sysTagList.get(id) : new ArrayList<String>();
+            if (row.getString("agentsstatus").equals("禁用") || row.getString("agentsstatus").equals("作废")) {
+                tag.removeAll(row.getJSONArray("agentstag").toJavaList(String.class));
+                sys_tag.removeAll(row.getJSONArray("agentstag").toJavaList(String.class));
+            }
+            //非系统标签
+            row.put("tag", tag);
+            //系统标签
+            row.put("tag_sys", sys_tag);
+            //预估手术总量
+            row.putIfAbsent("totalop", 0);
+            //关键人
+            row.putIfAbsent("keyperson", "");
+            //签约经销商
+            row.putIfAbsent("signagent", "");
         }
 
+        Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
+        Long sys_enterpriseid = rows.isNotEmpty() ? row.getLong("sys_enterpriseid") : 0;
+        Rows addressRows = dbConnect.runSqlQuery("SELECT * from  sys_enterprise_contacts WHERE isdefault=1 and workaddress=1 and deleted=0 and sys_enterpriseid=" + sys_enterpriseid + " and siteid='" + siteid + "'");
+        row.put("province", addressRows.isNotEmpty() ? addressRows.get(0).getString("province") : new Row());
+        row.put("city", addressRows.isNotEmpty() ? addressRows.get(0).getString("city") : new Row());
+        row.put("county", addressRows.isNotEmpty() ? addressRows.get(0).getString("county") : new Row());
+        row.put("address", addressRows.isNotEmpty() ? addressRows.get(0).getString("address") : new Row());
+
 
-        return getSucReturnObject().setData(rows.isNotEmpty() ? rows.get(0) : new Row()).toString();
+        return getSucReturnObject().setData(row).toString();
     }
 
-    @API(title = "我的客户列表", apiversion = R.ID20221012164402.v1.class)
-    @CACHEING
+    @API(title = "医院列表", apiversion = R.ID20221012164402.v1.class)
     public String selectList() throws YosException, IOException {
-        Long isend = content.getLongValue("isend");
         //  1:我负责的;2:我参与的;3:我下属负责的;4:我下属参与的
         int type = content.getIntValue("type");
         Long deleted = content.getLongValue("deleted");
@@ -669,87 +499,56 @@ public class Customer extends Controller {
         StringBuffer where = new StringBuffer(" 1=1 ");
         if (content.containsKey("where")) {
             JSONObject whereObject = content.getJSONObject("where");
-            if (isend == 0) {
-                if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
-                    where.append(" and(");
-//                    where.append("t1.createby like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("t1.sa_customersid like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t1.type like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t1.tradingstatus like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t1.datastatus like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t2.poolname like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t3.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t3.abbreviation like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t3.industry like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t3.grade like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t6.name like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append(")");
-                }
-            } else {
-                if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
-                    where.append(" and(");
-                    where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t1.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append("or t3.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
-                    where.append(")");
-                }
+
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.billno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.province like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.city like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.county like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t1.address like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.abbreviation like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t6.name like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t8.depname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
             }
+
             if (whereObject.containsKey("startdate") && !"".equals(whereObject.getString("startdate"))) {
                 where.append(" and(");
-                where.append("date_format(t1.createdate,'%Y-%m-%d') >='").append(whereObject.getString("startdate")).append("' ");
+                where.append("t1.createdate >='").append(whereObject.getString("startdate")).append(" 00:00:00' ");
                 where.append(")");
             }
             if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
                 where.append(" and(");
-                where.append("date_format(t1.createdate,'%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
+                where.append("t1.createdate <='").append(whereObject.getString("enddate")).append(" 23:59:59' ");
                 where.append(")");
             }
-            //客户状态
+            //开发状态
             if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
                 where.append(" and(");
                 where.append("t1.status ='").append(whereObject.getString("status")).append("' ");
                 where.append(")");
             }
-            //客户类型
+            //医院类型
             if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
                 where.append(" and(");
                 where.append("t1.type ='").append(whereObject.getString("type")).append("' ");
                 where.append(")");
             }
-            //行业
-            if (whereObject.containsKey("industry") && !"".equals(whereObject.getString("industry"))) {
-                where.append(" and(");
-                where.append("t3.industry like'%").append(whereObject.getString("industry")).append("%' ");
-                where.append(")");
-            }
-            //客户等级
-            if (whereObject.containsKey("customergrade") && !"".equals(whereObject.getString("customergrade"))) {
-                where.append(" and(");
-                where.append("t1.customergrade ='").append(whereObject.getString("customergrade")).append("' ");
-                where.append(")");
-            }
+            //医院等级
             if (whereObject.containsKey("grade") && !"".equals(whereObject.getString("grade"))) {
                 where.append(" and(");
-                where.append("t3.grade ='").append(whereObject.getString("grade")).append("' ");
+                where.append("t1.grade ='").append(whereObject.getString("grade")).append("' ");
                 where.append(")");
             }
+            //成交状态
             if (whereObject.containsKey("tradingstatus") && !"".equals(whereObject.getString("tradingstatus"))) {
                 where.append(" and(");
                 where.append("t1.tradingstatus ='").append(whereObject.getString("tradingstatus")).append("' ");
                 where.append(")");
             }
-            if (whereObject.containsKey("sa_customerpoolid") && !"".equals(whereObject.getString("sa_customerpoolid"))) {
-                where.append(" and(");
-                where.append("t1.sa_customerpoolid_source ='").append(whereObject.getString("sa_customerpoolid")).append("' ");
-                where.append(")");
-            }
-
-            if (whereObject.containsKey("sa_projectid") && !"".equals(whereObject.getString("sa_projectid"))) {
-                where.append(" and(");
-                where.append("exists(select *from sa_project_parties where t1.siteid=sa_project_parties.siteid and t1.sys_enterpriseid=sa_project_parties.sys_enterpriseid and sa_project_parties.sa_projectid='").append(whereObject.getString("sa_projectid")).append("' )");
-                where.append(")");
-            }
-
+            //标签
             if (whereObject.containsKey("tag") && !whereObject.getJSONArray("tag").isEmpty()) {
                 for (Object o : whereObject.getJSONArray("tag")) {
                     where.append(" and exists(select 1 from sys_datatag WHERE ownertable = 'sa_customers' and siteid='").append(siteid).append("' ");
@@ -757,41 +556,33 @@ public class Customer extends Controller {
                     where.append(")");
                 }
             }
-
-            if (whereObject.containsKey("departmentid") && !"".equals(whereObject.getString("departmentid"))) {
-                String departmentid = whereObject.getString("departmentid");
-                HashSet<Long> userIds = new HashSet<>(Hr.getSubUserIds(this, 1L, Long.parseLong(departmentid)));
+            //开发阶段
+            if (whereObject.containsKey("stagename") && !"".equals(whereObject.getString("stagename"))) {
+                where.append(" and(");
+                where.append("t1.stagename ='").append(whereObject.getString("stagename")).append("' ");
+                where.append(")");
+            }
+            //营销区域
+
+            if (whereObject.containsKey("sa_saleareaid") && !"".equals(whereObject.getString("sa_saleareaid"))) {
+                Long sa_saleareaid = whereObject.getLong("sa_saleareaid");
+                ArrayList<Long> sa_saleareaids = SaleArea.getSubSaleAreaIds(this, sa_saleareaid);
+                sa_saleareaids.add(-1L);
+                Rows rows = dbConnect.runSqlQuery("SELECT DISTINCT t2.userid from sa_salearea_hr t1 " +
+                        "inner join sys_hr t2 ON t2.hrid=t1.hrid and t2.siteid=t1.siteid " +
+                        "WHERE  t1.siteid='" + siteid + "' and t1.sa_saleareaid in(" + StringUtils.join(sa_saleareaids, ",") + ") and t2.userid>0");
+                HashSet<Long> userIds = new HashSet<>(rows.toArrayList("userid", new ArrayList<>()));
+                userIds.add(-1L);
                 where.append(" and(");
                 where.append(" t6.userid in ").append(userIds.toString().replace("[", "(").replace("]", ")"));
                 where.append(")");
             }
-
-//            where.append(getTableFilter("t3", "enterprisename", true));
-//            where.append(getTableFilter("t1", "sa_customersid", true));
-//            where.append(getTableFilter("t1", "type", false));
-//            where.append(getTableFilter("t1", "customergrade", false));
-//            where.append(getTableFilter("t3", "industry", true));
-//            where.append(getTableFilter("t4", "enterprisename", "superiorenterprisename", true));
-//            where.append(getTableFilter("t1", "tradingstatus", false));
-//            where.append(getTableFilter("t3", "contact", true));
-//            where.append(getTableFilter("t1", "status", false));
-//            where.append(getTableFilter("t1", "source", true));
-//            where.append(getTableFilter("t8", "poolname", "sourcepoolname", true));
         }
-        where.append(" and(");
         if (deleted == 1) {
-            where.append("t1.datastatus =1");
-        } else {
-            where.append("t1.datastatus in (0,2)");
-        }
-        where.append(")");
-        where.append(" and(");
-        if (isend == 1) {
-            where.append(" t1.sys_enterpriseid=0");
+            where.append(" and ( t1.datastatus =1 )");
         } else {
-            where.append("t1.sys_enterpriseid >0");
+            where.append(" and ( t1.datastatus in (0,2) )");
         }
-        where.append(")");
 
         String where2 = " 1=1 ";
         if (deleted == 0) {
@@ -806,13 +597,11 @@ public class Customer extends Controller {
         }
 
         boolean isExport = content.getBoolean("isExport");
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_customers", "sa_customersid", "createby", "createdate", "parentid",
-                "sys_enterpriseid", "status", "type", "sa_customerpoolid", "source", "tradingstatus", "datastatus", "customergrade", "ispublic", "sa_customerpoolid_source");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_customers", "sa_customersid", "createby", "createdate",
+                "sys_enterpriseid", "status", "type", "tradingstatus", "datastatus", "billno", "province", "city", "county", "address", "stagename", "grade");
         querySQL.setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_customerpool", "t2", "t2.sa_customerpoolid = t1.sa_customerpoolid AND t2.siteid = t1.siteid", "poolname", "freeget");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t3", "t3.sys_enterpriseid = t1.sys_enterpriseid AND t3.siteid = t1.siteid", "enterprisename", "abbreviation", "industry", "grade", "province", "city", "county", "address", "taxno", "phonenumber", "contact");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t7", "t1.parentid = t7.sa_customersid AND t7.siteid = t1.siteid");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t4", "t4.sys_enterpriseid = t7.sys_enterpriseid and t7.siteid = t4.siteid");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t2.sys_enterpriseid = t1.sys_enterpriseid AND t2.siteid = t1.siteid", "enterprisename");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_salearea", "t3", "t3.sa_saleareaid = t1.sa_saleareaid AND t3.siteid = t1.siteid", "areaname");
 
         QuerySQL t5 = SQLFactory.createQuerySQL(this, "sys_datafollowup", "ownerid");
         t5.setWhere("ownertable", "sa_customers");
@@ -822,18 +611,9 @@ public class Customer extends Controller {
         t5.setRoleDataLimit(false);
         querySQL.addJoinTable(JOINTYPE.left, t5, "t5", "t5.ownerid = t1.sa_customersid", "followdate");
         querySQL.addJoinTable(JOINTYPE.left, "sys_datateam", "t6", "t6.ownerid = t1.sa_customersid and t6.siteid = t1.siteid and t6.ownertable = 'sa_customers' and t6.isleader = 1");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_customerpool", "t8", "t8.sa_customerpoolid = t1.sa_customerpoolid_source AND t8.siteid = t1.siteid");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t9", "t1.siteid = t9.siteid and t1.sys_enterpriseid = t9.sys_enterpriseid");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t10", "t1.siteid = t10.siteid and t1.sa_customersid = t10.ownerid and t10.ownertable = 'sa_customers'", "deletereason");
-
-        querySQL.addQueryFields("superiorenterprisename", "t4.enterprisename");
-        querySQL.addQueryFields("sourcepoolname", "t8.poolname");
-        querySQL.addQueryFields("agentstag", "t9.type");
-        querySQL.addQueryFields("agentsstatus", "t9.status");
-        querySQL.addQueryFields("deletechangedate", "t10.changedate");
-        querySQL.addQueryFields("deletechangeby", "t10.changeby");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_hr", "t7", "t7.userid = t6.userid and t7.siteid = t6.siteid ");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t8", "t8.departmentid = t7.departmentid and t8.siteid = t7.siteid ");
         querySQL.setSiteid(siteid);
-        querySQL.setWhere("sa_customerpoolid", "0");
         querySQL.setWhere(where);
         querySQL.setWhere(where2);
         if (isExport) {
@@ -869,14 +649,18 @@ public class Customer extends Controller {
             row.put("tag", tag);
             //系统标签
             row.put("tag_sys", sys_tag);
-            if (!row.containsKey("industry") || row.getString("industry").equals("")) {
-                row.put("industry", new Rows());
-            }
+            row.putIfAbsent("followdate", "");
+            //预估手术总量
+            row.putIfAbsent("totalop", 0);
+            //关键人
+            row.putIfAbsent("keyperson", "");
+            //签约经销商
+            row.putIfAbsent("signagent", "");
         }
         if (isExport) {
-            ExcelFactory excelFactory = new ExcelFactory("客户导出");
+            ExcelFactory excelFactory = new ExcelFactory("医院管理导出");
 
-            XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("客户导出");
+            XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("医院管理");
             XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
             ExportExcel.setBatchDetailSheetColumn(sheet);// 设置工作薄列宽
             XSSFCellStyle titleCellStyle1 = ExportExcel.createTitleCellStyle(xssfFWorkbook);

+ 65 - 53
src/custom/restcontroller/sale/customer/ExportExcel.java

@@ -60,19 +60,22 @@ public class ExportExcel {
      **/
     public static void setBatchDetailSheetColumn(XSSFSheet sheet) {
         sheet.setDefaultRowHeight((short) 600);
-        sheet.setColumnWidth((short) 0, (short) 5500);
-        sheet.setColumnWidth((short) 1, (short) 5500);
-        sheet.setColumnWidth((short) 2, (short) 5500);
-        sheet.setColumnWidth((short) 3, (short) 5500);
-        sheet.setColumnWidth((short) 4, (short) 5500);
-        sheet.setColumnWidth((short) 5, (short) 5500);
-        sheet.setColumnWidth((short) 6, (short) 5500);
-        sheet.setColumnWidth((short) 7, (short) 5500);
-        sheet.setColumnWidth((short) 8, (short) 5500);
-        sheet.setColumnWidth((short) 9, (short) 5500);
-        sheet.setColumnWidth((short) 10, (short) 5500);
-        sheet.setColumnWidth((short) 11, (short) 5500);
-        sheet.setColumnWidth((short) 12, (short) 5500);
+        sheet.setColumnWidth((short) 0, (short) 6000);
+        sheet.setColumnWidth((short) 1, (short) 8000);
+        sheet.setColumnWidth((short) 2, (short) 6000);
+        sheet.setColumnWidth((short) 3, (short) 6000);
+        sheet.setColumnWidth((short) 4, (short) 6000);
+        sheet.setColumnWidth((short) 5, (short) 8000);
+        sheet.setColumnWidth((short) 6, (short) 6000);
+        sheet.setColumnWidth((short) 7, (short) 6000);
+        sheet.setColumnWidth((short) 8, (short) 6000);
+        sheet.setColumnWidth((short) 9, (short) 6000);
+        sheet.setColumnWidth((short) 10, (short) 6000);
+        sheet.setColumnWidth((short) 11, (short) 6000);
+        sheet.setColumnWidth((short) 12, (short) 6000);
+        sheet.setColumnWidth((short) 13, (short) 6000);
+        sheet.setColumnWidth((short) 14, (short) 6000);
+        sheet.setColumnWidth((short) 15, (short) 6000);
     }
 
     /**
@@ -104,59 +107,67 @@ public class ExportExcel {
         row = sheet.createRow(0);
         cell = row.createCell(0);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("标签");
+        cell.setCellValue("编号");
 
         cell = row.createCell(1);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("客户名称");
+        cell.setCellValue("医院名称");
 
         cell = row.createCell(2);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("客户等级");
+        cell.setCellValue("标签");
 
         cell = row.createCell(3);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("客户类型");
+        cell.setCellValue("医院等级");
 
         cell = row.createCell(4);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("客户分类");
+        cell.setCellValue("医院类型");
 
         cell = row.createCell(5);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("所属行业");
+        cell.setCellValue("省市县(区)");
 
         cell = row.createCell(6);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("上级企业");
+        cell.setCellValue("预估手术总量(把/年)");
 
         cell = row.createCell(7);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("负责人");
+        cell.setCellValue("关键人");
 
         cell = row.createCell(8);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("部门");
+        cell.setCellValue("开发状态");
 
         cell = row.createCell(9);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("合作状态");
+        cell.setCellValue("成交状态");
 
         cell = row.createCell(10);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("成交状态");
+        cell.setCellValue("负责人");
 
         cell = row.createCell(11);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("来源");
+        cell.setCellValue("所属部门");
 
         cell = row.createCell(12);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("最近跟进时间");
+        cell.setCellValue("营销区域");
 
         cell = row.createCell(13);// ID
         cell.setCellStyle(cellStyle1);
-        cell.setCellValue("来源公海");
+        cell.setCellValue("开发阶段");
+
+        cell = row.createCell(14);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("签约经销商");
+
+        cell = row.createCell(15);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("最近跟进时间");
 
         int rowNum = 1;
         /*第二行*/
@@ -164,6 +175,14 @@ public class ExportExcel {
             row = sheet.createRow(rowNum);
             cell = row.createCell(0);// ID
             cell.setCellStyle(cellStyle2);
+            cell.setCellValue(row1.containsKey("billno") ? row1.getString("billno") : "");
+
+            cell = row.createCell(1);// ID
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue(row1.containsKey("enterprisename") ? row1.getString("enterprisename") : "");
+
+            cell = row.createCell(2);// ID
+            cell.setCellStyle(cellStyle2);
             StringBuilder tag = new StringBuilder();
             for (Object o : (ArrayList) row1.get("tag")) {
                 tag.append(o).append("/");
@@ -176,64 +195,57 @@ public class ExportExcel {
             }
             cell.setCellValue(tag.toString());
 
-            cell = row.createCell(1);// ID
-            cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("enterprisename") ? row1.getString("enterprisename") : "");
-
-            cell = row.createCell(2);// ID
-            cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("grade") ? row1.getString("grade") : "");
-
             cell = row.createCell(3);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("type") ? row1.getString("type") : "");
+            cell.setCellValue(row1.containsKey("grade") ? row1.getString("grade") : "");
 
             cell = row.createCell(4);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("customergrade") ? row1.getString("customergrade") : "");
+            cell.setCellValue(row1.containsKey("type") ? row1.getString("type") : "");
 
             cell = row.createCell(5);// ID
             cell.setCellStyle(cellStyle2);
-            StringBuilder industry= new StringBuilder();
-            for(Object o : row1.getJSONArray("industry")){
-                industry.append(o).append("/");
-            }
-            if(industry.length()>0){
-                industry.deleteCharAt(industry.length()-1);
-            }
-            cell.setCellValue(industry.toString());
+            cell.setCellValue(row1.getString("province")+row1.getString("city")+row1.getString("county"));
 
             cell = row.createCell(6);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("superiorenterprisename") ? row1.getString("superiorenterprisename") : "");
+            cell.setCellValue(row1.containsKey("totalop") ? row1.getString("totalop") : "");
 
             cell = row.createCell(7);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("name") ? row1.getString("name") : "");
+            cell.setCellValue(row1.containsKey("keyperson") ? row1.getString("keyperson") : "");
 
             cell = row.createCell(8);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("depname") ? row1.getString("depname") : "");
+            cell.setCellValue(row1.containsKey("status") ? row1.getString("status") : "");
 
             cell = row.createCell(9);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("status") ? row1.getString("status") : "");
+            cell.setCellValue(row1.containsKey("tradingstatus") ? row1.getString("tradingstatus") : "");
 
             cell = row.createCell(10);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("tradingstatus") ? row1.getString("tradingstatus") : "");
+            cell.setCellValue(row1.containsKey("name") ? row1.getString("name") : "");
 
             cell = row.createCell(11);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("source") ? row1.getString("source") : "");
+            cell.setCellValue(row1.containsKey("depname") ? row1.getString("depname") : "");
 
             cell = row.createCell(12);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("followdate") ? row1.getString("followdate") : "");
+            cell.setCellValue(row1.containsKey("areaname") ? row1.getString("areaname") : "");
 
             cell = row.createCell(13);// ID
             cell.setCellStyle(cellStyle2);
-            cell.setCellValue(row1.containsKey("sourcepoolname") ? row1.getString("sourcepoolname") : "");
+            cell.setCellValue(row1.containsKey("stagename") ? row1.getString("stagename") : "");
+
+            cell = row.createCell(14);// ID
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue(row1.containsKey("signagent") ? row1.getString("signagent") : "");
+
+            cell = row.createCell(15);// ID
+            cell.setCellStyle(cellStyle2);
+            cell.setCellValue(row1.containsKey("followdate") ? row1.getString("followdate") : "");
 
             rowNum++;
         }

+ 11 - 74
src/custom/restcontroller/sale/customer/SQL/客户详情.sql

@@ -1,78 +1,15 @@
-SELECT t1.sa_customersid,
-       t1.createby,
-       t1.createdate,
-       t1.parentid,
-       t1.sys_enterpriseid,
-       t1.`status`,
-       t1.type,
-       t1.sa_customerpoolid,
-       t1.source,
-       t1.tradingstatus,
-       t1.datastatus,
-       t1.customergrade,
-       t1.ispublic,
-       t1.sa_customerpoolid_source,
-       t1.sa_agentsid,
-       t1.changeby,
-       t1.changedate,
-       t2.poolname,
-       t2.freeget,
-       t3.enterprisename,
-       t3.abbreviation,
-       t3.industry,
-       t3.grade,
-       t3.province,
-       t3.city,
-       t3.county,
-       t3.address,
-       t3.taxno,
-       t3.phonenumber,
-       t3.contact,
-       t3.telephone,
-       t4.enterprisename                    superiorenterprisename,
-       ifnull(t7.followdate, '')            followdate,
-       t8.poolname                          sourcepoolname,
-       (SELECT count(0)
-        FROM sa_order
-        WHERE sys_enterpriseid = t1.sys_enterpriseid
-          and type != '工具借用单'
-          and `status` in ('审核', '关闭')) contact_signnum,
-       t5.enterprisename                    agentname,
-       t9.erpagentnum,
-       t10.sa_agentsid                      isagent,
-       t10.status                           agentstatus,
-       t1.reward_rate,
-       t1.reward_point
+SELECT t1.*,
+       t2.enterprisename,
+       ifnull(t3.followdate, '')            followdate,
+       t4.areaname,
+       t5.deletereason
 FROM sa_customers t1
-         LEFT JOIN sa_customerpool t2 ON t2.sa_customerpoolid = t1.sa_customerpoolid AND t2.siteid = t1.siteid
-         LEFT JOIN sys_enterprise t3 ON t3.sys_enterpriseid = t1.sys_enterpriseid AND t3.siteid = t1.siteid
-         LEFT JOIN sys_enterprise t4 ON t4.sys_enterpriseid in
-                                        (SELECT sys_enterpriseid FROM sa_customers WHERE sa_customersid = t1.parentid)
-         LEFT JOIN sys_enterprise t5 ON t5.sys_enterpriseid in
-                                        (SELECT sys_enterpriseid FROM sa_agents WHERE sa_agentsid = t1.sa_agentsid)
+         LEFT JOIN sys_enterprise t2 ON t2.sys_enterpriseid = t1.sys_enterpriseid AND t2.siteid = t1.siteid
          LEFT JOIN (SELECT ownerid, max(createdate) followdate
                     FROM sys_datafollowup
-                    WHERE ownertable = 'sa_customers'
-                      AND siteid = $siteid$
-                    GROUP BY ownerid) t7 ON t7.ownerid = t1.sa_customersid
-         LEFT JOIN sa_customerpool t8 ON t8.sa_customerpoolid = t1.sa_customerpoolid_source AND t8.siteid = t1.siteid
-         LEFT JOIN sys_dataextend t9
-                   ON t1.sys_enterpriseid = t9.ownerid and ownertable = 'sys_enterprise' and t1.siteid = t9.siteid
-         LEFT JOIN sa_agents t10 ON t10.sys_enterpriseid = t1.sys_enterpriseid and t10.siteid = t1.siteid
+                    WHERE ownertable = 'sa_customers' and  siteid = $siteid$
+                    GROUP BY ownerid) t3 ON t3.ownerid = t1.sa_customersid
+         LEFT JOIN sa_salearea t4 on t4.sa_saleareaid = t1.sa_saleareaid and t1.siteid = t4.siteid
+         LEFT JOIN sys_dataextend t5 ON t5.ownertable='sa_customers' and t5.ownerid=t1.sa_customersid and t5.siteid=t1.siteid
 WHERE t1.siteid = $siteid$
-  and sa_customersid = $sa_customersid$
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+  and sa_customersid = $sa_customersid$

+ 0 - 316
src/custom/restcontroller/webmanage/sale/customer/Customer.java

@@ -42,322 +42,6 @@ public class Customer extends Controller {
         super(content);
     }
 
-    @API(title = "新增或更新", apiversion = R.ID20221010164302.v1.class, intervaltime = 2000)
-    @CACHEING_CLEAN(apiversions = {R.ID20221022165503.v1.class, R.ID20221011133602.class, R.ID20221013102602.class,
-            R.ID20221012164402.class, R.ID20221014164702.class, R.ID20220920083901.class, R.ID20220929085401.class,
-            R.ID20220920083901.v1.class})
-    public String insertOrUpdate() throws YosException {
-        String tablename = "sa_customers";
-        Long sys_enterpriseid = content.getLong("sys_enterpriseid");
-        String enterprisename = content.getString("enterprisename");
-
-        String telephone = content.getStringValue("telephone");
-        String taxno = content.getStringValue("taxno");
-        String address = content.getStringValue("address");
-        String province = content.getStringValue("province");
-        String city = content.getStringValue("city");
-        String county = content.getStringValue("county");
-
-        ArrayList<String> sqlList = new ArrayList<>();
-        //创建企业档案
-        SQLFactory sqlFactory = new SQLFactory(this, "客户企业档案新增");
-        if (sys_enterpriseid <= 0) {
-            sys_enterpriseid = createTableID("sys_enterprise");
-        } else {
-            sqlFactory = new SQLFactory(this, "客户企业档案更新");
-        }
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("userid", userid);
-        sqlFactory.addParameter("username", username);
-        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-        sqlFactory.addParameter("province", province);
-        sqlFactory.addParameter("city", city);
-        sqlFactory.addParameter("county", county);
-        sqlFactory.addParameter("address", address);
-        sqlFactory.addParameter("enterprisename", enterprisename);
-        sqlFactory.addParameter("abbreviation", content.getStringValue("abbreviation"));
-        sqlFactory.addParameter("taxno", taxno);
-        sqlFactory.addParameter("grade", content.getLongValue("grade") == 0 ? "null" : content.getLongValue("grade"));
-        sqlFactory.addParameter("industry", content.getJSONArray("industry"));
-        sqlFactory.addParameter("contact", content.getStringValue("contact"));
-        sqlFactory.addParameter("phonenumber", telephone);
-        sqlFactory.addParameter("telephone", telephone);
-
-        sqlList.add(sqlFactory.getSQL());
-
-
-        //扩展字段
-        String erpagentnum = content.getStringValue("erpagentnum");
-        String sql = "SELECT * from sys_dataextend WHERE ownertable='sys_enterprise' and ownerid=" + sys_enterpriseid + " and siteid = '" + siteid + "'";
-        Rows extendRows = dbConnect.runSqlQuery(sql);
-        Long sys_dataextendid = 0L;
-        if (extendRows.isEmpty()) {
-            sys_dataextendid = createTableID("sys_dataextend");
-            sqlFactory = new SQLFactory(this, "经销商扩展字段新增");
-        } else {
-            sys_dataextendid = extendRows.get(0).getLong("sys_dataextendid");
-            sqlFactory = new SQLFactory(this, "经销商扩展字段更新");
-
-        }
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("username", username);
-        sqlFactory.addParameter("userid", userid);
-        sqlFactory.addParameter("sys_dataextendid", sys_dataextendid);
-        sqlFactory.addParameter("ownerid", sys_enterpriseid);
-        sqlFactory.addParameter("ownertable", "sys_enterprise");
-        sqlFactory.addParameter("erpagentnum", erpagentnum);
-        sqlList.add(sqlFactory.getSQL());
-
-
-        Long sa_customersid = content.getLong("sa_customersid");
-        Long parentid = content.getLong("parentid");
-        String type = content.getString("type");
-        Long sa_customerpoolid = content.getLong("sa_customerpoolid");
-
-        boolean isAdd = true;
-        sqlFactory = new SQLFactory(this, "客户新增");
-        if (sa_customersid <= 0) {
-            sa_customersid = createTableID("sa_customers");
-            sqlList.add(DataTag.createTagSql(this, "sa_customers", sa_customersid, "潜在"));
-            isAdd = true;
-        } else {
-            sqlFactory = new SQLFactory(this, "客户更新");
-            isAdd = false;
-        }
-
-        if (siteid.equals("HY")) {
-            sqlFactory.addParameter("reward_point", "[\"订单核销审核\", \"物流单审核\", \"开票审核\"]");
-            sqlFactory.addParameter("reward_rate", 0);
-        } else {
-            sqlFactory.addParameter("reward_point", "null");
-            sqlFactory.addParameter("reward_rate", "null");
-        }
-
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter("userid", userid);
-        sqlFactory.addParameter("username", username);
-        sqlFactory.addParameter("sa_customersid", sa_customersid);
-        //上级客户ID
-        sqlFactory.addParameter("parentid", parentid == 0 ? "null" : parentid);
-        //合作企业档案ID
-        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-        //客户类型
-        sqlFactory.addParameter("type", type);
-        //客户池(公海池)ID
-        sqlFactory.addParameter("sa_customerpoolid", sa_customerpoolid);
-        //客户来源
-        sqlFactory.addParameter("source", content.getString("source"));
-        sqlFactory.addParameter("customergrade", content.getStringValue("customergrade"));
-        Long ispublic = content.getLongValue("ispublic", 1L);
-        sqlFactory.addParameter("ispublic", ispublic);
-        sqlFactory.addParameter("name", enterprisename);
-        sqlFactory.addParameter("province", province);
-        sqlFactory.addParameter("city", city);
-        sqlFactory.addParameter("county", county);
-        sqlFactory.addParameter("address", address);
-        sqlFactory.addParameter("phonenumber", telephone);
-
-        sqlList.add(sqlFactory.getSQL());
-
-        //操作记录
-        if (isAdd) {
-            if (ispublic == 1) {
-                sqlList.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "新建", "新建公海客户" + enterprisename).getSQL());
-            } else {
-                sqlList.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "新建", "新建客户" + enterprisename).getSQL());
-            }
-
-        } else {
-            if (ispublic == 1) {
-                sqlList.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "编辑", "编辑公海客户" + enterprisename).getSQL());
-            } else {
-                sqlList.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "编辑", "编辑客户" + enterprisename).getSQL());
-            }
-        }
-
-
-        Long sjssys_phonebookid = 0L;
-        if (type.equals("设计师")) {
-            if (dbConnect.runSqlQuery("select 1 from sys_enterprise_contacts where siteid='" + siteid + "' and name='" + enterprisename + "' and deleted=0 and workaddress=0 and sys_enterpriseid=" + sys_enterpriseid).isEmpty()) {
-                sjssys_phonebookid = createTableID("sys_phonebook");
-                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_phonebook");
-                insertSQL.setSiteid(siteid);
-                insertSQL.setValue("sys_phonebookid", sjssys_phonebookid);
-                insertSQL.setValue("createuserid", userid);
-                insertSQL.setValue("createby", username);
-                insertSQL.setDateValue("createdate");
-                insertSQL.setValue("changeuserid", userid);
-                insertSQL.setValue("changeby", username);
-                insertSQL.setValue("userid", userid);
-                insertSQL.setDateValue("changedate");
-                insertSQL.setValue("sys_phonebookgroupid", "0");
-                insertSQL.setValue("name", enterprisename);
-                sqlList.add(insertSQL.getSQL());
-                sqlList.add(DataContrlLog.createLog(this, "sys_phonebook", sjssys_phonebookid, "通讯录新增", "通讯录新增:" + enterprisename).getSQL());
-                sqlList.addAll(DataTeam.createTeamSQL(this, "sys_phonebook", sjssys_phonebookid, userid));
-                Long contactsid = createTableID("sys_enterprise_contacts");
-                insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_contacts");
-                insertSQL.setSiteid(siteid);
-                insertSQL.setValue("contactsid", contactsid);
-                insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
-                insertSQL.setValue("sys_phonebookid", sjssys_phonebookid);
-                insertSQL.setValue("createuserid", userid);
-                insertSQL.setValue("createby", username);
-                insertSQL.setDateValue("createdate");
-                insertSQL.setValue("changeuserid", userid);
-                insertSQL.setValue("changeby", username);
-                insertSQL.setDateValue("changedate");
-                insertSQL.setValue("workaddress", 0);
-                sqlList.add(insertSQL.getSQL());
-                sqlList.add(DataContrlLog.createLog(this, "sys_enterprise_contacts", contactsid, "新建联系人", "新建联系人" + enterprisename).getSQL());
-            }
-        }
-
-        content.put("sa_customersid", sa_customersid);
-        Long mrsys_phonebookid = 0L;
-        if (isAdd) {
-            //添加财务信息
-            {
-                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_finance");
-                Long sys_enterprise_financeid = createTableID("sys_enterprise_finance");
-                insertSQL.setSiteid(siteid);
-                insertSQL.setValue("sys_enterprise_financeid", sys_enterprise_financeid);
-                insertSQL.setValue("changeuserid", userid);
-                insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
-                insertSQL.setValue("enterprisename", enterprisename);
-                insertSQL.setValue("phonenumber", telephone);
-                insertSQL.setValue("taxno", taxno);
-                insertSQL.setValue("address", address);
-                insertSQL.setValue("isdefault", 1);
-                sqlList.add(insertSQL.getSQL());
-                sqlList.add(DataContrlLog.createLog(this, "sys_enterprise_finance", sys_enterprise_financeid, "新建开票信息", "新建开票信息" + enterprisename).getSQL());
-
-                //添加地址
-                Long contactsid = createTableID("sys_enterprise_contacts");
-                insertSQL = SQLFactory.createInsertSQL(this, "sys_enterprise_contacts");
-                insertSQL.setSiteid(siteid);
-                insertSQL.setValue("contactsid", contactsid);
-                insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
-                insertSQL.setValue("createuserid", userid);
-                insertSQL.setValue("createby", username);
-                insertSQL.setDateValue("createdate");
-                insertSQL.setValue("changeuserid", userid);
-                insertSQL.setValue("changeby", username);
-                insertSQL.setValue("phonenumber", telephone);
-                insertSQL.setValue("province", province);
-                insertSQL.setValue("city", city);
-                insertSQL.setValue("county", county);
-                insertSQL.setValue("address", address);
-                insertSQL.setValue("name", content.getStringValue("contact"));
-                insertSQL.setDateValue("changedate");
-                insertSQL.setValue("workaddress", 1);
-                insertSQL.setValue("isdefault", 1);
-                insertSQL.setValue("isprimary", 1);
-                sqlList.add(insertSQL.getSQL());
-            }
-            JSONObject contactsinfo = content.getJSONObject("contactsinfo");
-
-            mrsys_phonebookid = contactsinfo.getLong("sys_phonebookid");
-            String phonenumber = contactsinfo.getStringValue("phonenumber");
-            String name = contactsinfo.getStringValue("name");
-
-            if (mrsys_phonebookid <= 0 || dbConnect.runSqlQuery("select 1 from sys_phonebook where siteid='" + siteid + "' and sys_phonebookid=" + mrsys_phonebookid).isEmpty()) {
-                if (PhoneBook.verifyphonenumber(this, phonenumber, userid, mrsys_phonebookid)) {
-                    return getReturnObject().setCode("0056", new String[0]).toString(); //当前联系方式已存在
-                }
-                mrsys_phonebookid = createTableID("sys_phonebook");
-                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_phonebook");
-                insertSQL.setSiteid(siteid);
-                insertSQL.setValue("sys_phonebookid", mrsys_phonebookid);
-                insertSQL.setValue("createuserid", userid);
-                insertSQL.setValue("createby", username);
-                insertSQL.setDateValue("createdate");
-                insertSQL.setValue("changeuserid", userid);
-                insertSQL.setValue("changeby", username);
-                insertSQL.setDateValue("changedate");
-                insertSQL.setValue("userid", userid);
-                insertSQL.setValue("sys_phonebookgroupid", "0");
-                insertSQL.setValue("name", name);
-                insertSQL.setValue("phonenumber", phonenumber);
-                sqlList.add(insertSQL.getSQL());
-                sqlList.addAll(DataTeam.createTeamSQL(this, "sys_phonebook", mrsys_phonebookid, userid));
-                sqlList.add(DataContrlLog.createLog(this, "sys_phonebook", mrsys_phonebookid, "通讯录新增", "通讯录新增:" + name).getSQL());
-            } else {
-                Rows leaderWithoutHeadpic = DataTeam.getLeaderWithoutHeadpic(this, "sys_phonebook", mrsys_phonebookid);
-                Long leaderuserid = 0L;
-                if (leaderWithoutHeadpic.isNotEmpty()) {
-                    leaderuserid = leaderWithoutHeadpic.get(0).getLong("userid");
-                }
-                if (PhoneBook.verifyphonenumber(this, phonenumber, leaderuserid, mrsys_phonebookid)) {
-                    return getReturnObject().setCode("0056", new String[0]).toString(); //当前联系方式已存在
-                }
-                UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_phonebook");
-                updateSQL.setSiteid(siteid);
-                updateSQL.setWhere("sys_phonebookid", mrsys_phonebookid);
-                updateSQL.setValue("changeuserid", userid);
-                updateSQL.setValue("changeby", username);
-                updateSQL.setDateValue("changedate");
-                updateSQL.setValue("name", name);
-                updateSQL.setValue("phonenumber", phonenumber);
-                sqlList.add(updateSQL.getSQL());
-                sqlList.add(DataContrlLog.createLog(this, "sys_phonebook", mrsys_phonebookid, "通讯录编辑", "通讯录编辑:" + name).getSQL());
-            }
-
-
-            long contactsid = createTableID("sys_enterprise_contacts");
-            //添加联系人
-            InsertSQL contactsinsert = SQLFactory.createInsertSQL(this, "sys_enterprise_contacts");
-
-            contactsinsert.setValue("sys_enterpriseid", sys_enterpriseid);
-            contactsinsert.setValue("sys_phonebookid", mrsys_phonebookid);
-            contactsinsert.setValue("workaddress", 0);
-            contactsinsert.setValue("createuserid", userid);
-            contactsinsert.setValue("createby", username);
-            contactsinsert.setDateValue("createdate");
-            contactsinsert.setValue("changeuserid", userid);
-            contactsinsert.setValue("changeby", username);
-            contactsinsert.setDateValue("changedate");
-            contactsinsert.setValue("isdefault", 0);
-            contactsinsert.setValue("isprimary", 0);
-            contactsinsert.setValue("iscreate", 1);
-            contactsinsert.setValue("contactsid", contactsid);
-            contactsinsert.setSiteid(siteid);
-            sqlList.add(contactsinsert.getSQL());
-            sqlList.add(DataContrlLog.createLog(this, "sys_enterprise_contacts", contactsid, "新建联系人", "新建联系人" + name).getSQL());
-
-        }
-        dbConnect.runSqlUpdate(sqlList);
-
-        DataTag.deleteTag(this, "sa_customers", sa_customersid, "疑似重复");
-        //客户查重
-        if (isAdd) {
-
-            Rows teamRows = DataTeam.queryTeamRowWithoutHeadpic(this, "sa_customers", sa_customersid);
-            for (Row row : teamRows) {
-                DataTeam.createTeam(this, "sys_phonebook", sjssys_phonebookid, row.getLong("userid"));
-            }
-            for (Row row : teamRows) {
-                DataTeam.createTeam(this, "sys_phonebook", mrsys_phonebookid, row.getLong("userid"));
-            }
-            {
-                JSONObject extradata = new JSONObject();
-                extradata.put("extraUserList", getUsers(sa_customerpoolid));
-                Executor.sendEml_controller(this, "customers_add", sa_customersid, extradata);
-            }
-            ArrayList<Long> repeatIds = getRepeatCustomers(this, sa_customersid);
-            repeatIds.add(120L);
-            for (Object obj : repeatIds) {
-                Long id = Long.valueOf(obj.toString());
-                ArrayList<Long> userids = DataTeam.queryTeamRowWithoutHeadpic(this, "sa_customers", id).toArrayList("userid", new ArrayList<>());
-                JSONObject extradata = new JSONObject();
-                extradata.put("extraUserList", userids);
-                Executor.sendEml_controller(this, "customers_repeat", sa_customersid, extradata);
-            }
-        }
-
-        return selectDetail();
-    }
-
 
     @API(title = "数据状态变更", apiversion = R.ID20221010164402.v1.class)
     @CACHEING_CLEAN(apiversions = {R.ID20221011133602.class, R.ID20221013102602.class, R.ID20221012164402.class, R.ID20221014164702.class})

+ 1 - 4
src/custom/restcontroller/webmanage/sale/customer/SQL/客户查重信息.sql

@@ -7,11 +7,9 @@ SELECT t1.sa_customersid,
        t2.city,
        t2.county,
        t2.address,
-       t2.taxno,
        max(t3.createdate) followdate,
        t5.phonenumber,
-       t1.datastatus,
-       t1.sa_customerpoolid
+       t1.datastatus
 FROM sa_customers t1
          LEFT JOIN sys_enterprise t2 ON t2.sys_enterpriseid = t1.sys_enterpriseid AND t2.siteid = t1.siteid
          LEFT JOIN sys_datafollowup t3
@@ -30,5 +28,4 @@ group by t1.sa_customersid,
     t2.city,
     t2.county,
     t2.address,
-    t2.taxno,
     t5.phonenumber