|
|
@@ -1654,6 +1654,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
userService.subLiveTuiMoney(liveOrder);
|
|
|
}
|
|
|
}
|
|
|
+ // 删除限购记录
|
|
|
+ deletePurchaseLimitRecordsForLiveOrder(order);
|
|
|
|
|
|
return R.ok();
|
|
|
}
|
|
|
@@ -3661,6 +3663,12 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
this.payConfirm(1, null, payment.getPayCode(), payment.getTradeNo(), payment.getBankSerialNo(), payment.getBankSerialNo());
|
|
|
}
|
|
|
|
|
|
+ public void deStockIncSale(List<FsStoreCartQueryVO> cartInfo) {
|
|
|
+ for (FsStoreCartQueryVO storeCartVO : cartInfo) {
|
|
|
+ fsStoreProductService.decProductStock(storeCartVO.getProductId(),
|
|
|
+ storeCartVO.getProductAttrValueId(), storeCartVO.getCartNum());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
|
|
|
@@ -3697,20 +3705,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
Integer purchaseNum = Integer.parseInt(liveOrder.getTotalNum());
|
|
|
checkPurchaseLimitForLiveOrder(userId, liveOrder.getProductId(), purchaseNum);
|
|
|
|
|
|
- FsStoreProductAttrValueScrm attrValue = null;
|
|
|
- if (!Objects.isNull(liveOrder.getAttrValueId())) {
|
|
|
- attrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueById(liveOrder.getAttrValueId());
|
|
|
- }
|
|
|
- if (attrValue != null) {
|
|
|
- attrValue.setStock(attrValue.getStock() - Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
- attrValue.setSales(attrValue.getSales() + Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
- fsStoreProductAttrValueMapper.updateFsStoreProductAttrValue(attrValue);
|
|
|
- }
|
|
|
- // 更改店铺库存
|
|
|
- fsStoreProduct.setStock(fsStoreProduct.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
- fsStoreProduct.setSales(fsStoreProduct.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
- fsStoreProductScrmMapper.incStockDecSales(Long.valueOf("-" + liveOrder.getTotalNum()),fsStoreProduct.getProductId());
|
|
|
-
|
|
|
+ // 使用 deStockIncSale 方法处理库存和销量
|
|
|
+ deStockIncSale(liveOrder.getProductId(), liveOrder.getAttrValueId(), purchaseNum);
|
|
|
+ FsStoreProductAttrValueScrm attrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueById(liveOrder.getAttrValueId());
|
|
|
// 更新直播间库存
|
|
|
goods.setStock(goods.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
goods.setSales(goods.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
@@ -3986,8 +3983,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
goods.setStock(goods.getStock()+Long.parseLong(liveOrder.getTotalNum()));
|
|
|
// 更新商品库存
|
|
|
liveGoodsMapper.updateLiveGoods(goods);
|
|
|
- // 删除限购记录
|
|
|
- deletePurchaseLimitRecordsForLiveOrder(liveOrder);
|
|
|
+
|
|
|
// 退券
|
|
|
this.refundCoupon(order);
|
|
|
TemplateBean templateBean = TemplateBean.builder()
|
|
|
@@ -4011,6 +4007,14 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
* @param productId 商品ID
|
|
|
* @param num 购买数量
|
|
|
*/
|
|
|
+ /**
|
|
|
+ * 减库存加销量(直播订单)
|
|
|
+ */
|
|
|
+ private void deStockIncSale(Long productId, Long attrValueId, Integer num) {
|
|
|
+ // 使用 productService.decProductStock 方法,该方法已包含库存检查逻辑
|
|
|
+ fsStoreProductService.decProductStock(productId, attrValueId, num);
|
|
|
+ }
|
|
|
+
|
|
|
private void checkPurchaseLimitForLiveOrder(Long userId, Long productId, Integer num) {
|
|
|
// 查询商品信息
|
|
|
FsStoreProductScrm product = fsStoreProductService.selectFsStoreProductById(productId);
|