秒杀活动:纠正秒杀库存和秒杀总库存扣减错误的问题

This commit is contained in:
puhui999 2023-10-10 10:57:17 +08:00
parent 42fcbe0501
commit fdbebc406c
2 changed files with 4 additions and 7 deletions

View File

@ -77,8 +77,7 @@ public class SeckillActivityDO extends BaseDO {
private Integer singleLimitCount; private Integer singleLimitCount;
/** /**
* 秒杀库存-秒杀下单时怎加恢复库存是减少 * 秒杀库存(剩余库存秒杀时扣减)
* 也就是说这个是记录当前秒杀活动用户购买的商品数量和
*/ */
private Integer stock; private Integer stock;
/** /**

View File

@ -50,9 +50,8 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> {
Assert.isTrue(count > 0); Assert.isTrue(count > 0);
return update(null, new LambdaUpdateWrapper<SeckillActivityDO>() return update(null, new LambdaUpdateWrapper<SeckillActivityDO>()
.eq(SeckillActivityDO::getId, id) .eq(SeckillActivityDO::getId, id)
.gt(SeckillActivityDO::getTotalStock, 0) .gt(SeckillActivityDO::getStock, count)
.setSql("stock = stock + " + count) .setSql("stock = stock - " + count));
.setSql("total_stock = total_stock - " + count));
} }
/** /**
@ -66,8 +65,7 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> {
Assert.isTrue(count > 0); Assert.isTrue(count > 0);
return update(null, new LambdaUpdateWrapper<SeckillActivityDO>() return update(null, new LambdaUpdateWrapper<SeckillActivityDO>()
.eq(SeckillActivityDO::getId, id) .eq(SeckillActivityDO::getId, id)
.setSql("stock = stock - " + count) .setSql("stock = stock + " + count));
.setSql("total_stock = total_stock + " + count));
} }
default PageResult<SeckillActivityDO> selectPage(AppSeckillActivityPageReqVO pageReqVO, Integer status) { default PageResult<SeckillActivityDO> selectPage(AppSeckillActivityPageReqVO pageReqVO, Integer status) {