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;
try {
// 分布式锁占坑 // 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, goodsId); Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, goodsId);
try {
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,11 +102,11 @@ public class GoodsSpecsServiceImpl implements GoodsSpecsService {
String key = "GOODS_STOCK_NUM"; String key = "GOODS_STOCK_NUM";
GoodsSpecs goodsSpecs = queryDetailByGoodsId(specsId); GoodsSpecs goodsSpecs = queryDetailByGoodsId(specsId);
try {
// 分布式锁占坑 // 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, specsId); Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, specsId);
try {
if(Boolean.TRUE.equals(lock)) { if(Boolean.TRUE.equals(lock)) {
if (type == 1) { if (type == 1) {

Loading…
Cancel
Save