Browse Source

2025年3月10日09:07:32

纪新园 9 months ago
parent
commit
0d6f8d6914

+ 25 - 6
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/shoppingCart/service/impl/ShoppingCartServiceImpl.java

@@ -41,6 +41,7 @@ import org.springblade.salesPart.order.service.IPjIntegralDetailService;
 import org.springblade.salesPart.payMethod.PayService;
 import org.springblade.salesPart.productLaunch.mapper.ProductLaunchMapper;
 import org.springblade.salesPart.serial.service.IPjpfSerialService;
+import org.springblade.salesPart.share.entity.SharePutOnShelves;
 import org.springblade.salesPart.share.mapper.SharePutOnShelvesMapper;
 import org.springblade.salesPart.shoppingCart.mapper.ShoppingCartMapper;
 import org.springblade.salesPart.shoppingCart.service.IShoppingCartService;
@@ -161,7 +162,7 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, PjS
 				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 				throw new RuntimeException("生成系统编号失败");
 			}
-			billNo = billNo +"-"+ AuthUtil.getTenantId();
+			billNo = billNo + "-" + AuthUtil.getTenantId();
 			Integer i = 1;
 			// 获取系统编号
 			String SrcOrdNo = serialService.getBillNo("XS", "XS", "XS");
@@ -376,7 +377,7 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, PjS
 				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 				throw new RuntimeException("生成系统编号失败");
 			}
-			billNo = billNo +"-"+ AuthUtil.getTenantId();
+			billNo = billNo + "-" + AuthUtil.getTenantId();
 			Integer i = 1;
 			// 获取系统编号
 			String SrcOrdNo = serialService.getBillNo("XS", "XS", "XS");
@@ -572,7 +573,7 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, PjS
 				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 				throw new RuntimeException("生成系统编号失败");
 			}
-			billNo = billNo +"-"+ AuthUtil.getTenantId();
+			billNo = billNo + "-" + AuthUtil.getTenantId();
 			Integer i = 1;
 			// 获取系统编号
 			String SrcOrdNo = serialService.getBillNo("XS", "XS", "XS");
@@ -677,6 +678,15 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, PjS
 							baseMapper.updateById(e);
 							PjProductLaunch productLaunch = productLaunchMapper.selectById(e.getProductLaunchId());
 							if (ObjectUtils.isNotNull(productLaunch)) {
+								productLaunch.setInventory(productLaunch.getInventory().subtract(orderItems.getGoodsNum()));
+								productLaunchMapper.updateById(productLaunch);
+								List<SharePutOnShelves> sharePutOnShelvesList = sharePutOnShelvesMapper.selectListShare(productLaunch.getId() + "");
+								for (SharePutOnShelves item : sharePutOnShelvesList) {
+									item.setInventory(productLaunch.getInventory());
+									item.setUpdateTime(new Date());
+									item.setUpdateUser(AuthUtil.getUserId());
+									sharePutOnShelvesMapper.updateSharePutOnShelves(item);
+								}
 								pjProductLaunchList.add(productLaunch);
 							}
 						});
@@ -825,7 +835,7 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, PjS
 				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 				throw new RuntimeException("生成系统编号失败");
 			}
-			billNo = billNo +"-"+ AuthUtil.getTenantId();
+			billNo = billNo + "-" + AuthUtil.getTenantId();
 			int i = 1;
 			// 获取系统编号
 			String SrcOrdNo = serialService.getBillNo("JF", "JF", "JF");
@@ -1053,7 +1063,7 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, PjS
 					TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 					throw new RuntimeException("生成系统编号失败");
 				}
-				billNo = billNo +"-"+ AuthUtil.getTenantId();
+				billNo = billNo + "-" + AuthUtil.getTenantId();
 				List<PjOrder> pjOrderList = new ArrayList<>();
 				List<PjOrderItems> orderItemsList = new ArrayList<>();
 				List<PjOrderItems> orderItemsListShare = new ArrayList<>();
@@ -1292,7 +1302,7 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, PjS
 					order.setReceivableType("网络支付");
 					if (!orderItemsListShare.isEmpty()) {
 						order.setBillType(1);
-					}else{
+					} else {
 						order.setBillType(0);
 					}
 					orderService.save(order);
@@ -1453,6 +1463,15 @@ public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, PjS
 				orderItems.setGoodsName(item.getGoodsName());
 				orderItemsMapper.insert(orderItems);
 				orderItemsList.add(orderItems);
+				productLaunch.setInventory(productLaunch.getInventory().subtract(orderItems.getGoodsNum()));
+				productLaunchMapper.updateById(productLaunch);
+				List<SharePutOnShelves> sharePutOnShelvesList = sharePutOnShelvesMapper.selectListShare(productLaunch.getId() + "");
+				for (SharePutOnShelves items : sharePutOnShelvesList) {
+					items.setInventory(productLaunch.getInventory());
+					items.setUpdateTime(new Date());
+					items.setUpdateUser(AuthUtil.getUserId());
+					sharePutOnShelvesMapper.updateSharePutOnShelves(items);
+				}
 			} else {
 				//保存销售明细信息
 				PjOrderItems orderItems = new PjOrderItems();