Commit 9e894e04306bdd37ef0de348a3818d6b01ea231d
1 parent
66210e5e
mall + promotion:增加优惠劵的 mock 接口
Showing
6 changed files
with
215 additions
and
27 deletions
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java
| ... | ... | @@ -4,12 +4,10 @@ import cn.hutool.core.date.DateUtil; |
| 4 | 4 | import cn.hutool.core.util.RandomUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 7 | -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 8 | 7 | import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; |
| 9 | 8 | import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO; |
| 10 | 9 | import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO; |
| 11 | 10 | import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; |
| 12 | -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentAdditionalReqVO; | |
| 13 | 11 | import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; |
| 14 | 12 | import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO; |
| 15 | 13 | import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; |
| ... | ... | @@ -93,12 +91,10 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest { |
| 93 | 91 | o.setSkuId(generateId()); |
| 94 | 92 | o.setDescriptionScores(ProductCommentScoresEnum.FOUR.getScores()); |
| 95 | 93 | o.setBenefitScores(ProductCommentScoresEnum.FOUR.getScores()); |
| 96 | - o.setDeliveryScores(ProductCommentScoresEnum.FOUR.getScores()); | |
| 97 | 94 | o.setContent("真好吃"); |
| 98 | 95 | o.setReplyUserId(generateId()); |
| 99 | 96 | o.setReplyContent("确实"); |
| 100 | 97 | o.setReplyTime(LocalDateTime.now()); |
| 101 | - o.setAdditionalTime(LocalDateTime.now()); | |
| 102 | 98 | o.setCreateTime(LocalDateTime.now()); |
| 103 | 99 | o.setUpdateTime(LocalDateTime.now()); |
| 104 | 100 | }); |
| ... | ... | @@ -196,27 +192,4 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest { |
| 196 | 192 | assertEquals("测试", productCommentDO.getReplyContent()); |
| 197 | 193 | } |
| 198 | 194 | |
| 199 | - @Test | |
| 200 | - public void testCreateComment_success() { | |
| 201 | - // mock 测试 | |
| 202 | - ProductCommentDO productComment = randomPojo(ProductCommentDO.class, o -> { | |
| 203 | - o.setAdditionalContent(""); | |
| 204 | - }); | |
| 205 | - | |
| 206 | - productCommentService.createComment(productComment, Boolean.TRUE); | |
| 207 | - | |
| 208 | - MemberUserRespDTO user = new MemberUserRespDTO(); | |
| 209 | - user.setId(productComment.getUserId()); | |
| 210 | - | |
| 211 | - AppCommentAdditionalReqVO createReqVO = new AppCommentAdditionalReqVO(); | |
| 212 | - createReqVO.setId(productComment.getId()); | |
| 213 | - createReqVO.setAdditionalContent("追加"); | |
| 214 | - createReqVO.setAdditionalPicUrls(productComment.getAdditionalPicUrls()); | |
| 215 | - | |
| 216 | - productCommentService.additionalComment(user, createReqVO); | |
| 217 | - ProductCommentDO exist = productCommentMapper.selectById(productComment.getId()); | |
| 218 | - | |
| 219 | - assertEquals("追加", exist.getAdditionalContent()); | |
| 220 | - } | |
| 221 | - | |
| 222 | 195 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.app.coupon; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; | |
| 5 | +import io.swagger.v3.oas.annotations.Operation; | |
| 6 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 7 | +import org.springframework.validation.annotation.Validated; | |
| 8 | +import org.springframework.web.bind.annotation.PostMapping; | |
| 9 | +import org.springframework.web.bind.annotation.RequestBody; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RestController; | |
| 12 | + | |
| 13 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 14 | + | |
| 15 | +@Tag(name = "用户 App - 优惠劵") | |
| 16 | +@RestController | |
| 17 | +@RequestMapping("/promotion/coupon") | |
| 18 | +@Validated | |
| 19 | +public class AppCouponController { | |
| 20 | + | |
| 21 | + // TODO 芋艿:待实现 | |
| 22 | + @PostMapping("/take") | |
| 23 | + @Operation(description = "领取优惠劵") | |
| 24 | + public CommonResult<Long> takeCoupon(@RequestBody AppCouponTemplatePageReqVO pageReqVO) { | |
| 25 | + return success(1L); | |
| 26 | + } | |
| 27 | + | |
| 28 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.app.coupon; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; | |
| 8 | +import io.swagger.v3.oas.annotations.Operation; | |
| 9 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 10 | +import io.swagger.v3.oas.annotations.Parameters; | |
| 11 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 14 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 15 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 16 | +import org.springframework.web.bind.annotation.RestController; | |
| 17 | + | |
| 18 | +import javax.annotation.Resource; | |
| 19 | +import java.time.LocalDateTime; | |
| 20 | +import java.util.ArrayList; | |
| 21 | +import java.util.List; | |
| 22 | +import java.util.Random; | |
| 23 | + | |
| 24 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 25 | + | |
| 26 | +@Tag(name = "用户 App - 优惠劵模板") | |
| 27 | +@RestController | |
| 28 | +@RequestMapping("/promotion/coupon-template") | |
| 29 | +@Validated | |
| 30 | +public class AppCouponTemplateController { | |
| 31 | + | |
| 32 | + @Resource | |
| 33 | + private CouponTemplateService couponTemplateService; | |
| 34 | + | |
| 35 | + // TODO 芋艿:待实现 | |
| 36 | + @GetMapping("/list") | |
| 37 | + @Operation(description = "获得优惠劵模版列表") // 目前主要给商品详情使用 | |
| 38 | + @Parameters({ | |
| 39 | + @Parameter(name = "spuId", description = "商品 SPU 编号", required = true), | |
| 40 | + @Parameter(name = "useType", description = "使用类型"), | |
| 41 | + @Parameter(name = "count", description = "数量", required = true) | |
| 42 | + }) | |
| 43 | + public CommonResult<List<AppCouponTemplateRespVO>> getCouponTemplateList(@RequestParam("spuId") Long spuId, | |
| 44 | + @RequestParam(value = "useType", required = false) Integer useType) { | |
| 45 | + List<AppCouponTemplateRespVO> list = new ArrayList<>(); | |
| 46 | + Random random = new Random(); | |
| 47 | + for (int i = 0; i < 10; i++) { | |
| 48 | + AppCouponTemplateRespVO vo = new AppCouponTemplateRespVO(); | |
| 49 | + vo.setId(i + 1L); | |
| 50 | + vo.setName("优惠劵" + (i + 1)); | |
| 51 | + vo.setTakeLimitCount(random.nextInt(10) + 1); | |
| 52 | + vo.setUsePrice(random.nextInt(100) * 100); | |
| 53 | + vo.setValidityType(random.nextInt(2) + 1); | |
| 54 | + if (vo.getValidityType() == 1) { | |
| 55 | + vo.setValidStartTime(LocalDateTime.now().plusDays(random.nextInt(10))); | |
| 56 | + vo.setValidEndTime(LocalDateTime.now().plusDays(random.nextInt(20) + 10)); | |
| 57 | + } else { | |
| 58 | + vo.setFixedStartTerm(random.nextInt(10)); | |
| 59 | + vo.setFixedEndTerm(random.nextInt(10) + vo.getFixedStartTerm() + 1); | |
| 60 | + } | |
| 61 | + vo.setDiscountType(random.nextInt(2) + 1); | |
| 62 | + if (vo.getDiscountType() == 1) { | |
| 63 | + vo.setDiscountPercent(null); | |
| 64 | + vo.setDiscountPrice(random.nextInt(50) * 100); | |
| 65 | + vo.setDiscountLimitPrice(null); | |
| 66 | + } else { | |
| 67 | + vo.setDiscountPercent(random.nextInt(90) + 10); | |
| 68 | + vo.setDiscountPrice(null); | |
| 69 | + vo.setDiscountLimitPrice(random.nextInt(200) * 100); | |
| 70 | + } | |
| 71 | + vo.setTakeStatus(random.nextBoolean()); | |
| 72 | + list.add(vo); | |
| 73 | + } | |
| 74 | + return success(list); | |
| 75 | + } | |
| 76 | + | |
| 77 | + // TODO 芋艿:待实现 | |
| 78 | + @GetMapping("/page") | |
| 79 | + @Operation(description = "获得优惠劵模版分页") | |
| 80 | + public CommonResult<PageResult<AppCouponTemplateRespVO>> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) { | |
| 81 | + return null; | |
| 82 | + } | |
| 83 | + | |
| 84 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponTakeReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | + | |
| 8 | +@Schema(description = "用户 App - 优惠劵领取 Request VO") | |
| 9 | +@Data | |
| 10 | +public class AppCouponTakeReqVO { | |
| 11 | + | |
| 12 | + @Schema(description = "优惠劵模板编号", example = "1") | |
| 13 | + @NotNull(message = "优惠劵模板编号不能为空") | |
| 14 | + private Long templateId; | |
| 15 | + | |
| 16 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplatePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +@Schema(description = "用户 App - 优惠劵模板分页 Request VO") | |
| 10 | +@Data | |
| 11 | +@EqualsAndHashCode(callSuper = true) | |
| 12 | +@ToString(callSuper = true) | |
| 13 | +public class AppCouponTemplatePageReqVO extends PageParam { | |
| 14 | + | |
| 15 | + @Schema(description = "使用类型", example = "1") | |
| 16 | + // TODO 芋艿:这里要限制下枚举的使用 | |
| 17 | + private Integer useType; | |
| 18 | + | |
| 19 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.Min; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +@Schema(description = "用户 App - 优惠劵模板 Response VO") | |
| 10 | +@Data | |
| 11 | +public class AppCouponTemplateRespVO { | |
| 12 | + | |
| 13 | + @Schema(description = "优惠劵模板编号", required = true, example = "1") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @Schema(description = "优惠劵名", required = true, example = "春节送送送") | |
| 17 | + private String name; | |
| 18 | + | |
| 19 | + @Schema(description = "每人限领个数", required = true, example = "66") // -1 - 则表示不限制 | |
| 20 | + private Integer takeLimitCount; | |
| 21 | + | |
| 22 | + @Schema(description = "是否设置满多少金额可用", required = true, example = "100") // 单位:分;0 - 不限制 | |
| 23 | + private Integer usePrice; | |
| 24 | + | |
| 25 | + // TODO 芋艿:这两要改的 | |
| 26 | +// @Schema(description = "商品范围", required = true, example = "1") | |
| 27 | +// @InEnum(PromotionProductScopeEnum.class) | |
| 28 | +// private Integer productScope; | |
| 29 | +// | |
| 30 | +// @Schema(description = "商品 SPU 编号的数组", example = "1,3") | |
| 31 | +// private List<Long> productSpuIds; | |
| 32 | + | |
| 33 | + @Schema(description = "生效日期类型", required = true, example = "1") | |
| 34 | + private Integer validityType; | |
| 35 | + | |
| 36 | + @Schema(description = "固定日期 - 生效开始时间") | |
| 37 | + private LocalDateTime validStartTime; | |
| 38 | + | |
| 39 | + @Schema(description = "固定日期 - 生效结束时间") | |
| 40 | + private LocalDateTime validEndTime; | |
| 41 | + | |
| 42 | + @Schema(description = "领取日期 - 开始天数") | |
| 43 | + @Min(value = 0L, message = "开始天数必须大于 0") | |
| 44 | + private Integer fixedStartTerm; | |
| 45 | + | |
| 46 | + @Schema(description = "领取日期 - 结束天数") | |
| 47 | + @Min(value = 1L, message = "开始天数必须大于 1") | |
| 48 | + private Integer fixedEndTerm; | |
| 49 | + | |
| 50 | + @Schema(description = "优惠类型", required = true, example = "1") | |
| 51 | + private Integer discountType; | |
| 52 | + | |
| 53 | + @Schema(description = "折扣百分比", example = "80") // 例如说,80% 为 80 | |
| 54 | + private Integer discountPercent; | |
| 55 | + | |
| 56 | + @Schema(description = "优惠金额", example = "10") | |
| 57 | + @Min(value = 0, message = "优惠金额需要大于等于 0") | |
| 58 | + private Integer discountPrice; | |
| 59 | + | |
| 60 | + @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用 | |
| 61 | + private Integer discountLimitPrice; | |
| 62 | + | |
| 63 | + // ========== 用户相关字段 ========== | |
| 64 | + | |
| 65 | + @Schema(description = "是否已领取", required = true, example = "true") | |
| 66 | + private Boolean takeStatus; | |
| 67 | + | |
| 68 | +} | ... | ... |