parent
36da5d69b0
commit
e4a2c738b2
@ -1,21 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.jackson.core.databind;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
|
|
||||||
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_HOUR_MINUTE_SECOND;
|
|
||||||
|
|
||||||
public class LocalTimeJson {
|
|
||||||
|
|
||||||
public static final LocalTimeSerializer SERIALIZER = new LocalTimeSerializer(DateTimeFormatter
|
|
||||||
.ofPattern(FORMAT_HOUR_MINUTE_SECOND)
|
|
||||||
.withZone(ZoneId.systemDefault()));
|
|
||||||
|
|
||||||
public static final LocalTimeDeserializer DESERIALIZABLE = new LocalTimeDeserializer(DateTimeFormatter
|
|
||||||
.ofPattern(FORMAT_HOUR_MINUTE_SECOND)
|
|
||||||
.withZone(ZoneId.systemDefault()));
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.controller.app.order.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快递查询的轨迹 Resp DTO
|
||||||
|
*
|
||||||
|
* @author jason
|
||||||
|
*/
|
||||||
|
@Schema(description = "用户 App - 快递查询的轨迹 Response VO")
|
||||||
|
@Data
|
||||||
|
public class AppOrderExpressTrackRespDTO {
|
||||||
|
|
||||||
|
@Schema(description = "发生时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private LocalDateTime time;
|
||||||
|
|
||||||
|
@Schema(description = "快递状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "已签收")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.service.order;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交易订单【读】 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface TradeOrderQueryService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得订单的物流轨迹
|
||||||
|
*
|
||||||
|
* @param id 订单编号
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @return 物流轨迹数组
|
||||||
|
*/
|
||||||
|
List<ExpressTrackRespDTO> getExpressTrackList(Long id, Long userId);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.service.order;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
|
||||||
|
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||||
|
import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.ExpressClientFactory;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交易订单【读】 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ExpressClientFactory expressClientFactory;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TradeOrderMapper tradeOrderMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DeliveryExpressService deliveryExpressService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ExpressTrackRespDTO> getExpressTrackList(Long id, Long userId) {
|
||||||
|
// 查询订单
|
||||||
|
TradeOrderDO order = tradeOrderMapper.selectByIdAndUserId(id, userId);
|
||||||
|
if (order == null) {
|
||||||
|
throw exception(ORDER_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询物流公司
|
||||||
|
if (order.getLogisticsId() == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
DeliveryExpressDO express = deliveryExpressService.getDeliveryExpress(order.getLogisticsId());
|
||||||
|
if (express == null) {
|
||||||
|
throw exception(EXPRESS_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询物流轨迹
|
||||||
|
return expressClientFactory.getDefaultExpressClient().getExpressTrackList(
|
||||||
|
new ExpressTrackQueryReqDTO().setExpressCode(express.getCode()).setLogisticsNo(order.getLogisticsNo())
|
||||||
|
.setPhone(order.getReceiverMobile()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kd100.Kd100ExpressClient;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link Kd100ExpressClient} 的集成测试
|
||||||
|
*
|
||||||
|
* @author jason
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class Kd100ExpressClientIntegrationTest {
|
||||||
|
|
||||||
|
private Kd100ExpressClient client;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void init() {
|
||||||
|
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
||||||
|
TradeExpressProperties.Kd100Config config = new TradeExpressProperties.Kd100Config()
|
||||||
|
.setKey("pLXUGAwK5305")
|
||||||
|
.setCustomer("E77DF18BE109F454A5CD319E44BF5177");
|
||||||
|
client = new Kd100ExpressClient(restTemplate, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled("集成测试,暂时忽略")
|
||||||
|
public void testGetExpressTrackList() {
|
||||||
|
ExpressTrackQueryReqDTO reqDTO = new ExpressTrackQueryReqDTO();
|
||||||
|
reqDTO.setExpressCode("STO");
|
||||||
|
reqDTO.setLogisticsNo("773220402764314");
|
||||||
|
List<ExpressTrackRespDTO> tracks = client.getExpressTrackList(reqDTO);
|
||||||
|
System.out.println(JsonUtils.toJsonPrettyString(tracks));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressProperties;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackQueryReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.trade.framework.delivery.core.client.impl.kdniao.KdNiaoExpressClient;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link KdNiaoExpressClient} 的集成测试
|
||||||
|
*
|
||||||
|
* @author jason
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class KdNiaoExpressClientIntegrationTest {
|
||||||
|
|
||||||
|
private KdNiaoExpressClient client;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void init() {
|
||||||
|
RestTemplate restTemplate = new RestTemplateBuilder().build();
|
||||||
|
TradeExpressProperties.KdNiaoConfig config = new TradeExpressProperties.KdNiaoConfig()
|
||||||
|
.setApiKey("cb022f1e-48f1-4c4a-a723-9001ac9676b8")
|
||||||
|
.setBusinessId("1809751");
|
||||||
|
client = new KdNiaoExpressClient(restTemplate, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled("集成测试,暂时忽略")
|
||||||
|
public void testGetExpressTrackList() {
|
||||||
|
ExpressTrackQueryReqDTO reqDTO = new ExpressTrackQueryReqDTO();
|
||||||
|
reqDTO.setExpressCode("STO");
|
||||||
|
reqDTO.setLogisticsNo("663220402764314");
|
||||||
|
List<ExpressTrackRespDTO> tracks = client.getExpressTrackList(reqDTO);
|
||||||
|
System.out.println(JsonUtils.toJsonPrettyString(tracks));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue