master
袁野 6 months ago
parent 521783d82a
commit 6595bbc828
  1. 6
      service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java
  2. 4
      service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java

@ -107,10 +107,12 @@ public class GoodsMsgServiceImpl implements GoodsMsgService {
public void editSaleNum(Long goodsId, Integer num , Integer type) { public void editSaleNum(Long goodsId, Integer num , Integer type) {
String key = "GOODS" + goodsId; String key = "GOODS" + goodsId;
// 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, goodsId);
try { try {
// 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, goodsId);
System.out.println("==========================================================lock" + lock); System.out.println("==========================================================lock" + lock);
GoodsMsg goodsMsg = queryDetail(goodsId); GoodsMsg goodsMsg = queryDetail(goodsId);
System.out.println("==========================================================goodsMsg" + goodsMsg); System.out.println("==========================================================goodsMsg" + goodsMsg);

@ -102,10 +102,10 @@ public class GoodsSpecsServiceImpl implements GoodsSpecsService {
String key = "GOODS_STOCK_NUM"; String key = "GOODS_STOCK_NUM";
GoodsSpecs goodsSpecs = queryDetailByGoodsId(specsId); GoodsSpecs goodsSpecs = queryDetailByGoodsId(specsId);
// 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, specsId);
try { try {
// 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, specsId);
if(Boolean.TRUE.equals(lock)) { if(Boolean.TRUE.equals(lock)) {

Loading…
Cancel
Save