|
@@ -1,5 +1,6 @@
|
|
|
package restcontroller.webmanage.saletool.orderclue;
|
|
package restcontroller.webmanage.saletool.orderclue;
|
|
|
|
|
|
|
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import common.Controller;
|
|
import common.Controller;
|
|
@@ -481,6 +482,75 @@ public class orderclue extends Controller {
|
|
|
sqlDump.add(updateSQL);
|
|
sqlDump.add(updateSQL);
|
|
|
sqlDump.add(geSqlStatement(ischeck, sat_orderclueuploadbillid));
|
|
sqlDump.add(geSqlStatement(ischeck, sat_orderclueuploadbillid));
|
|
|
sqlDump.commit(this);
|
|
sqlDump.commit(this);
|
|
|
|
|
+
|
|
|
|
|
+ if (ischeck && dbConnect.runSqlQuery("SELECT autodistribution FROM sat_ordercluerule WHERE siteid = '" + siteid + "' and autodistribution=1").isNotEmpty()) {
|
|
|
|
|
+ SQLList sqlList = new SQLList();
|
|
|
|
|
+
|
|
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise", "sys_enterpriseid", "province", "city", "county").setTableAlias("t1");
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.inner, "sat_orderclue_area", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid and t2.cluetype='经销商'");
|
|
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
|
|
+ Rows agentAreaRows = querySQL.query();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ QuerySQL enterprise_hridQuery = SQLFactory.createQuerySQL(this, "sys_enterprise_hr", "sys_enterprise_hrid");
|
|
|
|
|
+ enterprise_hridQuery.setWhere("isleader", true);
|
|
|
|
|
+ enterprise_hridQuery.setWhere("sys_enterpriseid", agentAreaRows.toArrayList("sys_enterpriseid"));
|
|
|
|
|
+ RowsMap enterprise_hridMap = enterprise_hridQuery.query().toRowsMap("sys_enterpriseid");
|
|
|
|
|
+
|
|
|
|
|
+ QuerySQL sat_orderclueuploadbillmxQuery = SQLFactory.createQuerySQL(this, "sat_orderclueuploadbillmx", "sat_orderclueid", "province", "city", "county").setTableAlias("t1");
|
|
|
|
|
+ sat_orderclueuploadbillmxQuery.setWhere("t1.sat_orderclueuploadbillid", sat_orderclueuploadbillid);
|
|
|
|
|
+ Rows rows = sat_orderclueuploadbillmxQuery.query();
|
|
|
|
|
+
|
|
|
|
|
+ for (Row row : rows) {
|
|
|
|
|
+ long sat_orderclueid = row.getLong("sat_orderclueid");
|
|
|
|
|
+ String province = row.getString("province");
|
|
|
|
|
+ String city = row.getString("city");
|
|
|
|
|
+ String county = row.getString("county");
|
|
|
|
|
+ ArrayList<Long> match_sys_enterpriseids = new ArrayList<>();
|
|
|
|
|
+ //匹配到省,市,区
|
|
|
|
|
+ for (Row agentRow : agentAreaRows) {
|
|
|
|
|
+ if (agentRow.getString("province").contains(province) && agentRow.getString("city").contains(city) && agentRow.getString("county").contains(county)) {
|
|
|
|
|
+ match_sys_enterpriseids.add(agentRow.getLong("sys_enterpriseid"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //匹配到省,市
|
|
|
|
|
+ if (match_sys_enterpriseids.isEmpty()) {
|
|
|
|
|
+ for (Row agentRow : agentAreaRows) {
|
|
|
|
|
+ if (agentRow.getString("province").contains(province) && agentRow.getString("city").contains(city) && agentRow.getString("county").isEmpty()) {
|
|
|
|
|
+ match_sys_enterpriseids.add(agentRow.getLong("sys_enterpriseid"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //匹配到省
|
|
|
|
|
+ if (match_sys_enterpriseids.isEmpty()) {
|
|
|
|
|
+ for (Row agentRow : agentAreaRows) {
|
|
|
|
|
+ if (agentRow.getString("province").contains(province) && agentRow.getString("city").isEmpty() && agentRow.getString("county").isEmpty()) {
|
|
|
|
|
+ match_sys_enterpriseids.add(agentRow.getLong("sys_enterpriseid"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (match_sys_enterpriseids.isEmpty()) {
|
|
|
|
|
+ for (Row agentRow : agentAreaRows) {
|
|
|
|
|
+ if (agentRow.getString("province").contains(province) && agentRow.getString("county").contains(county)) {
|
|
|
|
|
+ match_sys_enterpriseids.add(agentRow.getLong("sys_enterpriseid"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (match_sys_enterpriseids.size() == 1) {
|
|
|
|
|
+ long sys_enterpriseid = match_sys_enterpriseids.get(0);
|
|
|
|
|
+ InsertSQL satOrderclueAuth = SQLFactory.createInsertSQL(this, "sat_orderclue_auth");
|
|
|
|
|
+ satOrderclueAuth.setValue("sat_orderclueid", sat_orderclueid);
|
|
|
|
|
+ satOrderclueAuth.setValue("sys_enterpriseid", sys_enterpriseid);
|
|
|
|
|
+ satOrderclueAuth.setValue("isused", true);
|
|
|
|
|
+ satOrderclueAuth.setValue("hrid", enterprise_hridMap.get(String.valueOf(sys_enterpriseid)).get(0).getLong("sys_enterprise_hrid"));
|
|
|
|
|
+ sqlList.add(satOrderclueAuth);
|
|
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sat_orderclue", sat_orderclueid, "分配", "线索分配成功!"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlList.commit(this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return getSucReturnObject().toString();
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
}
|
|
|
|
|
|