fix(PmsSkuServiceImpl.java):修复循环依赖问题

This commit is contained in:
有来技术 2021-10-20 23:29:56 +08:00
parent d5348e29ee
commit 1cbcdec8b5
2 changed files with 13 additions and 12 deletions

View File

@ -18,7 +18,7 @@ public interface IPmsSkuService extends IService<PmsSku> {
/**
* 锁定库存
*/
Boolean lockStockTcc(List<LockStockDTO> list);
// Boolean lockStockTcc(List<LockStockDTO> list);
/**
* 解锁库存

View File

@ -15,8 +15,6 @@ import com.youlai.mall.pms.pojo.dto.app.LockStockDTO;
import com.youlai.mall.pms.pojo.dto.app.SkuDTO;
import com.youlai.mall.pms.pojo.entity.PmsSku;
import com.youlai.mall.pms.service.IPmsSkuService;
import com.youlai.mall.pms.tcc.service.SeataTccSkuService;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
@ -34,17 +32,8 @@ public class PmsSkuServiceImpl extends ServiceImpl<PmsSkuMapper, PmsSku> impleme
private final StringRedisTemplate redisTemplate;
private final RedissonClient redissonClient;
private final SeataTccSkuService seataTccSkuService;
@Override
@GlobalTransactional
public Boolean lockStockTcc(List<LockStockDTO> skuLockList) {
seataTccSkuService.prepareSkuLockList(null, skuLockList);
String orderToken = skuLockList.get(0).getOrderToken();
redisTemplate.opsForValue().set(PmsConstants.LOCKED_STOCK_PREFIX + orderToken, JSONUtil.toJsonStr(skuLockList));
return true;
}
/**
* 创建订单时锁定库存
@ -189,4 +178,16 @@ public class PmsSkuServiceImpl extends ServiceImpl<PmsSkuMapper, PmsSku> impleme
return this.baseMapper.getSkuById(id);
}
/* private final SeataTccSkuService seataTccSkuService;
@Override
@GlobalTransactional
public Boolean lockStockTcc(List<LockStockDTO> skuLockList) {
seataTccSkuService.prepareSkuLockList(null, skuLockList);
String orderToken = skuLockList.get(0).getOrderToken();
redisTemplate.opsForValue().set(PmsConstants.LOCKED_STOCK_PREFIX + orderToken, JSONUtil.toJsonStr(skuLockList));
return true;
}*/
}