Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重复下单redis中库存还是会减小 #35

Open
wangsenyan opened this issue Jan 16, 2021 · 4 comments
Open

重复下单redis中库存还是会减小 #35

wangsenyan opened this issue Jan 16, 2021 · 4 comments

Comments

@wangsenyan
Copy link

long stock = redisService.decr(GoodsKey.getGoodsStock, "" + goodsId);//10
        if (stock < 0) {
            afterPropertiesSet();
            long stock2 = redisService.decr(GoodsKey.getGoodsStock, "" + goodsId);//10
            if(stock2 < 0){
                localOverMap.put(goodsId, true);
                return Result.error(CodeMsg.SECKILL_OVER);
            }
        }
        //判断重复秒杀
        //如果重复秒杀,是否多次减库存?
        SeckillOrder order = orderService.getOrderByUserIdGoodsId(user.getId(), goodsId);
        if (order != null) {
            return Result.error(CodeMsg.REPEATE_SECKILL);
        }

预减库存后,如果是重复秒杀,redis中的库存量还是会减少,导致其他用户不能下单

@zhuimengliujie
Copy link

这个您试过了吗

@zhuimengliujie
Copy link

您的项目启动成功了吗

@q258523454
Copy link

这个重复判断,是不是应该要放到预减库存的前面?

@EricTownsChina
Copy link

我也觉得重复秒杀判断应该放到减库存前面

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants