|
@@ -29,89 +29,92 @@ public class customer extends CrmBase {
|
|
|
RowsMap regionsMap = dbConnect.runSqlQuery("select code,name from t_regions where countryid=1").toRowsMap("code");
|
|
RowsMap regionsMap = dbConnect.runSqlQuery("select code,name from t_regions where countryid=1").toRowsMap("code");
|
|
|
|
|
|
|
|
for (Row row : rows) {
|
|
for (Row row : rows) {
|
|
|
- JSONObject jsonObject = row.toJsonObject();
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ JSONObject jsonObject = row.toJsonObject();
|
|
|
|
|
+ long syncid = jsonObject.getLong("syncid");
|
|
|
|
|
+ long cid = jsonObject.getLong("cid");
|
|
|
|
|
+ String createby = jsonObject.getString("createby");
|
|
|
|
|
+ String createtime = jsonObject.getString("createtime");
|
|
|
|
|
+ String changeby = jsonObject.getString("changeby");
|
|
|
|
|
+ String changetime = jsonObject.getString("changetime");
|
|
|
|
|
+ String customer_status = jsonObject.getString("customer_status");
|
|
|
|
|
+ String fchannel = jsonObject.getString("fchannel");
|
|
|
|
|
+ String fname = jsonObject.getString("fname");
|
|
|
|
|
+ String fphone = jsonObject.getString("fphone");
|
|
|
|
|
+ String fcommunity = jsonObject.getString("fcommunity");
|
|
|
|
|
+ String fcustom_num = jsonObject.getString("fcustom_num");
|
|
|
|
|
+ String fagent_num_created = jsonObject.getString("fagent_num_created");
|
|
|
|
|
+ String fagent_num = jsonObject.getString("fagent_num");
|
|
|
|
|
+ String fprovince = jsonObject.getString("fprovince");
|
|
|
|
|
+ String fcity = jsonObject.getString("fcity");
|
|
|
|
|
+ String fcounty = jsonObject.getString("fcounty");
|
|
|
|
|
|
|
|
- long syncid = jsonObject.getLong("syncid");
|
|
|
|
|
- long cid = jsonObject.getLong("cid");
|
|
|
|
|
- String createby = jsonObject.getString("createby");
|
|
|
|
|
- String createtime = jsonObject.getString("createtime");
|
|
|
|
|
- String changeby = jsonObject.getString("changeby");
|
|
|
|
|
- String changetime = jsonObject.getString("changetime");
|
|
|
|
|
- String customer_status = jsonObject.getString("customer_status");
|
|
|
|
|
- String fchannel = jsonObject.getString("fchannel");
|
|
|
|
|
- String fname = jsonObject.getString("fname");
|
|
|
|
|
- String fphone = jsonObject.getString("fphone");
|
|
|
|
|
- String fcommunity = jsonObject.getString("fcommunity");
|
|
|
|
|
- String fcustom_num = jsonObject.getString("fcustom_num");
|
|
|
|
|
- String fagent_num_created = jsonObject.getString("fagent_num_created");
|
|
|
|
|
- String fagent_num = jsonObject.getString("fagent_num");
|
|
|
|
|
- String fprovince = jsonObject.getString("fprovince");
|
|
|
|
|
- String fcity = jsonObject.getString("fcity");
|
|
|
|
|
- String fcounty = jsonObject.getString("fcounty");
|
|
|
|
|
|
|
+ if (agentRowsMap.containsKey(fagent_num_created)) {
|
|
|
|
|
+ if (dbConnect.runSqlQuery("select * from sa_customers where sa_customersid=" + cid).isEmpty()) {
|
|
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(dbConnect, "sa_customers");
|
|
|
|
|
+ insertSQL.setValue("siteid", "MD");
|
|
|
|
|
+ insertSQL.setValue("sa_customersid", cid);
|
|
|
|
|
+ insertSQL.setValue("createby", createby);
|
|
|
|
|
+ insertSQL.setValue("createdate", createtime);
|
|
|
|
|
+ insertSQL.setValue("changeby", changeby);
|
|
|
|
|
+ insertSQL.setValue("changedate", changetime);
|
|
|
|
|
+ insertSQL.setValue("sys_enterpriseid", agentRowsMap.get(fagent_num_created).get(0).getLong("sys_enterpriseid"));
|
|
|
|
|
+ insertSQL.setValue("sa_agentsid", agentRowsMap.get(fagent_num_created).get(0).getLong("sa_agentsid"));
|
|
|
|
|
+ if (agentRowsMap.containsKey(fagent_num)) {
|
|
|
|
|
+ insertSQL.setValue("sa_agentsid_to", agentRowsMap.get(fagent_num).get(0).getLong("sa_agentsid"));
|
|
|
|
|
+ }
|
|
|
|
|
+ insertSQL.setValue("status", customer_status);
|
|
|
|
|
+ insertSQL.setValue("source", fchannel);
|
|
|
|
|
+ insertSQL.setValue("tradingstatus", customer_status.equals("正式客户") ? "已成交" : "未成交");
|
|
|
|
|
+ insertSQL.setValue("datastatus", 0);
|
|
|
|
|
+ insertSQL.setValue("ispublic", 0);
|
|
|
|
|
+ insertSQL.setValue("name", fname);
|
|
|
|
|
+ insertSQL.setValue("phonenumber", fphone);
|
|
|
|
|
+ if (regionsMap.containsKey(fprovince)) {
|
|
|
|
|
+ insertSQL.setValue("province", regionsMap.get(fprovince).get(0).getString("name"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (regionsMap.containsKey(fcity)) {
|
|
|
|
|
+ insertSQL.setValue("city", regionsMap.get(fcity).get(0).getString("name"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (regionsMap.containsKey(fcounty)) {
|
|
|
|
|
+ insertSQL.setValue("county", regionsMap.get(fcounty).get(0).getString("name"));
|
|
|
|
|
+ }
|
|
|
|
|
+ insertSQL.setValue("address", fcommunity);
|
|
|
|
|
+ insertSQL.setValue("custnum", fcustom_num);
|
|
|
|
|
+ insertSQL.insert();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(dbConnect, "sa_customers");
|
|
|
|
|
+ updateSQL.setValue("changeby", changeby);
|
|
|
|
|
+ updateSQL.setValue("changedate", changetime);
|
|
|
|
|
+ if (agentRowsMap.containsKey(fagent_num)) {
|
|
|
|
|
+ updateSQL.setValue("sa_agentsid_to", agentRowsMap.get(fagent_num).get(0).getLong("sa_agentsid"));
|
|
|
|
|
+ }
|
|
|
|
|
+ updateSQL.setValue("status", customer_status);
|
|
|
|
|
+ updateSQL.setValue("source", fchannel);
|
|
|
|
|
+ updateSQL.setValue("tradingstatus", customer_status.equals("正式客户") ? "已成交" : "未成交");
|
|
|
|
|
+ updateSQL.setValue("name", fname);
|
|
|
|
|
+ updateSQL.setValue("phonenumber", fphone);
|
|
|
|
|
+ if (regionsMap.containsKey(fprovince)) {
|
|
|
|
|
+ updateSQL.setValue("province", regionsMap.get(fprovince).get(0).getString("name"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (regionsMap.containsKey(fcity)) {
|
|
|
|
|
+ updateSQL.setValue("city", regionsMap.get(fcity).get(0).getString("name"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (regionsMap.containsKey(fcounty)) {
|
|
|
|
|
+ updateSQL.setValue("county", regionsMap.get(fcounty).get(0).getString("name"));
|
|
|
|
|
+ }
|
|
|
|
|
+ updateSQL.setValue("address", fcommunity);
|
|
|
|
|
+ updateSQL.setValue("custnum", fcustom_num);
|
|
|
|
|
|
|
|
- if (agentRowsMap.containsKey(fagent_num_created)) {
|
|
|
|
|
- if (dbConnect.runSqlQuery("select * from sa_customers where sa_customersid=" + cid).isEmpty()) {
|
|
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(dbConnect, "sa_customers");
|
|
|
|
|
- insertSQL.setValue("siteid", "MD");
|
|
|
|
|
- insertSQL.setValue("sa_customersid", cid);
|
|
|
|
|
- insertSQL.setValue("createby", createby);
|
|
|
|
|
- insertSQL.setValue("createdate", createtime);
|
|
|
|
|
- insertSQL.setValue("changeby", changeby);
|
|
|
|
|
- insertSQL.setValue("changedate", changetime);
|
|
|
|
|
- insertSQL.setValue("sys_enterpriseid", agentRowsMap.get(fagent_num_created).get(0).getLong("sys_enterpriseid"));
|
|
|
|
|
- insertSQL.setValue("sa_agentsid", agentRowsMap.get(fagent_num_created).get(0).getLong("sa_agentsid"));
|
|
|
|
|
- if (agentRowsMap.containsKey(fagent_num)) {
|
|
|
|
|
- insertSQL.setValue("sa_agentsid_to", agentRowsMap.get(fagent_num).get(0).getLong("sa_agentsid"));
|
|
|
|
|
|
|
+ updateSQL.setWhere("siteid", "MD");
|
|
|
|
|
+ updateSQL.setWhere("sa_customersid", cid);
|
|
|
|
|
+ updateSQL.update();
|
|
|
}
|
|
}
|
|
|
- insertSQL.setValue("status", customer_status);
|
|
|
|
|
- insertSQL.setValue("source", fchannel);
|
|
|
|
|
- insertSQL.setValue("tradingstatus", customer_status.equals("正式客户") ? "已成交" : "未成交");
|
|
|
|
|
- insertSQL.setValue("datastatus", 0);
|
|
|
|
|
- insertSQL.setValue("ispublic", 0);
|
|
|
|
|
- insertSQL.setValue("name", fname);
|
|
|
|
|
- insertSQL.setValue("phonenumber", fphone);
|
|
|
|
|
- if (regionsMap.containsKey(fprovince)) {
|
|
|
|
|
- insertSQL.setValue("province", regionsMap.get(fprovince).get(0).getString("name"));
|
|
|
|
|
- }
|
|
|
|
|
- if (regionsMap.containsKey(fcity)) {
|
|
|
|
|
- insertSQL.setValue("city", regionsMap.get(fcity).get(0).getString("name"));
|
|
|
|
|
- }
|
|
|
|
|
- if (regionsMap.containsKey(fcounty)) {
|
|
|
|
|
- insertSQL.setValue("county", regionsMap.get(fcounty).get(0).getString("name"));
|
|
|
|
|
- }
|
|
|
|
|
- insertSQL.setValue("address", fcommunity);
|
|
|
|
|
- insertSQL.setValue("custnum", fcustom_num);
|
|
|
|
|
- insertSQL.insert();
|
|
|
|
|
- } else {
|
|
|
|
|
- UpdateSQL updateSQL = SQLFactory.createUpdateSQL(dbConnect, "sa_customers");
|
|
|
|
|
- updateSQL.setValue("changeby", changeby);
|
|
|
|
|
- updateSQL.setValue("changedate", changetime);
|
|
|
|
|
- if (agentRowsMap.containsKey(fagent_num)) {
|
|
|
|
|
- updateSQL.setValue("sa_agentsid_to", agentRowsMap.get(fagent_num).get(0).getLong("sa_agentsid"));
|
|
|
|
|
- }
|
|
|
|
|
- updateSQL.setValue("status", customer_status);
|
|
|
|
|
- updateSQL.setValue("source", fchannel);
|
|
|
|
|
- updateSQL.setValue("tradingstatus", customer_status.equals("正式客户") ? "已成交" : "未成交");
|
|
|
|
|
- updateSQL.setValue("name", fname);
|
|
|
|
|
- updateSQL.setValue("phonenumber", fphone);
|
|
|
|
|
- if (regionsMap.containsKey(fprovince)) {
|
|
|
|
|
- updateSQL.setValue("province", regionsMap.get(fprovince).get(0).getString("name"));
|
|
|
|
|
- }
|
|
|
|
|
- if (regionsMap.containsKey(fcity)) {
|
|
|
|
|
- updateSQL.setValue("city", regionsMap.get(fcity).get(0).getString("name"));
|
|
|
|
|
- }
|
|
|
|
|
- if (regionsMap.containsKey(fcounty)) {
|
|
|
|
|
- updateSQL.setValue("county", regionsMap.get(fcounty).get(0).getString("name"));
|
|
|
|
|
- }
|
|
|
|
|
- updateSQL.setValue("address", fcommunity);
|
|
|
|
|
- updateSQL.setValue("custnum", fcustom_num);
|
|
|
|
|
-
|
|
|
|
|
- updateSQL.setWhere("siteid", "MD");
|
|
|
|
|
- updateSQL.setWhere("sa_customersid", cid);
|
|
|
|
|
- updateSQL.update();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ crmDBConnect.runSqlUpdate("delete from e_order_sync where ownertable='st_customer' and ownerid=" + cid + " and id<=" + syncid);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
}
|
|
}
|
|
|
- crmDBConnect.runSqlUpdate("delete from e_order_sync where ownertable='st_customer' and ownerid=" + cid + " and id<=" + syncid);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|