feat: 订单

pull/1121/head
梁宇奇 2025-04-16 23:01:44 +08:00
parent 02a16a6590
commit eaa3d2464c
3 changed files with 61 additions and 4 deletions

View File

@ -23,4 +23,12 @@ public interface ExpressManager {
*/
String shipStoreOrder(ExpressShipReqDTO shipReqDTO);
/**
*
*
* @param waybillNo
* @return Base64
*/
String printOrder(String waybillNo);
}

View File

@ -8,10 +8,7 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.xkt.dto.express.ExpressShipReqDTO;
import com.ruoyi.xkt.enums.EExpressChannel;
import com.ruoyi.xkt.manager.ExpressManager;
import com.ruoyi.xkt.thirdpart.zto.EncryptionType;
import com.ruoyi.xkt.thirdpart.zto.ZopClient;
import com.ruoyi.xkt.thirdpart.zto.ZopPublicRequest;
import com.ruoyi.xkt.thirdpart.zto.ZtoCreateOrderReqDTO;
import com.ruoyi.xkt.thirdpart.zto.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ -28,6 +25,8 @@ public class ZtoExpressManagerImpl implements ExpressManager {
private static final String STRUCTURE_ADDRESS_URI = "zto.innovate.structureNamePhoneAddress";
public static final String ORDER_PRINT_URI = "zto.open.order.print";
@Value("${zto.appKey:}")
private String appKey;
@ -73,6 +72,29 @@ public class ZtoExpressManagerImpl implements ExpressManager {
throw new ServiceException("中通订单创建失败");
}
@Override
public String printOrder(String waybillNo) {
Assert.notEmpty(waybillNo);
ZopClient client = new ZopClient(appKey, appSecret);
ZopPublicRequest request = new ZopPublicRequest();
request.setBody(JSONUtil.toJsonStr(new ZtoPrintOrderReqDTO(1,waybillNo,true)));
request.setUrl(gatewayUrl + ORDER_PRINT_URI);
request.setEncryptionType(EncryptionType.MD5);
try {
String bodyStr = client.execute(request);
log.info("中通订单打印返回信息: {}", bodyStr);
JSONObject bodyJson = JSONUtil.parseObj(bodyStr);
boolean success = bodyJson.getBool("status");
if (success) {
//TODO 测试环境接口不通
return bodyJson.getJSONObject("result").getStr("billCode");
}
} catch (Exception e) {
log.error("中通订单打印异常", e);
}
throw new ServiceException("中通订单打印失败");
}
/**
*
*

View File

@ -0,0 +1,27 @@
package com.ruoyi.xkt.thirdpart.zto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author liangyq
* @date 2025-04-15 19:20
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ZtoPrintOrderReqDTO {
/**
* (0:JPG, 1:PDF.PDF)
*/
private Integer printType;
/**
*
*/
private String billCode;
/**
* logo(true:, false:.)
*/
private Boolean printLogo;
}