You've already forked FrameTour-BE
refactor(pricing): 优化优惠券配置实体和领取逻辑
- 将时间字段类型从 LocalDateTime 改为 Date - 为优惠券领取数量更新添加无条件增加方法 - 区分有限量和无限量优惠券的领取处理逻辑 - 实现有总量限制优惠券的库存检查机制 - 统一更新已领取数量的计数逻辑
This commit is contained in:
@@ -40,12 +40,19 @@ public interface PriceCouponConfigMapper extends BaseMapper<PriceCouponConfig> {
|
||||
int incrementUsedQuantity(Long couponId);
|
||||
|
||||
/**
|
||||
* 原子性增加已领取数量(仅对有限库存的优惠券生效)
|
||||
* 原子性增加已领取数量(仅对有限库存的优惠券生效,带库存检查)
|
||||
*/
|
||||
@Update("UPDATE price_coupon_config SET claimed_quantity = COALESCE(claimed_quantity, 0) + 1, " +
|
||||
"update_time = NOW() WHERE id = #{couponId} AND total_quantity IS NOT NULL AND total_quantity > 0 " +
|
||||
"AND COALESCE(claimed_quantity, 0) < total_quantity")
|
||||
int incrementClaimedQuantityIfAvailable(@Param("couponId") Long couponId);
|
||||
|
||||
/**
|
||||
* 无条件增加已领取数量(用于无限量优惠券的领取统计)
|
||||
*/
|
||||
@Update("UPDATE price_coupon_config SET claimed_quantity = COALESCE(claimed_quantity, 0) + 1, " +
|
||||
"update_time = NOW() WHERE id = #{couponId}")
|
||||
int incrementClaimedQuantity(@Param("couponId") Long couponId);
|
||||
|
||||
/**
|
||||
* 插入优惠券配置
|
||||
|
||||
Reference in New Issue
Block a user