Commit e1bb54646051f8dc454d995ef2be996e991fc5a3

Authored by YunaiV
1 parent 07e610b3

✨ MALL:1)优惠劵增加返回使用范围;2)商品分类增加 id 批量查询

Showing 15 changed files with 107 additions and 15 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java
1 package cn.iocoder.yudao.module.product.controller.app.category; 1 package cn.iocoder.yudao.module.product.controller.app.category;
2 2
  3 +import cn.hutool.core.collection.CollUtil;
3 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
4 import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO; 6 import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO;
5 import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert; 7 import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert;
6 import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; 8 import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
7 import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; 9 import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
8 import io.swagger.v3.oas.annotations.Operation; 10 import io.swagger.v3.oas.annotations.Operation;
  11 +import io.swagger.v3.oas.annotations.Parameter;
9 import io.swagger.v3.oas.annotations.tags.Tag; 12 import io.swagger.v3.oas.annotations.tags.Tag;
10 import org.springframework.validation.annotation.Validated; 13 import org.springframework.validation.annotation.Validated;
11 import org.springframework.web.bind.annotation.GetMapping; 14 import org.springframework.web.bind.annotation.GetMapping;
12 import org.springframework.web.bind.annotation.RequestMapping; 15 import org.springframework.web.bind.annotation.RequestMapping;
  16 +import org.springframework.web.bind.annotation.RequestParam;
13 import org.springframework.web.bind.annotation.RestController; 17 import org.springframework.web.bind.annotation.RestController;
14 18
15 import jakarta.annotation.Resource; 19 import jakarta.annotation.Resource;
  20 +
  21 +import java.util.Collection;
  22 +import java.util.Collections;
16 import java.util.Comparator; 23 import java.util.Comparator;
17 import java.util.List; 24 import java.util.List;
18 25
@@ -32,7 +39,19 @@ public class AppCategoryController { @@ -32,7 +39,19 @@ public class AppCategoryController {
32 public CommonResult<List<AppCategoryRespVO>> getProductCategoryList() { 39 public CommonResult<List<AppCategoryRespVO>> getProductCategoryList() {
33 List<ProductCategoryDO> list = categoryService.getEnableCategoryList(); 40 List<ProductCategoryDO> list = categoryService.getEnableCategoryList();
34 list.sort(Comparator.comparing(ProductCategoryDO::getSort)); 41 list.sort(Comparator.comparing(ProductCategoryDO::getSort));
35 - return success(ProductCategoryConvert.INSTANCE.convertList03(list)); 42 + return success(BeanUtils.toBean(list, AppCategoryRespVO.class));
  43 + }
  44 +
  45 + @GetMapping("/list-by-ids")
  46 + @Operation(summary = "获得商品分类列表,指定编号")
  47 + @Parameter(name = "ids", description = "商品分类编号数组", required = true)
  48 + public CommonResult<List<AppCategoryRespVO>> getProductCategoryList(@RequestParam("ids") List<Long> ids) {
  49 + if (CollUtil.isEmpty(ids)) {
  50 + return success(Collections.emptyList());
  51 + }
  52 + List<ProductCategoryDO> list = categoryService.getEnableCategoryList(ids);
  53 + list.sort(Comparator.comparing(ProductCategoryDO::getSort));
  54 + return success(BeanUtils.toBean(list, AppCategoryRespVO.class));
36 } 55 }
37 56
38 } 57 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
@@ -78,9 +78,7 @@ public class AppProductSpuController { @@ -78,9 +78,7 @@ public class AppProductSpuController {
78 78
79 @GetMapping("/list-by-ids") 79 @GetMapping("/list-by-ids")
80 @Operation(summary = "获得商品 SPU 列表") 80 @Operation(summary = "获得商品 SPU 列表")
81 - @Parameters({  
82 - @Parameter(name = "ids", description = "编号列表", required = true)  
83 - }) 81 + @Parameter(name = "ids", description = "编号列表", required = true)
84 public CommonResult<List<AppProductSpuPageRespVO>> getSpuList(@RequestParam("ids") Set<Long> ids) { 82 public CommonResult<List<AppProductSpuPageRespVO>> getSpuList(@RequestParam("ids") Set<Long> ids) {
85 List<ProductSpuDO> list = productSpuService.getSpuList(ids); 83 List<ProductSpuDO> list = productSpuService.getSpuList(ids);
86 if (CollUtil.isEmpty(list)) { 84 if (CollUtil.isEmpty(list)) {
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java
@@ -18,6 +18,7 @@ public class AppProductSpuPageReqVO extends PageParam { @@ -18,6 +18,7 @@ public class AppProductSpuPageReqVO extends PageParam {
18 18
19 public static final String SORT_FIELD_PRICE = "price"; 19 public static final String SORT_FIELD_PRICE = "price";
20 public static final String SORT_FIELD_SALES_COUNT = "salesCount"; 20 public static final String SORT_FIELD_SALES_COUNT = "salesCount";
  21 + public static final String SORT_FIELD_CREATE_TIME = "createTime";
21 22
22 public static final String RECOMMEND_TYPE_HOT = "hot"; 23 public static final String RECOMMEND_TYPE_HOT = "hot";
23 public static final String RECOMMEND_TYPE_BENEFIT = "benefit"; 24 public static final String RECOMMEND_TYPE_BENEFIT = "benefit";
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/category/ProductCategoryConvert.java
@@ -28,5 +28,4 @@ public interface ProductCategoryConvert { @@ -28,5 +28,4 @@ public interface ProductCategoryConvert {
28 28
29 List<ProductCategoryRespVO> convertList(List<ProductCategoryDO> list); 29 List<ProductCategoryRespVO> convertList(List<ProductCategoryDO> list);
30 30
31 - List<AppCategoryRespVO> convertList03(List<ProductCategoryDO> list);  
32 } 31 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/category/ProductCategoryMapper.java
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCateg @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCateg
6 import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; 6 import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
7 import org.apache.ibatis.annotations.Mapper; 7 import org.apache.ibatis.annotations.Mapper;
8 8
  9 +import java.util.Collection;
9 import java.util.List; 10 import java.util.List;
10 11
11 /** 12 /**
@@ -32,4 +33,10 @@ public interface ProductCategoryMapper extends BaseMapperX&lt;ProductCategoryDO&gt; { @@ -32,4 +33,10 @@ public interface ProductCategoryMapper extends BaseMapperX&lt;ProductCategoryDO&gt; {
32 return selectList(ProductCategoryDO::getStatus, status); 33 return selectList(ProductCategoryDO::getStatus, status);
33 } 34 }
34 35
  36 + default List<ProductCategoryDO> selectListByIdAndStatus(Collection<Long> ids, Integer status) {
  37 + return selectList(new LambdaQueryWrapperX<ProductCategoryDO>()
  38 + .in(ProductCategoryDO::getId, ids)
  39 + .eq(ProductCategoryDO::getStatus, status));
  40 + }
  41 +
35 } 42 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java
@@ -84,6 +84,9 @@ public interface ProductSpuMapper extends BaseMapperX&lt;ProductSpuDO&gt; { @@ -84,6 +84,9 @@ public interface ProductSpuMapper extends BaseMapperX&lt;ProductSpuDO&gt; {
84 } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_PRICE)) { 84 } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_PRICE)) {
85 query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getPrice) 85 query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getPrice)
86 .orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); 86 .orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId);
  87 + } else if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_CREATE_TIME)) {
  88 + query.orderBy(true, pageReqVO.getSortAsc(), ProductSpuDO::getCreateTime)
  89 + .orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId);
87 } else { 90 } else {
88 query.orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId); 91 query.orderByDesc(ProductSpuDO::getSort).orderByDesc(ProductSpuDO::getId);
89 } 92 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryService.java
@@ -77,6 +77,14 @@ public interface ProductCategoryService { @@ -77,6 +77,14 @@ public interface ProductCategoryService {
77 List<ProductCategoryDO> getEnableCategoryList(); 77 List<ProductCategoryDO> getEnableCategoryList();
78 78
79 /** 79 /**
  80 + * 获得开启状态的商品分类列表,指定编号
  81 + *
  82 + * @param ids 商品分类编号数组
  83 + * @return 商品分类列表
  84 + */
  85 + List<ProductCategoryDO> getEnableCategoryList(List<Long> ids);
  86 +
  87 + /**
80 * 校验商品分类是否有效。如下情况,视为无效: 88 * 校验商品分类是否有效。如下情况,视为无效:
81 * 1. 商品分类编号不存在 89 * 1. 商品分类编号不存在
82 * 2. 商品分类被禁用 90 * 2. 商品分类被禁用
@@ -84,4 +92,5 @@ public interface ProductCategoryService { @@ -84,4 +92,5 @@ public interface ProductCategoryService {
84 * @param ids 商品分类编号数组 92 * @param ids 商品分类编号数组
85 */ 93 */
86 void validateCategoryList(Collection<Long> ids); 94 void validateCategoryList(Collection<Long> ids);
  95 +
87 } 96 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java
@@ -170,4 +170,9 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { @@ -170,4 +170,9 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
170 return productCategoryMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus()); 170 return productCategoryMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
171 } 171 }
172 172
  173 + @Override
  174 + public List<ProductCategoryDO> getEnableCategoryList(List<Long> ids) {
  175 + return productCategoryMapper.selectListByIdAndStatus(ids, CommonStatusEnum.ENABLE.getStatus());
  176 + }
  177 +
173 } 178 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponController.java
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.app.coupon; @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.app.coupon;
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6 import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; 7 import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
7 import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.*; 8 import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.*;
8 import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert; 9 import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
@@ -59,7 +60,8 @@ public class AppCouponController { @@ -59,7 +60,8 @@ public class AppCouponController {
59 @Operation(summary = "获得匹配指定商品的优惠劵列表", description = "用于下单页,展示优惠劵列表") 60 @Operation(summary = "获得匹配指定商品的优惠劵列表", description = "用于下单页,展示优惠劵列表")
60 public CommonResult<List<AppCouponMatchRespVO>> getMatchCouponList(AppCouponMatchReqVO matchReqVO) { 61 public CommonResult<List<AppCouponMatchRespVO>> getMatchCouponList(AppCouponMatchReqVO matchReqVO) {
61 // todo: 优化:优惠金额倒序 62 // todo: 优化:优惠金额倒序
62 - return success(CouponConvert.INSTANCE.convertList(couponService.getMatchCouponList(getLoginUserId(), matchReqVO))); 63 + List<CouponDO> list = couponService.getMatchCouponList(getLoginUserId(), matchReqVO);
  64 + return success(BeanUtils.toBean(list, AppCouponMatchRespVO.class));
63 } 65 }
64 66
65 @GetMapping("/page") 67 @GetMapping("/page")
@@ -68,7 +70,16 @@ public class AppCouponController { @@ -68,7 +70,16 @@ public class AppCouponController {
68 public CommonResult<PageResult<AppCouponRespVO>> getCouponPage(AppCouponPageReqVO pageReqVO) { 70 public CommonResult<PageResult<AppCouponRespVO>> getCouponPage(AppCouponPageReqVO pageReqVO) {
69 PageResult<CouponDO> pageResult = couponService.getCouponPage( 71 PageResult<CouponDO> pageResult = couponService.getCouponPage(
70 CouponConvert.INSTANCE.convert(pageReqVO, Collections.singleton(getLoginUserId()))); 72 CouponConvert.INSTANCE.convert(pageReqVO, Collections.singleton(getLoginUserId())));
71 - return success(CouponConvert.INSTANCE.convertAppPage(pageResult)); 73 + return success(BeanUtils.toBean(pageResult, AppCouponRespVO.class));
  74 + }
  75 +
  76 + @GetMapping("/get")
  77 + @Operation(summary = "获得优惠劵")
  78 + @Parameter(name = "id", description = "优惠劵编号", required = true, example = "1024")
  79 + @PreAuthenticated
  80 + public CommonResult<AppCouponRespVO> getCoupon(@RequestParam("id") Long id) {
  81 + CouponDO coupon = couponService.getCoupon(getLoginUserId(), id);
  82 + return success(BeanUtils.toBean(coupon, AppCouponRespVO.class));
72 } 83 }
73 84
74 @GetMapping(value = "/get-unused-count") 85 @GetMapping(value = "/get-unused-count")
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/AppCouponTemplateController.java
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.controller.app.coupon; @@ -2,6 +2,7 @@ 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.framework.common.util.object.BeanUtils;
5 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; 6 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
6 import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; 7 import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
7 import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; 8 import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
@@ -43,6 +44,20 @@ public class AppCouponTemplateController { @@ -43,6 +44,20 @@ public class AppCouponTemplateController {
43 @Resource 44 @Resource
44 private ProductSpuApi productSpuApi; 45 private ProductSpuApi productSpuApi;
45 46
  47 + @GetMapping("/get")
  48 + @Operation(summary = "获得优惠劵模版")
  49 + @Parameter(name = "id", description = "优惠券模板编号", required = true, example = "1024")
  50 + public CommonResult<AppCouponTemplateRespVO> getCouponTemplate(Long id) {
  51 + CouponTemplateDO template = couponTemplateService.getCouponTemplate(id);
  52 + if (template == null) {
  53 + return success(null);
  54 + }
  55 + // 处理是否可领取
  56 + Map<Long, Boolean> canCanTakeMap = couponService.getUserCanCanTakeMap(getLoginUserId(), List.of(template));
  57 + return success(BeanUtils.toBean(template, AppCouponTemplateRespVO.class)
  58 + .setCanTake(canCanTakeMap.get(template.getId())));
  59 + }
  60 +
46 @GetMapping("/list") 61 @GetMapping("/list")
47 @Operation(summary = "获得优惠劵模版列表") 62 @Operation(summary = "获得优惠劵模版列表")
48 @Parameters({ 63 @Parameters({
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/coupon/AppCouponRespVO.java
@@ -5,6 +5,7 @@ import lombok.Data; @@ -5,6 +5,7 @@ import lombok.Data;
5 5
6 import jakarta.validation.constraints.Min; 6 import jakarta.validation.constraints.Min;
7 import java.time.LocalDateTime; 7 import java.time.LocalDateTime;
  8 +import java.util.List;
8 9
9 @Schema(description = "用户 App - 优惠劵 Response VO") 10 @Schema(description = "用户 App - 优惠劵 Response VO")
10 @Data 11 @Data
@@ -19,10 +20,15 @@ public class AppCouponRespVO { @@ -19,10 +20,15 @@ public class AppCouponRespVO {
19 @Schema(description = "优惠劵状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 参见 CouponStatusEnum 枚举 20 @Schema(description = "优惠劵状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") // 参见 CouponStatusEnum 枚举
20 private Integer status; 21 private Integer status;
21 22
22 - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")  
23 - // 单位:分;0 - 不限制 23 + @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制
24 private Integer usePrice; 24 private Integer usePrice;
25 25
  26 + @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  27 + private Integer productScope;
  28 +
  29 + @Schema(description = "商品范围编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  30 + private List<Long> productScopeValues;
  31 +
26 @Schema(description = "固定日期 - 生效开始时间") 32 @Schema(description = "固定日期 - 生效开始时间")
27 private LocalDateTime validStartTime; 33 private LocalDateTime validStartTime;
28 34
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java
1 package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template; 1 package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template;
2 2
  3 +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
  4 +import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
  5 +import com.baomidou.mybatisplus.annotation.TableField;
3 import io.swagger.v3.oas.annotations.media.Schema; 6 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 7 import lombok.Data;
5 8
6 import jakarta.validation.constraints.Min; 9 import jakarta.validation.constraints.Min;
7 import java.time.LocalDateTime; 10 import java.time.LocalDateTime;
  11 +import java.util.List;
8 12
9 @Schema(description = "用户 App - 优惠劵模板 Response VO") 13 @Schema(description = "用户 App - 优惠劵模板 Response VO")
10 @Data 14 @Data
@@ -19,10 +23,15 @@ public class AppCouponTemplateRespVO { @@ -19,10 +23,15 @@ public class AppCouponTemplateRespVO {
19 @Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制 23 @Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制
20 private Integer takeLimitCount; 24 private Integer takeLimitCount;
21 25
22 - @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")  
23 - // 单位:分;0 - 不限制 26 + @Schema(description = "是否设置满多少金额可用", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") // 单位:分;0 - 不限制
24 private Integer usePrice; 27 private Integer usePrice;
25 28
  29 + @Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  30 + private Integer productScope;
  31 +
  32 + @Schema(description = "商品范围编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  33 + private List<Long> productScopeValues;
  34 +
26 @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") 35 @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
27 private Integer validityType; 36 private Integer validityType;
28 37
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java
@@ -58,8 +58,4 @@ public interface CouponConvert { @@ -58,8 +58,4 @@ public interface CouponConvert {
58 58
59 CouponPageReqVO convert(AppCouponPageReqVO pageReqVO, Collection<Long> userIds); 59 CouponPageReqVO convert(AppCouponPageReqVO pageReqVO, Collection<Long> userIds);
60 60
61 - PageResult<AppCouponRespVO> convertAppPage(PageResult<CouponDO> pageResult);  
62 -  
63 - List<AppCouponMatchRespVO> convertList(List<CouponDO> list);  
64 -  
65 } 61 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponService.java
@@ -168,4 +168,13 @@ public interface CouponService { @@ -168,4 +168,13 @@ public interface CouponService {
168 */ 168 */
169 Map<Long, Boolean> getUserCanCanTakeMap(Long userId, List<CouponTemplateDO> templates); 169 Map<Long, Boolean> getUserCanCanTakeMap(Long userId, List<CouponTemplateDO> templates);
170 170
  171 + /**
  172 + * 获得优惠劵
  173 + *
  174 + * @param userId 用户编号
  175 + * @param id 编号
  176 + * @return 优惠劵
  177 + */
  178 + CouponDO getCoupon(Long userId, Long id);
  179 +
171 } 180 }
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java
@@ -315,6 +315,11 @@ public class CouponServiceImpl implements CouponService { @@ -315,6 +315,11 @@ public class CouponServiceImpl implements CouponService {
315 userIds.removeIf(userId -> MapUtil.getInt(userTakeCountMap, userId, 0) >= couponTemplate.getTakeLimitCount()); 315 userIds.removeIf(userId -> MapUtil.getInt(userTakeCountMap, userId, 0) >= couponTemplate.getTakeLimitCount());
316 } 316 }
317 317
  318 + @Override
  319 + public CouponDO getCoupon(Long userId, Long id) {
  320 + return couponMapper.selectByIdAndUserId(id, userId);
  321 + }
  322 +
318 /** 323 /**
319 * 获得自身的代理对象,解决 AOP 生效问题 324 * 获得自身的代理对象,解决 AOP 生效问题
320 * 325 *