20230922-ljl-fixBug
ljl 1 year ago
parent 34a0995947
commit f045e53a9d

@ -21,6 +21,7 @@ import com.ms.api.dto.dsorder.ResultDTO;
import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO; import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO;
import com.ms.api.exception.DeliveryNotReceivedException; import com.ms.api.exception.DeliveryNotReceivedException;
import com.ms.api.service.*; import com.ms.api.service.*;
import com.ms.api.tool.CommonTool;
import com.ms.api.tool.OrderTool; import com.ms.api.tool.OrderTool;
import com.ms.api.tool.PurchaseTool; import com.ms.api.tool.PurchaseTool;
import com.ms.dal.bo.OpLogisticsBO; import com.ms.dal.bo.OpLogisticsBO;
@ -106,7 +107,7 @@ public class OutstorageServiceImpl implements OutstorageService {
dataSourceTransactionManager.commit(transactionStatus); dataSourceTransactionManager.commit(transactionStatus);
} catch (Throwable e) { } catch (Throwable e) {
dataSourceTransactionManager.rollback(transactionStatus); dataSourceTransactionManager.rollback(transactionStatus);
log.error("saveOrderMultiPackageOutstorageResult transaction error: ", e); log.error("saveOrderMultiPackageOutstorageResultTransactionError: ", e);
throw new RuntimeException("处理异常"); throw new RuntimeException("处理异常");
} }
return result; return result;
@ -241,7 +242,13 @@ public class OutstorageServiceImpl implements OutstorageService {
} }
opOrderOutstorageHistoryService.addHistoryByOrder(opOrder, Integer.valueOf(packageInfo.getLogisticsId()), packageInfo.getLogisticsCode(), source, 0, result); opOrderOutstorageHistoryService.addHistoryByOrder(opOrder, Integer.valueOf(packageInfo.getLogisticsId()), packageInfo.getLogisticsCode(), source, 0, result);
} }
try {
updateOrderStatusAfterPackageSend(Collections.singletonList(opOrder.getOrderId())); updateOrderStatusAfterPackageSend(Collections.singletonList(opOrder.getOrderId()));
} catch (Throwable e) {
log.error("updateOrderStatusAfterPackageSendError", e);
throw new RuntimeException(e.getMessage() == null ? "处理数据状态异常": e.getMessage());
}
} }
private Map<Long, OpLogisticsBO> getDdLogisticsListByLogisticsIds(List<String> logisticsIds) { private Map<Long, OpLogisticsBO> getDdLogisticsListByLogisticsIds(List<String> logisticsIds) {
@ -500,6 +507,7 @@ public class OutstorageServiceImpl implements OutstorageService {
log.info("orderIdAndChildOrderIdAndComboNumMap: " + orderIdAndChildOrderIdAndComboNumMap); log.info("orderIdAndChildOrderIdAndComboNumMap: " + orderIdAndChildOrderIdAndComboNumMap);
List<OpOrderChildLogistics> childLogisticsRows = opOrderChildLogisticsService.getListByOrderIds(orderIds); List<OpOrderChildLogistics> childLogisticsRows = opOrderChildLogisticsService.getListByOrderIds(orderIds);
Map<String, Map<String, Integer>> orderIdAndChildOrderIdAndShippedNumMap = new HashMap<>(); Map<String, Map<String, Integer>> orderIdAndChildOrderIdAndShippedNumMap = new HashMap<>();
log.info("childLogisticsRows: " + childLogisticsRows);
for (OpOrderChildLogistics childLogistics: childLogisticsRows) { for (OpOrderChildLogistics childLogistics: childLogisticsRows) {
Map<String, Integer> childOrderIdAndShippedNumMap = new HashMap<>(); Map<String, Integer> childOrderIdAndShippedNumMap = new HashMap<>();
if (orderIdAndChildOrderIdAndShippedNumMap.containsKey(childLogistics.getOrderId())) { if (orderIdAndChildOrderIdAndShippedNumMap.containsKey(childLogistics.getOrderId())) {
@ -512,18 +520,20 @@ public class OutstorageServiceImpl implements OutstorageService {
} }
orderIdAndChildOrderIdAndShippedNumMap.put(childLogistics.getOrderId(), childOrderIdAndShippedNumMap); orderIdAndChildOrderIdAndShippedNumMap.put(childLogistics.getOrderId(), childOrderIdAndShippedNumMap);
} }
log.info("orderIdAndChildOrderIdAndComboNumMap: " + orderIdAndChildOrderIdAndComboNumMap); log.info("orderIdAndChildOrderIdAndShippedNumMap: " + orderIdAndChildOrderIdAndShippedNumMap);
List<Integer> beforeStatusList = new ArrayList<>(); List<Integer> beforeStatusList = new ArrayList<>();
beforeStatusList.add(OrderConst.ORDER_STATUS_WAIT_SELLER_SEND_GOODS); beforeStatusList.add(OrderConst.ORDER_STATUS_WAIT_SELLER_SEND_GOODS);
beforeStatusList.add(OrderConst.ORDER_STATUS_PART_DELIVERY); beforeStatusList.add(OrderConst.ORDER_STATUS_PART_DELIVERY);
for (Map.Entry<String, Map<String, Integer>> entry: orderIdAndChildOrderIdAndComboNumMap.entrySet()) { for (Map.Entry<String, Map<String, Integer>> entry: orderIdAndChildOrderIdAndComboNumMap.entrySet()) {
String orderId = entry.getKey(); String orderId = entry.getKey();
Map<String, Integer> comboIdAndShippedNumMap = orderIdAndChildOrderIdAndShippedNumMap.get(orderId); Map<String, Integer> comboIdAndShippedNumMap = orderIdAndChildOrderIdAndShippedNumMap.get(orderId);
log.info("comboIdAndShippedNumMap: " + comboIdAndShippedNumMap);
boolean allNotShipped = true; boolean allNotShipped = true;
boolean allShipped = true; boolean allShipped = true;
for (Map.Entry<String, Integer> subEntry: entry.getValue().entrySet()) { for (Map.Entry<String, Integer> subEntry: entry.getValue().entrySet()) {
String childOrderId = subEntry.getKey(); String childOrderId = subEntry.getKey();
Integer comboNum = subEntry.getValue(); Integer comboNum = subEntry.getValue();
log.info("childOrderId: " + childOrderId);
Integer shippedNum = comboIdAndShippedNumMap.get(childOrderId); Integer shippedNum = comboIdAndShippedNumMap.get(childOrderId);
if (shippedNum == 0) { if (shippedNum == 0) {
allShipped = false; allShipped = false;
@ -535,6 +545,7 @@ public class OutstorageServiceImpl implements OutstorageService {
allShipped = false; allShipped = false;
childOrderStatus = OrderConst.ORDER_STATUS_PART_DELIVERY; childOrderStatus = OrderConst.ORDER_STATUS_PART_DELIVERY;
} }
log.info("updateOrderStatusByChildOrderId: " + childOrderStatus + "_" + orderId + "_" + childOrderId + "_" + beforeStatusList);
opOrderChildService.updateOrderStatusByChildOrderId(childOrderStatus, orderId, childOrderId, beforeStatusList); opOrderChildService.updateOrderStatusByChildOrderId(childOrderStatus, orderId, childOrderId, beforeStatusList);
} }
if (allNotShipped) { if (allNotShipped) {
@ -543,6 +554,7 @@ public class OutstorageServiceImpl implements OutstorageService {
Integer orderStatus = allShipped ? OrderConst.ORDER_STATUS_WAIT_BUYER_CONFIRM_GOODS : OrderConst.ORDER_STATUS_PART_DELIVERY; Integer orderStatus = allShipped ? OrderConst.ORDER_STATUS_WAIT_BUYER_CONFIRM_GOODS : OrderConst.ORDER_STATUS_PART_DELIVERY;
opOrderService.updateOrderStatusByOrderId(orderStatus, orderId, beforeStatusList); opOrderService.updateOrderStatusByOrderId(orderStatus, orderId, beforeStatusList);
} }
log.info("finishUpdateOrderStatusAfterPackageSend");
} }
private static Map<String, Map<String, Integer>> buildOrderIdAndChildOrderIdAndComboNumMap(List<OpOrderChild> children) { private static Map<String, Map<String, Integer>> buildOrderIdAndChildOrderIdAndComboNumMap(List<OpOrderChild> children) {
@ -791,22 +803,19 @@ public class OutstorageServiceImpl implements OutstorageService {
public String getCorrectDdWaybillCode(String waybillCode, String logisticsName) { public String getCorrectDdWaybillCode(String waybillCode, String logisticsName) {
waybillCode = waybillCode.trim().toUpperCase(); waybillCode = waybillCode.trim().toUpperCase();
Pattern p = Pattern.compile("^([T|W])JT\\d+$"); Pattern p = Pattern.compile("^([T|W])(JT\\d+)$");
Matcher m = p.matcher(waybillCode); Matcher m = p.matcher(waybillCode);
if (m.find()) { if (m.find()) {
String field = m.group(1); waybillCode = m.group(2);
waybillCode = waybillCode.replaceAll("^([T|W])JT\\d+$", field);
} }
p = Pattern.compile("^\\d+$"); if ("极兔快递".equals(logisticsName) && Pattern.compile("^\\d+$").matcher(waybillCode).find()) {
m = p.matcher(waybillCode);
if ("极兔快递".equals(logisticsName) && m.find()) {
return "JT" + waybillCode; return "JT" + waybillCode;
} }
String[] others = {"其他", "其它", "其它快递"}; String[] others = {"其他", "其它", "其它快递"};
List<String> otherList = Arrays.stream(others).collect(Collectors.toList()); List<String> otherList = Arrays.stream(others).collect(Collectors.toList());
if (otherList.contains(logisticsName)) { if (otherList.contains(logisticsName)) {
Matcher m2 = Pattern.compile("^[A-Z]{2}YT\\d+$").matcher(waybillCode); Matcher m2 = Pattern.compile("^[A-Z]{2}(YT\\d+)$").matcher(waybillCode);
Matcher m3 = Pattern.compile("^[A-Z]{2}JT\\d+$").matcher(waybillCode); Matcher m3 = Pattern.compile("^[A-Z]{2}(JT\\d+)$").matcher(waybillCode);
p = Pattern.compile("^T77[03567]\\d+$"); p = Pattern.compile("^T77[03567]\\d+$");
if (p.matcher(waybillCode).find()) { if (p.matcher(waybillCode).find()) {
@ -820,11 +829,9 @@ public class OutstorageServiceImpl implements OutstorageService {
} else if (Pattern.compile("^TYT\\d+$").matcher(waybillCode).find()) { } else if (Pattern.compile("^TYT\\d+$").matcher(waybillCode).find()) {
return waybillCode.replaceAll("^T", ""); return waybillCode.replaceAll("^T", "");
} else if (m2.find()) { } else if (m2.find()) {
String field = m.group(1); return m.group(2);
return waybillCode.replaceAll("^([A-Z]{2})(YT\\d+)$", field);
} else if (m3.find()) { } else if (m3.find()) {
String field = m.group(1); return m.group(2);
return waybillCode.replaceAll("^([A-Z]{2})(JT\\d+)$", field);
} }
} }
if (Pattern.compile("^WL77[03567]\\d+$").matcher(waybillCode).find() && Objects.equals(logisticsName, "点点送")) { if (Pattern.compile("^WL77[03567]\\d+$").matcher(waybillCode).find() && Objects.equals(logisticsName, "点点送")) {
@ -855,7 +862,6 @@ public class OutstorageServiceImpl implements OutstorageService {
if (logisticsName.contains("丹鸟")) { if (logisticsName.contains("丹鸟")) {
logisticsName = "丹鸟"; logisticsName = "丹鸟";
} }
logisticsName = logisticsName.replaceAll("\\([^\\\\(]+\\)", ""); logisticsName = logisticsName.replaceAll("\\([^\\\\(]+\\)", "");
logisticsName = logisticsName.replace("股份", ""); logisticsName = logisticsName.replace("股份", "");
logisticsName = logisticsName.replace("'有限公司'", ""); logisticsName = logisticsName.replace("'有限公司'", "");
@ -867,7 +873,7 @@ public class OutstorageServiceImpl implements OutstorageService {
} }
} }
if (logisticsName.contains("中通") && logisticsName.contains("中通快运") || Arrays.asList("其他", "其它", "其它快递", "卖家负责配送").contains(logisticsName) && Pattern.compile("^78299\\d+$").matcher(waybillCode).find()) { if ((logisticsName.contains("中通") && logisticsName.contains("中通快运")) || (Arrays.asList("其他", "其它", "其它快递", "卖家负责配送").contains(logisticsName) && CommonTool.isMatch("^78299\\d+$", waybillCode))) {
logisticsName = "中通快递"; logisticsName = "中通快递";
} }
if (logisticsName.contains("EMS") || logisticsName.contains("邮政标准")) { if (logisticsName.contains("EMS") || logisticsName.contains("邮政标准")) {
@ -876,13 +882,13 @@ public class OutstorageServiceImpl implements OutstorageService {
logisticsName = "邮政快递包裹"; logisticsName = "邮政快递包裹";
} }
if (logisticsName.contains("圆通") && logisticsName.contains("圆通快运") || Arrays.asList("其他", "其它", "其它快递", "卖家负责配送").contains(logisticsName) && Pattern.compile("^YT\\d+$").matcher(waybillCode).find()) { if ((logisticsName.contains("圆通") && logisticsName.contains("圆通快运")) || (Arrays.asList("其他", "其它", "其它快递", "卖家负责配送").contains(logisticsName) && Pattern.compile("^YT\\d+$").matcher(waybillCode).find())) {
logisticsName = "圆通快递"; logisticsName = "圆通快递";
} }
if (logisticsName.contains("国通")) { if (logisticsName.contains("国通")) {
logisticsName = "国通快递"; logisticsName = "国通快递";
} }
if (logisticsName.contains("申通达") || ( Arrays.asList("点点送", "菜鸟裹裹商家寄件", "官方直送", "其他", "其它", "其它快递", "卖家负责配送").contains(logisticsName) && Pattern.compile("^77[03567]\\d+$").matcher(waybillCode).find())) { if (logisticsName.contains("申通达") || (Arrays.asList("点点送", "菜鸟裹裹商家寄件", "官方直送", "其他", "其它", "其它快递", "卖家负责配送").contains(logisticsName) && Pattern.compile("^77[03567]\\d+$").matcher(waybillCode).find())) {
logisticsName = "申通快递"; logisticsName = "申通快递";
} }
if ((logisticsName.contains("韵达") && logisticsName.contains("韵达快运")) || ("官方物流".equals(logisticsName) && Pattern.compile("^462\\d+$").matcher(waybillCode).find())) { if ((logisticsName.contains("韵达") && logisticsName.contains("韵达快运")) || ("官方物流".equals(logisticsName) && Pattern.compile("^462\\d+$").matcher(waybillCode).find())) {
@ -923,14 +929,10 @@ public class OutstorageServiceImpl implements OutstorageService {
if (LogisticsConst.getIgnoreNoticeLogisticsNameList().contains(logisticsName)) { if (LogisticsConst.getIgnoreNoticeLogisticsNameList().contains(logisticsName)) {
return true; return true;
} }
Pattern p1 = Pattern.compile("^(LE)?\\d+$"); if (Pattern.compile("^(LE)?\\d+$").matcher(logisticsName).find()) {
Matcher m1 = p1.matcher(logisticsName);
if (m1.find()) {
return true; return true;
} }
Pattern p2 = Pattern.compile("^[\\da-zA-Z]+$"); if (Objects.equals(waybillCode, "-") || !Pattern.compile("^[\\da-zA-Z]+$").matcher(waybillCode).find()) {
Matcher m2 = p2.matcher(waybillCode);
if (Objects.equals(waybillCode, "-") || !m2.find()) {
return true; return true;
} }
if (waybillCode.contains("停发")) { if (waybillCode.contains("停发")) {

@ -1019,4 +1019,8 @@ public class CommonTool {
} }
} }
} }
public static boolean isMatch(String regex, String str) {
return Pattern.compile(regex).matcher(str).find();
}
} }

Loading…
Cancel
Save