From 6e111540101da844f3b83a4557f92203ff9fdfc2 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 20 Oct 2023 11:35:16 +0800 Subject: [PATCH] =?UTF-8?q?SPU:=20=E6=B7=BB=E5=8A=A0=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/enums/ErrorCodeConstants.java | 5 +-- .../yudao-module-product-biz/pom.xml | 5 +++ .../admin/spu/ProductSpuController.java | 10 +++++- .../admin/spu/vo/ProductSpuBaseVO.java | 20 ++++++++--- .../convert/spu/ProductSpuConvert.java | 13 +++++--- .../service/spu/ProductSpuServiceImpl.java | 33 ++++++++++++++++--- .../api/coupon/CouponTemplateApi.java | 23 +++++++++++++ .../api/coupon/dto/CouponTemplateRespDTO.java | 30 +++++++++++++++++ .../api/coupon/CouponTemplateApiImpl.java | 28 ++++++++++++++++ .../convert/coupon/CouponTemplateConvert.java | 3 ++ .../mysql/coupon/CouponTemplateMapper.java | 13 ++++++-- .../service/coupon/CouponTemplateService.java | 9 +++++ .../coupon/CouponTemplateServiceImpl.java | 6 ++++ .../mapper/coupon/CouponTemplateMapper.xml | 11 ------- 14 files changed, 180 insertions(+), 29 deletions(-) create mode 100644 yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponTemplateApi.java create mode 100644 yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponTemplateApiImpl.java delete mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/coupon/CouponTemplateMapper.xml diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java index 102f858fc..1d0ea189f 100644 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java @@ -34,8 +34,9 @@ public interface ErrorCodeConstants { // ========== 商品 SPU 1-008-005-000 ========== ErrorCode SPU_NOT_EXISTS = new ErrorCode(1_008_005_000, "商品 SPU 不存在"); ErrorCode SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1_008_005_001, "商品分类不正确,原因:必须使用第二级的商品分类及以下"); - ErrorCode SPU_NOT_ENABLE = new ErrorCode(1_008_005_002, "商品 SPU【{}】不处于上架状态"); - ErrorCode SPU_NOT_RECYCLE = new ErrorCode(1_008_005_003, "商品 SPU 不处于回收站状态"); + ErrorCode SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_008_005_002, "商品 SPU 保存失败,原因:优惠卷不存在"); + ErrorCode SPU_NOT_ENABLE = new ErrorCode(1_008_005_003, "商品 SPU【{}】不处于上架状态"); + ErrorCode SPU_NOT_RECYCLE = new ErrorCode(1_008_005_004, "商品 SPU 不处于回收站状态"); // ========== 商品 SKU 1-008-006-000 ========== ErrorCode SKU_NOT_EXISTS = new ErrorCode(1_008_006_000, "商品 SKU 不存在"); diff --git a/yudao-module-mall/yudao-module-product-biz/pom.xml b/yudao-module-mall/yudao-module-product-biz/pom.xml index f6190ceda..385b6690e 100644 --- a/yudao-module-mall/yudao-module-product-biz/pom.xml +++ b/yudao-module-mall/yudao-module-product-biz/pom.xml @@ -28,6 +28,11 @@ yudao-module-member-api ${revision} + + cn.iocoder.boot + yudao-module-promotion-api + ${revision} + diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java index 7f88dd8c6..f41138179 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java @@ -11,6 +11,8 @@ import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; +import cn.iocoder.yudao.module.promotion.api.coupon.CouponTemplateApi; +import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -43,6 +45,9 @@ public class ProductSpuController { @Resource private ProductSkuService productSkuService; + @Resource + private CouponTemplateApi couponTemplateApi; + @PostMapping("/create") @Operation(summary = "创建商品 SPU") @PreAuthorize("@ss.hasPermission('product:spu:create')") @@ -87,7 +92,10 @@ public class ProductSpuController { } // 查询商品 SKU List skus = productSkuService.getSkuListBySpuId(spu.getId()); - return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus)); + // 查询优惠卷 + List couponTemplateList = couponTemplateApi.getCouponTemplateListByIds( + spu.getGiveCouponTemplateIds()); + return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus, couponTemplateList)); } @GetMapping("/list-all-simple") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java index 23c2467f8..8ab8376c8 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java @@ -96,19 +96,31 @@ public class ProductSpuBaseVO { @NotNull(message = "商品赠送积分不能为空") private Integer giveIntegral; - @Schema(description = "赠送的优惠劵编号的数组", example = "[1, 10]") // TODO 这块前端还未实现 - private List giveCouponTemplateIds; + @Schema(description = "赠送的优惠劵数组包含优惠券编号和名称") + private List giveCouponTemplate; @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") @NotNull(message = "商品分销类型不能为空") private Boolean subCommissionType; - @Schema(description = "活动展示顺序", example = "[1, 3, 2, 4, 5]") // TODO 这块前端还未实现 + @Schema(description = "活动展示顺序", example = "[1, 3, 2, 4, 5]") private List activityOrders; // ========== 统计相关字段 ========= - @Schema(description = "虚拟销量", example = "芋道") + @Schema(description = "虚拟销量", example = "66") private Integer virtualSalesCount; + @Schema(description = "管理后台 - 商品 SPU 赠送的优惠卷") + @Data + public static class GiveCouponTemplate { + + @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") + private String name; + + } + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java index e8e6a8bc1..b4083b854 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java @@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.enums.DictTypeConstants; +import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Named; @@ -100,10 +101,14 @@ public interface ProductSpuConvert { List convertListForGetSpuDetail(List skus); - default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List skus) { - ProductSpuDetailRespVO detailRespVO = convert03(spu); - detailRespVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); - return detailRespVO; + List convertList04(List couponTemplateList); + + default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List skus, + List couponTemplateList) { + ProductSpuDetailRespVO respVO = convert03(spu); + respVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); + respVO.setGiveCouponTemplate(convertList04(couponTemplateList)); + return respVO; } default List convertForSpuDetailRespListVO(List spus, List skus) { diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index 521a5fefe..9d371eff2 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java @@ -16,8 +16,10 @@ import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; -import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; +import cn.iocoder.yudao.module.promotion.api.coupon.CouponTemplateApi; +import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; +import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; import com.google.common.collect.Maps; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -26,10 +28,10 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.*; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; @@ -52,9 +54,9 @@ public class ProductSpuServiceImpl implements ProductSpuService { private ProductBrandService brandService; @Resource private ProductCategoryService categoryService; + @Resource - @Lazy // 循环依赖,避免报错 - private ProductPropertyValueService productPropertyValueService; + private CouponTemplateApi couponTemplateApi; @Override @Transactional(rollbackFor = Exception.class) @@ -62,6 +64,9 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 校验分类、品牌 validateCategory(createReqVO.getCategoryId()); brandService.validateProductBrand(createReqVO.getBrandId()); + // 校验优惠券 + Set giveCouponTemplateIds = convertSet(createReqVO.getGiveCouponTemplate(), ProductSpuCreateReqVO.GiveCouponTemplate::getId); + validateCouponTemplate(giveCouponTemplateIds); // 校验 SKU List skuSaveReqList = createReqVO.getSkus(); productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); @@ -69,6 +74,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); // 初始化 SPU 中 SKU 相关属性 initSpuFromSkus(spu, skuSaveReqList); + // 设置优惠券 + spu.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds)); // 插入 SPU productSpuMapper.insert(spu); // 插入 SKU @@ -85,6 +92,9 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 校验分类、品牌 validateCategory(updateReqVO.getCategoryId()); brandService.validateProductBrand(updateReqVO.getBrandId()); + // 校验优惠券 + Set giveCouponTemplateIds = convertSet(updateReqVO.getGiveCouponTemplate(), ProductSpuUpdateReqVO.GiveCouponTemplate::getId); + validateCouponTemplate(giveCouponTemplateIds); // 校验SKU List skuSaveReqList = updateReqVO.getSkus(); productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); @@ -92,6 +102,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 更新 SPU ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); initSpuFromSkus(updateObj, skuSaveReqList); + // 设置优惠券 + updateObj.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds)); productSpuMapper.updateById(updateObj); // 批量更新 SKU productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus()); @@ -125,6 +137,10 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 默认商品浏览量 spu.setBrowseCount(0); } + // 如果活动顺序为空则默认初始化 + if (CollUtil.isEmpty(spu.getActivityOrders())) { + spu.setActivityOrders(Arrays.stream(PromotionTypeEnum.ARRAYS).boxed().collect(Collectors.toList())); + } } /** @@ -140,6 +156,13 @@ public class ProductSpuServiceImpl implements ProductSpuService { } } + private void validateCouponTemplate(Collection ids) { + List couponTemplateList = couponTemplateApi.getCouponTemplateListByIds(ids); + if (couponTemplateList.size() != ids.size()) { + throw exception(SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS); + } + } + @Override public List validateSpuList(Collection ids) { if (CollUtil.isEmpty(ids)) { diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponTemplateApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponTemplateApi.java new file mode 100644 index 000000000..d31e80ec1 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponTemplateApi.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.promotion.api.coupon; + +import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; + +import java.util.Collection; +import java.util.List; + +/** + * 优惠劵模版 API 接口 + * + * @author HUIHUI + */ +public interface CouponTemplateApi { + + /** + * 获得优惠券模版的精简信息列表 + * + * @param ids 优惠券模版编号 + * @return 优惠券模版的精简信息列表 + */ + List getCouponTemplateListByIds(Collection ids); + +} diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java new file mode 100644 index 000000000..a54ccf2b0 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponTemplateRespDTO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.promotion.api.coupon.dto; + +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import lombok.Data; + +/** + * 优惠券模版 Response DTO + * + * @author HUIHUI + */ +@Data +public class CouponTemplateRespDTO { + /** + * 模板编号,自增唯一 + */ + + private Long id; + /** + * 优惠劵名 + */ + private String name; + + /** + * 状态 + * + * 枚举 {@link CommonStatusEnum} + */ + private Integer status; + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponTemplateApiImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponTemplateApiImpl.java new file mode 100644 index 000000000..77d2c2cde --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponTemplateApiImpl.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.promotion.api.coupon; + +import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; +import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; +import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +/** + * 优惠劵模版 API 接口实现类 + * + * @author HUIHUI + */ +@Service +public class CouponTemplateApiImpl implements CouponTemplateApi { + + @Resource + private CouponTemplateService couponTemplateService; + + @Override + public List getCouponTemplateListByIds(Collection ids) { + return CouponTemplateConvert.INSTANCE.convertList(couponTemplateService.getCouponTemplateListByIds(ids)); + } + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java index e09d0f013..8e1c57f5c 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponTemplateConvert.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.convert.coupon; import cn.hutool.core.map.MapUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateRespVO; @@ -58,4 +59,6 @@ public interface CouponTemplateConvert { } } + List convertList(List list); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java index f5715298d..ba5706a77 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/coupon/CouponTemplateMapper.java @@ -8,10 +8,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; import java.time.LocalDateTime; +import java.util.Collection; import java.util.List; import java.util.function.Consumer; @@ -39,7 +40,11 @@ public interface CouponTemplateMapper extends BaseMapperX { .orderByDesc(CouponTemplateDO::getId)); } - void updateTakeCount(@Param("id") Long id, @Param("incrCount") Integer incrCount); + default void updateTakeCount(Long id, Integer incrCount) { + update(null, new LambdaUpdateWrapper() + .eq(CouponTemplateDO::getId, id) + .setSql("take_count = take_count + " + incrCount)); + } default List selectListByTakeType(Integer takeType) { return selectList(CouponTemplateDO::getTakeType, takeType); @@ -70,4 +75,8 @@ public interface CouponTemplateMapper extends BaseMapperX { return canTakeConsumer; } + default List selectListByIds(Collection ids) { + return selectList(new LambdaQueryWrapperX().in(CouponTemplateDO::getId, ids)); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java index db0fa6cb4..a47644a4c 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateService.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum; import javax.validation.Valid; +import java.util.Collection; import java.util.List; /** @@ -91,4 +92,12 @@ public interface CouponTemplateService { List getCouponTemplateList(List canTakeTypes, Integer productScope, Long productScopeValue, Integer count); + /** + * 获得优惠券模版列表 + * + * @param ids 优惠券模版编号 + * @return 优惠券模版列表 + */ + List getCouponTemplateListByIds(Collection ids); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java index 2228df71a..8a7fbb8ba 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImpl.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.Collection; import java.util.List; import java.util.Objects; @@ -126,4 +127,9 @@ public class CouponTemplateServiceImpl implements CouponTemplateService { return couponTemplateMapper.selectList(canTakeTypes, productScope, productScopeValue, count); } + @Override + public List getCouponTemplateListByIds(Collection ids) { + return couponTemplateMapper.selectListByIds(ids); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/coupon/CouponTemplateMapper.xml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/coupon/CouponTemplateMapper.xml deleted file mode 100644 index 987143534..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/coupon/CouponTemplateMapper.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - UPDATE promotion_coupon_template - SET take_count = take_count + #{incrCount} - WHERE id = #{id} - - -