mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	快递查询、 通过快递鸟查询实现
This commit is contained in:
		@@ -0,0 +1,52 @@
 | 
			
		||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.impl;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressQueryProperties;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.ExpressQueryReqDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.ExpressQueryRespDTO;
 | 
			
		||||
import org.junit.jupiter.api.BeforeEach;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
 | 
			
		||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
 | 
			
		||||
import org.springframework.boot.test.context.SpringBootTest;
 | 
			
		||||
import org.springframework.boot.web.client.RestTemplateBuilder;
 | 
			
		||||
import org.springframework.context.annotation.Import;
 | 
			
		||||
import org.springframework.test.context.ActiveProfiles;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static org.junit.jupiter.api.Assertions.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author jason
 | 
			
		||||
 */
 | 
			
		||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = KdNiaoExpressQueryProviderTest.Application.class)
 | 
			
		||||
@ActiveProfiles("trade-delivery-query") // 设置使用 trade-delivery-query 配置文件
 | 
			
		||||
public class KdNiaoExpressQueryProviderTest {
 | 
			
		||||
    @Resource
 | 
			
		||||
    private RestTemplateBuilder builder;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private TradeExpressQueryProperties expressQueryProperties;
 | 
			
		||||
 | 
			
		||||
    private KdNiaoExpressQueryProvider kdNiaoExpressQueryProvider;
 | 
			
		||||
 | 
			
		||||
    @BeforeEach
 | 
			
		||||
    public void init(){
 | 
			
		||||
        kdNiaoExpressQueryProvider = new KdNiaoExpressQueryProvider(builder.build(),expressQueryProperties.getKdNiao());
 | 
			
		||||
    }
 | 
			
		||||
    @Test
 | 
			
		||||
    void queryExpress() {
 | 
			
		||||
        ExpressQueryReqDTO reqDTO = new ExpressQueryReqDTO();
 | 
			
		||||
        reqDTO.setExpressCompanyCode("yto");
 | 
			
		||||
        reqDTO.setLogisticsNo("YT1764381060802");
 | 
			
		||||
        List<ExpressQueryRespDTO> expressQueryRespDTOS = kdNiaoExpressQueryProvider.realTimeQueryExpress(reqDTO);
 | 
			
		||||
        assertNotNull(expressQueryRespDTOS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Import({
 | 
			
		||||
            RestTemplateAutoConfiguration.class
 | 
			
		||||
    })
 | 
			
		||||
    @EnableConfigurationProperties(TradeExpressQueryProperties.class)
 | 
			
		||||
    public static class Application {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,15 @@
 | 
			
		||||
spring:
 | 
			
		||||
  main:
 | 
			
		||||
    lazy-initialization: true # 开启懒加载,加快速度
 | 
			
		||||
    banner-mode: off # 单元测试,禁用 Banner
 | 
			
		||||
 | 
			
		||||
--- #################### 数据库相关配置 ####################
 | 
			
		||||
 | 
			
		||||
yudao:
 | 
			
		||||
  trade:
 | 
			
		||||
    express:
 | 
			
		||||
      query:
 | 
			
		||||
        express-query-provider: kd_niao
 | 
			
		||||
        kd-niao:
 | 
			
		||||
          api-key: 8e22d97d-6a3d-442e-b243-2190c9f0cfdd
 | 
			
		||||
          business-id: 1801700
 | 
			
		||||
		Reference in New Issue
	
	Block a user