Commit ef656cf76213df84a7261906d495daab36414cfa
1 parent
b3c1be10
mall + promotion:
1、增加获得符合条件的优惠劵
Showing
4 changed files
with
80 additions
and
168 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java
| @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.promotion.controller.app.coupon; | @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.promotion.controller.app.coupon; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponMatchRespVO; | ||
| 5 | import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO; | 7 | import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO; |
| 6 | import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO; | 8 | import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO; |
| 7 | import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; | 9 | import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO; |
| @@ -31,6 +33,38 @@ public class AppCouponController { | @@ -31,6 +33,38 @@ public class AppCouponController { | ||
| 31 | } | 33 | } |
| 32 | 34 | ||
| 33 | // TODO 芋艿:待实现 | 35 | // TODO 芋艿:待实现 |
| 36 | + @GetMapping("/match-list") | ||
| 37 | + @Operation(summary = "获得匹配指定商品的优惠劵列表") | ||
| 38 | + public CommonResult<List<AppCouponMatchRespVO>> getMatchCouponList(AppCouponMatchReqVO matchReqVO) { | ||
| 39 | + List<AppCouponMatchRespVO> list = new ArrayList<>(); | ||
| 40 | + Random random = new Random(); | ||
| 41 | + for (int i = 0; i < 10; i++) { | ||
| 42 | + AppCouponMatchRespVO vo = new AppCouponMatchRespVO(); | ||
| 43 | + vo.setId(i + 1L); | ||
| 44 | + vo.setName("优惠劵" + (i + 1)); | ||
| 45 | + vo.setUsePrice(random.nextInt(100) * 100); | ||
| 46 | + vo.setValidStartTime(LocalDateTime.now().plusDays(random.nextInt(10))); | ||
| 47 | + vo.setValidEndTime(LocalDateTime.now().plusDays(random.nextInt(20) + 10)); | ||
| 48 | + vo.setDiscountType(random.nextInt(2) + 1); | ||
| 49 | + if (vo.getDiscountType() == 1) { | ||
| 50 | + vo.setDiscountPercent(null); | ||
| 51 | + vo.setDiscountPrice(random.nextInt(50) * 100); | ||
| 52 | + vo.setDiscountLimitPrice(null); | ||
| 53 | + } else { | ||
| 54 | + vo.setDiscountPercent(random.nextInt(90) + 10); | ||
| 55 | + vo.setDiscountPrice(null); | ||
| 56 | + vo.setDiscountLimitPrice(random.nextInt(200) * 100); | ||
| 57 | + } | ||
| 58 | + vo.setMatch(random.nextBoolean()); | ||
| 59 | + if (!vo.getMatch()) { | ||
| 60 | + vo.setDescription("不符合条件噢"); | ||
| 61 | + } | ||
| 62 | + list.add(vo); | ||
| 63 | + } | ||
| 64 | + return success(list); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + // TODO 芋艿:待实现 | ||
| 34 | @GetMapping("/page") | 68 | @GetMapping("/page") |
| 35 | @Operation(summary = "优惠劵列表", description = "我的优惠劵") | 69 | @Operation(summary = "优惠劵列表", description = "我的优惠劵") |
| 36 | public CommonResult<PageResult<AppCouponRespVO>> takeCoupon(AppCouponPageReqVO pageReqVO) { | 70 | public CommonResult<PageResult<AppCouponRespVO>> takeCoupon(AppCouponPageReqVO pageReqVO) { |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchReqVO.java
0 → 100755
| 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.NotEmpty; | ||
| 7 | +import javax.validation.constraints.NotNull; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +@Schema(description = "用户 App - 优惠劵的匹配 Request VO") | ||
| 11 | +@Data | ||
| 12 | +public class AppCouponMatchReqVO { | ||
| 13 | + | ||
| 14 | + @Schema(description = "商品金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 15 | + @NotNull(message = "商品金额不能为空") | ||
| 16 | + private Integer price; | ||
| 17 | + | ||
| 18 | + @Schema(description = "商品 SPU 编号的数组", required = true, example = "[1, 2]") | ||
| 19 | + @NotEmpty(message = "商品 SPU 编号不能为空") | ||
| 20 | + private List<Long> spuIds; | ||
| 21 | + | ||
| 22 | + @Schema(description = "商品 SKU 编号的数组", required = true, example = "[1, 2]") | ||
| 23 | + @NotEmpty(message = "商品 SKU 编号不能为空") | ||
| 24 | + private List<Long> skuIds; | ||
| 25 | + | ||
| 26 | + @Schema(description = "分类编号的数组", required = true, example = "[10, 20]") | ||
| 27 | + @NotEmpty(message = "分类编号不能为空") | ||
| 28 | + private List<Long> categoryIds; | ||
| 29 | + | ||
| 30 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponMatchRespVO.java
0 → 100755
| 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 | +@Schema(description = "用户 App - 优惠劵 Response VO") | ||
| 7 | +@Data | ||
| 8 | +public class AppCouponMatchRespVO extends AppCouponRespVO { | ||
| 9 | + | ||
| 10 | + @Schema(description = "是否匹配", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | ||
| 11 | + private Boolean match; | ||
| 12 | + | ||
| 13 | + @Schema(description = "匹配条件的提示", example = "所结算商品没有符合条件的商品") | ||
| 14 | + private String description; | ||
| 15 | + | ||
| 16 | +} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/vo/AppTradeOrderGetCreateInfoRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.controller.app.order.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.AllArgsConstructor; | ||
| 5 | -import lombok.Data; | ||
| 6 | - | ||
| 7 | -import java.util.List; | ||
| 8 | - | ||
| 9 | -@Schema(description = "用户 App - 订单获得创建信息 Response VO") | ||
| 10 | -@Data | ||
| 11 | -public class AppTradeOrderGetCreateInfoRespVO { | ||
| 12 | - | ||
| 13 | - /** | ||
| 14 | - * 商品分组数组 | ||
| 15 | - */ | ||
| 16 | - private List<ItemGroup> itemGroups; | ||
| 17 | - /** | ||
| 18 | - * 费用 | ||
| 19 | - */ | ||
| 20 | - private Fee fee; | ||
| 21 | - | ||
| 22 | -// /** | ||
| 23 | -// * 优惠劵列表 TODO 芋艿,后续改改 | ||
| 24 | -// */ | ||
| 25 | -// private List<CouponCardAvailableRespDTO> coupons; | ||
| 26 | - | ||
| 27 | - @Schema(description = "商品分组") // 多个商品,参加同一个活动,从而形成分组 | ||
| 28 | - @Data | ||
| 29 | - public static class ItemGroup { | ||
| 30 | - | ||
| 31 | -// /** | ||
| 32 | -// * 优惠活动 | ||
| 33 | -// */ | ||
| 34 | -// private PromotionActivityRespDTO activity; // TODO 芋艿,偷懒 | ||
| 35 | - /** | ||
| 36 | - * 商品 SKU 数组 | ||
| 37 | - */ | ||
| 38 | - private List<Sku> items; | ||
| 39 | - | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - @Schema(description = "商品 SKU") | ||
| 43 | - @Data | ||
| 44 | - public static class Sku { | ||
| 45 | - | ||
| 46 | - // SKU 自带信息 | ||
| 47 | - @Schema(description = "SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 48 | - private Integer id; | ||
| 49 | - /** | ||
| 50 | - * SPU 信息 | ||
| 51 | - */ | ||
| 52 | - private Spu spu; | ||
| 53 | - /** | ||
| 54 | - * 图片地址 | ||
| 55 | - */ | ||
| 56 | - private String picURL; | ||
| 57 | -// /** | ||
| 58 | -// * 属性数组 | ||
| 59 | -// */ | ||
| 60 | -// private List<ProductAttrKeyValueRespVO> attrs; // TODO 后面改下 | ||
| 61 | - /** | ||
| 62 | - * 价格,单位:分 | ||
| 63 | - */ | ||
| 64 | - private Integer price; | ||
| 65 | - /** | ||
| 66 | - * 库存数量 | ||
| 67 | - */ | ||
| 68 | - private Integer stock; | ||
| 69 | - | ||
| 70 | - // 非 SKU 自带信息 | ||
| 71 | - | ||
| 72 | - /** | ||
| 73 | - * 购买数量 | ||
| 74 | - */ | ||
| 75 | - private Integer buyQuantity; | ||
| 76 | -// /** | ||
| 77 | -// * 优惠活动 | ||
| 78 | -// */ | ||
| 79 | -// private PromotionActivityRespDTO activity; // TODO 芋艿,偷懒 | ||
| 80 | - /** | ||
| 81 | - * 原始单价,单位:分。 | ||
| 82 | - */ | ||
| 83 | - private Integer originPrice; | ||
| 84 | - /** | ||
| 85 | - * 购买单价,单位:分 | ||
| 86 | - */ | ||
| 87 | - private Integer buyPrice; | ||
| 88 | - /** | ||
| 89 | - * 最终价格,单位:分。 | ||
| 90 | - */ | ||
| 91 | - private Integer presentPrice; | ||
| 92 | - /** | ||
| 93 | - * 购买总金额,单位:分 | ||
| 94 | - * | ||
| 95 | - * 用途类似 {@link #presentTotal} | ||
| 96 | - */ | ||
| 97 | - private Integer buyTotal; | ||
| 98 | - /** | ||
| 99 | - * 优惠总金额,单位:分。 | ||
| 100 | - */ | ||
| 101 | - private Integer discountTotal; | ||
| 102 | - /** | ||
| 103 | - * 最终总金额,单位:分。 | ||
| 104 | - * | ||
| 105 | - * 注意,presentPrice * quantity 不一定等于 presentTotal 。 | ||
| 106 | - * 因为,存在无法整除的情况。 | ||
| 107 | - * 举个例子,presentPrice = 8.33 ,quantity = 3 的情况,presentTotal 有可能是 24.99 ,也可能是 25 。 | ||
| 108 | - * 所以,需要存储一个该字段。 | ||
| 109 | - */ | ||
| 110 | - private Integer presentTotal; | ||
| 111 | - | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - @Data | ||
| 115 | - public static class Spu { | ||
| 116 | - | ||
| 117 | - /** | ||
| 118 | - * SPU 编号 | ||
| 119 | - */ | ||
| 120 | - private Integer id; | ||
| 121 | - | ||
| 122 | - // ========== 基本信息 ========= | ||
| 123 | - /** | ||
| 124 | - * SPU 名字 | ||
| 125 | - */ | ||
| 126 | - private String name; | ||
| 127 | - /** | ||
| 128 | - * 分类编号 | ||
| 129 | - */ | ||
| 130 | - private Integer cid; | ||
| 131 | - /** | ||
| 132 | - * 商品主图地址 | ||
| 133 | - * | ||
| 134 | - * 数组,以逗号分隔 | ||
| 135 | - * | ||
| 136 | - * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 | ||
| 137 | - */ | ||
| 138 | - private List<String> picUrls; | ||
| 139 | - | ||
| 140 | - } | ||
| 141 | - | ||
| 142 | - @Schema(description = "费用(合计)") | ||
| 143 | - @Data | ||
| 144 | - @AllArgsConstructor | ||
| 145 | - public static class Fee { | ||
| 146 | - | ||
| 147 | - @Schema(description = "购买总价", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 148 | - private Integer buyPrice; | ||
| 149 | - /** | ||
| 150 | - * 优惠总价 | ||
| 151 | - * | ||
| 152 | - * 注意,满多少元包邮,不算在优惠中。 | ||
| 153 | - */ | ||
| 154 | - private Integer discountTotal; | ||
| 155 | - /** | ||
| 156 | - * 邮费 | ||
| 157 | - */ | ||
| 158 | - private Integer postageTotal; | ||
| 159 | - /** | ||
| 160 | - * 最终价格 | ||
| 161 | - * | ||
| 162 | - * 计算公式 = 总价 - 优惠总价 + 邮费 | ||
| 163 | - */ | ||
| 164 | - private Integer presentTotal; | ||
| 165 | - | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | -} |