|
@@ -89,7 +89,7 @@ public class JhmTask {
|
|
|
FsCompanyCustomer newCustomer = new FsCompanyCustomer();
|
|
FsCompanyCustomer newCustomer = new FsCompanyCustomer();
|
|
|
newCustomer.setPhone(phone);
|
|
newCustomer.setPhone(phone);
|
|
|
newCustomer.setCustomerName(order.getBuyer().getConsignee());
|
|
newCustomer.setCustomerName(order.getBuyer().getConsignee());
|
|
|
- newCustomer.setAddress(order.getBuyer().getAddressDetail());
|
|
|
|
|
|
|
+ newCustomer.setAddress(buildFullAddress(order.getBuyer()));
|
|
|
|
|
|
|
|
// 成交状态:订单状态为4(已完成)设为1,否则0
|
|
// 成交状态:订单状态为4(已完成)设为1,否则0
|
|
|
Integer kdzlMakeStatus = (order.getStatus() != null && order.getStatus() == 4) ? 1 : 0;
|
|
Integer kdzlMakeStatus = (order.getStatus() != null && order.getStatus() == 4) ? 1 : 0;
|
|
@@ -111,13 +111,12 @@ public class JhmTask {
|
|
|
newCustomer.setProcessStatus(0); // 待完善
|
|
newCustomer.setProcessStatus(0); // 待完善
|
|
|
|
|
|
|
|
toInsertList.add(newCustomer);
|
|
toInsertList.add(newCustomer);
|
|
|
- log.debug("新增客户,手机号[{}]", phone);
|
|
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ========== 客户已存在,判断是否需要更新 ==========
|
|
// ========== 客户已存在,判断是否需要更新 ==========
|
|
|
Integer kdzlMakeStatus = (order.getStatus() != null && order.getStatus() == 4) ? 1 : 0;
|
|
Integer kdzlMakeStatus = (order.getStatus() != null && order.getStatus() == 4) ? 1 : 0;
|
|
|
- String address = order.getBuyer().getAddressDetail();
|
|
|
|
|
|
|
+ String address = buildFullAddress(order.getBuyer());
|
|
|
String customerName = order.getBuyer().getConsignee();
|
|
String customerName = order.getBuyer().getConsignee();
|
|
|
Date orderTime = order.getCreatedAt() != null ?
|
|
Date orderTime = order.getCreatedAt() != null ?
|
|
|
Date.from(Instant.ofEpochSecond(order.getCreatedAt())) : null;
|
|
Date.from(Instant.ofEpochSecond(order.getCreatedAt())) : null;
|
|
@@ -231,4 +230,59 @@ public class JhmTask {
|
|
|
}
|
|
}
|
|
|
return response.getData();
|
|
return response.getData();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建完整收货地址,避免省市区与详细地址重复
|
|
|
|
|
+ */
|
|
|
|
|
+ private String buildFullAddress(JHMOrderDetail.Buyer buyer) {
|
|
|
|
|
+ String province = buyer.getProvince();
|
|
|
|
|
+ String city = buyer.getCity();
|
|
|
|
|
+ String area = buyer.getArea();
|
|
|
|
|
+ String address = buyer.getAddress();
|
|
|
|
|
+ String addressDetail = buyer.getAddressDetail();
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 优先使用省市区独立字段 + 详细地址
|
|
|
|
|
+ if (isNotBlank(province) || isNotBlank(city) || isNotBlank(area)) {
|
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
|
+ if (isNotBlank(province)) sb.append(province);
|
|
|
|
|
+ if (isNotBlank(city)) {
|
|
|
|
|
+ if (sb.length() > 0) sb.append(" ");
|
|
|
|
|
+ sb.append(city);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isNotBlank(area)) {
|
|
|
|
|
+ if (sb.length() > 0) sb.append(" ");
|
|
|
|
|
+ sb.append(area);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isNotBlank(addressDetail)) {
|
|
|
|
|
+ if (sb.length() > 0) sb.append(" ");
|
|
|
|
|
+ sb.append(addressDetail);
|
|
|
|
|
+ }
|
|
|
|
|
+ return sb.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 省市区字段均为空,使用 address 和 addressDetail 组合
|
|
|
|
|
+ if (isBlank(address)) {
|
|
|
|
|
+ return addressDetail == null ? "" : addressDetail;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isBlank(addressDetail)) {
|
|
|
|
|
+ return address;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 去重处理:若一个包含另一个,取较长者;否则用空格拼接
|
|
|
|
|
+ if (address.contains(addressDetail) || addressDetail.contains(address)) {
|
|
|
|
|
+ return address.length() >= addressDetail.length() ? address : addressDetail;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return address + " " + addressDetail;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 字符串判空辅助方法
|
|
|
|
|
+ private boolean isBlank(String str) {
|
|
|
|
|
+ return str == null || str.trim().isEmpty();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean isNotBlank(String str) {
|
|
|
|
|
+ return !isBlank(str);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|