|
|
|
@@ -487,12 +487,17 @@ public class WxOrderServiceImpl implements WxOrderService { |
|
|
|
|
|
|
|
try { |
|
|
|
// 减库存 |
|
|
|
wxCouponMapper.reduceInventory(coupon.getId(), 1, coupon.getRemainInventory()); |
|
|
|
int num = wxCouponMapper.reduceInventory(coupon.getId(), 1, coupon.getRemainInventory()); |
|
|
|
if (num <= 0) { |
|
|
|
logger.error("此券减库存失败, couponId: " + couponIdStr); |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_FAIL); |
|
|
|
} |
|
|
|
} catch (RuntimeException e) { |
|
|
|
// 解锁 |
|
|
|
redisLock.unlock(couponIdStr, timeStr); |
|
|
|
logger.error("此券减库存失败, couponId: " + couponIdStr); |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_FAIL); |
|
|
|
} finally { |
|
|
|
// 解锁 |
|
|
|
redisLock.unlock(couponIdStr, timeStr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -527,8 +532,6 @@ public class WxOrderServiceImpl implements WxOrderService { |
|
|
|
try { |
|
|
|
int num = wxCouponMapper.backInventory(coupon.getId(), 1, coupon.getRemainInventory()); |
|
|
|
if (num <= 0) { |
|
|
|
// 解锁 |
|
|
|
redisLock.unlock(couponIdStr, timeStr); |
|
|
|
logger.error("此券加库存失败, couponId: " + couponIdStr); |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_FAIL); |
|
|
|
} |
|
|
|
|