mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-08 15:21:52 +08:00
Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
This commit is contained in:
@@ -67,8 +67,8 @@ public class CouponBaseVO {
|
||||
@InEnum(PromotionProductScopeEnum.class)
|
||||
private Integer productScope;
|
||||
|
||||
@Schema(description = "商品 SPU 编号的数组", example = "1,3")
|
||||
private List<Long> productSpuIds;
|
||||
@Schema(description = "商品范围编号的数组", example = "1,3")
|
||||
private List<Long> productScopeValues;
|
||||
// ========== 使用规则 END ==========
|
||||
|
||||
// ========== 使用效果 BEGIN ==========
|
||||
|
@@ -54,8 +54,8 @@ public class CouponTemplateBaseVO {
|
||||
@InEnum(PromotionProductScopeEnum.class)
|
||||
private Integer productScope;
|
||||
|
||||
@Schema(description = "商品 SPU 编号的数组", example = "1,3")
|
||||
private List<Long> productSpuIds;
|
||||
@Schema(description = "商品范围编号的数组", example = "[1, 3]")
|
||||
private List<Long> productScopeValues;
|
||||
|
||||
@Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "生效日期类型不能为空")
|
||||
@@ -95,11 +95,11 @@ public class CouponTemplateBaseVO {
|
||||
@Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用
|
||||
private Integer discountLimitPrice;
|
||||
|
||||
@AssertTrue(message = "商品 SPU 编号的数组不能为空")
|
||||
@AssertTrue(message = "商品范围编号的数组不能为空")
|
||||
@JsonIgnore
|
||||
public boolean isProductSpuIdsValid() {
|
||||
public boolean isProductScopeValuesValid() {
|
||||
return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空
|
||||
|| CollUtil.isNotEmpty(productSpuIds);
|
||||
|| CollUtil.isNotEmpty(productScopeValues);
|
||||
}
|
||||
|
||||
@AssertTrue(message = "生效开始时间不能为空")
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.combination;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO;
|
||||
@@ -16,8 +16,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@@ -58,7 +58,7 @@ public class AppCombinationRecordController {
|
||||
record.setId((long) i);
|
||||
record.setNickname("用户" + i);
|
||||
record.setAvatar("头像" + i);
|
||||
record.setExpireTime(new Date());
|
||||
record.setExpireTime(LocalDateTime.now());
|
||||
record.setUserSize(10);
|
||||
record.setUserCount(i);
|
||||
record.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
|
||||
@@ -79,7 +79,7 @@ public class AppCombinationRecordController {
|
||||
headRecord.setId(1L);
|
||||
headRecord.setNickname("用户" + 1);
|
||||
headRecord.setAvatar("头像" + 1);
|
||||
headRecord.setExpireTime(DateUtils.addTime(Duration.ofDays(1)));
|
||||
headRecord.setExpireTime(LocalDateTimeUtils.addTime(Duration.ofDays(1)));
|
||||
headRecord.setUserSize(10);
|
||||
headRecord.setUserCount(3);
|
||||
headRecord.setStatus(1);
|
||||
@@ -94,7 +94,7 @@ public class AppCombinationRecordController {
|
||||
record.setId((long) i);
|
||||
record.setNickname("用户" + i);
|
||||
record.setAvatar("头像" + i);
|
||||
record.setExpireTime(new Date());
|
||||
record.setExpireTime(LocalDateTime.now());
|
||||
record.setUserSize(10);
|
||||
record.setUserCount(i);
|
||||
record.setStatus(1);
|
||||
|
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "用户 App - 拼团记录 Response VO")
|
||||
@Data
|
||||
@@ -22,7 +22,7 @@ public class AppCombinationRecordRespVO {
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Date expireTime;
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
@Schema(description = "可参团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
private Integer userSize;
|
||||
|
@@ -28,8 +28,8 @@ public class AppCouponTemplateRespVO {
|
||||
// @InEnum(PromotionProductScopeEnum.class)
|
||||
// private Integer productScope;
|
||||
//
|
||||
// @Schema(description = "商品 SPU 编号的数组", example = "1,3")
|
||||
// private List<Long> productSpuIds;
|
||||
// @Schema(description = "商品范围编号的数组", example = "1,3")
|
||||
// private List<Long> productScopeValues;
|
||||
|
||||
@Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer validityType;
|
||||
|
@@ -33,7 +33,7 @@ public interface CouponConvert {
|
||||
.setTakeType(template.getTakeType())
|
||||
.setUsePrice(template.getUsePrice())
|
||||
.setProductScope(template.getProductScope())
|
||||
.setProductSpuIds(template.getProductSpuIds())
|
||||
.setProductScopeValues(template.getProductScopeValues())
|
||||
.setDiscountType(template.getDiscountType())
|
||||
.setDiscountPercent(template.getDiscountPercent())
|
||||
.setDiscountPrice(template.getDiscountPrice())
|
||||
|
@@ -89,12 +89,12 @@ public class CouponDO extends BaseDO {
|
||||
*/
|
||||
private Integer productScope;
|
||||
/**
|
||||
* 商品 SPU 编号的数组
|
||||
* 商品范围编号的数组
|
||||
*
|
||||
* 冗余 {@link CouponTemplateDO#getProductSpuIds()}
|
||||
* 冗余 {@link CouponTemplateDO#getProductScopeValues()}
|
||||
*/
|
||||
@TableField(typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> productSpuIds;
|
||||
private List<Long> productScopeValues;
|
||||
// ========== 使用规则 END ==========
|
||||
|
||||
// ========== 使用效果 BEGIN ==========
|
||||
|
@@ -85,10 +85,10 @@ public class CouponTemplateDO extends BaseDO {
|
||||
*/
|
||||
private Integer productScope;
|
||||
/**
|
||||
* 商品 SPU 编号的数组
|
||||
* 商品范围编号的数组
|
||||
*/
|
||||
@TableField(typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> productSpuIds;
|
||||
private List<Long> productScopeValues;
|
||||
/**
|
||||
* 生效日期类型
|
||||
*
|
||||
|
@@ -93,6 +93,7 @@ public class CouponServiceImpl implements CouponService {
|
||||
public void useCoupon(Long id, Long userId, Long orderId) {
|
||||
// 校验优惠劵
|
||||
validCoupon(id, userId);
|
||||
|
||||
// 更新状态
|
||||
int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(),
|
||||
new CouponDO().setStatus(CouponStatusEnum.USED.getStatus())
|
||||
@@ -115,12 +116,14 @@ public class CouponServiceImpl implements CouponService {
|
||||
}
|
||||
|
||||
// 退还
|
||||
// TODO @疯狂:最好 where status,避免可能存在的并发问题
|
||||
Integer status = LocalDateTimeUtils.beforeNow(coupon.getValidEndTime())
|
||||
// 退还时可能已经过期了
|
||||
? CouponStatusEnum.EXPIRE.getStatus()
|
||||
? CouponStatusEnum.EXPIRE.getStatus() // 退还时可能已经过期了
|
||||
: CouponStatusEnum.UNUSED.getStatus();
|
||||
couponMapper.updateById(new CouponDO().setId(id).setStatus(status));
|
||||
int updateCount = couponMapper.updateByIdAndStatus(id, CouponStatusEnum.UNUSED.getStatus(),
|
||||
new CouponDO().setStatus(status));
|
||||
if (updateCount == 0) {
|
||||
throw exception(COUPON_STATUS_NOT_USED);
|
||||
}
|
||||
|
||||
// TODO 增加优惠券变动记录?
|
||||
}
|
||||
|
Reference in New Issue
Block a user