|
|
|
@@ -3784,15 +3784,15 @@ public class WxOrderServiceImpl implements WxOrderService { |
|
|
|
|
|
|
|
}else { |
|
|
|
//此处判断是否存在绝对保证库存不超卖的缓存,如果没有,则把当前的库存设置为最大值。如果有,则是后台设置的时候保存的,以那个为准。 |
|
|
|
boolean hascache = redisLock.hasCouponStockCache(coupon.getCouponId()); |
|
|
|
boolean hascache = redisLock.hasCouponStockCache(coupon.getId()); |
|
|
|
if (!hascache) { |
|
|
|
long time = System.currentTimeMillis() + RedisLock.TIMEOUT; |
|
|
|
String timeStr = String.valueOf(time); |
|
|
|
boolean stocksetlock = redisLock.lock("couponLockStockSetByOrder_"+coupon.getId(), timeStr); |
|
|
|
if (stocksetlock) { |
|
|
|
try { |
|
|
|
if (!redisLock.hasCouponStockCache(coupon.getCouponId())) { |
|
|
|
redisLock.setCouponStock(coupon.getCouponId(), coupon.getRemainInventory()); |
|
|
|
if (!redisLock.hasCouponStockCache(coupon.getId())) { |
|
|
|
redisLock.setCouponStock(coupon.getId(), coupon.getRemainInventory()); |
|
|
|
} |
|
|
|
}catch(Exception e) { |
|
|
|
logger.error("save order stock cache error.",e); |
|
|
|
|