Browse Source

2025年2月17日17:17:01

纪新园 10 months ago
parent
commit
53b0673ff8

+ 5 - 0
blade-service-api/blade-sales-part-api/src/main/java/org/springblade/salesPart/entity/PjProductLaunch.java

@@ -343,4 +343,9 @@ public class PjProductLaunch implements Serializable {
 	 */
 	@ApiModelProperty(value = "是否是积分商品")
 	private String whetherIntegral;
+
+	@TableField(exist = false)
+	private BigDecimal inventoryShare;
+	@TableField(exist = false)
+	private BigDecimal inventoryLocal;
 }

+ 4 - 0
blade-service-api/blade-sales-part-api/src/main/java/org/springblade/salesPart/shopping/entity/ShoppingMallDetail.java

@@ -58,6 +58,10 @@ public class ShoppingMallDetail implements Serializable {
 	private String brandItem;
 	private String specificationAndModel;
 	private BigDecimal inventory;
+	@TableField(exist = false)
+	private BigDecimal inventoryShare;
+	@TableField(exist = false)
+	private BigDecimal inventoryLocal;
 	private BigDecimal priceOne;
 	private BigDecimal priceTwo;
 	private BigDecimal priceThree;

+ 1 - 1
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/order/service/impl/OrderServiceImpl.java

@@ -4188,7 +4188,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
 			throw new RuntimeException("生成系统编号失败");
 		}
 		sharePjOrder.setOrdNo(billNo);
-		sharePjOrder.setSrcOrdNo(billNo);
+		sharePjOrder.setSrcOrdNo(srcOrdNo);
 		sharePjOrder.setBusinesDate(new Date());
 		sharePjOrder.setCreateUser(AuthUtil.getUserId());
 		sharePjOrder.setCreateTime(new Date());

+ 1 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/productLaunch/controller/ProductLaunchController.java

@@ -651,6 +651,7 @@ public class ProductLaunchController extends BladeController {
 			for (PjProductLaunch item : pages.getRecords()) {
 				if (!stockDescList.isEmpty()) {
 					item.setInventory(stockDescList.stream().filter(e -> e.getGoodsId().equals(item.getGoodsId())).map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+					item.setInventoryLocal(item.getInventory());
 				}
 				if (!pjProductLaunchFilesList.isEmpty()) {
 					List<PjProductLaunchFiles> list = pjProductLaunchFilesList.stream().filter(e -> e.getPid().equals(item.getId())).collect(Collectors.toList());

+ 3 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/share/mapper/SharePutOnShelvesMapper.java

@@ -51,6 +51,9 @@ public interface SharePutOnShelvesMapper extends BaseMapper<SharePutOnShelves> {
 	int updateSharePutOnShelves(SharePutOnShelves item);
 
 	@TenantIgnore
+	int updateShareCost(SharePutOnShelves item);
+
+	@TenantIgnore
 	List<SharePutOnShelves> selectShare(@Param("ids")String ids);
 
 	@TenantIgnore

+ 3 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/share/mapper/SharePutOnShelvesMapper.xml

@@ -59,6 +59,9 @@
     <update id="updateSharePutOnShelves">
         UPDATE pjpf_share_put_on_shelves SET inventory = #{inventory} WHERE id = #{id} And tenant_id = #{tenantId}
     </update>
+    <update id="updateShareCost">
+        UPDATE pjpf_share_put_on_shelves SET share_cost = #{shareCost} WHERE product_launch_id = #{productLaunchId}
+    </update>
 
     <select id="selectSharePutOnShelvesPage" resultMap="sharePutOnShelvesResultMap">
         select * from pjpf_share_put_on_shelves where is_deleted = 0

+ 151 - 120
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/share/service/impl/SharePutOnShelvesServiceImpl.java

@@ -579,9 +579,24 @@ public class SharePutOnShelvesServiceImpl extends ServiceImpl<SharePutOnShelvesM
 		}
 
 		List<SharePutOnShelves> sharePutOnShelvesList = new ArrayList<>();
+		List<SharePutOnShelves> sharePutOnShelvesUpdateList = new ArrayList<>();
 		List<PjProductLaunch> pjProductLaunchListNew = new ArrayList<>();
 		List<String> sharedCompanyList = new ArrayList<>();
+		List<String> goodsList = excelList.stream().map(SharePutOnShelvesImportExcel::getGoodsName).collect(Collectors.toList());
+		List<SharePutOnShelves> shelvesList = baseMapper.selectList(new LambdaQueryWrapper<SharePutOnShelves>()
+			.eq(SharePutOnShelves::getIsDeleted, 0)
+			.eq(SharePutOnShelves::getTenantId, AuthUtil.getTenantId())
+			.in(SharePutOnShelves::getGoodsName, goodsList)
+			.eq(SharePutOnShelves::getBillType, 0));
 		for (SharePutOnShelvesImportExcel excel : excelList) {
+			SharePutOnShelves shelves = null;
+			boolean status = false;
+			if (!shelvesList.isEmpty()) {
+				shelves = shelvesList.stream().filter(e -> e.getGoodsName().equals(excel.getGoodsName())).findFirst().orElse(null);
+				if (shelves != null) {
+					status = true;
+				}
+			}
 			PjProductLaunch item = pjProductLaunchList.stream().filter(e -> e.getCname().equals(excel.getGoodsName())).findFirst().orElse(null);
 			if (item != null) {
 				item.setWhetherShare(1);
@@ -651,140 +666,156 @@ public class SharePutOnShelvesServiceImpl extends ServiceImpl<SharePutOnShelvesM
 				}
 				String[] arr = excel.getSharedCompany().split(",");
 				sharedCompanyList.addAll(Arrays.asList(arr));
-				SharePutOnShelves sharePutOnShelves = new SharePutOnShelves();
-				sharePutOnShelves.setCreateUser(AuthUtil.getUserId());
-				sharePutOnShelves.setCreateTime(new Date());
-				sharePutOnShelves.setTenantId(AuthUtil.getTenantId());
-				sharePutOnShelves.setGoodsId(item.getGoodsId());
-				PjGoodsDesc goodsDesc = goodsDescList.stream().filter(e -> e.getId().equals(item.getGoodsId())).findFirst().orElse(null);
-				if (goodsDesc != null) {
-					item.setCode(goodsDesc.getCode());
-					item.setGoodsSize(goodsDesc.getGoodsSize());
+				if (status) {
+					if (shelves != null) {
+						shelves.setShareCost(excel.getShareCost());
+						sharePutOnShelvesUpdateList.add(shelves);
+					}
 				} else {
-					throw new RuntimeException("未查到商品:" + item.getCname());
-				}
-				sharePutOnShelves.setGoodsCode(item.getCode());
-				sharePutOnShelves.setGoodsName(item.getCname());
-				sharePutOnShelves.setGoodsInt(item.getCnameInt());
-				sharePutOnShelves.setSpecificationAndModel(item.getSpecificationAndModel());
-				sharePutOnShelves.setGoodsSize(item.getGoodsSize());
-				sharePutOnShelves.setBrandId(item.getBrandId());
-				sharePutOnShelves.setBrandName(item.getBrandName());
-				sharePutOnShelves.setGoodsDescription(item.getDetailsText());
-				sharePutOnShelves.setBrandItem(item.getBrandItem());
-				sharePutOnShelves.setPlaceProduction(item.getPlaceProduction());
-				sharePutOnShelves.setExplosionProof(item.getExplosionProof());
-				sharePutOnShelves.setOriginalFactory(item.getOriginalFactory());
-				sharePutOnShelves.setSelfRecovery(item.getSelfRecovery());
-				sharePutOnShelves.setSalesCompanyId(item.getSalesCompanyId());
-				sharePutOnShelves.setSalesCompanyName(item.getSalesCompanyName());
-				sharePutOnShelves.setInventory(item.getInventory());
-				sharePutOnShelves.setShareCost(excel.getShareCost());
-				sharePutOnShelves.setPriceOne(item.getPriceOne());
-				sharePutOnShelves.setPriceTwo(item.getPriceTwo());
-				sharePutOnShelves.setPriceThree(item.getPriceThree());
-				sharePutOnShelves.setPriceFour(item.getPriceFour());
-				sharePutOnShelves.setProductLaunchId(item.getId());
-				sharePutOnShelves.setSrcTenantId(item.getTenantId());
-				sharePutOnShelves.setSrcSalesCompanyId(item.getSalesCompanyId());
-				sharePutOnShelves.setSrcSalesCompanyName(item.getSalesCompanyName());
-				sharePutOnShelves.setSrcGoodsId(item.getGoodsId());
-				sharePutOnShelves.setSrcGoodsCode(item.getCode());
-				sharePutOnShelves.setSrcGoodsName(item.getCname());
-				sharePutOnShelves.setSrcBrandId(item.getBrandId());
-				sharePutOnShelves.setSrcBrandName(item.getBrandName());
-				sharePutOnShelves.setBillType(0);
-				if (ObjectUtils.isNotNull(item.getFilesList()) && !item.getFilesList().isEmpty()) {
-					sharePutOnShelves.setUrl(item.getFilesList().get(0).getUrl());
+					SharePutOnShelves sharePutOnShelves = new SharePutOnShelves();
+					sharePutOnShelves.setCreateUser(AuthUtil.getUserId());
+					sharePutOnShelves.setCreateTime(new Date());
+					sharePutOnShelves.setTenantId(AuthUtil.getTenantId());
+					sharePutOnShelves.setGoodsId(item.getGoodsId());
+					PjGoodsDesc goodsDesc = goodsDescList.stream().filter(e -> e.getId().equals(item.getGoodsId())).findFirst().orElse(null);
+					if (goodsDesc != null) {
+						item.setCode(goodsDesc.getCode());
+						item.setGoodsSize(goodsDesc.getGoodsSize());
+					} else {
+						throw new RuntimeException("未查到商品:" + item.getCname());
+					}
+					sharePutOnShelves.setGoodsCode(item.getCode());
+					sharePutOnShelves.setGoodsName(item.getCname());
+					sharePutOnShelves.setGoodsInt(item.getCnameInt());
+					sharePutOnShelves.setSpecificationAndModel(item.getSpecificationAndModel());
+					sharePutOnShelves.setGoodsSize(item.getGoodsSize());
+					sharePutOnShelves.setBrandId(item.getBrandId());
+					sharePutOnShelves.setBrandName(item.getBrandName());
+					sharePutOnShelves.setGoodsDescription(item.getDetailsText());
+					sharePutOnShelves.setBrandItem(item.getBrandItem());
+					sharePutOnShelves.setPlaceProduction(item.getPlaceProduction());
+					sharePutOnShelves.setExplosionProof(item.getExplosionProof());
+					sharePutOnShelves.setOriginalFactory(item.getOriginalFactory());
+					sharePutOnShelves.setSelfRecovery(item.getSelfRecovery());
+					sharePutOnShelves.setSalesCompanyId(item.getSalesCompanyId());
+					sharePutOnShelves.setSalesCompanyName(item.getSalesCompanyName());
+					sharePutOnShelves.setInventory(item.getInventory());
+					sharePutOnShelves.setShareCost(excel.getShareCost());
+					sharePutOnShelves.setPriceOne(item.getPriceOne());
+					sharePutOnShelves.setPriceTwo(item.getPriceTwo());
+					sharePutOnShelves.setPriceThree(item.getPriceThree());
+					sharePutOnShelves.setPriceFour(item.getPriceFour());
+					sharePutOnShelves.setProductLaunchId(item.getId());
+					sharePutOnShelves.setSrcTenantId(item.getTenantId());
+					sharePutOnShelves.setSrcSalesCompanyId(item.getSalesCompanyId());
+					sharePutOnShelves.setSrcSalesCompanyName(item.getSalesCompanyName());
+					sharePutOnShelves.setSrcGoodsId(item.getGoodsId());
+					sharePutOnShelves.setSrcGoodsCode(item.getCode());
+					sharePutOnShelves.setSrcGoodsName(item.getCname());
+					sharePutOnShelves.setSrcBrandId(item.getBrandId());
+					sharePutOnShelves.setSrcBrandName(item.getBrandName());
+					sharePutOnShelves.setBillType(0);
+					if (ObjectUtils.isNotNull(item.getFilesList()) && !item.getFilesList().isEmpty()) {
+						sharePutOnShelves.setUrl(item.getFilesList().get(0).getUrl());
+					}
+					sharePutOnShelvesList.add(sharePutOnShelves);
 				}
-				sharePutOnShelvesList.add(sharePutOnShelves);
 				pjProductLaunchListNew.add(item);
 			} else {
 				throw new RuntimeException("商品:" + excel.getGoodsName() + "未查到上架数据");
 			}
 		}
 		productLaunchService.updateBatchById(pjProductLaunchListNew);
-		this.saveBatch(sharePutOnShelvesList);
-		String sharedCompany = "";
-		if (!sharedCompanyList.isEmpty()) {
-			sharedCompany = sharedCompanyList.stream().distinct().collect(Collectors.joining(","));
+		if (!sharePutOnShelvesList.isEmpty()) {
+			this.saveBatch(sharePutOnShelvesList);
 		}
-		List<Dept> deptList = iSysClient.getDeptListByNames(sharedCompany);
-		if (deptList.isEmpty()) {
-			throw new RuntimeException("请选择共享公司");
+		if (!sharePutOnShelvesUpdateList.isEmpty()) {
+			for (SharePutOnShelves item : sharePutOnShelvesUpdateList) {
+				baseMapper.updateShareCost(item);
+			}
 		}
-		List<SharePutOnShelves> sharePutOnShelves = new ArrayList<>();
-		String msg = "";
-		for (Dept deptItem : deptList) {
-			for (SharePutOnShelves item : sharePutOnShelvesList) {
-				if (0 != item.getBillType()) {
-					throw new RuntimeException(item.getGoodsName() + "商品为被共享商品,共享失败");
-				}
-				item.setShareStatus("已共享");
-				if (ObjectUtils.isNotNull(item.getSharedCompanyId()) && ObjectUtils.isNotNull(item.getSharedCompany())) {
-					List<String> sharedCompanyId = Arrays.asList(item.getSharedCompanyId().split(","));
-					sharedCompanyId.add(deptItem.getId() + "");
-					item.setSharedCompanyId(sharedCompanyId.stream().distinct().collect(Collectors.joining(",")));
-					List<String> sharedCompanyName = Arrays.asList(item.getSharedCompany().split(","));
-					sharedCompanyName.add(deptItem.getDeptName());
-					item.setSharedCompany(sharedCompanyName.stream().distinct().collect(Collectors.joining(",")));
-				} else {
-					item.setSharedCompanyId(deptItem.getId() + "");
-					item.setSharedCompany(deptItem.getDeptName());
-				}
-				List<SharePutOnShelves> sharePutOnShelvesList1 = baseMapper.selectSharePutOnShelvesList(item.getGoodsCode(), deptItem.getDeptName(), deptItem.getTenantId());
-				if (!sharePutOnShelvesList1.isEmpty()) {
-					for (SharePutOnShelves shelves : sharePutOnShelvesList1) {
-						if (0 == shelves.getBillType() && shelves.getSharedCompany().contains(deptName)) {
-							msg = msg + item.getGoodsName() + ",";
-						} else {
-							shelves.setInventory(item.getInventory());
-							shelves.setShareCost(item.getShareCost());
-							sharePutOnShelves.add(shelves);
+		if (!sharePutOnShelvesList.isEmpty()) {
+			String sharedCompany = "";
+			if (!sharedCompanyList.isEmpty()) {
+				sharedCompany = sharedCompanyList.stream().distinct().collect(Collectors.joining(","));
+			}
+			List<Dept> deptList = iSysClient.getDeptListByNames(sharedCompany);
+			if (deptList.isEmpty()) {
+				throw new RuntimeException("请选择共享公司");
+			}
+			List<SharePutOnShelves> sharePutOnShelves = new ArrayList<>();
+			String msg = "";
+			for (Dept deptItem : deptList) {
+				for (SharePutOnShelves item : sharePutOnShelvesList) {
+					if (0 != item.getBillType()) {
+						throw new RuntimeException(item.getGoodsName() + "商品为被共享商品,共享失败");
+					}
+					item.setShareStatus("已共享");
+					if (ObjectUtils.isNotNull(item.getSharedCompanyId()) && ObjectUtils.isNotNull(item.getSharedCompany())) {
+						List<String> sharedCompanyId = Arrays.asList(item.getSharedCompanyId().split(","));
+						sharedCompanyId.add(deptItem.getId() + "");
+						item.setSharedCompanyId(sharedCompanyId.stream().distinct().collect(Collectors.joining(",")));
+						List<String> sharedCompanyName = Arrays.asList(item.getSharedCompany().split(","));
+						sharedCompanyName.add(deptItem.getDeptName());
+						item.setSharedCompany(sharedCompanyName.stream().distinct().collect(Collectors.joining(",")));
+					} else {
+						item.setSharedCompanyId(deptItem.getId() + "");
+						item.setSharedCompany(deptItem.getDeptName());
+					}
+					List<SharePutOnShelves> sharePutOnShelvesList1 = baseMapper.selectSharePutOnShelvesList(item.getGoodsCode(), deptItem.getDeptName(), deptItem.getTenantId());
+					if (!sharePutOnShelvesList1.isEmpty()) {
+						for (SharePutOnShelves shelves : sharePutOnShelvesList1) {
+							if (0 == shelves.getBillType() && shelves.getSharedCompany().contains(deptName)) {
+								msg = msg + item.getGoodsName() + ",";
+							} else {
+								shelves.setInventory(item.getInventory());
+								shelves.setShareCost(item.getShareCost());
+								sharePutOnShelves.add(shelves);
+							}
 						}
+					} else {
+						SharePutOnShelves shelves = new SharePutOnShelves();
+						shelves.setShareStatus("暂存");
+						shelves.setTenantId(deptItem.getTenantId());
+						shelves.setGoodsCode(item.getGoodsCode());
+						shelves.setGoodsName(item.getGoodsName());
+						shelves.setGoodsInt(item.getGoodsInt());
+						shelves.setSpecificationAndModel(item.getSpecificationAndModel());
+						shelves.setGoodsSize(item.getGoodsSize());
+						shelves.setBrandName(item.getBrandName());
+						shelves.setGoodsDescription(item.getGoodsDescription());
+						shelves.setBrandItem(item.getBrandItem());
+						shelves.setPlaceProduction(item.getPlaceProduction());
+						shelves.setExplosionProof(item.getExplosionProof());
+						shelves.setOriginalFactory(item.getOriginalFactory());
+						shelves.setSelfRecovery(item.getSelfRecovery());
+						shelves.setSalesCompanyId(deptItem.getId());
+						shelves.setSalesCompanyName(deptItem.getDeptName());
+						shelves.setInventory(item.getInventory());
+						shelves.setShareCost(item.getShareCost());
+						shelves.setProductLaunchId(item.getProductLaunchId());
+						shelves.setSrcTenantId(item.getSrcTenantId());
+						shelves.setSrcSalesCompanyId(item.getSrcSalesCompanyId());
+						shelves.setSrcSalesCompanyName(item.getSrcSalesCompanyName());
+						shelves.setSrcGoodsId(item.getGoodsId());
+						shelves.setSrcGoodsCode(item.getGoodsCode());
+						shelves.setSrcGoodsName(item.getGoodsName());
+						shelves.setSrcBrandId(item.getBrandId());
+						shelves.setSrcBrandName(item.getBrandName());
+						shelves.setBillType(1);
+						shelves.setSrcSharedId(item.getId());
+						shelves.setUrl(item.getUrl());
+						sharePutOnShelves.add(shelves);
 					}
-				} else {
-					SharePutOnShelves shelves = new SharePutOnShelves();
-					shelves.setShareStatus("暂存");
-					shelves.setTenantId(deptItem.getTenantId());
-					shelves.setGoodsCode(item.getGoodsCode());
-					shelves.setGoodsName(item.getGoodsName());
-					shelves.setGoodsInt(item.getGoodsInt());
-					shelves.setSpecificationAndModel(item.getSpecificationAndModel());
-					shelves.setGoodsSize(item.getGoodsSize());
-					shelves.setBrandName(item.getBrandName());
-					shelves.setGoodsDescription(item.getGoodsDescription());
-					shelves.setBrandItem(item.getBrandItem());
-					shelves.setPlaceProduction(item.getPlaceProduction());
-					shelves.setExplosionProof(item.getExplosionProof());
-					shelves.setOriginalFactory(item.getOriginalFactory());
-					shelves.setSelfRecovery(item.getSelfRecovery());
-					shelves.setSalesCompanyId(deptItem.getId());
-					shelves.setSalesCompanyName(deptItem.getDeptName());
-					shelves.setInventory(item.getInventory());
-					shelves.setShareCost(item.getShareCost());
-					shelves.setProductLaunchId(item.getProductLaunchId());
-					shelves.setSrcTenantId(item.getSrcTenantId());
-					shelves.setSrcSalesCompanyId(item.getSrcSalesCompanyId());
-					shelves.setSrcSalesCompanyName(item.getSrcSalesCompanyName());
-					shelves.setSrcGoodsId(item.getGoodsId());
-					shelves.setSrcGoodsCode(item.getGoodsCode());
-					shelves.setSrcGoodsName(item.getGoodsName());
-					shelves.setSrcBrandId(item.getBrandId());
-					shelves.setSrcBrandName(item.getBrandName());
-					shelves.setBillType(1);
-					shelves.setSrcSharedId(item.getId());
-					shelves.setUrl(item.getUrl());
-					sharePutOnShelves.add(shelves);
 				}
 			}
-		}
-		if (ObjectUtils.isNotNull(msg)) {
-			throw new RuntimeException("商品:" + msg + "存在相互共享!");
-		}
-		this.updateBatchById(sharePutOnShelvesList);
-		if (!sharePutOnShelves.isEmpty()) {
-			this.saveOrUpdateBatch(sharePutOnShelves);
+			if (ObjectUtils.isNotNull(msg)) {
+				throw new RuntimeException("商品:" + msg + "存在相互共享!");
+			}
+			this.updateBatchById(sharePutOnShelvesList);
+			if (!sharePutOnShelves.isEmpty()) {
+				this.saveOrUpdateBatch(sharePutOnShelves);
+			}
 		}
 		return R.data(sharePutOnShelvesList);
 	}

+ 6 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/shopping/controller/ShoppingMallDetailController.java

@@ -281,10 +281,12 @@ public class ShoppingMallDetailController extends BladeController {
 						.filter(e -> e.getGoodsCode().equals(item.getGoodsCode())).findFirst().orElse(null);
 					if (shoppingMallDetail != null) {
 						BeanUtil.copyProperties(shoppingMallDetail, item);
+						item.setInventoryLocal(item.getInventory());
 						if (!shoppingMallDetailShareList.isEmpty()) {
 							BigDecimal inventory = shoppingMallDetailShareList.stream().filter(e -> e.getGoodsCode().equals(item.getGoodsCode()))
 								.map(ShoppingMallDetail::getInventory).reduce(BigDecimal.ZERO, BigDecimal::add);
 							item.setInventory(item.getInventory().add(inventory));
+							item.setInventoryShare(inventory);
 						}
 					} else {
 						if (!shoppingMallDetailShareList.isEmpty()) {
@@ -292,6 +294,8 @@ public class ShoppingMallDetailController extends BladeController {
 								.filter(e -> e.getGoodsCode().equals(item.getGoodsCode())).findFirst().orElse(null);
 							if (shoppingMallShareDetail != null) {
 								BeanUtil.copyProperties(shoppingMallShareDetail, item);
+								item.setInventoryShare(item.getInventory());
+								item.setInventoryLocal(new BigDecimal("0"));
 							}
 						}
 					}
@@ -301,6 +305,8 @@ public class ShoppingMallDetailController extends BladeController {
 							.filter(e -> e.getGoodsCode().equals(item.getGoodsCode())).findFirst().orElse(null);
 						if (shoppingMallShareDetail != null) {
 							BeanUtil.copyProperties(shoppingMallShareDetail, item);
+							item.setInventoryShare(item.getInventory());
+							item.setInventoryLocal(new BigDecimal("0"));
 						}
 					}
 				}