|
@@ -161,6 +161,9 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsUserAddressService fsUserAddressService;
|
|
private IFsUserAddressService fsUserAddressService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private com.fs.his.utils.RedisCacheUtil redisCacheUtil;
|
|
|
/**
|
|
/**
|
|
|
* 查询积分商品订单
|
|
* 查询积分商品订单
|
|
|
*
|
|
*
|
|
@@ -312,6 +315,10 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
throw new CustomException("库存不足");
|
|
throw new CustomException("库存不足");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 清除商品缓存
|
|
|
|
|
+ redisCacheUtil.delSpringCacheKey("getIntegralGoodsById", integralGoods.getGoodsId());
|
|
|
|
|
+ redisCacheUtil.delRedisKey("getIntegralGoodsList");
|
|
|
|
|
+
|
|
|
integralGoods.setNum(1);
|
|
integralGoods.setNum(1);
|
|
|
List<FsIntegralGoods> goodsItem = new ArrayList<>();
|
|
List<FsIntegralGoods> goodsItem = new ArrayList<>();
|
|
|
goodsItem.add(integralGoods);
|
|
goodsItem.add(integralGoods);
|
|
@@ -467,6 +474,9 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
throw new CustomException("库存不足");
|
|
throw new CustomException("库存不足");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 清除商品缓存
|
|
|
|
|
+ redisCacheUtil.delSpringCacheKey("getIntegralGoodsById", integralGoods.getGoodsId());
|
|
|
|
|
+
|
|
|
totalIntegral += integralGoods.getIntegral() * cart.getCartNum();
|
|
totalIntegral += integralGoods.getIntegral() * cart.getCartNum();
|
|
|
totalCash = totalCash.add(integralGoods.getCash().multiply(BigDecimal.valueOf(cart.getCartNum())));
|
|
totalCash = totalCash.add(integralGoods.getCash().multiply(BigDecimal.valueOf(cart.getCartNum())));
|
|
|
|
|
|
|
@@ -474,6 +484,9 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
goodsItem.add(integralGoods);
|
|
goodsItem.add(integralGoods);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 清除商品列表缓存
|
|
|
|
|
+ redisCacheUtil.delRedisKey("getIntegralGoodsList");
|
|
|
|
|
+
|
|
|
return createOrder(user, address, totalIntegral, totalCash, goodsItem, null);
|
|
return createOrder(user, address, totalIntegral, totalCash, goodsItem, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -576,11 +589,21 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
// 还原库存
|
|
// 还原库存
|
|
|
if (order.getItemJson().startsWith("[") && order.getItemJson().endsWith("]")){
|
|
if (order.getItemJson().startsWith("[") && order.getItemJson().endsWith("]")){
|
|
|
List<FsIntegralGoods> goodsItem = JSONUtil.toBean(order.getItemJson(), new TypeReference<List<FsIntegralGoods>>(){}, true);
|
|
List<FsIntegralGoods> goodsItem = JSONUtil.toBean(order.getItemJson(), new TypeReference<List<FsIntegralGoods>>(){}, true);
|
|
|
- goodsItem.forEach(goods -> fsIntegralGoodsMapper.addStock(goods.getGoodsId(), Objects.isNull(goods.getNum()) ? 1 : goods.getNum()));
|
|
|
|
|
|
|
+ goodsItem.forEach(goods -> {
|
|
|
|
|
+ fsIntegralGoodsMapper.addStock(goods.getGoodsId(), Objects.isNull(goods.getNum()) ? 1 : goods.getNum());
|
|
|
|
|
+ // 清除商品缓存
|
|
|
|
|
+ redisCacheUtil.delSpringCacheKey("getIntegralGoodsById", goods.getGoodsId());
|
|
|
|
|
+ log.info("取消订单还原库存,清除商品缓存, goodsId: {}", goods.getGoodsId());
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
FsIntegralGoods integralGoods = JSONUtil.toBean(order.getItemJson(), FsIntegralGoods.class);
|
|
FsIntegralGoods integralGoods = JSONUtil.toBean(order.getItemJson(), FsIntegralGoods.class);
|
|
|
fsIntegralGoodsMapper.addStock(integralGoods.getGoodsId(), Objects.isNull(integralGoods.getNum()) ? 1 : integralGoods.getNum());
|
|
fsIntegralGoodsMapper.addStock(integralGoods.getGoodsId(), Objects.isNull(integralGoods.getNum()) ? 1 : integralGoods.getNum());
|
|
|
|
|
+ // 清除商品缓存
|
|
|
|
|
+ redisCacheUtil.delSpringCacheKey("getIntegralGoodsById", integralGoods.getGoodsId());
|
|
|
|
|
+ log.info("取消订单还原库存,清除商品缓存, goodsId: {}", integralGoods.getGoodsId());
|
|
|
}
|
|
}
|
|
|
|
|
+ // 清除商品列表缓存
|
|
|
|
|
+ redisCacheUtil.delRedisKey("getIntegralGoodsList");
|
|
|
|
|
|
|
|
// 还原积分
|
|
// 还原积分
|
|
|
FsUser user=fsUserMapper.selectFsUserByUserId(order.getUserId());
|
|
FsUser user=fsUserMapper.selectFsUserByUserId(order.getUserId());
|