修改butg

20240115-ljl-multiPay
ljl 12 months ago
parent a21b15bf5e
commit f9e404d6b9

@ -1,8 +1,6 @@
package com.ms.biz.consts;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -106,4 +104,13 @@ public class LogisticsConst {
};
return Arrays.stream(logisticsNames).collect(Collectors.toList());
}
public static String getDDLogisticsName(String aliLogisticsName) {
Map<String, String> logisticsNameMap = new HashMap<>();
logisticsNameMap.put("顺丰速运", "顺丰速运(常用)");
if (logisticsNameMap.containsKey(aliLogisticsName)) {
return logisticsNameMap.get(aliLogisticsName);
}
return aliLogisticsName;
}
}

@ -0,0 +1,21 @@
package com.ms.biz.service;
import com.ms.dal.entity.LogisticsMatchRule;
/**
*
*/
public interface LogisticsMatchRuleService {
int deleteByPrimaryKey(Long id);
int insert(LogisticsMatchRule record);
int insertSelective(LogisticsMatchRule record);
LogisticsMatchRule selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(LogisticsMatchRule record);
int updateByPrimaryKey(LogisticsMatchRule record);
}

@ -0,0 +1,25 @@
package com.ms.biz.service;
import com.ms.dal.entity.Logistics;
import java.util.Map;
/**
*
*/
public interface LogisticsService {
int deleteByPrimaryKey(Long id);
int insert(Logistics record);
int insertSelective(Logistics record);
Logistics selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(Logistics record);
int updateByPrimaryKey(Logistics record);
Map<String, String> matchLogisticsInfo(String platform, String originLogisticsName, String originWaybillCode, Map<String, Logistics> logisticsNameAndLogisticsInfoMap);
}

@ -1,6 +1,11 @@
package com.ms.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.order_logisticsAddMultiPack.param.OrderLogisticsAddMultiPackParam;
import com.doudian.open.api.order_logisticsAddMultiPack.param.PackListItem;
import com.doudian.open.api.order_logisticsAddMultiPack.param.ShippedOrderInfoItem;
import com.doudian.open.api.supplyCenter_order_cancel.param.SupplyCenterOrderCancelParam;
import com.doudian.open.api.supplyCenter_order_confirm.param.SupplyCenterOrderConfirmParam;
import com.doudian.open.api.supplyCenter_order_logistics.param.SupplyCenterOrderLogisticsParam;
@ -13,10 +18,7 @@ import com.doudian.open.api.supplyCenter_refund_operate.param.Address;
import com.doudian.open.api.supplyCenter_refund_operate.param.SkuRefundInfosItem;
import com.doudian.open.api.supplyCenter_refund_operate.param.SupplyCenterRefundOperateParam;
import com.jinritemai.cloud.base.core.util.AuthThreadLocalUtil;
import com.ms.biz.consts.DsMessageConst;
import com.ms.biz.consts.PurchaseOrderConst;
import com.ms.biz.consts.Refund1688Const;
import com.ms.biz.consts.StatusConst;
import com.ms.biz.consts.*;
import com.ms.biz.quque.Group;
import com.ms.biz.quque.Producer;
import com.ms.biz.quque.Topic;
@ -56,6 +58,7 @@ public class DsMessageServiceImpl implements DsMessageService {
private PlatformPurchaseOrderSkuMapper platformPurchaseOrderSkuMapper;
private PurchaseOrderMapper purchaseOrderMapper;
private PurchaseOrderItemMapper purchaseOrderItemMapper;
private LogisticsMapper logisticsMapper;
@Override
public int deleteByPrimaryKey(Long id) {
@ -212,7 +215,7 @@ public class DsMessageServiceImpl implements DsMessageService {
switch (dsMessage.getBizType()) {
case DsMessageConst.BIZ_TYPE_RELATE_PURCHASE_ORDER:
handlePurchaseOrderRelate((PurchaseOrderRelateMessageDTO)messageDTO);
// handlePurchaseOrderRelate((PurchaseOrderRelateMessageDTO)messageDTO);
break;
case DsMessageConst.BIZ_TYPE_PURCHASE_ORDER_CHANGE:
handlePurchaseOrderChange((PurchaseOrderChangeMessageDTO)messageDTO);
@ -263,7 +266,7 @@ public class DsMessageServiceImpl implements DsMessageService {
handlePurchaseOrderAfterPay(purchaseOrderDTO, purchaseOrder, skuIdAndPlatformPurchaseOrderSkuMap);
break;
case PurchaseOrderConst.PURCHASE_ORDER_STATUS_HAS_SEND:
handlePurchaseOrderAfterSend(purchaseOrderDTO, purchaseOrder);
handlePurchaseOrderAfterSend(purchaseOrderDTO, purchaseOrder, skuIdAndPlatformPurchaseOrderSkuMap);
break;
case PurchaseOrderConst.PURCHASE_ORDER_STATUS_FINISHED:
handlePurchaseOrderAfterFinish(purchaseOrderDTO, purchaseOrder);
@ -309,7 +312,7 @@ public class DsMessageServiceImpl implements DsMessageService {
DDApi.supplyCenterOrderPay(param);
}
private void handlePurchaseOrderAfterSend(PurchaseOrderDTO purchaseOrderDTO, PurchaseOrder purchaseOrder) {
private void handlePurchaseOrderAfterSend(PurchaseOrderDTO purchaseOrderDTO, PurchaseOrder purchaseOrder, Map<Long, PlatformPurchaseOrderSku> skuIdAndPlatformPurchaseOrderSkuMap) {
Date purchaseOrderSendTime = CommonTool.parseDate(purchaseOrderDTO.getPurchaseOrderUpdateTime());
purchaseOrder.setPurchaseOrderSendTime(purchaseOrderSendTime);
purchaseOrder.setPurchaseOrderLogisticsName(purchaseOrder.getPurchaseOrderLogisticsName());
@ -322,6 +325,39 @@ public class DsMessageServiceImpl implements DsMessageService {
}
param.setExpressType(1);
DDApi.supplyCenterOrderLogistics(param);
logisticsAddMultiPack(purchaseOrderDTO, skuIdAndPlatformPurchaseOrderSkuMap);
}
private void logisticsAddMultiPack(PurchaseOrderDTO purchaseOrderDTO, Map<Long, PlatformPurchaseOrderSku> skuIdAndPlatformPurchaseOrderSkuMap) {
OrderLogisticsAddMultiPackParam param = new OrderLogisticsAddMultiPackParam();
param.setOrderId(purchaseOrderDTO.getPlatformOrderId());
List<PackListItem> packageList = new ArrayList<>();
PackListItem packListItem = new PackListItem();
packListItem.setLogisticsCode(purchaseOrderDTO.getPurchaseOrderWaybillCode());
String logisticsName = LogisticsConst.getDDLogisticsName(purchaseOrderDTO.getPurchaseOrderLogisticsName());
Logistics logistics = logisticsMapper.getByLogisticsName(logisticsName);
if (logistics == null) {
log.info("物流不存在: 1688[{}] 抖店[{}]", purchaseOrderDTO.getPurchaseOrderLogisticsName(), logisticsName);
throw new RuntimeException("物流不存在");
}
packListItem.setCompanyCode(logistics.getLogisticsCode());
packListItem.setCompanyCode(logisticsName);
List<ShippedOrderInfoItem> shippedOrderInfo = new ArrayList<>();
for (PurchaseOrderItemDTO item: purchaseOrderDTO.getItems()) {
PlatformPurchaseOrderSku platformPurchaseOrderSku = skuIdAndPlatformPurchaseOrderSkuMap.get(item.getSkuId());
ShippedOrderInfoItem shippedOrderInfoItem = new ShippedOrderInfoItem();
shippedOrderInfoItem.setShippedNum(Long.valueOf(item.getPurchaseNum()));
shippedOrderInfoItem.setShippedOrderId(platformPurchaseOrderSku.getSkuOrderId());
shippedOrderInfo.add(shippedOrderInfoItem);
}
packListItem.setShippedOrderInfo(shippedOrderInfo);
packageList.add(packListItem);
param.setPackList(packageList);
param.setRequestId(UUID.randomUUID().toString());
DDApi.logisticsAddMultiPack(param);
}
private void handlePurchaseOrderAfterFinish(PurchaseOrderDTO purchaseOrderDTO, PurchaseOrder purchaseOrder) {

@ -0,0 +1,53 @@
package com.ms.biz.service.impl;
import com.ms.dal.entity.LogisticsMatchRule;
import com.ms.biz.service.LogisticsMatchRuleService;
import com.ms.dal.mapper.LogisticsMatchRuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
*/
@Service
public class LogisticsMatchRuleServiceImpl implements LogisticsMatchRuleService {
@Autowired
private LogisticsMatchRuleMapper logisticsMatchRuleMapper;
@Override
public int deleteByPrimaryKey(Long id) {
return logisticsMatchRuleMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(LogisticsMatchRule record) {
return logisticsMatchRuleMapper.insert(record);
}
@Override
public int insertSelective(LogisticsMatchRule record) {
return logisticsMatchRuleMapper.insertSelective(record);
}
@Override
public LogisticsMatchRule selectByPrimaryKey(Long id) {
return logisticsMatchRuleMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(LogisticsMatchRule record) {
return logisticsMatchRuleMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(LogisticsMatchRule record) {
return logisticsMatchRuleMapper.updateByPrimaryKey(record);
}
}

@ -0,0 +1,276 @@
package com.ms.biz.service.impl;
import com.ms.biz.consts.LogisticsConst;
import com.ms.biz.tool.CommonTool;
import com.ms.dal.entity.Logistics;
import com.ms.biz.service.LogisticsService;
import com.ms.dal.entity.LogisticsMatchRule;
import com.ms.dal.mapper.LogisticsMapper;
import com.ms.dal.mapper.LogisticsMatchRuleMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
*
*/
@Slf4j
@Service
public class LogisticsServiceImpl implements LogisticsService{
@Autowired
private LogisticsMapper logisticsMapper;
@Autowired
private LogisticsMatchRuleMapper logisticsMatchRuleMapper;
@Override
public int deleteByPrimaryKey(Long id) {
return logisticsMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(Logistics record) {
return logisticsMapper.insert(record);
}
@Override
public int insertSelective(Logistics record) {
return logisticsMapper.insertSelective(record);
}
@Override
public Logistics selectByPrimaryKey(Long id) {
return logisticsMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(Logistics record) {
return logisticsMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(Logistics record) {
return logisticsMapper.updateByPrimaryKey(record);
}
@Override
public Map<String, String> matchLogisticsInfo(String platform, String originLogisticsName, String originWaybillCode, Map<String, Logistics> logisticsNameAndLogisticsInfoMap) {
if (logisticsNameAndLogisticsInfoMap == null) {
List<Logistics> logisticsList = logisticsMapper.getList();
logisticsNameAndLogisticsInfoMap = logisticsList.stream().collect(Collectors.toMap(Logistics::getLogisticsName, x -> x));
}
String logisticsName = correctLogisticsNameByLogisticsMatchRule(originLogisticsName, originWaybillCode, platform);
if (!isMatchDdLogistics(logisticsNameAndLogisticsInfoMap, logisticsName, originWaybillCode)) {
originWaybillCode = getCorrectDdWaybillCode(originWaybillCode, logisticsName);
logisticsName = correctLogisticsName(logisticsName, originWaybillCode);
}
boolean isMatch = logisticsNameAndLogisticsInfoMap.containsKey(logisticsName);
if (!isMatch && !isIgnoreNoticeLogisticsNameMismatch(logisticsName, originWaybillCode)) {
log.error("matchPurchaseLogisticsInfoError: " + logisticsName);
}
Map<String, String> result = new HashMap<>();
result.put("logisticsName", logisticsName);
result.put("waybillCode", originWaybillCode);
return result;
}
private String correctLogisticsNameByLogisticsMatchRule(String logisticsName, String purchaseOrderWaybillCode, String platform) {
List<LogisticsMatchRule> rules = logisticsMatchRuleMapper.getListByPlatform(platform);
if (rules.isEmpty()) {
return logisticsName;
}
for (LogisticsMatchRule rule: rules) {
String realLogisticsName = rule.getLogisticsName();
if (!"all".equals(rule.getPlatform()) && !rule.getPlatform().equals(platform)) {
break;
}
String purchaseLogisticsName = rule.getPlatformLogisticsName().toLowerCase();
String waybillCodeRule = rule.getWaybillCodeRule();
if (!purchaseLogisticsName.equals(logisticsName.toLowerCase())) {
continue;
}
if (!waybillCodeRule.isEmpty() && !purchaseOrderWaybillCode.isEmpty()) {
Pattern p = Pattern.compile(waybillCodeRule);
Matcher m = p.matcher(purchaseOrderWaybillCode);
if (!m.find()) {
continue;
}
}
logisticsName = realLogisticsName;
break;
}
return logisticsName;
}
private boolean isMatchDdLogistics(Map<String, Logistics> logisticsNameAndLogisticsInfoMap, String logisticsName, String waybillCode) {
boolean isMatch = logisticsNameAndLogisticsInfoMap.containsKey(logisticsName);
Pattern p = Pattern.compile("^JT\\d+$");
Matcher m = p.matcher(waybillCode.trim().toLowerCase());
if (m.find() && logisticsName.trim().toLowerCase().contains("龙邦速递")) {
isMatch = false;
}
return isMatch;
}
public String getCorrectDdWaybillCode(String waybillCode, String logisticsName) {
waybillCode = waybillCode.trim().toUpperCase();
Pattern p = Pattern.compile("^([T|W])(JT\\d+)$");
Matcher m = p.matcher(waybillCode);
if (m.find()) {
waybillCode = m.group(2);
}
if ("极兔快递".equals(logisticsName) && Pattern.compile("^\\d+$").matcher(waybillCode).find()) {
return "JT" + waybillCode;
}
String[] others = {"其他", "其它", "其它快递"};
List<String> otherList = Arrays.stream(others).collect(Collectors.toList());
if (otherList.contains(logisticsName)) {
Matcher m2 = Pattern.compile("^[A-Z]{2}(YT\\d+)$").matcher(waybillCode);
Matcher m3 = Pattern.compile("^[A-Z]{2}(JT\\d+)$").matcher(waybillCode);
p = Pattern.compile("^T77[03567]\\d+$");
if (p.matcher(waybillCode).find()) {
return waybillCode.trim();
} else if (Pattern.compile("^77[03567]\\d+ST$").matcher(waybillCode).find()) {
return waybillCode.replaceAll("^ST", "");
} else if (Pattern.compile("^A78299\\d+$").matcher(waybillCode).find()) {
return waybillCode.replaceAll("^A", "");
} else if (Pattern.compile("^YT\\d+YT$").matcher(waybillCode).find()) {
return waybillCode.replaceAll("^YT", "");
} else if (Pattern.compile("^TYT\\d+$").matcher(waybillCode).find()) {
return waybillCode.replaceAll("^T", "");
} else if (m2.find()) {
return m.group(2);
} else if (m3.find()) {
return m.group(2);
}
}
if (Pattern.compile("^WL77[03567]\\d+$").matcher(waybillCode).find() && Objects.equals(logisticsName, "点点送")) {
return waybillCode.replaceAll("^WL", "");
}
if (Pattern.compile("^WLJT\\d+$").matcher(waybillCode).find() && Objects.equals(logisticsName, "点点送")) {
return waybillCode.replaceAll("^WL", "");
}
if (Pattern.compile("^T462\\d+$").matcher(waybillCode).find() && Objects.equals(logisticsName, "官方物流")) {
return waybillCode.replaceAll("^T", "");
}
if (Pattern.compile("^CS\\d+$").matcher(waybillCode).find() && Objects.equals(logisticsName, "其他物流")) {
return waybillCode.replaceAll("^CS", "");
}
if (Pattern.compile("^KF\\d+$").matcher(waybillCode).find() && Objects.equals(logisticsName, "其他物流")) {
return waybillCode.replaceAll("^KF", "");
}
if (Pattern.compile("^EN\\d+$").matcher(waybillCode).find() && Objects.equals(logisticsName, "其他物流")) {
return waybillCode.replaceAll("^EN", "");
}
if (Pattern.compile("^JT\\d+Q$").matcher(waybillCode).find() && Objects.equals(logisticsName, "juti")) {
return waybillCode.replaceAll("^Q", "");
}
return waybillCode;
}
public String correctLogisticsName(String logisticsName, String waybillCode) {
if (logisticsName.contains("丹鸟")) {
logisticsName = "丹鸟";
}
logisticsName = logisticsName.replaceAll("\\([^\\\\(]+\\)", "");
logisticsName = logisticsName.replace("股份", "");
logisticsName = logisticsName.replace("'有限公司'", "");
if (logisticsName.contains("无界")) {
logisticsName = logisticsName.replace("无界", "");
if (!Pattern.compile("速递").matcher(logisticsName).find()) {
logisticsName += "快递";
}
}
if ((logisticsName.contains("中通") && logisticsName.contains("中通快运")) || (Arrays.asList("其他", "其它", "其它快递", "卖家负责配送").contains(logisticsName) && CommonTool.isMatch("^78299\\d+$", waybillCode))) {
logisticsName = "中通快递";
}
if (logisticsName.contains("EMS") || logisticsName.contains("邮政标准")) {
logisticsName = "邮政EMS";
} else if (logisticsName.contains("邮政") && logisticsName.contains("邮政电商标快")) {
logisticsName = "邮政快递包裹";
}
if ((logisticsName.contains("圆通") && logisticsName.contains("圆通快运")) || (Arrays.asList("其他", "其它", "其它快递", "卖家负责配送").contains(logisticsName) && Pattern.compile("^YT\\d+$").matcher(waybillCode).find())) {
logisticsName = "圆通快递";
}
if (logisticsName.contains("国通")) {
logisticsName = "国通快递";
}
if (logisticsName.contains("申通达") || (Arrays.asList("点点送", "菜鸟裹裹商家寄件", "官方直送", "其他", "其它", "其它快递", "卖家负责配送").contains(logisticsName) && Pattern.compile("^77[03567]\\d+$").matcher(waybillCode).find())) {
logisticsName = "申通快递";
}
if ((logisticsName.contains("韵达") && logisticsName.contains("韵达快运")) || ("官方物流".equals(logisticsName) && Pattern.compile("^462\\d+$").matcher(waybillCode).find())) {
logisticsName = "韵达快递";
}
if (logisticsName.contains("德邦") && (logisticsName.contains("德邦物流") || Pattern.compile("^DPK\\d+$").matcher(waybillCode).find())) {
logisticsName = "德邦快递";
}
if (Arrays.asList("其他", "其它", "卖家负责配送").contains(logisticsName) && Pattern.compile("^2\\d{8,9}").matcher(waybillCode).find()) {
logisticsName = "德邦快递";
}
if (Pattern.compile("圆通.+快递").matcher(logisticsName).find()) {
logisticsName = "圆通快递";
}
if (Pattern.compile("^JT\\d+$").matcher(waybillCode).find() && (logisticsName.contains("龙邦速递") || logisticsName.contains("百世") || logisticsName.contains("极兔") || Arrays.asList("其他", "其它", "卖家负责配送", "点点送", "juti").contains(logisticsName))) {
logisticsName = "极兔速递";
}
if (logisticsName.contains("百世物流") && Pattern.compile("^919\\d+$").matcher(waybillCode).find()) {
logisticsName = "百世快运";
}
if (Pattern.compile("^SF\\d+$").matcher(waybillCode).find()) {
logisticsName = "顺丰快递";
}
if (logisticsName.contains("丰网")) {
logisticsName = "丰网速运";
}
if (Pattern.compile("^JD[a-zA-Z0-9]+$").matcher(waybillCode).find() && logisticsName.contains("京东")) {
logisticsName = "京东快递";
}
return logisticsName;
}
private boolean isIgnoreNoticeLogisticsNameMismatch(String logisticsName, String waybillCode) {
if (logisticsName.isEmpty() && waybillCode.isEmpty()) {
return true;
}
if (LogisticsConst.getIgnoreNoticeLogisticsNameList().contains(logisticsName)) {
return true;
}
if (Pattern.compile("^(LE)?\\d+$").matcher(logisticsName).find()) {
return true;
}
if (Objects.equals(waybillCode, "-") || !Pattern.compile("^[\\da-zA-Z]+$").matcher(waybillCode).find()) {
return true;
}
if (waybillCode.contains("停发")) {
return true;
}
if (logisticsName.contains("停发")) {
return true;
}
if (logisticsName.contains("疫情")) {
return true;
}
if (logisticsName.contains("C2M")) {
return true;
}
return waybillCode.length() <= 5;
}
}

@ -2,6 +2,10 @@ package com.ms.biz.util;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackRequest;
import com.doudian.open.api.order_logisticsAddMultiPack.OrderLogisticsAddMultiPackResponse;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData;
import com.doudian.open.api.order_logisticsAddMultiPack.param.OrderLogisticsAddMultiPackParam;
import com.doudian.open.api.supplyCenter_cargo_detail.SupplyCenterCargoDetailRequest;
import com.doudian.open.api.supplyCenter_cargo_detail.SupplyCenterCargoDetailResponse;
import com.doudian.open.api.supplyCenter_cargo_detail.data.SupplyCenterCargoDetailData;
@ -53,7 +57,7 @@ public class DDApi {
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static SupplyCenterOrderSyncSupplierInfoData supplyCenterOrderSyncSupplierInfo(SupplyCenterOrderSyncSupplierInfoParam param) {
@ -64,7 +68,7 @@ public class DDApi {
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static SupplyCenterOrderLogisticsData supplyCenterOrderLogistics(SupplyCenterOrderLogisticsParam param) {
@ -75,7 +79,7 @@ public class DDApi {
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static SupplyCenterOrderCancelData supplyCenterOrderCancel(SupplyCenterOrderCancelParam param) {
@ -86,7 +90,7 @@ public class DDApi {
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static SupplyCenterOrderPayData supplyCenterOrderPay(SupplyCenterOrderPayParam param) {
@ -97,7 +101,7 @@ public class DDApi {
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static SupplyCenterRefundOperateData supplyCenterRefundOperate(SupplyCenterRefundOperateParam param) {
@ -108,7 +112,7 @@ public class DDApi {
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static SupplyCenterCargoDetailData supplyCenterCargoDetail(SupplyCenterCargoDetailParam param) {
@ -119,7 +123,7 @@ public class DDApi {
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static SupplyCenterOrderQueryData supplyCenterOrderQuery(SupplyCenterOrderQueryParam param) {
@ -130,7 +134,17 @@ public class DDApi {
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
public static OrderLogisticsAddMultiPackData logisticsAddMultiPack(OrderLogisticsAddMultiPackParam param) {
OrderLogisticsAddMultiPackRequest request = new OrderLogisticsAddMultiPackRequest();
request.setParam(param);
OrderLogisticsAddMultiPackResponse response = request.execute();
if (response.isSuccess()) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:%s", response.getMsg()));
}
private static <T, R> T execute(DoudianOpRequest<R> request) {

@ -0,0 +1,51 @@
package com.ms.dal.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
*
* @TableName logistics
*/
@Data
public class Logistics implements Serializable {
/**
* id
*/
private Long logisticsId;
/**
*
*/
private String logisticsName;
/**
*
*/
private String logisticsCode;
/**
*
*/
private String status;
/**
*
*/
private Integer sort;
/**
*
*/
private Date gmtCreate;
/**
*
*/
private Date gmtModified;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,51 @@
package com.ms.dal.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
*
* @TableName logistics_match_rule
*/
@Data
public class LogisticsMatchRule implements Serializable {
/**
*
*/
private Integer logisticsMatchRuleId;
/**
*
*/
private String logisticsName;
/**
*
*/
private String platform;
/**
*
*/
private String platformLogisticsName;
/**
*
*/
private String waybillCodeRule;
/**
*
*/
private Date gmtCreate;
/**
*
*/
private Date gmtModified;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,32 @@
package com.ms.dal.mapper;
import com.ms.dal.entity.Logistics;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Entity com.ms.dal.entity.Logistics
*/
@Mapper
public interface LogisticsMapper {
int deleteByPrimaryKey(Long id);
int insert(Logistics record);
int insertOrUpdate(Logistics record);
int insertSelective(Logistics record);
Logistics selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(Logistics record);
int updateByPrimaryKey(Logistics record);
List<Logistics> getList();
Logistics getByLogisticsName(@Param("logisticsName") String logisticsName);
}

@ -0,0 +1,30 @@
package com.ms.dal.mapper;
import com.ms.dal.entity.LogisticsMatchRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Entity com.ms.dal.entity.LogisticsMatchRule
*/
@Mapper
public interface LogisticsMatchRuleMapper {
int deleteByPrimaryKey(Long id);
int insert(LogisticsMatchRule record);
int insertOrUpdate(LogisticsMatchRule record);
int insertSelective(LogisticsMatchRule record);
LogisticsMatchRule selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(LogisticsMatchRule record);
int updateByPrimaryKey(LogisticsMatchRule record);
List<LogisticsMatchRule> getListByPlatform(@Param("platform") String platform);
}

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ms.dal.mapper.LogisticsMapper">
<resultMap id="BaseResultMap" type="com.ms.dal.entity.Logistics">
<id property="logisticsId" column="logistics_id" jdbcType="BIGINT"/>
<result property="logisticsName" column="logistics_name" jdbcType="VARCHAR"/>
<result property="logisticsCode" column="logistics_code" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
<result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
<result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
logistics_id,logistics_name,logistics_code,
status,sort,gmt_create,
gmt_modified
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from logistics
where logistics_id = #{logisticsId,jdbcType=BIGINT}
</select>
<select id="getList" resultType="com.ms.dal.entity.Logistics">
select
<include refid="Base_Column_List" />
from logistics
</select>
<select id="getByLogisticsName" resultType="com.ms.dal.entity.Logistics">
select
<include refid="Base_Column_List" />
from logistics
where logistics_name = #{logisticsName,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from logistics
where logistics_id = #{logisticsId,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="logistics_id" keyProperty="logisticsId" parameterType="com.ms.dal.entity.Logistics" useGeneratedKeys="true">
insert into logistics
( logistics_id,logistics_name,logistics_code
,status,sort,gmt_create
,gmt_modified)
values (#{logisticsId,jdbcType=BIGINT},#{logisticsName,jdbcType=VARCHAR},#{logisticsCode,jdbcType=VARCHAR}
,#{status,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER},#{gmtCreate,jdbcType=TIMESTAMP}
,#{gmtModified,jdbcType=TIMESTAMP})
</insert>
<update id="insertOrUpdate" keyColumn="logistics_id" keyProperty="logisticsId" parameterType="com.ms.dal.entity.Logistics"
useGeneratedKeys="true">
insert into logistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="logisticsId != null">logistics_id,</if>
<if test="logisticsName != null">logistics_name,</if>
<if test="logisticsCode != null">logistics_code,</if>
<if test="status != null">status,</if>
<if test="sort != null">sort,</if>
<if test="gmtCreate != null">gmt_create,</if>
<if test="gmtModified != null">gmt_modified,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="logisticsId != null">#{logisticsId,jdbcType=BIGINT},</if>
<if test="logisticsName != null">#{logisticsName,jdbcType=VARCHAR},</if>
<if test="logisticsCode != null">#{logisticsCode,jdbcType=VARCHAR},</if>
<if test="status != null">#{status,jdbcType=VARCHAR},</if>
<if test="sort != null">#{sort,jdbcType=INTEGER},</if>
<if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
<if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
</trim>
ON DUPLICATE KEY UPDATE
<trim suffixOverrides=",">
<if test="logisticsName != null">
logistics_name = #{logisticsName,jdbcType=VARCHAR},
</if>
<if test="logisticsCode != null">
logistics_code = #{logisticsCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</trim>
</update>
<insert id="insertSelective" keyColumn="logistics_id" keyProperty="logisticsId" parameterType="com.ms.dal.entity.Logistics" useGeneratedKeys="true">
insert into logistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="logisticsId != null">logistics_id,</if>
<if test="logisticsName != null">logistics_name,</if>
<if test="logisticsCode != null">logistics_code,</if>
<if test="status != null">status,</if>
<if test="sort != null">sort,</if>
<if test="gmtCreate != null">gmt_create,</if>
<if test="gmtModified != null">gmt_modified,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="logisticsId != null">#{logisticsId,jdbcType=BIGINT},</if>
<if test="logisticsName != null">#{logisticsName,jdbcType=VARCHAR},</if>
<if test="logisticsCode != null">#{logisticsCode,jdbcType=VARCHAR},</if>
<if test="status != null">#{status,jdbcType=VARCHAR},</if>
<if test="sort != null">#{sort,jdbcType=INTEGER},</if>
<if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
<if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ms.dal.entity.Logistics">
update logistics
<set>
<if test="logisticsName != null">
logistics_name = #{logisticsName,jdbcType=VARCHAR},
</if>
<if test="logisticsCode != null">
logistics_code = #{logisticsCode,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</set>
where logistics_id = #{logisticsId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.Logistics">
update logistics
set
logistics_name = #{logisticsName,jdbcType=VARCHAR},
logistics_code = #{logisticsCode,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where logistics_id = #{logisticsId,jdbcType=BIGINT}
</update>
</mapper>

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ms.dal.mapper.LogisticsMatchRuleMapper">
<resultMap id="BaseResultMap" type="com.ms.dal.entity.LogisticsMatchRule">
<id property="logisticsMatchRuleId" column="logistics_match_rule_id" jdbcType="INTEGER"/>
<result property="logisticsName" column="logistics_name" jdbcType="VARCHAR"/>
<result property="platform" column="platform" jdbcType="VARCHAR"/>
<result property="platformLogisticsName" column="platform_logistics_name" jdbcType="VARCHAR"/>
<result property="waybillCodeRule" column="waybill_code_rule" jdbcType="VARCHAR"/>
<result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
<result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
logistics_match_rule_id,logistics_name,platform,
platform_logistics_name,waybill_code_rule,gmt_create,
gmt_modified
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from logistics_match_rule
where logistics_match_rule_id = #{logisticsMatchRuleId,jdbcType=INTEGER}
</select>
<select id="getListByPlatform" resultType="com.ms.dal.entity.LogisticsMatchRule">
select
<include refid="Base_Column_List" />
from logistics_match_rule
where platform in ('all', #{platform,jdbcType=VARCHAR})
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from logistics_match_rule
where logistics_match_rule_id = #{logisticsMatchRuleId,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="logistics_match_rule_id" keyProperty="logisticsMatchRuleId" parameterType="com.ms.dal.entity.LogisticsMatchRule" useGeneratedKeys="true">
insert into logistics_match_rule
( logistics_match_rule_id,logistics_name,platform
,platform_logistics_name,waybill_code_rule,gmt_create
,gmt_modified)
values (#{logisticsMatchRuleId,jdbcType=INTEGER},#{logisticsName,jdbcType=VARCHAR},#{platform,jdbcType=VARCHAR}
,#{platformLogisticsName,jdbcType=VARCHAR},#{waybillCodeRule,jdbcType=VARCHAR},#{gmtCreate,jdbcType=TIMESTAMP}
,#{gmtModified,jdbcType=TIMESTAMP})
</insert>
<update id="insertOrUpdate" keyColumn="logistics_match_rule_id" keyProperty="logisticsMatchRuleId" parameterType="com.ms.dal.entity.LogisticsMatchRule"
useGeneratedKeys="true">
insert into logistics_match_rule
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="logisticsMatchRuleId != null">logistics_match_rule_id,</if>
<if test="logisticsName != null">logistics_name,</if>
<if test="platform != null">platform,</if>
<if test="platformLogisticsName != null">platform_logistics_name,</if>
<if test="waybillCodeRule != null">waybill_code_rule,</if>
<if test="gmtCreate != null">gmt_create,</if>
<if test="gmtModified != null">gmt_modified,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="logisticsMatchRuleId != null">#{logisticsMatchRuleId,jdbcType=INTEGER},</if>
<if test="logisticsName != null">#{logisticsName,jdbcType=VARCHAR},</if>
<if test="platform != null">#{platform,jdbcType=VARCHAR},</if>
<if test="platformLogisticsName != null">#{platformLogisticsName,jdbcType=VARCHAR},</if>
<if test="waybillCodeRule != null">#{waybillCodeRule,jdbcType=VARCHAR},</if>
<if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
<if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
</trim>
ON DUPLICATE KEY UPDATE
<trim suffixOverrides=",">
<if test="logisticsName != null">
logistics_name = #{logisticsName,jdbcType=VARCHAR},
</if>
<if test="platform != null">
platform = #{platform,jdbcType=VARCHAR},
</if>
<if test="platformLogisticsName != null">
platform_logistics_name = #{platformLogisticsName,jdbcType=VARCHAR},
</if>
<if test="waybillCodeRule != null">
waybill_code_rule = #{waybillCodeRule,jdbcType=VARCHAR},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</trim>
</update>
<insert id="insertSelective" keyColumn="logistics_match_rule_id" keyProperty="logisticsMatchRuleId" parameterType="com.ms.dal.entity.LogisticsMatchRule" useGeneratedKeys="true">
insert into logistics_match_rule
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="logisticsMatchRuleId != null">logistics_match_rule_id,</if>
<if test="logisticsName != null">logistics_name,</if>
<if test="platform != null">platform,</if>
<if test="platformLogisticsName != null">platform_logistics_name,</if>
<if test="waybillCodeRule != null">waybill_code_rule,</if>
<if test="gmtCreate != null">gmt_create,</if>
<if test="gmtModified != null">gmt_modified,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="logisticsMatchRuleId != null">#{logisticsMatchRuleId,jdbcType=INTEGER},</if>
<if test="logisticsName != null">#{logisticsName,jdbcType=VARCHAR},</if>
<if test="platform != null">#{platform,jdbcType=VARCHAR},</if>
<if test="platformLogisticsName != null">#{platformLogisticsName,jdbcType=VARCHAR},</if>
<if test="waybillCodeRule != null">#{waybillCodeRule,jdbcType=VARCHAR},</if>
<if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
<if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ms.dal.entity.LogisticsMatchRule">
update logistics_match_rule
<set>
<if test="logisticsName != null">
logistics_name = #{logisticsName,jdbcType=VARCHAR},
</if>
<if test="platform != null">
platform = #{platform,jdbcType=VARCHAR},
</if>
<if test="platformLogisticsName != null">
platform_logistics_name = #{platformLogisticsName,jdbcType=VARCHAR},
</if>
<if test="waybillCodeRule != null">
waybill_code_rule = #{waybillCodeRule,jdbcType=VARCHAR},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</set>
where logistics_match_rule_id = #{logisticsMatchRuleId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.LogisticsMatchRule">
update logistics_match_rule
set
logistics_name = #{logisticsName,jdbcType=VARCHAR},
platform = #{platform,jdbcType=VARCHAR},
platform_logistics_name = #{platformLogisticsName,jdbcType=VARCHAR},
waybill_code_rule = #{waybillCodeRule,jdbcType=VARCHAR},
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where logistics_match_rule_id = #{logisticsMatchRuleId,jdbcType=INTEGER}
</update>
</mapper>

@ -59,6 +59,9 @@ public class Test {
@Autowired
private DsApiService dsApiService;
@Autowired
private LogisticsService logisticsService;
@Autowired
private DistributionOrderService distributionOrderService;
@ -263,4 +266,10 @@ public class Test {
return "";
}
@GetMapping("/match-rule")
public String matchRule() {
Map<String, String> result = logisticsService.matchLogisticsInfo("1688DS", "顺丰速运", "SF1610042925672", null);
System.out.println(result);
return result.toString();
}
}

Loading…
Cancel
Save