mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
commit
af0771a175
@ -27,8 +27,12 @@ public interface ErrorCodeConstants {
|
||||
// ========== 优惠劵模板 1013004000 ==========
|
||||
ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1013004000, "优惠劵模板不存在");
|
||||
ErrorCode COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL = new ErrorCode(1013004001, "发放数量不能小于已领取数量({})");
|
||||
ErrorCode COUPON_TEMPLATE_TASK_EMPTY = new ErrorCode(1013004002, "当前剩余数量不够领取");
|
||||
ErrorCode COUPON_TEMPLATE_USER_TASKED = new ErrorCode(1013004003, "用户已领取过此优惠券");
|
||||
ErrorCode COUPON_TEMPLATE_EXPIRED = new ErrorCode(1013004004, "优惠券已过期");
|
||||
ErrorCode COUPON_TEMPLATE_CANNOT_TAKE = new ErrorCode(1013004005, "领取方式不正确");
|
||||
|
||||
// ========== 优惠劵模板 1013005000 ==========
|
||||
// ========== 优惠劵 1013005000 ==========
|
||||
ErrorCode COUPON_NOT_EXISTS = new ErrorCode(1013005000, "优惠券不存在");
|
||||
ErrorCode COUPON_DELETE_FAIL_USED = new ErrorCode(1013005001, "回收优惠劵失败,优惠劵已被使用");
|
||||
ErrorCode COUPON_STATUS_NOT_UNUSED = new ErrorCode(1013005002, "优惠劵不处于待使用状态");
|
||||
|
@ -14,9 +14,11 @@ import java.util.Arrays;
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum CouponTakeTypeEnum implements IntArrayValuable {
|
||||
|
||||
COMMON(0, "通用"),
|
||||
BY_USER(1, "直接领取"), // 用户可在首页、每日领劵直接领取
|
||||
BY_ADMIN(2, "指定发放"), // 后台指定会员赠送优惠劵
|
||||
BY_REGISTER(3, "新人券"), // 注册时自动领取
|
||||
BY_EXCHANGE(4, "兑换"), // 一般渠道券通过兑换领取
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTakeTypeEnum::getValue).toArray();
|
||||
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponSendReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
|
||||
@ -72,4 +73,11 @@ public class CouponController {
|
||||
return success(pageResulVO);
|
||||
}
|
||||
|
||||
@PostMapping("/send")
|
||||
@Operation(summary = "发送优惠劵")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:coupon:send')")
|
||||
public CommonResult<Boolean> sendCoupon(@Valid @RequestBody CouponSendReqVO reqVO) {
|
||||
Boolean result = couponService.sendCoupon(reqVO.getTemplateId(), reqVO.getUserIds());
|
||||
return success(result);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.coupon;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.*;
|
||||
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert;
|
||||
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.service.coupon.CouponTemplateService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@ -76,4 +79,13 @@ public class CouponTemplateController {
|
||||
return success(CouponTemplateConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/can-take-page")
|
||||
@Operation(summary = "获得可用于领取的优惠劵模板分页")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:coupon-template:query')")
|
||||
public CommonResult<PageResult<CouponTemplateRespVO>> getCanTakeCouponTemplatePage(@Valid CouponTemplatePageReqVO pageVO) {
|
||||
List<Integer> canTakeTypes = ListUtil.of(CouponTakeTypeEnum.COMMON.getValue(), CouponTakeTypeEnum.BY_ADMIN.getValue());
|
||||
PageResult<CouponTemplateDO> pageResult = couponTemplateService.getCanTakeCouponTemplatePage(pageVO, canTakeTypes);
|
||||
return success(CouponTemplateConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class CouponBaseVO {
|
||||
// ========== 基本信息 BEGIN ==========
|
||||
@Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "优惠劵模板编号不能为空")
|
||||
private Integer templateId;
|
||||
private Long templateId;
|
||||
|
||||
@Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送")
|
||||
@NotNull(message = "优惠劵名不能为空")
|
||||
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 优惠劵发放 Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class CouponSendReqVO {
|
||||
|
||||
@Schema(description = "优惠劵模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "优惠劵模板编号不能为空")
|
||||
private Long templateId;
|
||||
|
||||
@Schema(description = "用户编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
|
||||
@NotEmpty(message = "用户编号列表不能为空")
|
||||
private Set<Long> userIds;
|
||||
|
||||
}
|
@ -1,12 +1,18 @@
|
||||
package cn.iocoder.yudao.module.promotion.convert.coupon;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 优惠劵 Convert
|
||||
*
|
||||
@ -21,4 +27,27 @@ public interface CouponConvert {
|
||||
|
||||
CouponRespDTO convert(CouponDO bean);
|
||||
|
||||
default CouponDO convert(CouponTemplateDO template, Long userId) {
|
||||
CouponDO couponDO = new CouponDO()
|
||||
.setTemplateId(template.getId())
|
||||
.setName(template.getName())
|
||||
.setTakeType(template.getTakeType())
|
||||
.setUsePrice(template.getUsePrice())
|
||||
.setProductScope(template.getProductScope())
|
||||
.setProductSpuIds(template.getProductSpuIds())
|
||||
.setDiscountType(template.getDiscountType())
|
||||
.setDiscountPercent(template.getDiscountPercent())
|
||||
.setDiscountPrice(template.getDiscountPrice())
|
||||
.setDiscountLimitPrice(template.getDiscountLimitPrice())
|
||||
.setStatus(CouponStatusEnum.UNUSED.getStatus())
|
||||
.setUserId(userId);
|
||||
if (CouponTemplateValidityTypeEnum.DATE.getType().equals(template.getValidityType())) {
|
||||
couponDO.setValidStartTime(template.getValidStartTime());
|
||||
couponDO.setValidEndTime(template.getValidEndTime());
|
||||
} else if (CouponTemplateValidityTypeEnum.TERM.getType().equals(template.getValidityType())) {
|
||||
couponDO.setValidStartTime(LocalDateTime.now().plusDays(template.getFixedStartTerm()));
|
||||
couponDO.setValidEndTime(LocalDateTime.now().plusDays(template.getFixedEndTerm()));
|
||||
}
|
||||
return couponDO;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class CouponDO extends BaseDO {
|
||||
*
|
||||
* 关联 {@link CouponTemplateDO#getId()}
|
||||
*/
|
||||
private Integer templateId;
|
||||
private Long templateId;
|
||||
/**
|
||||
* 优惠劵名
|
||||
*
|
||||
|
@ -55,4 +55,11 @@ public interface CouponMapper extends BaseMapperX<CouponDO> {
|
||||
.eq(CouponDO::getStatus, status));
|
||||
}
|
||||
|
||||
default List<CouponDO> selectByTemplateIdAndUserId(Long templateId, Collection<Long> userIds) {
|
||||
return selectList(new LambdaQueryWrapperX<CouponDO>()
|
||||
.eq(CouponDO::getTemplateId, templateId)
|
||||
.in(CouponDO::getUserId, userIds)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,19 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.mysql.coupon;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
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 org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 优惠劵模板 Mapper
|
||||
*
|
||||
@ -25,6 +31,28 @@ public interface CouponTemplateMapper extends BaseMapperX<CouponTemplateDO> {
|
||||
.orderByDesc(CouponTemplateDO::getId));
|
||||
}
|
||||
|
||||
default PageResult<CouponTemplateDO> selectCanTakePage(CouponTemplatePageReqVO reqVO, Collection<Integer> takeTypes) {
|
||||
// 构建可领取的查询条件, 好啰嗦 ( ╯-_-)╯┴—┴
|
||||
Consumer<LambdaQueryWrapper<CouponTemplateDO>> canTakeConsumer = w ->
|
||||
// 1.状态为可用的
|
||||
w.eq(CouponTemplateDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
// 2.领取方式一致
|
||||
.in(CouponTemplateDO::getTakeType, takeTypes)
|
||||
// 3.未过期
|
||||
.and(ww -> ww.isNull(CouponTemplateDO::getValidEndTime)
|
||||
.or()
|
||||
.gt(CouponTemplateDO::getValidEndTime, LocalDateTime.now()))
|
||||
// 4.剩余数量大于0
|
||||
.apply(" take_count < total_count ");
|
||||
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<CouponTemplateDO>()
|
||||
.likeIfPresent(CouponTemplateDO::getName, reqVO.getName())
|
||||
.eqIfPresent(CouponTemplateDO::getDiscountType, reqVO.getDiscountType())
|
||||
.betweenIfPresent(CouponTemplateDO::getCreateTime, reqVO.getCreateTime())
|
||||
.and(canTakeConsumer)
|
||||
.orderByDesc(CouponTemplateDO::getId));
|
||||
}
|
||||
|
||||
void updateTakeCount(@Param("id") Long id, @Param("incrCount") Integer incrCount);
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.coupon;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 优惠劵 Service 接口
|
||||
@ -75,4 +78,46 @@ public interface CouponService {
|
||||
*/
|
||||
Long getUnusedCouponCount(Long userId);
|
||||
|
||||
/**
|
||||
* 领取优惠券
|
||||
*
|
||||
* @param templateId 优惠券模板编号
|
||||
* @param userIds 用户编号列表
|
||||
* @param takType 领取方式
|
||||
* @return 领取结果
|
||||
*/
|
||||
Boolean takeCoupon(Long templateId, Set<Long> userIds, CouponTakeTypeEnum takType);
|
||||
|
||||
/**
|
||||
* 【管理员】 给用户发送优惠券
|
||||
*
|
||||
* @param templateId 优惠券模板编号
|
||||
* @param userIds 用户编号列表
|
||||
* @return 发送结果
|
||||
*/
|
||||
default Boolean sendCoupon(Long templateId, Set<Long> userIds) {
|
||||
return takeCoupon(templateId, userIds, CouponTakeTypeEnum.BY_ADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【会员】 领取优惠券
|
||||
*
|
||||
* @param templateId 优惠券模板编号
|
||||
* @param userId 用户编号
|
||||
* @return 发送结果
|
||||
*/
|
||||
default Boolean receiveCoupon(Long templateId, Long userId) {
|
||||
return takeCoupon(templateId, CollUtil.newHashSet(userId), CouponTakeTypeEnum.BY_USER);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【系统】 给用户发送新人券
|
||||
*
|
||||
* @param templateId 优惠券模板编号
|
||||
* @param userId 用户编号列表
|
||||
* @return 发送结果
|
||||
*/
|
||||
default Boolean sendCoupon(Long templateId, Long userId) {
|
||||
return takeCoupon(templateId, CollUtil.newHashSet(userId), CouponTakeTypeEnum.BY_REGISTER);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.coupon;
|
||||
|
||||
import cn.hutool.core.collection.CollStreamUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -9,9 +11,13 @@ import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponMapper;
|
||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -19,7 +25,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
@ -125,4 +133,82 @@ public class CouponServiceImpl implements CouponService {
|
||||
return couponMapper.selectCountByUserIdAndStatus(userId, CouponStatusEnum.UNUSED.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean takeCoupon(Long templateId, Set<Long> userIds, CouponTakeTypeEnum takType) {
|
||||
CouponTemplateDO template = couponTemplateService.getCouponTemplate(templateId);
|
||||
// 校验并过滤用户
|
||||
userIds = validateAndFilterTakeUserId(template, userIds, takType);
|
||||
|
||||
List<CouponDO> couponList = userIds.stream()
|
||||
.map(userId -> CouponConvert.INSTANCE.convert(template, userId))
|
||||
.collect(Collectors.toList());
|
||||
// 批量保存
|
||||
couponMapper.insertBatch(couponList);
|
||||
|
||||
// 增加优惠劵模板的领取数量
|
||||
couponTemplateService.updateCouponTemplateTakeCount(templateId, userIds.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验优惠券模板, 并过滤不可以领取的用户
|
||||
*
|
||||
* @param couponTemplate 优惠券模板
|
||||
* @param userIds 领取人列表
|
||||
* @param takeType 领取方式
|
||||
* @return 可领取此券的用户列表
|
||||
*/
|
||||
private Set<Long> validateAndFilterTakeUserId(CouponTemplateDO couponTemplate, Set<Long> userIds, CouponTakeTypeEnum takeType) {
|
||||
// 校验模板
|
||||
if (couponTemplate == null) {
|
||||
throw exception(COUPON_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
if (couponTemplate.getTotalCount() > 0) {
|
||||
// 校验剩余数量
|
||||
if (couponTemplate.getTakeCount() + userIds.size() > couponTemplate.getTotalCount()) {
|
||||
throw exception(COUPON_TEMPLATE_TASK_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
// 校验"固定日期"的有效期类型是否过期
|
||||
if (CouponTemplateValidityTypeEnum.DATE.getType().equals(couponTemplate.getValidityType())) {
|
||||
if (LocalDateTimeUtils.beforeNow(couponTemplate.getValidEndTime())) {
|
||||
throw exception(COUPON_TEMPLATE_EXPIRED);
|
||||
}
|
||||
}
|
||||
|
||||
// 校验领取方式
|
||||
if (!CouponTakeTypeEnum.COMMON.getValue().equals(couponTemplate.getTakeType())) {
|
||||
if (ObjectUtil.notEqual(couponTemplate.getTakeType(), takeType.getValue())) {
|
||||
throw exception(COUPON_TEMPLATE_CANNOT_TAKE);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取领取过此券的用户
|
||||
List<CouponDO> takedList = couponMapper.selectByTemplateIdAndUserId(couponTemplate.getId(), userIds);
|
||||
|
||||
// 校验新人券
|
||||
if (CouponTakeTypeEnum.BY_REGISTER.equals(takeType)) {
|
||||
if (!takedList.isEmpty()) {
|
||||
throw exception(COUPON_TEMPLATE_USER_TASKED);
|
||||
}
|
||||
}
|
||||
|
||||
// 校验领取数量限制
|
||||
if (couponTemplate.getTakeLimitCount() > 0) {
|
||||
// 统计用户的领取数量
|
||||
Map<Long, Integer> userTakeCountMap = CollStreamUtil.groupBy(takedList, CouponDO::getUserId, Collectors.summingInt(c -> 1));
|
||||
//过滤掉达到领取数量限制的用户
|
||||
userIds.removeIf(userId -> MapUtil.getInt(userTakeCountMap, userId, 0) >= couponTemplate.getTakeLimitCount());
|
||||
// 用户全部领取过此优惠券
|
||||
if (userIds.isEmpty()) {
|
||||
throw exception(COUPON_TEMPLATE_USER_TASKED);
|
||||
}
|
||||
}
|
||||
|
||||
return userIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.Cou
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠劵模板 Service 接口
|
||||
@ -33,7 +34,7 @@ public interface CouponTemplateService {
|
||||
/**
|
||||
* 更新优惠劵模板的状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @param id 编号
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateCouponTemplateStatus(Long id, Integer status);
|
||||
@ -61,10 +62,21 @@ public interface CouponTemplateService {
|
||||
*/
|
||||
PageResult<CouponTemplateDO> getCouponTemplatePage(CouponTemplatePageReqVO pageReqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 获得优惠劵模板分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param canTakeTypes 可领取的方式
|
||||
* @return 优惠劵模板分页
|
||||
*/
|
||||
PageResult<CouponTemplateDO> getCanTakeCouponTemplatePage(CouponTemplatePageReqVO pageReqVO,
|
||||
List<Integer> canTakeTypes);
|
||||
|
||||
/**
|
||||
* 更新优惠劵模板的领取数量
|
||||
*
|
||||
* @param id 优惠劵模板编号
|
||||
* @param id 优惠劵模板编号
|
||||
* @param incrCount 增加数量
|
||||
*/
|
||||
void updateCouponTemplateTakeCount(Long id, int incrCount);
|
||||
|
@ -12,9 +12,11 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_TOTAL_COUNT_TOO_SMALL;
|
||||
|
||||
/**
|
||||
* 优惠劵模板 Service 实现类
|
||||
@ -86,6 +88,11 @@ public class CouponTemplateServiceImpl implements CouponTemplateService {
|
||||
return couponTemplateMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CouponTemplateDO> getCanTakeCouponTemplatePage(CouponTemplatePageReqVO pageReqVO, List<Integer> canTakeTypes) {
|
||||
return couponTemplateMapper.selectCanTakePage(pageReqVO, canTakeTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCouponTemplateTakeCount(Long id, int incrCount) {
|
||||
couponTemplateMapper.updateTakeCount(id, incrCount);
|
||||
|
Loading…
Reference in New Issue
Block a user