|
|
@@ -100,257 +100,169 @@ public class agents extends Controller {
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "经销商详情查询");
|
|
|
sqlFactory.addParameter("sa_agentsid", sa_agentsid);
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
- Rows agentRows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
- for (Row agentRow : agentRows) {
|
|
|
- agentRow.put("hrs", getEnterpriseHrs(agentRow.getLong("sys_enterpriseid")));
|
|
|
-
|
|
|
- SQLFactory salersql = new SQLFactory(this, "经销商详情查询_业务员查询");
|
|
|
- salersql.addParameter("siteid", siteid);
|
|
|
- salersql.addParameter_in("sa_saleareaid", SaleArea.getSaleAreaIds(this, agentRow.getLong("sys_enterpriseid")));
|
|
|
- Rows salerrows = dbConnect.runSqlQuery(salersql.getSQL());
|
|
|
- agentRow.put("salers", salerrows);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ RowsMap areaRowsMap = getAreaRowsMap(rows.toArrayList("sa_agentsid", new ArrayList<>()));
|
|
|
+ RowsMap salerRowsMap = getSalerNameRowsMap(rows.toArrayList("sa_agentsid", new ArrayList<>()));
|
|
|
+ for (Row row : rows) {
|
|
|
+ row.put("hrs", getEnterpriseHrs(row.getLong("sys_enterpriseid")));
|
|
|
+ Rows areaRows = areaRowsMap.getOrDefault(row.getString("sa_agentsid"), new Rows());
|
|
|
+ row.put("areanames", StringUtils.join(areaRows.toArrayList("areaname"), ","));
|
|
|
+ Rows salerRows = salerRowsMap.getOrDefault(row.getString("sa_agentsid"), new Rows());
|
|
|
+ row.put("salernames", StringUtils.join(salerRows.toArrayList("name"), ","));
|
|
|
+ row.putIfAbsent("scale", "");
|
|
|
+ row.putIfAbsent("mainproducts", "");
|
|
|
}
|
|
|
- return getSucReturnObject().setData(agentRows.isNotEmpty() ? agentRows.get(0) : new Row()).toString();
|
|
|
+ return getSucReturnObject().setData(rows.isNotEmpty() ? rows.get(0) : new Row()).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public RowsMap getAreaRowsMap(ArrayList<Long> sa_agentsids) throws YosException {
|
|
|
+
|
|
|
+ String sql = "SELECT DISTINCT t2.areaname,t1.sa_agentsid from sys_enterprise_tradefield t1 " +
|
|
|
+ "INNER JOIN sa_salearea t2 ON t2.sa_saleareaid=t1.sa_saleareaid " +
|
|
|
+ "WHERE t1.siteid='YOSTEST1' and t1.sa_agentsid in " + sa_agentsids;
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+
|
|
|
+ return dbConnect.runSqlQuery(sql).toRowsMap("sa_agentsid");
|
|
|
+ }
|
|
|
+
|
|
|
+ public RowsMap getSalerNameRowsMap(ArrayList<Long> sa_agentsids) throws YosException {
|
|
|
+
|
|
|
+ String sql = "SELECT DISTINCT t2.name,t1.sa_agentsid from sys_enterprise_tradefield t1 " +
|
|
|
+ "INNER JOIN sys_hr t2 ON t2.hrid=t1.hrid " +
|
|
|
+ "WHERE t1.siteid='YOSTEST1' and t1.sa_agentsid in " + sa_agentsids;
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+
|
|
|
+ return dbConnect.runSqlQuery(sql).toRowsMap("sa_agentsid");
|
|
|
}
|
|
|
|
|
|
|
|
|
- @API(title = "经销商新增修改", intervaltime = 2000)
|
|
|
+ @API(title = "经销商新增修改", apiversion = R.ID2025102310145302.v1.class, intervaltime = 2000)
|
|
|
@CACHEING_CLEAN(cms = {@cm(clazz = agents.class, method = {"query_agentList", "query_agentMain"}), @cm(clazz = salearea.class, method = {"query_agent"}), @cm(clazz = salearea.class, method = {"query_agent"})},
|
|
|
apiversions = {R.ID20220920083901.v1.class, R.ID20221022165803.v1.class, R.ID20220920083901.v1.class, R.ID20221012164402.v1.class})
|
|
|
public String insertormodify_agent() throws YosException {
|
|
|
- long sa_agentsid = content.getLongValue("sa_agentsid");//新增时传0
|
|
|
- long sys_enterpriseid = content.getLongValue("sys_enterpriseid");
|
|
|
- long parentid = content.getLongValue("parentid");
|
|
|
- String agentnum = content.getString("agentnum", "sa_agents");
|
|
|
- JSONArray type = content.getJSONArray("type");
|
|
|
- String signdate = content.getStringValue("signdate");
|
|
|
- String cooperationstatus = content.getStringValue("cooperationstatus");
|
|
|
- long isallsale = content.getLongValue("isallsale");
|
|
|
|
|
|
+ Long sa_agentsid = content.getLongValue("sa_agentsid");
|
|
|
+ Long sys_enterpriseid = content.getLongValue("sys_enterpriseid");
|
|
|
+ String enterprisename = content.getStringValue("enterprisename");
|
|
|
+ String cooperatetype = content.getStringValue("cooperatetype");
|
|
|
+ String agentnum = content.getStringValue("agentnum");
|
|
|
+ String erpagentnum = content.getStringValue("erpagentnum");
|
|
|
+ String gmname = content.getStringValue("gmname");
|
|
|
+ String gmphonenumber = content.getStringValue("gmphonenumber");
|
|
|
+ String province = content.getStringValue("province");
|
|
|
+ String city = content.getStringValue("city");
|
|
|
+ String county = content.getStringValue("county");
|
|
|
+ String address = content.getStringValue("address");
|
|
|
+ Long parentid = content.getLongValue("parentid");
|
|
|
+ String remarks = content.getStringValue("remarks");
|
|
|
+
|
|
|
+ ArrayList<String> sqllist = new ArrayList<>();
|
|
|
Boolean isadd = Boolean.FALSE;
|
|
|
|
|
|
if (parentid != 0 && dbConnect.runSqlQuery("select * from sa_agents where siteid='" + siteid + "' and sa_agentsid=" + parentid).isEmpty()) {
|
|
|
- return getReturnObject().setCode("0186",new String[0]).toString();//指定的上级商户不存在
|
|
|
-
|
|
|
+ return getReturnObject().setCode("0186").toString();//指定的上级商户不存在
|
|
|
}
|
|
|
|
|
|
- Row enterpriseRow = Enterprise.getEnterprise(this, sys_enterpriseid);
|
|
|
- if (enterpriseRow.isEmpty()) {
|
|
|
- return getReturnObject().setCode("0189",new String[0]).toString();//未选择企业
|
|
|
+ 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("enterprisename", enterprisename);
|
|
|
+ insertSQL.setValue("province", province);
|
|
|
+ insertSQL.setValue("city", city);
|
|
|
+ insertSQL.setValue("county", county);
|
|
|
+ insertSQL.setValue("address", address);
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ } else {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_enterprise");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sys_enterpriseid);
|
|
|
+ updateSQL.setValue("enterprisename", enterprisename);
|
|
|
+ updateSQL.setValue("province", province);
|
|
|
+ updateSQL.setValue("city", city);
|
|
|
+ updateSQL.setValue("county", county);
|
|
|
+ updateSQL.setValue("address", address);
|
|
|
+ sqllist.add(updateSQL.getSQL());
|
|
|
}
|
|
|
- String enterprisename = enterpriseRow.getString("enterprisename");
|
|
|
-
|
|
|
- ArrayList<String> sqllist = new ArrayList<>();
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "经销商新增");
|
|
|
- if (sa_agentsid <= 0 || dbConnect.runSqlQuery("select sa_agentsid from sa_agents where sa_agentsid=" + sa_agentsid).isEmpty()) {
|
|
|
- if (dbConnect.runSqlQuery("select sa_agentsid from sa_agents where sys_enterpriseid=" + sys_enterpriseid).isNotEmpty()) {
|
|
|
- return getReturnObject().setCode("0187",new String[0]).toString();//当前商户已经创建经销商档案,不可重复创建
|
|
|
|
|
|
- }
|
|
|
+ if (sa_agentsid <= 0) {
|
|
|
isadd = Boolean.TRUE;
|
|
|
sa_agentsid = createTableID("sa_agents");
|
|
|
- addAccount(sys_enterpriseid);
|
|
|
- Rows customersRows = dbConnect.runSqlQuery("SELECT sa_customersid from sa_customers WHERE sys_enterpriseid =" + sys_enterpriseid + " and siteid = '" + siteid + "'");
|
|
|
- if (customersRows.isNotEmpty()) {
|
|
|
- Long id = customersRows.get(0).getLong("sa_customersid");
|
|
|
- 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_agent_add", sa_agentsid, extradata);
|
|
|
- }
|
|
|
- sqllist.add(DataContrlLog.createLog(this, "sa_agents", sa_agentsid, "新建", "新建合作伙伴:" + enterprisename).getSQL());
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_agents");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(sa_agentsid);
|
|
|
+ insertSQL.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ insertSQL.setValue("cooperatetype", cooperatetype);
|
|
|
+ insertSQL.setValue("agentnum", agentnum);
|
|
|
+ insertSQL.setValue("gmname", gmname);
|
|
|
+ insertSQL.setValue("gmphonenumber", gmphonenumber);
|
|
|
+ insertSQL.setValue("parentid", parentid);
|
|
|
+ insertSQL.setValue("remarks", remarks);
|
|
|
+ insertSQL.setValue("status", "启用");
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ sqllist.add(DataContrlLog.createLog(this, "sa_agents", sa_agentsid, "新建", "新建经销商:" + enterprisename).getSQL());
|
|
|
} else {
|
|
|
- sqlFactory = new SQLFactory(this, "经销商修改");
|
|
|
- sqllist.add(DataContrlLog.createLog(this, "sa_agents", sa_agentsid, "编辑", "编辑合作伙伴:" + enterprisename).getSQL());
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_agents");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sa_agentsid);
|
|
|
+ updateSQL.setValue("cooperatetype", cooperatetype);
|
|
|
+ updateSQL.setValue("agentnum", agentnum);
|
|
|
+ updateSQL.setValue("gmname", gmname);
|
|
|
+ updateSQL.setValue("gmphonenumber", gmphonenumber);
|
|
|
+ updateSQL.setValue("parentid", parentid);
|
|
|
+ updateSQL.setValue("remarks", remarks);
|
|
|
+ sqllist.add(updateSQL.getSQL());
|
|
|
+ sqllist.add(DataContrlLog.createLog(this, "sa_agents", sa_agentsid, "编辑", "编辑经销商:" + enterprisename).getSQL());
|
|
|
}
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("sa_agentsid", sa_agentsid);
|
|
|
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- sqlFactory.addParameter("changeuserid", userid);
|
|
|
- sqlFactory.addParameter("agentnum", agentnum);
|
|
|
- sqlFactory.addParameter("type", type);
|
|
|
- sqlFactory.addParameter("cooperationstatus", cooperationstatus);
|
|
|
- sqlFactory.addParameter("parentid", parentid == 0 ? "null" : String.valueOf(parentid));
|
|
|
- sqlFactory.addParameter("signdate", signdate.equals("") ? "null" : signdate);
|
|
|
- sqlFactory.addParameter("isservice", content.getLongValue("isservice", 0L));
|
|
|
- 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, "经销商扩展字段新增");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sys_dataextend");
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setUniqueid(sys_dataextendid);
|
|
|
+ insertSQL.setValue("ownerid", sys_enterpriseid);
|
|
|
+ insertSQL.setValue("ownertable", "sys_enterprise");
|
|
|
+ insertSQL.setValue("erpagentnum", erpagentnum);
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
} else {
|
|
|
sys_dataextendid = extendRows.get(0).getLong("sys_dataextendid");
|
|
|
- sqlFactory = new SQLFactory(this, "经销商扩展字段更新");
|
|
|
-
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sys_dataextend");
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(sys_dataextendid);
|
|
|
+ updateSQL.setValue("ownerid", sys_enterpriseid);
|
|
|
+ updateSQL.setValue("ownertable", "sys_enterprise");
|
|
|
+ updateSQL.setValue("erpagentnum", erpagentnum);
|
|
|
+ sqllist.add(updateSQL.getSQL());
|
|
|
}
|
|
|
- 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());
|
|
|
-
|
|
|
-
|
|
|
- sqlFactory = new SQLFactory(this, "商户档案修改");
|
|
|
- sqlFactory.addParameter("limitreturnday", content.getLongValue("limitreturnday"));
|
|
|
- sqlFactory.addParameter("freefreightamount", content.getBigDecimalValue("freefreightamount"));
|
|
|
- //开票节点(1:订单审核:2:发货)
|
|
|
- sqlFactory.addParameter("invoicingpoint", content.getLongValue("invoicingpoint") == 0 ? 2 : content.getLongValue("invoicingpoint"));
|
|
|
- //是否需要经营授权,默认1
|
|
|
- sqlFactory.addParameter("saleclassauth", content.getBooleanValue("saleclassauth") == false ? 0 : 1);
|
|
|
- //是否需要标准授权,默认1
|
|
|
- sqlFactory.addParameter("standardsauth", content.getBooleanValue("standardsauth") == false ? 0 : 1);
|
|
|
- sqlFactory.addParameter("grade", content.getLongValue("grade"));
|
|
|
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- sqlFactory.addParameter("changeuserid", userid);
|
|
|
- sqllist.add(sqlFactory.getSQL());
|
|
|
-
|
|
|
-
|
|
|
- //企业信息同步到【我的客户】,并将该客户打上经销商标签,
|
|
|
- Rows customersRows = dbConnect.runSqlQuery("SELECT sa_customersid,datastatus from sa_customers WHERE sys_enterpriseid =" + sys_enterpriseid + " and siteid = '" + siteid + "'");
|
|
|
-
|
|
|
- String phonenumber = enterpriseRow.getString("phonenumber");
|
|
|
- String taxno = enterpriseRow.getString("taxno");
|
|
|
- String address = enterpriseRow.getString("address");
|
|
|
- Long sa_customersid = 0L;
|
|
|
- if (customersRows.isNotEmpty()) {
|
|
|
- sa_customersid = customersRows.get(0).getLong("sa_customersid");
|
|
|
- Long datastatus = customersRows.get(0).getLong("datastatus");
|
|
|
- if (isadd && datastatus == 1) {
|
|
|
- sqllist.add(DataContrlLog.createLog(this, "sa_customers", sa_customersid, "恢复", "从回收站内恢复").getSQL());
|
|
|
- sqllist.add("update sa_customers set datastatus =0 where siteid='" + siteid + "' and sa_customersid=" + sa_customersid);
|
|
|
- }
|
|
|
- sqlFactory = new SQLFactory(this, "客户更新");
|
|
|
|
|
|
- } else {
|
|
|
- sa_customersid = createTableID("sa_customers");
|
|
|
- sqlFactory = new SQLFactory(this, "客户新增");
|
|
|
-
|
|
|
- //添加财务信息
|
|
|
- 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", phonenumber);
|
|
|
- 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());
|
|
|
-
|
|
|
- //添加地址
|
|
|
+ //添加地址
|
|
|
+ if (isadd) {
|
|
|
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("name", enterpriseRow.getString("contact"));
|
|
|
- insertSQL.setValue("province", enterpriseRow.getString("province"));
|
|
|
- insertSQL.setValue("city", enterpriseRow.getString("city"));
|
|
|
- insertSQL.setValue("county", enterpriseRow.getString("county"));
|
|
|
+ insertSQL.setValue("name", gmname);
|
|
|
+ insertSQL.setValue("province", province);
|
|
|
+ insertSQL.setValue("city", city);
|
|
|
+ insertSQL.setValue("county", county);
|
|
|
insertSQL.setValue("address", address);
|
|
|
- insertSQL.setValue("phonenumber", phonenumber);
|
|
|
- insertSQL.setDateValue("changedate");
|
|
|
+ insertSQL.setValue("phonenumber", gmphonenumber);
|
|
|
insertSQL.setValue("workaddress", 1);
|
|
|
insertSQL.setValue("isdefault", 1);
|
|
|
insertSQL.setValue("isprimary", 1);
|
|
|
sqllist.add(insertSQL.getSQL());
|
|
|
}
|
|
|
|
|
|
- if (siteid.equals("HY")) {
|
|
|
- sqlFactory.addParameter("reward_point", "[\"订单核销审核\", \"物流单审核\", \"开票审核\"]");
|
|
|
- sqlFactory.addParameter("reward_rate", 0);
|
|
|
- } else {
|
|
|
- sqlFactory.addParameter("reward_point", "null");
|
|
|
- sqlFactory.addParameter("reward_rate", "null");
|
|
|
- }
|
|
|
- long parent_sa_customersid = 0L;
|
|
|
- Rows rows = dbConnect.runSqlQuery("SELECT sa_customersid from sa_customers WHERE sys_enterpriseid in (SELECT sys_enterpriseid from sa_agents WHERE sa_agentsid=" + parentid + ") and siteid='" + siteid + "'");
|
|
|
- if (rows.isNotEmpty()) {
|
|
|
- parent_sa_customersid = rows.get(0).getLong("sa_customersid");
|
|
|
- }
|
|
|
-
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("userid", userid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- sqlFactory.addParameter("sa_customersid", sa_customersid);
|
|
|
- //上级客户ID
|
|
|
- sqlFactory.addParameter("parentid", parent_sa_customersid);
|
|
|
- //合作企业档案ID
|
|
|
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- //客户类型
|
|
|
- sqlFactory.addParameter("type", "经销商");
|
|
|
- //客户池(公海池)ID
|
|
|
- sqlFactory.addParameter("sa_customerpoolid", 0);
|
|
|
- //客户来源
|
|
|
- sqlFactory.addParameter("source", "经销商同步");
|
|
|
- sqlFactory.addParameter("customergrade", "null");
|
|
|
- sqlFactory.addParameter("ispublic", 0);
|
|
|
- sqlFactory.addParameter("name", enterpriseRow.getString("enterprisename"));
|
|
|
- sqlFactory.addParameter("province", enterpriseRow.getString("province"));
|
|
|
- sqlFactory.addParameter("city", enterpriseRow.getString("city"));
|
|
|
- sqlFactory.addParameter("county", enterpriseRow.getString("county"));
|
|
|
- sqlFactory.addParameter("address", enterpriseRow.getString("address"));
|
|
|
- sqlFactory.addParameter("phonenumber", enterpriseRow.getString("phonenumber"));
|
|
|
- sqllist.add(sqlFactory.getSQL());
|
|
|
-
|
|
|
-
|
|
|
- String bank = content.getStringValue("bank");
|
|
|
- String bankcardno = content.getStringValue("bankcardno");
|
|
|
- String bankname = content.getStringValue("bankname");
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(bankname) && StringUtils.isNotEmpty(bankcardno) && StringUtils.isNotEmpty(bank)) {
|
|
|
- long sys_enterprise_bankid = content.getLongValue("sys_enterprise_bankid");
|
|
|
- if (sys_enterprise_bankid <= 0 || dbConnect.runSqlQuery("select 1 from sys_enterprise_bank where siteid='" + siteid + "' and sys_enterprise_bankid=" + sys_enterprise_bankid).isEmpty()) {
|
|
|
- sys_enterprise_bankid = createTableID("sys_enterprise_bank");
|
|
|
- sqlFactory = new SQLFactory(this, "银行卡信息新增");
|
|
|
- sqllist.add(DataContrlLog.createLog(this, "sa_agents", sa_agentsid, "新建", "新建银行卡:" + bankcardno).getSQL());
|
|
|
- } else {
|
|
|
- sqlFactory = new SQLFactory(this, "银行卡信息修改");
|
|
|
- sqllist.add(DataContrlLog.createLog(this, "sa_agents", sa_agentsid, "编辑", "编辑银行卡:" + bankcardno).getSQL());
|
|
|
- }
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("sys_enterprise_bankid", sys_enterprise_bankid);
|
|
|
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- sqlFactory.addParameter("name", bankname);
|
|
|
- sqlFactory.addParameter("bankcardno", bankcardno);
|
|
|
- sqlFactory.addParameter("bank", bank);
|
|
|
- sqlFactory.addParameter("userid", userid);
|
|
|
- sqlFactory.addParameter("username", username);
|
|
|
- sqllist.add(sqlFactory.getSQL());
|
|
|
- }
|
|
|
dbConnect.runSqlUpdate(sqllist);
|
|
|
content.put("sa_agentsid", sa_agentsid);
|
|
|
|
|
|
- ArrayList<String> typeList = dbConnect.runSqlQuery("SELECT value from sys_optiontypemx WHERE optiontypeid in (SELECT optiontypeid from sys_optiontype WHERE typename='agenttypemx')").toArrayList("value");
|
|
|
- DataTag.deleteTag(this, "sa_customers", sa_customersid, typeList);
|
|
|
- if (customersRows.isEmpty()) {
|
|
|
- DataTag.createSystemTag(this, "sa_customers", sa_customersid, "潜在");
|
|
|
- }
|
|
|
- //打经销商标签
|
|
|
- for (Object obj : type) {
|
|
|
- DataTag.createSystemTag(this, "sa_customers", sa_customersid, obj.toString());
|
|
|
- }
|
|
|
-
|
|
|
- updateprojecttag(sys_enterpriseid);
|
|
|
return query_agentMain();
|
|
|
}
|
|
|
|
|
|
@@ -727,7 +639,7 @@ public class agents extends Controller {
|
|
|
String addr = row.getString("province") + row.getString("city") + row.getString("county") + row.getString("address");
|
|
|
|
|
|
if (row.getBoolean("isdefault")) {
|
|
|
- batchDeleteErr.addErr(row.getLong("contactsid"), "0662",new String[]{row.getString("name")});
|
|
|
+ batchDeleteErr.addErr(row.getLong("contactsid"), "0662", new String[]{row.getString("name")});
|
|
|
continue;
|
|
|
} else {
|
|
|
sqlList.add("update sys_enterprise_contacts set deleted=1 where contactsid =" + row.getLong("contactsid"));
|
|
|
@@ -1104,26 +1016,4 @@ public class agents extends Controller {
|
|
|
}
|
|
|
return sheet;
|
|
|
}
|
|
|
-
|
|
|
- public void updateprojecttag(Long sys_enterpriseid) throws YosException {
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "客户关联项目查询");
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
- ArrayList<Long> projectidList = dbConnect.runSqlQuery(sqlFactory).toArrayList("sa_projectid", new ArrayList<Long>());
|
|
|
- sqlFactory = new SQLFactory(this, "项目关联客户类型查询");
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter_in("sa_projectid", projectidList);
|
|
|
- RowsMap cusTagRowsMap = dbConnect.runSqlQuery(sqlFactory).toRowsMap("sa_projectid");
|
|
|
- HashMap<Long, ArrayList<String>> projectTagRowsMap = DataTag.queryTag(this, "sa_project", projectidList, true);
|
|
|
- for (Long sa_projectid : projectTagRowsMap.keySet()) {
|
|
|
- ArrayList<String> cusTagList = cusTagRowsMap.get(sa_projectid.toString()).toArrayList("tag");
|
|
|
- if (cusTagList.contains("经销商") && !projectTagRowsMap.get(sa_projectid).contains("经销")) {
|
|
|
- DataTag.deleteTag(this, "sa_project", sa_projectid, "直销");
|
|
|
- DataTag.createSystemTag(this, "sa_project", sa_projectid, "经销");
|
|
|
- } else if (!cusTagList.contains("经销商") && cusTagList.contains("直销客户") && !projectTagRowsMap.get(sa_projectid).contains("直销")) {
|
|
|
- DataTag.deleteTag(this, "sa_project", sa_projectid, "经销");
|
|
|
- DataTag.createSystemTag(this, "sa_project", sa_projectid, "直销");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|