mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-16 03:01:53 +08:00
Merge remote-tracking branch 'yudao/develop' into develop
This commit is contained in:
@@ -33,6 +33,9 @@ public class CouponTemplateBaseVO {
|
||||
@NotNull(message = "优惠劵名不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "优惠券说明", example = "优惠券使用说明")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "发行总量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") // -1 - 则表示不限制发放数量
|
||||
@NotNull(message = "发行总量不能为空")
|
||||
private Integer totalCount;
|
||||
|
@@ -1,8 +1,5 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -20,6 +17,9 @@ public class AppCouponTemplateRespVO {
|
||||
@Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "优惠券说明", example = "优惠券使用说明")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "每人限领个数", requiredMode = Schema.RequiredMode.REQUIRED, example = "66") // -1 - 则表示不限制
|
||||
private Integer takeLimitCount;
|
||||
|
||||
|
@@ -40,6 +40,10 @@ public class CouponTemplateDO extends BaseDO {
|
||||
* 优惠劵名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 优惠券说明
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
@@ -158,9 +162,9 @@ public class CouponTemplateDO extends BaseDO {
|
||||
* 使用优惠券的次数
|
||||
*/
|
||||
private Integer useCount;
|
||||
|
||||
// ========== 统计信息 END ==========
|
||||
|
||||
// TODO 芋艿:领取开始时间、领取结束时间
|
||||
|
||||
// TODO 芋艿:要不要加描述
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
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.common.PromotionProductScopeEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.github.yulichang.toolkit.MPJWrappers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -108,11 +107,4 @@ public interface CouponMapper extends BaseMapperX<CouponDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default List<CouponDO> selectListByIdAndUserIdAndTakeType(Long couponId, Long userId, Integer takeType) {
|
||||
return selectList(new LambdaQueryWrapper<CouponDO>()
|
||||
.eq(CouponDO::getId, couponId)
|
||||
.eq(CouponDO::getUserId, userId)
|
||||
.eq(CouponDO::getTakeType, takeType));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -123,7 +123,7 @@ public interface CouponService {
|
||||
*/
|
||||
int expireCoupon();
|
||||
|
||||
//======================= 查询相关 =======================
|
||||
// ======================= 查询相关 =======================
|
||||
|
||||
/**
|
||||
* 获得未使用的优惠劵数量
|
||||
|
@@ -179,7 +179,7 @@ public class CouponServiceImpl implements CouponService {
|
||||
// 循环收回
|
||||
for (Long couponId : giveCouponIds) {
|
||||
try {
|
||||
getSelf().takeBackCoupon(couponId, userId, CouponTakeTypeEnum.ADMIN);
|
||||
getSelf().invalidateCoupon(couponId, userId);
|
||||
} catch (Exception e) {
|
||||
log.error("[invalidateCouponsByAdmin][couponId({}) 收回优惠券失败]", couponId, e);
|
||||
}
|
||||
@@ -191,10 +191,9 @@ public class CouponServiceImpl implements CouponService {
|
||||
*
|
||||
* @param couponId 模版编号
|
||||
* @param userId 用户编号
|
||||
* @param takeType 领取方式
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void takeBackCoupon(Long couponId, Long userId, CouponTakeTypeEnum takeType) {
|
||||
public void invalidateCoupon(Long couponId, Long userId) {
|
||||
// 1.1 校验优惠券
|
||||
CouponDO coupon = couponMapper.selectByIdAndUserId(couponId, userId);
|
||||
if (coupon == null) {
|
||||
@@ -205,19 +204,15 @@ public class CouponServiceImpl implements CouponService {
|
||||
if (couponTemplate == null) {
|
||||
throw exception(COUPON_TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
// 1.3 校验领取方式
|
||||
if (ObjectUtil.notEqual(couponTemplate.getTakeType(), takeType.getValue())) {
|
||||
throw exception(COUPON_TEMPLATE_CANNOT_TAKE);
|
||||
}
|
||||
|
||||
// 2.1 校验优惠券是否已经使用,如若使用则先不管
|
||||
// 1.3 校验优惠券是否已经使用,如若使用则先不管
|
||||
if (ObjUtil.equal(coupon.getStatus(), CouponStatusEnum.USED.getStatus())) {
|
||||
log.info("[invalidateCoupon][coupon({}) 已经使用,无法作废]", couponId);
|
||||
return;
|
||||
}
|
||||
// 2.2 减少优惠劵模板的领取数量
|
||||
|
||||
// 2.1 减少优惠劵模板的领取数量
|
||||
couponTemplateService.updateCouponTemplateTakeCount(couponTemplate.getId(), -1);
|
||||
// 2.3 批量作废优惠劵
|
||||
// TODO @puhui999:捉摸了下,貌似搞成逻辑删除好了?不然好多地方的 status 都要做一些变动。可能未来加个 invalidateType 来标识,是管理后台删除,还是取消回收。或者优惠劵的 change log 可能更好。
|
||||
// 2.2 作废优惠劵
|
||||
couponMapper.deleteById(couponId);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user