Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
# Conflicts: # yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppCommentController.java # yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentBaseVO.java # yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java # yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java # yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.javaplp
commit
5cfcaa1a6e
@ -1,24 +0,0 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 营销")
|
||||
@RestController
|
||||
@RequestMapping("/market/test")
|
||||
@Validated
|
||||
public class AppMarketTestController {
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取 market 信息")
|
||||
public CommonResult<String> get() {
|
||||
return success("true");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.activity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "用户 App - 营销活动 Response VO")
|
||||
@Data
|
||||
public class AppActivityRespVO {
|
||||
|
||||
@Schema(description = "活动编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "活动类型", required = true, example = "1") // 对应 PromotionTypeEnum 枚举
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "活动名称", required = true, example = "618 大促")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "活动开始时间", required = true)
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "活动结束时间", required = true)
|
||||
private LocalDateTime endTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 优惠劵")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/coupon")
|
||||
@Validated
|
||||
public class AppCouponController {
|
||||
|
||||
// TODO 芋艿:待实现
|
||||
@PostMapping("/take")
|
||||
@Operation(summary = "领取优惠劵")
|
||||
public CommonResult<Long> takeCoupon(@RequestBody AppCouponTemplatePageReqVO pageReqVO) {
|
||||
return success(1L);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 优惠劵模板")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/coupon-template")
|
||||
@Validated
|
||||
public class AppCouponTemplateController {
|
||||
|
||||
@Resource
|
||||
private CouponTemplateService couponTemplateService;
|
||||
|
||||
// TODO 芋艿:待实现
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得优惠劵模版列表") // 目前主要给商品详情使用
|
||||
@Parameters({
|
||||
@Parameter(name = "spuId", description = "商品 SPU 编号", required = true),
|
||||
@Parameter(name = "useType", description = "使用类型"),
|
||||
@Parameter(name = "count", description = "数量", required = true)
|
||||
})
|
||||
public CommonResult<List<AppCouponTemplateRespVO>> getCouponTemplateList(@RequestParam("spuId") Long spuId,
|
||||
@RequestParam(value = "useType", required = false) Integer useType) {
|
||||
List<AppCouponTemplateRespVO> list = new ArrayList<>();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
AppCouponTemplateRespVO vo = new AppCouponTemplateRespVO();
|
||||
vo.setId(i + 1L);
|
||||
vo.setName("优惠劵" + (i + 1));
|
||||
vo.setTakeLimitCount(random.nextInt(10) + 1);
|
||||
vo.setUsePrice(random.nextInt(100) * 100);
|
||||
vo.setValidityType(random.nextInt(2) + 1);
|
||||
if (vo.getValidityType() == 1) {
|
||||
vo.setValidStartTime(LocalDateTime.now().plusDays(random.nextInt(10)));
|
||||
vo.setValidEndTime(LocalDateTime.now().plusDays(random.nextInt(20) + 10));
|
||||
} else {
|
||||
vo.setFixedStartTerm(random.nextInt(10));
|
||||
vo.setFixedEndTerm(random.nextInt(10) + vo.getFixedStartTerm() + 1);
|
||||
}
|
||||
vo.setDiscountType(random.nextInt(2) + 1);
|
||||
if (vo.getDiscountType() == 1) {
|
||||
vo.setDiscountPercent(null);
|
||||
vo.setDiscountPrice(random.nextInt(50) * 100);
|
||||
vo.setDiscountLimitPrice(null);
|
||||
} else {
|
||||
vo.setDiscountPercent(random.nextInt(90) + 10);
|
||||
vo.setDiscountPrice(null);
|
||||
vo.setDiscountLimitPrice(random.nextInt(200) * 100);
|
||||
}
|
||||
vo.setTakeStatus(random.nextBoolean());
|
||||
list.add(vo);
|
||||
}
|
||||
return success(list);
|
||||
}
|
||||
|
||||
// TODO 芋艿:待实现
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得优惠劵模版分页")
|
||||
public CommonResult<PageResult<AppCouponTemplateRespVO>> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "用户 App - 优惠劵领取 Request VO")
|
||||
@Data
|
||||
public class AppCouponTakeReqVO {
|
||||
|
||||
@Schema(description = "优惠劵模板编号", example = "1")
|
||||
@NotNull(message = "优惠劵模板编号不能为空")
|
||||
private Long templateId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "用户 App - 优惠劵模板分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AppCouponTemplatePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "使用类型", example = "1")
|
||||
// TODO 芋艿:这里要限制下枚举的使用
|
||||
private Integer useType;
|
||||
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.seckill;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.AppSeckillActivitiDetailRespVO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 秒杀活动")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/seckill-activity")
|
||||
@Validated
|
||||
public class AppSeckillActivityController {
|
||||
|
||||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得秒杀活动明细")
|
||||
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
|
||||
public CommonResult<AppSeckillActivitiDetailRespVO> getSeckillActivity(@RequestParam("id") Long id) {
|
||||
// TODO 芋艿:如果禁用的时候,需要抛出异常;
|
||||
AppSeckillActivitiDetailRespVO obj = new AppSeckillActivitiDetailRespVO();
|
||||
// 设置其属性的值
|
||||
obj.setId(id);
|
||||
obj.setName("晚九点限时秒杀");
|
||||
obj.setStatus(1);
|
||||
obj.setStartTime(LocalDateTime.of(2023, 6, 11, 0, 0, 0));
|
||||
obj.setEndTime(LocalDateTime.of(2023, 6, 11, 23, 59, 0));
|
||||
obj.setSpuId(633L);
|
||||
// 创建一个Product对象的列表
|
||||
List<AppSeckillActivitiDetailRespVO.Product> productList = new ArrayList<>();
|
||||
// 创建三个新的Product对象并设置其属性的值
|
||||
AppSeckillActivitiDetailRespVO.Product product1 = new AppSeckillActivitiDetailRespVO.Product();
|
||||
product1.setSkuId(1L);
|
||||
product1.setSeckillPrice(100);
|
||||
product1.setQuota(50);
|
||||
product1.setLimitCount(3);
|
||||
// 将第一个Product对象添加到列表中
|
||||
productList.add(product1);
|
||||
// 创建第二个Product对象并设置其属性的值
|
||||
AppSeckillActivitiDetailRespVO.Product product2 = new AppSeckillActivitiDetailRespVO.Product();
|
||||
product2.setSkuId(2L);
|
||||
product2.setSeckillPrice(200);
|
||||
product2.setQuota(100);
|
||||
product2.setLimitCount(4);
|
||||
// 将第二个Product对象添加到列表中
|
||||
productList.add(product2);
|
||||
// 创建第三个Product对象并设置其属性的值
|
||||
AppSeckillActivitiDetailRespVO.Product product3 = new AppSeckillActivitiDetailRespVO.Product();
|
||||
product3.setSkuId(3L);
|
||||
product3.setSeckillPrice(300);
|
||||
product3.setQuota(150);
|
||||
product3.setLimitCount(5);
|
||||
// 将第三个Product对象添加到列表中
|
||||
productList.add(product3);
|
||||
// 将Product列表设置为对象的属性值
|
||||
obj.setProducts(productList);
|
||||
return success(obj);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.seckill.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 秒杀活动 Response VO")
|
||||
@Data
|
||||
public class AppSeckillActivitiDetailRespVO {
|
||||
|
||||
@Schema(description = "秒杀活动编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "秒杀活动名称", required = true, example = "晚九点限时秒杀")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "活动状态", required = true, example = "1")
|
||||
private Integer status;
|
||||
|
||||
// TODO @芋艿:开始时间、结束时间,要和场次结合起来;就是要算到当前场次,是几点哈;
|
||||
|
||||
@Schema(description = "活动开始时间", required = true)
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "活动结束时间", required = true)
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", required = true, example = "2048")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品 SPU 名字", required = true)
|
||||
private List<Product> products;
|
||||
|
||||
@Schema(description = "商品信息")
|
||||
@Data
|
||||
public static class Product {
|
||||
|
||||
@Schema(description = "商品 SKU 编号", required = true, example = "4096")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "秒杀金额,单位:分", required = true, example = "100")
|
||||
private Integer seckillPrice;
|
||||
|
||||
@Schema(description = "秒杀限量库存", required = true, example = "50")
|
||||
private Integer quota;
|
||||
|
||||
@Schema(description = "limitCount", required = true, example = "10")
|
||||
private Integer limitCount;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.ExpressQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.ExpressQueryRespDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 快递查询服务商
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
public interface ExpressQueryProvider {
|
||||
|
||||
/**
|
||||
* 快递实时查询
|
||||
*
|
||||
* @param reqDTO 查询请求参数
|
||||
*/
|
||||
List<ExpressQueryRespDTO> realTimeQueryExpress(ExpressQueryReqDTO reqDTO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.convert;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.ExpressQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.ExpressQueryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.provider.kd100.Kd100ExpressQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.provider.kd100.Kd100ExpressQueryRespDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.provider.kdniao.KdNiaoExpressQueryReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.provider.kdniao.KdNiaoExpressQueryRespDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ExpressQueryConvert {
|
||||
|
||||
ExpressQueryConvert INSTANCE = Mappers.getMapper(ExpressQueryConvert.class);
|
||||
|
||||
List<ExpressQueryRespDTO> convertList(List<KdNiaoExpressQueryRespDTO.ExpressTrack> expressTrackList);
|
||||
|
||||
List<ExpressQueryRespDTO> convertList2(List<Kd100ExpressQueryRespDTO.ExpressTrack> expressTrackList);
|
||||
|
||||
KdNiaoExpressQueryReqDTO convert(ExpressQueryReqDTO dto);
|
||||
|
||||
Kd100ExpressQueryReqDTO convert2(ExpressQueryReqDTO dto);
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.dto.provider.kd100;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 快递 100 实时快递查询 Resp DTO 参见 <a href="https://api.kuaidi100.com/document/5f0ffb5ebc8da837cbd8aefc">快递 100 文档</a>
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class Kd100ExpressQueryRespDTO {
|
||||
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
@JsonProperty("com")
|
||||
private String expressCompanyCode;
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
@JsonProperty("nu")
|
||||
private String logisticsNo;
|
||||
/**
|
||||
* 快递单当前状态
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 查询结果
|
||||
*
|
||||
* 失败返回 "false"
|
||||
*/
|
||||
private String result;
|
||||
/**
|
||||
* 查询结果失败时的错误信息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
@JsonProperty("data")
|
||||
private List<ExpressTrack> tracks;
|
||||
|
||||
@Data
|
||||
public static class ExpressTrack {
|
||||
/**
|
||||
* 轨迹发生时间
|
||||
*/
|
||||
@JsonProperty("time")
|
||||
private String time;
|
||||
/**
|
||||
* 轨迹描述
|
||||
*/
|
||||
@JsonProperty("context")
|
||||
private String state;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.dto.provider.kdniao;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 快递鸟快递查询 Resp DTO 参见 <a href="https://www.yuque.com/kdnjishuzhichi/dfcrg1/wugo6k">快递鸟接口文档</a>
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Data
|
||||
public class KdNiaoExpressQueryRespDTO {
|
||||
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
@JsonProperty("ShipperCode")
|
||||
private String expressCompanyCode;
|
||||
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
@JsonProperty("LogisticCode")
|
||||
private String logisticsNo;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
@JsonProperty("OrderCode")
|
||||
private String orderNo;
|
||||
|
||||
@JsonProperty("EBusinessID")
|
||||
private String businessId;
|
||||
@JsonProperty("State")
|
||||
private String state;
|
||||
/**
|
||||
* 成功与否
|
||||
*/
|
||||
@JsonProperty("Success")
|
||||
private Boolean success;
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
@JsonProperty("Reason")
|
||||
private String reason;
|
||||
|
||||
@JsonProperty("Traces")
|
||||
private List<ExpressTrack> tracks;
|
||||
|
||||
@Data
|
||||
public static class ExpressTrack {
|
||||
/**
|
||||
* 轨迹发生时间
|
||||
*/
|
||||
@JsonProperty("AcceptTime")
|
||||
private String time;
|
||||
/**
|
||||
* 轨迹描述
|
||||
*/
|
||||
@JsonProperty("AcceptStation")
|
||||
private String state;
|
||||
}
|
||||
|
||||
// {
|
||||
// "EBusinessID": "1237100",
|
||||
// "Traces": [],
|
||||
// "State": "0",
|
||||
// "ShipperCode": "STO",
|
||||
// "LogisticCode": "638650888018",
|
||||
// "Success": true,
|
||||
// "Reason": "暂无轨迹信息"
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.trade.framework.delivery.core.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.config.TradeExpressQueryProperties;
|
||||
import cn.iocoder.yudao.module.trade.framework.delivery.core.dto.ExpressQueryReqDTO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
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 static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
/**
|
||||
* @author jason
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = Kd100ExpressQueryProviderTest.Application.class)
|
||||
@ActiveProfiles("trade-delivery-query") // 设置使用 trade-delivery-query 配置文件
|
||||
public class Kd100ExpressQueryProviderTest {
|
||||
@Resource
|
||||
private RestTemplateBuilder builder;
|
||||
@Resource
|
||||
private TradeExpressQueryProperties expressQueryProperties;
|
||||
|
||||
private Kd100ExpressQueryProvider kd100ExpressQueryProvider;
|
||||
|
||||
@BeforeEach
|
||||
public void init(){
|
||||
kd100ExpressQueryProvider = new Kd100ExpressQueryProvider(builder.build(),expressQueryProperties.getKd100());
|
||||
}
|
||||
@Test
|
||||
@Disabled("需要 授权 key. 暂时忽略")
|
||||
void testRealTimeQueryExpressFailed() {
|
||||
ServiceException t = assertThrows(ServiceException.class, () -> {
|
||||
ExpressQueryReqDTO reqDTO = new ExpressQueryReqDTO();
|
||||
reqDTO.setExpressCompanyCode("yto");
|
||||
reqDTO.setLogisticsNo("YT9383342193097");
|
||||
kd100ExpressQueryProvider.realTimeQueryExpress(reqDTO);
|
||||
});
|
||||
assertEquals(1011003007, t.getCode());
|
||||
}
|
||||
|
||||
@Import({
|
||||
RestTemplateAutoConfiguration.class
|
||||
})
|
||||
@EnableConfigurationProperties(TradeExpressQueryProperties.class)
|
||||
public static class Application {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
spring:
|
||||
main:
|
||||
lazy-initialization: true # 开启懒加载,加快速度
|
||||
banner-mode: off # 单元测试,禁用 Banner
|
||||
|
||||
--- #################### 交易快递查询相关配置 ####################
|
||||
|
||||
yudao:
|
||||
trade:
|
||||
express:
|
||||
query:
|
||||
express-query-provider: kd_niao
|
||||
kd-niao:
|
||||
api-key: xxx
|
||||
business-id: xxxxxxxx
|
||||
kd100:
|
||||
customer: xxxx
|
||||
key: xxxxx
|
||||
Loading…
Reference in New Issue