快递100面单下单
This commit is contained in:
1 parent
47d148e967
commit
97dfbe2760
13 files changed
+635
-8
No files matched your search
@@ -133,6 +133,7 @@
|
||||
<artifactId>transmittable-thread-local</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fhs-opensource</groupId> <!-- VO 数据翻译 -->
|
||||
<artifactId>easy-trans-anno</artifactId> <!-- 默认引入的原因,方便 xxx-module-api 包使用 -->
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode ORDER_CANCEL_PAID_FAIL = new ErrorCode(1_011_000_033, "交易订单取消支付失败,原因:订单不是【{}】状态");
|
||||
ErrorCode ORDER_PICK_UP_FAIL_NOT_VERIFY_USER = new ErrorCode(1_011_000_034, "交易订单自提失败,原因:你没有核销该门店订单的权限");
|
||||
ErrorCode ORDER_CREATE_FAIL_INSUFFICIENT_USER_POINTS = new ErrorCode(1_011_000_035, "交易订单创建失败,原因:用户积分不足");
|
||||
ErrorCode OMS_EXPRESS_ORDER_CREATE_ERROR = new ErrorCode(1_011_000_036, "快递订单创建失败,原因:{}");
|
||||
|
||||
// ========== After Sale 模块 1-011-000-100 ==========
|
||||
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1_011_000_100, "售后单不存在");
|
||||
|
||||
@@ -92,6 +92,14 @@
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 快递一百-->
|
||||
<dependency>
|
||||
<groupId>com.github.kuaidi100-api</groupId>
|
||||
<artifactId>sdk</artifactId>
|
||||
<version>1.0.23</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
+12
-1
@@ -11,4 +11,15 @@ tenant-id: {{adminTenantId}}
|
||||
### 获得交易订单的物流轨迹 => 成功
|
||||
GET {{baseUrl}}/trade/order/get-express-track-list?id=21
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
|
||||
### 申通快递订单创建
|
||||
PUT {{baseUrl}}/trade/order/delivery-STO?id=14
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
|
||||
### 快递100订单创建
|
||||
PUT {{baseUrl}}/trade/order/delivery-kuaidi100?id=14
|
||||
Authorization: Bearer {{token}}
|
||||
tenant-id: {{adminTenantId}}
|
||||
+15
@@ -115,6 +115,21 @@ public class TradeOrderController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/delivery-STO")
|
||||
@Operation(summary = "申通快递订单创建")
|
||||
@PreAuthorize("@ss.hasPermission('trade:order:update')")
|
||||
public CommonResult<Boolean> deliverySto(@RequestParam("id") Long id) {
|
||||
tradeOrderUpdateService.deliverySto(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/delivery-kuaidi100")
|
||||
@Operation(summary = "申通快递(快递100)订单创建")
|
||||
@PreAuthorize("@ss.hasPermission('trade:order:update')")
|
||||
public CommonResult<String> deliveryKuaidi100(@RequestParam("id") Long id) {
|
||||
return success(tradeOrderUpdateService.deliveryKuaidi100(id));
|
||||
}
|
||||
|
||||
@PutMapping("/update-remark")
|
||||
@Operation(summary = "订单备注")
|
||||
@PreAuthorize("@ss.hasPermission('trade:order:update')")
|
||||
|
||||
+3
@@ -218,4 +218,7 @@ public interface TradeOrderUpdateService {
|
||||
*/
|
||||
void updateOrderGiveCouponIds(Long userId, Long orderId, List<Long> giveCouponIds);
|
||||
|
||||
void deliverySto(Long id);
|
||||
|
||||
String deliveryKuaidi100(Long id);
|
||||
}
|
||||
+290
-4
@@ -13,6 +13,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||
import cn.iocoder.yudao.module.member.api.address.MemberAddressApi;
|
||||
import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO;
|
||||
import cn.iocoder.yudao.module.pay.api.order.PayOrderApi;
|
||||
@@ -52,23 +53,48 @@ import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
|
||||
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryPickUpStoreService;
|
||||
import cn.iocoder.yudao.module.trade.service.message.TradeMessageService;
|
||||
import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO;
|
||||
import cn.iocoder.yudao.module.trade.service.order.bo.StoOrderCreateContentBo;
|
||||
import cn.iocoder.yudao.module.trade.service.order.bo.StoRequestBo;
|
||||
import cn.iocoder.yudao.module.trade.service.order.bo.StoResponseBo;
|
||||
import cn.iocoder.yudao.module.trade.service.order.handler.TradeOrderHandler;
|
||||
import cn.iocoder.yudao.module.trade.service.price.TradePriceService;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateReqBO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||
import cn.iocoder.yudao.module.trade.service.price.calculator.TradePriceCalculatorHelper;
|
||||
import cn.iocoder.yudao.module.trade.util.SignatureUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.kuaidi100.sdk.api.LabelV2;
|
||||
import com.kuaidi100.sdk.contant.ApiInfoConstant;
|
||||
import com.kuaidi100.sdk.contant.CompanyConstant;
|
||||
import com.kuaidi100.sdk.contant.PrintType;
|
||||
import com.kuaidi100.sdk.core.IBaseClient;
|
||||
import com.kuaidi100.sdk.pojo.HttpResult;
|
||||
import com.kuaidi100.sdk.request.ManInfo;
|
||||
import com.kuaidi100.sdk.request.PrintReq;
|
||||
import com.kuaidi100.sdk.request.labelV2.OrderReq;
|
||||
import com.kuaidi100.sdk.response.PrintBaseResp;
|
||||
import com.kuaidi100.sdk.response.PrintCloudData;
|
||||
import com.kuaidi100.sdk.response.labelV2.OrderResult;
|
||||
import com.kuaidi100.sdk.response.labelV2.Result;
|
||||
import com.kuaidi100.sdk.utils.SignUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
@@ -125,6 +151,21 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
|
||||
// =================== Order ===================
|
||||
|
||||
@Value("${sto.api_url}")
|
||||
private String api_url;
|
||||
|
||||
@Value("${sto.from_appkey}")
|
||||
private String from_appkey;
|
||||
|
||||
@Value("${sto.from_code}")
|
||||
private String from_code;
|
||||
|
||||
@Value("${sto.to_appkey}")
|
||||
private String to_appkey;
|
||||
|
||||
@Value("${sto.to_code}")
|
||||
private String to_code;
|
||||
|
||||
@Override
|
||||
public AppTradeOrderSettlementRespVO settlementOrder(Long userId, AppTradeOrderSettlementReqVO settlementReqVO) {
|
||||
// 1. 获得收货地址
|
||||
@@ -403,6 +444,250 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
getSelf().sendDeliveryOrderMessage(order, deliveryReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deliverySto(Long id) {
|
||||
// 1.1 校验并获得交易订单(可发货)
|
||||
TradeOrderDO order = validateOrderDeliverable(id);
|
||||
// 1.2 校验 deliveryType 是否为快递,是快递才可以发货
|
||||
if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType())) {
|
||||
throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS);
|
||||
}
|
||||
if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.UNDELIVERED.getStatus())) {
|
||||
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
|
||||
}
|
||||
StoOrderCreateContentBo orderCreateContentBo = new StoOrderCreateContentBo();
|
||||
orderCreateContentBo.setOrderNo(order.getNo());
|
||||
//todo
|
||||
orderCreateContentBo.setOrderSource("WMYKT");
|
||||
|
||||
orderCreateContentBo.setBillType("00");
|
||||
orderCreateContentBo.setOrderType("01");
|
||||
orderCreateContentBo.setSender(new StoOrderCreateContentBo.Sender()
|
||||
.setName("杨林").setMobile("15325380110")
|
||||
.setProvince("浙江省").setCity("嘉兴市").setArea("南湖区")
|
||||
.setAddress("新嘉街道建国北路锦江商务楼3A")
|
||||
);
|
||||
|
||||
// String area = AreaUtils.format(order.getReceiverAreaId());
|
||||
String[] areas = AreaUtils.format(order.getReceiverAreaId()).split(" ");
|
||||
orderCreateContentBo.setReceiver(new StoOrderCreateContentBo.Receiver()
|
||||
.setName(order.getReceiverName()).setMobile(order.getReceiverMobile())
|
||||
.setProvince(areas.length > 0 ? areas[0] : "")
|
||||
.setCity(areas.length > 1 ? areas[1] : "")
|
||||
.setArea(areas.length > 2 ? areas[2] : "")
|
||||
.setAddress(order.getReceiverDetailAddress())
|
||||
);
|
||||
//todo
|
||||
orderCreateContentBo.setCargo(new StoOrderCreateContentBo.Cargo()
|
||||
.setBattery("10")
|
||||
.setGoodsType("小件")
|
||||
.setGoodsName("测试物品")
|
||||
);
|
||||
orderCreateContentBo.setCustomer(new StoOrderCreateContentBo.Customer()
|
||||
.setSiteCode("314056")
|
||||
.setCustomerName("314056015779")
|
||||
.setSitePwd("JXsto123")
|
||||
);
|
||||
/* orderCreateContentBo.setCustomer(new StoOrderCreateContentBo.Customer()
|
||||
.setSiteCode("666666")
|
||||
.setCustomerName("666666000001")
|
||||
.setSitePwd("abc123")
|
||||
);*/
|
||||
String content = JSON.toJSONString(orderCreateContentBo);
|
||||
// 创建申通发货订单
|
||||
/* StoRequestBo requestBo = new StoRequestBo();
|
||||
requestBo.setApi_name("OMS_EXPRESS_ORDER_CREATE");
|
||||
requestBo.setContent(content);
|
||||
requestBo.setFrom_appkey(from_appkey);
|
||||
requestBo.setFrom_code(from_code);
|
||||
requestBo.setTo_appkey(to_appkey);
|
||||
requestBo.setTo_code(to_code);
|
||||
requestBo.setData_digest(SignatureUtils.getSignature(content, from_appkey));*/
|
||||
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
|
||||
// 将 StoRequestBo 转换为表单参数
|
||||
MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
|
||||
formData.add("api_name", "OMS_EXPRESS_ORDER_CREATE");
|
||||
formData.add("content", content);
|
||||
formData.add("from_appkey", from_appkey);
|
||||
formData.add("from_code", from_code);
|
||||
formData.add("to_appkey", to_appkey);
|
||||
formData.add("to_code", to_code);
|
||||
formData.add("data_digest", SignatureUtils.getSignature(content, from_appkey));
|
||||
// 创建请求实体
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(formData, headers);
|
||||
|
||||
// 创建RestTemplate
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
// try {
|
||||
// 发送请求并解析响应
|
||||
ResponseEntity<String> response = restTemplate.exchange(
|
||||
api_url,
|
||||
HttpMethod.POST,
|
||||
requestEntity,
|
||||
String.class
|
||||
);
|
||||
String responseBody = new String(response.getBody().getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
|
||||
// String responseBody = response.getBody();
|
||||
log.info("[deliverySto][申通快递响应内容: {}]", responseBody);
|
||||
// 手动解析响应
|
||||
|
||||
StoResponseBo body = JSON.parseObject(responseBody, StoResponseBo.class);
|
||||
|
||||
// StoResponseBo body = response.getBody();
|
||||
if (body != null && body.isSuccess()) {
|
||||
// 2. 更新订单为已发货
|
||||
TradeOrderDO updateOrderObj = new TradeOrderDO();
|
||||
// 2.1 快递发货
|
||||
DeliveryExpressDO express = null;
|
||||
TradeOrderDeliveryReqVO deliveryReqVO = new TradeOrderDeliveryReqVO();
|
||||
deliveryReqVO.setId(order.getId());
|
||||
//1是申通
|
||||
deliveryReqVO.setLogisticsId(1L);
|
||||
deliveryReqVO.setLogisticsNo(body.getData().getWaybillNo());
|
||||
if (ObjectUtil.notEqual(deliveryReqVO.getLogisticsId(), TradeOrderDO.LOGISTICS_ID_NULL)) {
|
||||
express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId());
|
||||
updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo());
|
||||
} else {
|
||||
// 2.2 无需发货
|
||||
updateOrderObj.setLogisticsId(0L).setLogisticsNo("");
|
||||
}
|
||||
// 执行更新
|
||||
updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
|
||||
int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj);
|
||||
if (updateCount == 0) {
|
||||
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
|
||||
}
|
||||
|
||||
// 3. 记录订单日志
|
||||
TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus(),
|
||||
MapUtil.<String, Object>builder().put("deliveryName", express != null ? express.getName() : "")
|
||||
.put("logisticsNo", express != null ? deliveryReqVO.getLogisticsNo() : "").build());
|
||||
|
||||
// 4.1 发送站内信
|
||||
tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO()
|
||||
.setOrderId(order.getId()).setUserId(order.getUserId()).setMessage(null));
|
||||
// 4.2 发送订阅消息
|
||||
getSelf().sendDeliveryOrderMessage(order, deliveryReqVO);
|
||||
} else {
|
||||
if (body != null) {
|
||||
throw exception(OMS_EXPRESS_ORDER_CREATE_ERROR, body.getErrorMsg());
|
||||
} else {
|
||||
throw exception(OMS_EXPRESS_ORDER_CREATE_ERROR, "接口无返回内容");
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// log.error("[deliverySto][申通快递订单创建失败,订单ID:{}]", id, e);
|
||||
// throw exception(OMS_EXPRESS_ORDER_CREATE_ERROR, e.getMessage());
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deliveryKuaidi100(Long id) {
|
||||
// 1.1 校验并获得交易订单(可发货)
|
||||
TradeOrderDO order = validateOrderDeliverable(id);
|
||||
// 1.2 校验 deliveryType 是否为快递,是快递才可以发货
|
||||
if (ObjectUtil.notEqual(order.getDeliveryType(), DeliveryTypeEnum.EXPRESS.getType())) {
|
||||
throw exception(ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS);
|
||||
}
|
||||
if (ObjectUtil.notEqual(order.getStatus(), TradeOrderStatusEnum.UNDELIVERED.getStatus())) {
|
||||
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
|
||||
}
|
||||
|
||||
String key = "moaqEZhD6889";
|
||||
String secret = "f46d0c0071be4841818482c5ed8c27b5";
|
||||
|
||||
ManInfo recManInfo = new ManInfo();
|
||||
recManInfo.setName(order.getReceiverName());
|
||||
recManInfo.setMobile(order.getReceiverMobile());
|
||||
recManInfo.setPrintAddr(AreaUtils.format(
|
||||
order.getReceiverAreaId()).replace(" ", "")
|
||||
+order.getReceiverDetailAddress());
|
||||
|
||||
ManInfo sendManInfo = new ManInfo();
|
||||
sendManInfo.setName("杨林");
|
||||
sendManInfo.setMobile("15325380110");
|
||||
sendManInfo.setPrintAddr("浙江省嘉兴市南湖区新嘉街道建国北路锦江商务楼3A");
|
||||
|
||||
OrderReq orderReq = new OrderReq();
|
||||
orderReq.setKuaidicom(CompanyConstant.ST);
|
||||
orderReq.setCount(1);
|
||||
orderReq.setPartnerId("314056015779");
|
||||
orderReq.setPartnerKey("JXsto123");
|
||||
orderReq.setNet("314056");
|
||||
orderReq.setCode("44");
|
||||
// orderReq.setSiid("siid");
|
||||
orderReq.setTempId("bc7291b4521c40d981767247c1e8f52d");
|
||||
orderReq.setSendMan(sendManInfo);
|
||||
orderReq.setRecMan(recManInfo);
|
||||
|
||||
// orderReq.setPrintType(PrintType.CLOUD);
|
||||
orderReq.setPrintType(PrintType.HTML);
|
||||
|
||||
String param = new Gson().toJson(orderReq);
|
||||
String t = System.currentTimeMillis() + "";
|
||||
|
||||
PrintReq printReq = new PrintReq();
|
||||
printReq.setT(t);
|
||||
printReq.setKey(key);
|
||||
printReq.setSign(SignUtils.printSign(param, t, key, secret));
|
||||
printReq.setMethod(ApiInfoConstant.ORDER);
|
||||
printReq.setParam(param);
|
||||
|
||||
IBaseClient baseClient = new LabelV2();
|
||||
try {
|
||||
HttpResult httpResult = baseClient.execute(printReq);
|
||||
System.out.println(httpResult);
|
||||
if (httpResult.getStatus() == org.apache.http.HttpStatus.SC_OK && StringUtils.isNotBlank(httpResult.getBody())){
|
||||
Result<OrderResult> result = new Gson().fromJson(httpResult.getBody(),new TypeToken<Result<OrderResult>>(){}.getType());
|
||||
if (result.getCode() == 200){
|
||||
// 2. 更新订单为已发货
|
||||
TradeOrderDO updateOrderObj = new TradeOrderDO();
|
||||
// 2.1 快递发货
|
||||
TradeOrderDeliveryReqVO deliveryReqVO = new TradeOrderDeliveryReqVO();
|
||||
deliveryReqVO.setId(order.getId());
|
||||
//1是申通
|
||||
deliveryReqVO.setLogisticsId(1L);
|
||||
//快递单号
|
||||
deliveryReqVO.setLogisticsNo(result.getData().getKuaidinum());
|
||||
DeliveryExpressDO express = deliveryExpressService.validateDeliveryExpress(deliveryReqVO.getLogisticsId());
|
||||
updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo());
|
||||
|
||||
// 执行更新
|
||||
updateOrderObj.setStatus(TradeOrderStatusEnum.DELIVERED.getStatus()).setDeliveryTime(LocalDateTime.now());
|
||||
int updateCount = tradeOrderMapper.updateByIdAndStatus(order.getId(), order.getStatus(), updateOrderObj);
|
||||
if (updateCount == 0) {
|
||||
throw exception(ORDER_DELIVERY_FAIL_STATUS_NOT_UNDELIVERED);
|
||||
}
|
||||
|
||||
// 3. 记录订单日志
|
||||
TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.DELIVERED.getStatus(),
|
||||
MapUtil.<String, Object>builder().put("deliveryName", express != null ? express.getName() : "")
|
||||
.put("logisticsNo", express != null ? deliveryReqVO.getLogisticsNo() : "").build());
|
||||
|
||||
// 4.1 发送站内信
|
||||
tradeMessageService.sendMessageWhenDeliveryOrder(new TradeOrderMessageWhenDeliveryOrderReqBO()
|
||||
.setOrderId(order.getId()).setUserId(order.getUserId()).setMessage(null));
|
||||
// 4.2 发送订阅消息
|
||||
getSelf().sendDeliveryOrderMessage(order, deliveryReqVO);
|
||||
return result.getData().getLabel();
|
||||
}else {
|
||||
throw exception(OMS_EXPRESS_ORDER_CREATE_ERROR, result.getMessage());
|
||||
}
|
||||
}else {
|
||||
throw exception(OMS_EXPRESS_ORDER_CREATE_ERROR, "接口无返回内容");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw exception(OMS_EXPRESS_ORDER_CREATE_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendDeliveryOrderMessage(TradeOrderDO order, TradeOrderDeliveryReqVO deliveryReqVO) {
|
||||
// 构建并发送模版消息
|
||||
@@ -928,6 +1213,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
tradeOrderMapper.updateById(new TradeOrderDO().setId(orderId).setGiveCouponIds(giveCouponIds));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建单个订单的评论
|
||||
*
|
||||
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
package cn.iocoder.yudao.module.trade.service.order.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class StoOrderCreateContentBo {
|
||||
//订单号(客户系统自己生成,唯一)
|
||||
private String orderNo;
|
||||
//订单来源(订阅服务时填写的来源编码)
|
||||
private String orderSource;
|
||||
//获取面单的类型(00-普通、03-国际、01-代收、02-到付、04-生鲜),默认普通业务,如果有其他业务先与业务方沟通清楚
|
||||
private String billType;
|
||||
// 订单类型(01-普通订单、02-调度订单)默认01-普通订单,如果有散单业务需先业务方沟通清楚
|
||||
private String orderType;
|
||||
// 寄件人信息
|
||||
private Sender sender;
|
||||
//收件人信息
|
||||
private Receiver receiver;
|
||||
//包裹信息
|
||||
private Cargo cargo;
|
||||
//客户信息,在线下单取运单号必填,代单号下单不需要填写,测试账号传值如下,生产账号联系合作业务方提供
|
||||
private Customer customer;
|
||||
//国际订单附属信息(国际业务订单必填,其他业务不要填写)
|
||||
private InternationalAnnex internationalAnnex;
|
||||
|
||||
private String waybillNo;
|
||||
|
||||
private AssignAnnex assignAnnex;
|
||||
|
||||
private String codValue;
|
||||
|
||||
private String freightCollectValue;
|
||||
|
||||
private String timelessType;
|
||||
|
||||
private String productType;
|
||||
|
||||
private List<String> serviceTypeList;
|
||||
|
||||
private ExtendFieldMap extendFieldMap;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String expressDirection;
|
||||
|
||||
private String createChannel;
|
||||
|
||||
private String regionType;
|
||||
|
||||
private InsuredAnnex insuredAnnex;
|
||||
|
||||
private String expectValue;
|
||||
|
||||
private String payModel;
|
||||
|
||||
/**
|
||||
* 发货人信息
|
||||
*/
|
||||
@Data
|
||||
public static class Sender
|
||||
{
|
||||
private String name;
|
||||
|
||||
private String tel;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private String postCode;
|
||||
|
||||
private String country;
|
||||
|
||||
private String province;
|
||||
|
||||
private String city;
|
||||
|
||||
private String area;
|
||||
|
||||
private String town;
|
||||
|
||||
private String address;
|
||||
}
|
||||
|
||||
/**
|
||||
* 收货人信息
|
||||
*/
|
||||
@Data
|
||||
public static class Receiver
|
||||
{
|
||||
private String name;
|
||||
|
||||
private String tel;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private String postCode;
|
||||
|
||||
private String country;
|
||||
|
||||
private String province;
|
||||
|
||||
private String city;
|
||||
|
||||
private String area;
|
||||
|
||||
private String town;
|
||||
|
||||
private String address;
|
||||
|
||||
private String safeNo;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Cargo
|
||||
{
|
||||
private String battery;
|
||||
|
||||
private String goodsType;
|
||||
|
||||
private String goodsName;
|
||||
|
||||
private Integer goodsCount;
|
||||
|
||||
private Double spaceX;
|
||||
|
||||
private Double spaceY;
|
||||
|
||||
private Double spaceZ;
|
||||
|
||||
private Double weight;
|
||||
|
||||
private String goodsAmount;
|
||||
|
||||
private List<CargoItem> cargoItemList;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class CargoItem
|
||||
{
|
||||
private String serialNumber;
|
||||
|
||||
private String referenceNumber;
|
||||
|
||||
private String productId;
|
||||
|
||||
private String name;
|
||||
|
||||
private int qty;
|
||||
|
||||
private int unitPrice;
|
||||
|
||||
private int amount;
|
||||
|
||||
private String currency;
|
||||
|
||||
private int weight;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class Customer
|
||||
{
|
||||
private String siteCode;
|
||||
|
||||
private String customerName;
|
||||
|
||||
private String sitePwd;
|
||||
|
||||
private String monthCustomerCode;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class InternationalAnnex
|
||||
{
|
||||
private String internationalProductType;
|
||||
|
||||
private boolean customsDeclaration;
|
||||
|
||||
private String senderCountry;
|
||||
|
||||
private String receiverCountry;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class AssignAnnex
|
||||
{
|
||||
private String takeCompanyCode;
|
||||
|
||||
private String takeUserCode;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ExtendFieldMap
|
||||
{
|
||||
private String mapValue;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class InsuredAnnex
|
||||
{
|
||||
private String insuredValue;
|
||||
|
||||
private String goodsValue;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.trade.service.order.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 申通请求公共参数
|
||||
*/
|
||||
@Data
|
||||
public class StoRequestBo {
|
||||
// api_name:调用的目标接口ID(控制台列表中称为API,为英文、数字及下划线组成的字串,非API中文名称)。
|
||||
private String api_name;
|
||||
// content:结构化的业务报文体,具体内容由订阅的接口规定(API文档中的 请求参数 表格),可以是 JSON 或 XML 格式的字串。请参考下方“请求示例”,注意:content内容中不允许有特殊字符,例如\u001b。
|
||||
private String content;
|
||||
// from_appkey:订阅方appkey,即合作方应用key。
|
||||
private String from_appkey;
|
||||
// from_code:订阅方资源code,即合作方应用的资源code。
|
||||
private String from_code;
|
||||
// to_appkey:注册方appkey,即提供该订阅接口服务的申通应用key,
|
||||
private String to_appkey;
|
||||
// to_code:注册方资源code,即上述申通应用的资源code,目前值等于to_appkey。
|
||||
private String to_code;
|
||||
// data_digest:报文签名,网关会统一校验。构造方法请参考下方“签名构造”。
|
||||
private String data_digest;
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.trade.service.order.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@Data
|
||||
@XmlRootElement(name = "response")
|
||||
public class StoResponseBo {
|
||||
|
||||
@XmlElement(name = "success")
|
||||
private boolean success;
|
||||
|
||||
@XmlElement(name = "errorCode")
|
||||
private String errorCode;
|
||||
|
||||
@XmlElement(name = "errorMsg")
|
||||
private String errorMsg;
|
||||
|
||||
@XmlElement(name = "data")
|
||||
private OrderCreateResponse data;
|
||||
|
||||
@Data
|
||||
public static class OrderCreateResponse {
|
||||
private String orderNo;
|
||||
|
||||
private String waybillNo;
|
||||
|
||||
private String bigWord;
|
||||
|
||||
private String packagePlace;
|
||||
|
||||
private String sourceOrderId;
|
||||
|
||||
private String safeNo;
|
||||
|
||||
private String newBlockCode;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.trade.util;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
public class SignatureUtils {
|
||||
|
||||
private SignatureUtils() {
|
||||
throw new IllegalStateException("SignatureUtils class");
|
||||
}
|
||||
|
||||
public static String getSignature(String content, String secretKey) {
|
||||
String text = content + secretKey;
|
||||
byte[] md5 = DigestUtils.md5(text);
|
||||
return Base64.encodeBase64String(md5);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String content="{\"orderNo\":\"8885452262\"}";
|
||||
String secretKey="123abc";
|
||||
System.out.println(getSignature(content,secretKey));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -80,7 +80,7 @@ spring:
|
||||
host: 127.0.0.1 # 地址
|
||||
port: 6379 # 端口
|
||||
database: 0 # 数据库索引
|
||||
# password: 123456 # 密码,建议生产环境开启
|
||||
password: 123456 # 密码,建议生产环境开启
|
||||
|
||||
--- #################### 定时任务相关配置 ####################
|
||||
|
||||
|
||||
@@ -367,9 +367,9 @@ pf4j:
|
||||
|
||||
sto:
|
||||
# 正式环境
|
||||
# api_url: 'https://cloudinter-linkgateway.sto.cn/gateway/link.do'
|
||||
api_url: 'https://cloudinter-linkgateway.sto.cn/gateway/link.do'
|
||||
# 测试环境
|
||||
api_url: 'http://cloudinter-linkgatewaytest.sto.cn/gateway/link.do'
|
||||
# api_url: 'http://cloudinter-linkgatewaytest.sto.cn/gateway/link.do'
|
||||
from_appkey: 'CAKWRKlMXSPewDL'
|
||||
from_code: 'CAKWRKlMXSPewDL'
|
||||
to_appkey: 'sto_oms'
|
||||
|
||||
Reference in new issue
Block a user