feat: 物流

pull/1121/head
梁宇奇 2025-04-29 22:30:56 +08:00
parent fb9b58049c
commit 6bd48f2e62
7 changed files with 263 additions and 13 deletions

View File

@ -0,0 +1,19 @@
package com.ruoyi.xkt.dto.express;
import lombok.Data;
/**
* @author liangyq
* @date 2025-04-29 17:57
*/
@Data
public class ExpressInterceptReqDTO {
/**
*
*/
private String expressReqNo;
/**
*
*/
private String expressWaybillNo;
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.xkt.manager;
import com.ruoyi.xkt.dto.express.ExpressCancelReqDTO;
import com.ruoyi.xkt.dto.express.ExpressInterceptReqDTO;
import com.ruoyi.xkt.dto.express.ExpressPrintDTO;
import com.ruoyi.xkt.dto.express.ExpressShipReqDTO;
import com.ruoyi.xkt.enums.EExpressChannel;
@ -34,7 +35,14 @@ public interface ExpressManager {
* @param cancelReqDTO
* @return
*/
boolean cancelShipOrder(ExpressCancelReqDTO cancelReqDTO);
boolean cancelShip(ExpressCancelReqDTO cancelReqDTO);
/**
*
*
* @return
*/
boolean interceptShip(ExpressInterceptReqDTO interceptReqDTO);
/**
*

View File

@ -7,6 +7,7 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.xkt.dto.express.ExpressCancelReqDTO;
import com.ruoyi.xkt.dto.express.ExpressInterceptReqDTO;
import com.ruoyi.xkt.dto.express.ExpressPrintDTO;
import com.ruoyi.xkt.dto.express.ExpressShipReqDTO;
import com.ruoyi.xkt.enums.EExpressChannel;
@ -74,7 +75,7 @@ public class YtoExpressManagerImpl implements ExpressManager {
}
@Override
public boolean cancelShipOrder(ExpressCancelReqDTO cancelReqDTO) {
public boolean cancelShip(ExpressCancelReqDTO cancelReqDTO) {
Assert.notNull(cancelReqDTO);
Assert.notEmpty(cancelReqDTO.getExpressReqNo());
YtoCancelOrderParam cancelOrderParam = new YtoCancelOrderParam();
@ -104,6 +105,36 @@ public class YtoExpressManagerImpl implements ExpressManager {
return false;
}
@Override
public boolean interceptShip(ExpressInterceptReqDTO interceptReqDTO) {
Assert.notNull(interceptReqDTO);
Assert.notEmpty(interceptReqDTO.getExpressWaybillNo());
YtoInterceptReturnParam interceptReturnParam = new YtoInterceptReturnParam();
interceptReturnParam.setWaybillNo(interceptReqDTO.getExpressWaybillNo());
interceptReturnParam.setWantedDesc("拦截退回");
try {
String param = JSONUtil.toJsonStr(interceptReturnParam);
String sign = YtoSignUtil.sign("wanted_report_adapter", "v1", param, appSecret);
YtoPublicRequest request = YtoPublicRequest.builder()
.timestamp(System.currentTimeMillis())
.param(param)
.format(YtoPublicRequest.EFormat.JSON)
.sign(sign).build();
String rtnStr = HttpUtil.post(gatewayUrl + "open/wanted_report_adapter/v1/N364gM/" + appKey,
JSONUtil.toJsonStr(request));
log.info("圆通订单拦截返回信息: {}", rtnStr);
JSONObject rtnJson = JSONUtil.parseObj(rtnStr);
Integer statusCode = rtnJson.getInt("statusCode");
if (statusCode != null && statusCode == 0) {
return true;
}
} catch (Exception e) {
log.error("圆通订单拦截异常", e);
}
log.warn("圆通订单拦截失败: {}", interceptReqDTO);
return false;
}
@Override
public List<ExpressPrintDTO> printOrder(Collection<String> waybillNos) {
Assert.notEmpty(waybillNos);

View File

@ -2,12 +2,14 @@ package com.ruoyi.xkt.manager.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.xkt.dto.express.ExpressCancelReqDTO;
import com.ruoyi.xkt.dto.express.ExpressInterceptReqDTO;
import com.ruoyi.xkt.dto.express.ExpressPrintDTO;
import com.ruoyi.xkt.dto.express.ExpressShipReqDTO;
import com.ruoyi.xkt.enums.EExpressChannel;
@ -36,6 +38,8 @@ public class ZtoExpressManagerImpl implements ExpressManager, InitializingBean {
private static final String CANCEL_ORDER_URI = "zto.open.cancelPreOrder";
private static final String INTERCEPT_URI = "thirdcenter.createIntercept";
private static final String STRUCTURE_ADDRESS_URI = "zto.innovate.structureNamePhoneAddress";
public static final String ORDER_PRINT_URI = "zto.open.order.print";
@ -90,7 +94,7 @@ public class ZtoExpressManagerImpl implements ExpressManager, InitializingBean {
}
@Override
public boolean cancelShipOrder(ExpressCancelReqDTO cancelReqDTO) {
public boolean cancelShip(ExpressCancelReqDTO cancelReqDTO) {
Assert.notNull(cancelReqDTO);
Assert.notEmpty(cancelReqDTO.getExpressWaybillNo());
ZtoCancelOrderParam cancelOrderParam = new ZtoCancelOrderParam();
@ -115,6 +119,148 @@ public class ZtoExpressManagerImpl implements ExpressManager, InitializingBean {
return false;
}
@Override
public boolean interceptShip(ExpressInterceptReqDTO interceptReqDTO) {
Assert.notNull(interceptReqDTO);
Assert.notEmpty(interceptReqDTO.getExpressWaybillNo());
Assert.notEmpty(interceptReqDTO.getExpressReqNo());
ZtoInterceptReturnParam interceptReturnParam = new ZtoInterceptReturnParam();
interceptReturnParam.setBillCode(interceptReqDTO.getExpressWaybillNo());
interceptReturnParam.setRequestId(IdUtil.simpleUUID());
interceptReturnParam.setDestinationType(1);
interceptReturnParam.setThirdBizNo(interceptReqDTO.getExpressReqNo());
ZopPublicRequest request = new ZopPublicRequest();
request.setBody(JSONUtil.toJsonStr(interceptReturnParam));
request.setUrl(gatewayUrl + INTERCEPT_URI);
request.setEncryptionType(EncryptionType.MD5);
try {
String bodyStr = client.execute(request);
log.info("中通订单拦截返回信息: {}", bodyStr);
/**
* E23101
*
*
* E23102
*
*
* E23108
* 退
* destinationType
* E23110
* 使
*
* E23111
*
*
* E23112
*
*
* E23113
*
*
* E23114
*
*
* E23115
*
*
* E23116
* /
*
* E23118
* /
* platform
* E23119
*
*
* E23120
*
*
* E23121
* ,
*
* E23122
*
*
* E23123
* 退
*
* E23124
*
*
* E23127
* ,
* destinationType
* E23130
* ,
*
* E23131
* ,
*
* E23135
* ,
*
* E23136
*
*
* E23137
*
*
* E23138
*
*
* E23139
*
*
* E23140
*
*
* E23141
*
*
* E23144
* CRM
*
* E23146
* /退
*
* E23148
*
* receivePhone
* E23149
*
* receivePhone
* E23150
* 16
* receivePhone
* E23151
* ,
* destinationType
* E23153
*
*
* E23154
*
*
* E23157
*
*
* E23160
*
*
*/
JSONObject bodyJson = JSONUtil.parseObj(bodyStr);
boolean success = bodyJson.getBool("status");
if (success) {
return true;
}
} catch (Exception e) {
log.error("中通订单拦截异常", e);
}
log.warn("中通订单拦截失败: {}", interceptReqDTO);
return false;
}
@Override
public List<ExpressPrintDTO> printOrder(Collection<String> waybillNos) {
Assert.notEmpty(waybillNos);

View File

@ -609,11 +609,11 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
order.getOrderNo()));
}
}
if (EExpressType.STORE.getValue().equals(containDetail.getExpressType())) {
//已存在档口发货的明细
throw new ServiceException(CharSequenceUtil.format("订单[{}]由档口物流发货!",
order.getOrderNo()));
}
// if (EExpressType.STORE.getValue().equals(containDetail.getExpressType())) {
// //已存在档口发货的明细
// throw new ServiceException(CharSequenceUtil.format("订单[{}]由档口物流发货!",
// order.getOrderNo()));
// }
}
List<StoreOrderDetail> orderDetails = storeOrderDetailMapper.selectByIds(storeOrderDetailIds);
for (StoreOrderDetail orderDetail : orderDetails) {
@ -699,11 +699,11 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
order.getOrderNo()));
}
}
if (EExpressType.PLATFORM.getValue().equals(containDetail.getExpressType())) {
//已存在平台发货的明细
throw new ServiceException(CharSequenceUtil.format("订单[{}]由平台物流发货!",
order.getOrderNo()));
}
// if (EExpressType.PLATFORM.getValue().equals(containDetail.getExpressType())) {
// //已存在平台发货的明细
// throw new ServiceException(CharSequenceUtil.format("订单[{}]由平台物流发货!",
// order.getOrderNo()));
// }
}
List<StoreOrderDetail> orderDetails = storeOrderDetailMapper.selectByIds(storeOrderDetailIds);
List<Long> orderDetailIdList = new ArrayList<>(orderDetails.size());

View File

@ -0,0 +1,19 @@
package com.ruoyi.xkt.thirdpart.yto;
import lombok.Data;
/**
* @author liangyq
* @date 2025-04-29 18:13
*/
@Data
public class YtoInterceptReturnParam {
/**
*
*/
private String waybillNo;
/**
*
*/
private String wantedDesc;
}

View File

@ -0,0 +1,27 @@
package com.ruoyi.xkt.thirdpart.zto;
import lombok.Data;
/**
* @author liangyq
* @date 2025-04-29 18:13
*/
@Data
public class ZtoInterceptReturnParam {
/**
*
*/
private String billCode;
/**
* ID
*/
private String requestId;
/**
* :1 2 3 4 退
*/
private Integer destinationType;
/**
*
*/
private String thirdBizNo;
}