dev
袁野 5 months ago
parent c2040cab21
commit 6aedff2fa6
  1. 5
      service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java

@ -111,9 +111,9 @@ public class GoodsMsgServiceImpl implements GoodsMsgService {
try { try {
// 分布式锁占坑 // 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, goodsId); Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, goodsId);
System.out.println("==========================================================lock" + lock);
GoodsMsg goodsMsg = queryDetail(goodsId); GoodsMsg goodsMsg = queryDetail(goodsId);
System.out.println("==========================================================goodsMsg" + goodsMsg);
if (goodsMsg != null) { if (goodsMsg != null) {
if(Boolean.TRUE.equals(lock)) { if(Boolean.TRUE.equals(lock)) {
@ -126,6 +126,7 @@ public class GoodsMsgServiceImpl implements GoodsMsgService {
update(goodsMsg); update(goodsMsg);
} else { } else {
System.out.println("==========================================================加锁失败,重试");
// 加锁失败,重试 // 加锁失败,重试
Thread.sleep(100); Thread.sleep(100);
editSaleNum(goodsId , num , type); editSaleNum(goodsId , num , type);

Loading…
Cancel
Save