feat: 订单
parent
02a16a6590
commit
eaa3d2464c
|
|
@ -23,4 +23,12 @@ public interface ExpressManager {
|
|||
*/
|
||||
String shipStoreOrder(ExpressShipReqDTO shipReqDTO);
|
||||
|
||||
/**
|
||||
* 打印面单
|
||||
*
|
||||
* @param waybillNo
|
||||
* @return 文件流Base64编码
|
||||
*/
|
||||
String printOrder(String waybillNo);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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("中通订单打印失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 智能解析
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
Loading…
Reference in New Issue