mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
SPU: 添加选择优惠卷
This commit is contained in:
parent
ffbf9278b8
commit
6e11154010
@ -34,8 +34,9 @@ public interface ErrorCodeConstants {
|
|||||||
// ========== 商品 SPU 1-008-005-000 ==========
|
// ========== 商品 SPU 1-008-005-000 ==========
|
||||||
ErrorCode SPU_NOT_EXISTS = new ErrorCode(1_008_005_000, "商品 SPU 不存在");
|
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_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1_008_005_001, "商品分类不正确,原因:必须使用第二级的商品分类及以下");
|
||||||
ErrorCode SPU_NOT_ENABLE = new ErrorCode(1_008_005_002, "商品 SPU【{}】不处于上架状态");
|
ErrorCode SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_008_005_002, "商品 SPU 保存失败,原因:优惠卷不存在");
|
||||||
ErrorCode SPU_NOT_RECYCLE = new ErrorCode(1_008_005_003, "商品 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 ==========
|
// ========== 商品 SKU 1-008-006-000 ==========
|
||||||
ErrorCode SKU_NOT_EXISTS = new ErrorCode(1_008_006_000, "商品 SKU 不存在");
|
ErrorCode SKU_NOT_EXISTS = new ErrorCode(1_008_006_000, "商品 SKU 不存在");
|
||||||
|
@ -28,6 +28,11 @@
|
|||||||
<artifactId>yudao-module-member-api</artifactId>
|
<artifactId>yudao-module-member-api</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-module-promotion-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -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.enums.spu.ProductSpuStatusEnum;
|
||||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
||||||
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
|
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.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -43,6 +45,9 @@ public class ProductSpuController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProductSkuService productSkuService;
|
private ProductSkuService productSkuService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CouponTemplateApi couponTemplateApi;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建商品 SPU")
|
@Operation(summary = "创建商品 SPU")
|
||||||
@PreAuthorize("@ss.hasPermission('product:spu:create')")
|
@PreAuthorize("@ss.hasPermission('product:spu:create')")
|
||||||
@ -87,7 +92,10 @@ public class ProductSpuController {
|
|||||||
}
|
}
|
||||||
// 查询商品 SKU
|
// 查询商品 SKU
|
||||||
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
|
List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
|
||||||
return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus));
|
// 查询优惠卷
|
||||||
|
List<CouponTemplateRespDTO> couponTemplateList = couponTemplateApi.getCouponTemplateListByIds(
|
||||||
|
spu.getGiveCouponTemplateIds());
|
||||||
|
return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus, couponTemplateList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list-all-simple")
|
@GetMapping("/list-all-simple")
|
||||||
|
@ -96,19 +96,31 @@ public class ProductSpuBaseVO {
|
|||||||
@NotNull(message = "商品赠送积分不能为空")
|
@NotNull(message = "商品赠送积分不能为空")
|
||||||
private Integer giveIntegral;
|
private Integer giveIntegral;
|
||||||
|
|
||||||
@Schema(description = "赠送的优惠劵编号的数组", example = "[1, 10]") // TODO 这块前端还未实现
|
@Schema(description = "赠送的优惠劵数组包含优惠券编号和名称")
|
||||||
private List<Long> giveCouponTemplateIds;
|
private List<GiveCouponTemplate> giveCouponTemplate;
|
||||||
|
|
||||||
@Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||||
@NotNull(message = "商品分销类型不能为空")
|
@NotNull(message = "商品分销类型不能为空")
|
||||||
private Boolean subCommissionType;
|
private Boolean subCommissionType;
|
||||||
|
|
||||||
@Schema(description = "活动展示顺序", example = "[1, 3, 2, 4, 5]") // TODO 这块前端还未实现
|
@Schema(description = "活动展示顺序", example = "[1, 3, 2, 4, 5]")
|
||||||
private List<Integer> activityOrders;
|
private List<Integer> activityOrders;
|
||||||
|
|
||||||
// ========== 统计相关字段 =========
|
// ========== 统计相关字段 =========
|
||||||
|
|
||||||
@Schema(description = "虚拟销量", example = "芋道")
|
@Schema(description = "虚拟销量", example = "66")
|
||||||
private Integer virtualSalesCount;
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.sku.ProductSkuDO;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||||
import cn.iocoder.yudao.module.product.enums.DictTypeConstants;
|
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.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Named;
|
import org.mapstruct.Named;
|
||||||
@ -100,10 +101,14 @@ public interface ProductSpuConvert {
|
|||||||
|
|
||||||
List<AppProductSpuDetailRespVO.Sku> convertListForGetSpuDetail(List<ProductSkuDO> skus);
|
List<AppProductSpuDetailRespVO.Sku> convertListForGetSpuDetail(List<ProductSkuDO> skus);
|
||||||
|
|
||||||
default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus) {
|
List<ProductSpuDetailRespVO.GiveCouponTemplate> convertList04(List<CouponTemplateRespDTO> couponTemplateList);
|
||||||
ProductSpuDetailRespVO detailRespVO = convert03(spu);
|
|
||||||
detailRespVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus));
|
default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus,
|
||||||
return detailRespVO;
|
List<CouponTemplateRespDTO> couponTemplateList) {
|
||||||
|
ProductSpuDetailRespVO respVO = convert03(spu);
|
||||||
|
respVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus));
|
||||||
|
respVO.setGiveCouponTemplate(convertList04(couponTemplateList));
|
||||||
|
return respVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<ProductSpuDetailRespVO> convertForSpuDetailRespListVO(List<ProductSpuDO> spus, List<ProductSkuDO> skus) {
|
default List<ProductSpuDetailRespVO> convertForSpuDetailRespListVO(List<ProductSpuDO> spus, List<ProductSkuDO> skus) {
|
||||||
|
@ -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.enums.spu.ProductSpuStatusEnum;
|
||||||
import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
|
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.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.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 com.google.common.collect.Maps;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -26,10 +28,10 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
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.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.*;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
|
|
||||||
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
||||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
@ -52,9 +54,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||||||
private ProductBrandService brandService;
|
private ProductBrandService brandService;
|
||||||
@Resource
|
@Resource
|
||||||
private ProductCategoryService categoryService;
|
private ProductCategoryService categoryService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@Lazy // 循环依赖,避免报错
|
private CouponTemplateApi couponTemplateApi;
|
||||||
private ProductPropertyValueService productPropertyValueService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@ -62,6 +64,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||||||
// 校验分类、品牌
|
// 校验分类、品牌
|
||||||
validateCategory(createReqVO.getCategoryId());
|
validateCategory(createReqVO.getCategoryId());
|
||||||
brandService.validateProductBrand(createReqVO.getBrandId());
|
brandService.validateProductBrand(createReqVO.getBrandId());
|
||||||
|
// 校验优惠券
|
||||||
|
Set<Long> giveCouponTemplateIds = convertSet(createReqVO.getGiveCouponTemplate(), ProductSpuCreateReqVO.GiveCouponTemplate::getId);
|
||||||
|
validateCouponTemplate(giveCouponTemplateIds);
|
||||||
// 校验 SKU
|
// 校验 SKU
|
||||||
List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus();
|
List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus();
|
||||||
productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType());
|
productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType());
|
||||||
@ -69,6 +74,8 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||||||
ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO);
|
ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO);
|
||||||
// 初始化 SPU 中 SKU 相关属性
|
// 初始化 SPU 中 SKU 相关属性
|
||||||
initSpuFromSkus(spu, skuSaveReqList);
|
initSpuFromSkus(spu, skuSaveReqList);
|
||||||
|
// 设置优惠券
|
||||||
|
spu.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds));
|
||||||
// 插入 SPU
|
// 插入 SPU
|
||||||
productSpuMapper.insert(spu);
|
productSpuMapper.insert(spu);
|
||||||
// 插入 SKU
|
// 插入 SKU
|
||||||
@ -85,6 +92,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||||||
// 校验分类、品牌
|
// 校验分类、品牌
|
||||||
validateCategory(updateReqVO.getCategoryId());
|
validateCategory(updateReqVO.getCategoryId());
|
||||||
brandService.validateProductBrand(updateReqVO.getBrandId());
|
brandService.validateProductBrand(updateReqVO.getBrandId());
|
||||||
|
// 校验优惠券
|
||||||
|
Set<Long> giveCouponTemplateIds = convertSet(updateReqVO.getGiveCouponTemplate(), ProductSpuUpdateReqVO.GiveCouponTemplate::getId);
|
||||||
|
validateCouponTemplate(giveCouponTemplateIds);
|
||||||
// 校验SKU
|
// 校验SKU
|
||||||
List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus();
|
List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus();
|
||||||
productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType());
|
productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType());
|
||||||
@ -92,6 +102,8 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||||||
// 更新 SPU
|
// 更新 SPU
|
||||||
ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO);
|
ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO);
|
||||||
initSpuFromSkus(updateObj, skuSaveReqList);
|
initSpuFromSkus(updateObj, skuSaveReqList);
|
||||||
|
// 设置优惠券
|
||||||
|
updateObj.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds));
|
||||||
productSpuMapper.updateById(updateObj);
|
productSpuMapper.updateById(updateObj);
|
||||||
// 批量更新 SKU
|
// 批量更新 SKU
|
||||||
productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus());
|
productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus());
|
||||||
@ -125,6 +137,10 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||||||
// 默认商品浏览量
|
// 默认商品浏览量
|
||||||
spu.setBrowseCount(0);
|
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<Long> ids) {
|
||||||
|
List<CouponTemplateRespDTO> couponTemplateList = couponTemplateApi.getCouponTemplateListByIds(ids);
|
||||||
|
if (couponTemplateList.size() != ids.size()) {
|
||||||
|
throw exception(SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProductSpuDO> validateSpuList(Collection<Long> ids) {
|
public List<ProductSpuDO> validateSpuList(Collection<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
@ -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<CouponTemplateRespDTO> getCouponTemplateListByIds(Collection<Long> ids);
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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<CouponTemplateRespDTO> getCouponTemplateListByIds(Collection<Long> ids) {
|
||||||
|
return CouponTemplateConvert.INSTANCE.convertList(couponTemplateService.getCouponTemplateListByIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.convert.coupon;
|
|||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.CouponTemplateCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateRespVO;
|
||||||
@ -58,4 +59,6 @@ public interface CouponTemplateConvert {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<CouponTemplateRespDTO> convertList(List<CouponTemplateDO> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.controller.admin.coupon.vo.template.CouponTemplatePageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@ -39,7 +40,11 @@ public interface CouponTemplateMapper extends BaseMapperX<CouponTemplateDO> {
|
|||||||
.orderByDesc(CouponTemplateDO::getId));
|
.orderByDesc(CouponTemplateDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTakeCount(@Param("id") Long id, @Param("incrCount") Integer incrCount);
|
default void updateTakeCount(Long id, Integer incrCount) {
|
||||||
|
update(null, new LambdaUpdateWrapper<CouponTemplateDO>()
|
||||||
|
.eq(CouponTemplateDO::getId, id)
|
||||||
|
.setSql("take_count = take_count + " + incrCount));
|
||||||
|
}
|
||||||
|
|
||||||
default List<CouponTemplateDO> selectListByTakeType(Integer takeType) {
|
default List<CouponTemplateDO> selectListByTakeType(Integer takeType) {
|
||||||
return selectList(CouponTemplateDO::getTakeType, takeType);
|
return selectList(CouponTemplateDO::getTakeType, takeType);
|
||||||
@ -70,4 +75,8 @@ public interface CouponTemplateMapper extends BaseMapperX<CouponTemplateDO> {
|
|||||||
return canTakeConsumer;
|
return canTakeConsumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<CouponTemplateDO> selectListByIds(Collection<Long> ids) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<CouponTemplateDO>().in(CouponTemplateDO::getId, ids));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
|||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,4 +92,12 @@ public interface CouponTemplateService {
|
|||||||
List<CouponTemplateDO> getCouponTemplateList(List<Integer> canTakeTypes, Integer productScope,
|
List<CouponTemplateDO> getCouponTemplateList(List<Integer> canTakeTypes, Integer productScope,
|
||||||
Long productScopeValue, Integer count);
|
Long productScopeValue, Integer count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得优惠券模版列表
|
||||||
|
*
|
||||||
|
* @param ids 优惠券模版编号
|
||||||
|
* @return 优惠券模版列表
|
||||||
|
*/
|
||||||
|
List<CouponTemplateDO> getCouponTemplateListByIds(Collection<Long> ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -126,4 +127,9 @@ public class CouponTemplateServiceImpl implements CouponTemplateService {
|
|||||||
return couponTemplateMapper.selectList(canTakeTypes, productScope, productScopeValue, count);
|
return couponTemplateMapper.selectList(canTakeTypes, productScope, productScopeValue, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CouponTemplateDO> getCouponTemplateListByIds(Collection<Long> ids) {
|
||||||
|
return couponTemplateMapper.selectListByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper">
|
|
||||||
|
|
||||||
<update id="updateTakeCount">
|
|
||||||
UPDATE promotion_coupon_template
|
|
||||||
SET take_count = take_count + #{incrCount}
|
|
||||||
WHERE id = #{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
</mapper>
|
|
Loading…
Reference in New Issue
Block a user