Browse Source

2024年5月13日17:37:41

纪新园 1 year ago
parent
commit
127a078c7e

+ 6 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/cur/entity/BCurrency.java

@@ -198,5 +198,11 @@ public class BCurrency implements Serializable {
 	@TableField(exist = false)
 	@TableField(exist = false)
 	private String dc;
 	private String dc;
 
 
+	/**
+	 * 类型  1业务  2财务
+	 */
+	@TableField(exist = false)
+	private String type;
+
 
 
 }
 }

+ 58 - 14
blade-service/blade-los/src/main/java/org/springblade/los/basic/cur/service/impl/BCurrencyServiceImpl.java

@@ -589,24 +589,68 @@ public class BCurrencyServiceImpl extends ServiceImpl<CurrencyMapper, BCurrency>
 					}
 					}
 					BCurExrate bCurExrate = bCurExrateService.getOne(lambdaQueryWrapper);
 					BCurExrate bCurExrate = bCurExrateService.getOne(lambdaQueryWrapper);
 					if ("D".equals(bCurrency.getDc())) {
 					if ("D".equals(bCurrency.getDc())) {
-						if (ObjectUtils.isNull(bCurExrate)) {
-							throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");
-						}
-						if (ObjectUtils.isNull(bCurExrate.getExrateReceipts()) &&
-							new BigDecimal("0.00").compareTo(bCurExrate.getExrateReceipts()) == 0) {
-							throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "实收汇率");
+						if ("1".equals(bCurrency.getType())) {
+							if (ObjectUtils.isNull(bCurExrate)) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");
+							}
+							if (ObjectUtils.isNull(bCurExrate.getExrateReceivable()) &&
+								new BigDecimal("0.00").compareTo(bCurExrate.getExrateReceivable()) == 0) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "实收汇率");
+							} else {
+								details.setExrate(bCurExrate.getExrateReceivable());
+							}
+						} else if ("2".equals(bCurrency.getType())) {
+							if (ObjectUtils.isNull(bCurExrate)) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");
+							}
+							if (ObjectUtils.isNull(bCurExrate.getExrateReceipts()) &&
+								new BigDecimal("0.00").compareTo(bCurExrate.getExrateReceipts()) == 0) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "实收汇率");
+							} else {
+								details.setExrate(bCurExrate.getExrateReceipts());
+							}
 						} else {
 						} else {
-							details.setExrate(bCurExrate.getExrateReceipts());
+							if (ObjectUtils.isNull(bCurExrate)) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");
+							}
+							if (ObjectUtils.isNull(bCurExrate.getExrateReceipts()) &&
+								new BigDecimal("0.00").compareTo(bCurExrate.getExrateReceipts()) == 0) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "实收汇率");
+							} else {
+								details.setExrate(bCurExrate.getExrateReceipts());
+							}
 						}
 						}
 					} else if ("C".equals(bCurrency.getDc())) {
 					} else if ("C".equals(bCurrency.getDc())) {
-						if (ObjectUtils.isNull(bCurExrate)) {
-							throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");
-						}
-						if (ObjectUtils.isNull(bCurExrate.getExratePayment()) &&
-							new BigDecimal("0.00").compareTo(bCurExrate.getExratePayment()) == 0) {
-							throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "实付汇率");
+						if ("1".equals(bCurrency.getType())) {
+							if (ObjectUtils.isNull(bCurExrate)) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");
+							}
+							if (ObjectUtils.isNull(bCurExrate.getExratePayable()) &&
+								new BigDecimal("0.00").compareTo(bCurExrate.getExratePayable()) == 0) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "实付汇率");
+							} else {
+								details.setExrate(bCurExrate.getExratePayable());
+							}
+						} else if ("2".equals(bCurrency.getType())) {
+							if (ObjectUtils.isNull(bCurExrate)) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");
+							}
+							if (ObjectUtils.isNull(bCurExrate.getExratePayment()) &&
+								new BigDecimal("0.00").compareTo(bCurExrate.getExratePayment()) == 0) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "实付汇率");
+							} else {
+								details.setExrate(bCurExrate.getExratePayment());
+							}
 						} else {
 						} else {
-							details.setExrate(bCurExrate.getExratePayment());
+							if (ObjectUtils.isNull(bCurExrate)) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");
+							}
+							if (ObjectUtils.isNull(bCurExrate.getExratePayment()) &&
+								new BigDecimal("0.00").compareTo(bCurExrate.getExratePayment()) == 0) {
+								throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "实付汇率");
+							} else {
+								details.setExrate(bCurExrate.getExratePayment());
+							}
 						}
 						}
 					} else {
 					} else {
 						throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");
 						throw new RuntimeException("请维护" + year + "年" + month + "月," + details.getCode() + "汇率");

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/controller/BFeesController.java

@@ -86,6 +86,8 @@ public class BFeesController extends BladeController {
 			.and(ObjectUtils.isNotNull(bFees.getCnName()), i -> i.like(BFees::getCnName, bFees.getCnName()).or()
 			.and(ObjectUtils.isNotNull(bFees.getCnName()), i -> i.like(BFees::getCnName, bFees.getCnName()).or()
 				.like(BFees::getEnName, bFees.getCnName()).or().like(BFees::getCode, bFees.getCnName()))
 				.like(BFees::getEnName, bFees.getCnName()).or().like(BFees::getCode, bFees.getCnName()))
 			.like(ObjectUtils.isNotNull(bFees.getStatus()), BFees::getStatus, bFees.getStatus())
 			.like(ObjectUtils.isNotNull(bFees.getStatus()), BFees::getStatus, bFees.getStatus())
+			.like(ObjectUtils.isNotNull(bFees.getCode()), BFees::getCode, bFees.getCode())
+			.like(ObjectUtils.isNotNull(bFees.getEnName()), BFees::getEnName, bFees.getEnName())
 			.like(ObjectUtils.isNotNull(bFees.getFeesTypeId()), BFees::getFeesTypeId, bFees.getFeesTypeId())
 			.like(ObjectUtils.isNotNull(bFees.getFeesTypeId()), BFees::getFeesTypeId, bFees.getFeesTypeId())
 			.orderByDesc(BFees::getCreateTime);
 			.orderByDesc(BFees::getCreateTime);
 		IPage<BFees> pages = bFeesService.page(Condition.getPage(query), lambdaQueryWrapper);
 		IPage<BFees> pages = bFeesService.page(Condition.getPage(query), lambdaQueryWrapper);

+ 3 - 2
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/controller/BillsController.java

@@ -78,7 +78,7 @@ public class BillsController extends BladeController {
 		lambdaQueryWrapper.select(Bills::getId, Bills::getBillNo, Bills::getBillType, Bills::getMasterBillNo,
 		lambdaQueryWrapper.select(Bills::getId, Bills::getBillNo, Bills::getBillType, Bills::getMasterBillNo,
 			Bills::getCorpCnName, Bills::getCorpId, Bills::getCorpEnName, Bills::getVesselCnName,
 			Bills::getCorpCnName, Bills::getCorpId, Bills::getCorpEnName, Bills::getVesselCnName,
 			Bills::getVesselId, Bills::getVoyageNo, Bills::getMblno, Bills::getHblno, Bills::getEta, Bills::getEtd,
 			Bills::getVesselId, Bills::getVoyageNo, Bills::getMblno, Bills::getHblno, Bills::getEta, Bills::getEtd,
-			Bills::getPolCnName, Bills::getPolId, Bills::getPodCnName, Bills::getPodId, Bills::getLoadType, Bills::getPlaceReceiptName,
+			Bills::getPolEnName, Bills::getPolId, Bills::getPodEnName, Bills::getPodId, Bills::getLoadType, Bills::getPlaceReceiptName,
 			Bills::getCargoType, Bills::getMarks, Bills::getQuantity, Bills::getGrossWeight, Bills::getNetWeight,
 			Bills::getCargoType, Bills::getMarks, Bills::getQuantity, Bills::getGrossWeight, Bills::getNetWeight,
 			Bills::getMeasurement, Bills::getQuantityV20, Bills::getQuantityV40, Bills::getQuantityV40hc, Bills::getQuantityV45,
 			Bills::getMeasurement, Bills::getQuantityV20, Bills::getQuantityV40, Bills::getQuantityV40hc, Bills::getQuantityV45,
 			Bills::getQuantityV48, Bills::getIsNeedLand, Bills::getIsNeedDeclare, Bills::getIsNeedIq, Bills::getAmountDr,
 			Bills::getQuantityV48, Bills::getIsNeedLand, Bills::getIsNeedDeclare, Bills::getIsNeedIq, Bills::getAmountDr,
@@ -86,7 +86,8 @@ public class BillsController extends BladeController {
 			Bills::getAmountDrLoc, Bills::getAmountCrLoc, Bills::getAmountProfitLoc, Bills::getCheckCrStatusDescr, Bills::getCheckDrStatusDescr,
 			Bills::getAmountDrLoc, Bills::getAmountCrLoc, Bills::getAmountProfitLoc, Bills::getCheckCrStatusDescr, Bills::getCheckDrStatusDescr,
 			Bills::getStlCrStatusDescr, Bills::getStlDrStatusDescr, Bills::getInvoiceCrStatusDescr, Bills::getInvoiceDrStatusDescr, Bills::getCreateUserName,
 			Bills::getStlCrStatusDescr, Bills::getStlDrStatusDescr, Bills::getInvoiceCrStatusDescr, Bills::getInvoiceDrStatusDescr, Bills::getCreateUserName,
 			Bills::getCreateTime, Bills::getUpdateUserName, Bills::getUpdateTime, Bills::getStatus, Bills::getBillStatus,
 			Bills::getCreateTime, Bills::getUpdateUserName, Bills::getUpdateTime, Bills::getStatus, Bills::getBillStatus,
-			Bills::getAccountStatus, Bills::getRemarks, Bills::getPackingUnit, Bills::getBillDate, Bills::getTeamName,Bills::getCreateUser,Bills::getTeu,Bills::getIssueType);
+			Bills::getAccountStatus, Bills::getRemarks, Bills::getPackingUnit, Bills::getBillDate, Bills::getTeamName,
+			Bills::getCreateUser,Bills::getTeu,Bills::getIssueType,Bills::getBookingNo,Bills::getQuantityCntrDescr);
 		lambdaQueryWrapper.eq(Bills::getIsDeleted, 0)
 		lambdaQueryWrapper.eq(Bills::getIsDeleted, 0)
 			.eq(Bills::getTenantId, AuthUtil.getTenantId())
 			.eq(Bills::getTenantId, AuthUtil.getTenantId())
 			.and(i -> i.isNull(Bills::getMasterId).or()
 			.and(i -> i.isNull(Bills::getMasterId).or()

+ 15 - 6
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/order/controller/OrderController.java

@@ -179,11 +179,11 @@ public class OrderController extends BladeController {
 						item.setUpdateUserName(user.getName());
 						item.setUpdateUserName(user.getName());
 					}
 					}
 				}
 				}
-				if (item.getGoodsTotalNum().compareTo(item.getReturnsNumber()) == 0){
+				if (item.getGoodsTotalNum().compareTo(item.getReturnsNumber()) == 0) {
 					item.setReturnsStatus("全退");
 					item.setReturnsStatus("全退");
-				}else if (item.getGoodsTotalNum().compareTo(item.getReturnsNumber()) > 0){
+				} else if (item.getGoodsTotalNum().compareTo(item.getReturnsNumber()) > 0 && new BigDecimal("0.00").compareTo(item.getReturnsNumber()) != 0) {
 					item.setReturnsStatus("部分");
 					item.setReturnsStatus("部分");
-				}else{
+				} else {
 					item.setReturnsStatus("无");
 					item.setReturnsStatus("无");
 				}
 				}
 
 
@@ -280,11 +280,11 @@ public class OrderController extends BladeController {
 						item.setUpdateUserName(user.getName());
 						item.setUpdateUserName(user.getName());
 					}
 					}
 				}
 				}
-				if (item.getGoodsTotalNum().compareTo(item.getReturnsNumber()) == 0){
+				if (item.getGoodsTotalNum().compareTo(item.getReturnsNumber()) == 0) {
 					item.setReturnsStatus("全退");
 					item.setReturnsStatus("全退");
-				}else if (item.getGoodsTotalNum().compareTo(item.getReturnsNumber()) > 0){
+				} else if (item.getGoodsTotalNum().compareTo(item.getReturnsNumber()) > 0 && new BigDecimal("0.00").compareTo(item.getReturnsNumber()) != 0) {
 					item.setReturnsStatus("部分");
 					item.setReturnsStatus("部分");
-				}else{
+				} else {
 					item.setReturnsStatus("无");
 					item.setReturnsStatus("无");
 				}
 				}
 				if (ObjectUtil.isNotEmpty(createUserList)) {
 				if (ObjectUtil.isNotEmpty(createUserList)) {
@@ -753,6 +753,15 @@ public class OrderController extends BladeController {
 		}
 		}
 		lambdaQueryWrapper.orderByDesc(PjOrder::getCreateTime);
 		lambdaQueryWrapper.orderByDesc(PjOrder::getCreateTime);
 		IPage<PjOrder> pages = orderService.page(Condition.getPage(query), lambdaQueryWrapper);
 		IPage<PjOrder> pages = orderService.page(Condition.getPage(query), lambdaQueryWrapper);
+		for (PjOrder item : pages.getRecords()) {
+			if ("TKXS".equals(item.getBsType()) || "TKCG".equals(item.getBsType())) {
+				item.setGoodsTotalNum(new BigDecimal("0"));
+				item.setTotalMoney(new BigDecimal("0.00"));
+			}else{
+				item.setReturnsAmount(new BigDecimal("0.00"));
+				item.setReturnsNumber(new BigDecimal("0"));
+			}
+		}
 		return R.data(pages);
 		return R.data(pages);
 	}
 	}
 
 

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

@@ -2057,6 +2057,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
 		details.setOriginalStatus("录入");
 		details.setOriginalStatus("录入");
 		details.setGenerateTask("未生成");
 		details.setGenerateTask("未生成");
 		details.setShortcutWarehousingStatus("0");
 		details.setShortcutWarehousingStatus("0");
+		details.setActualPaymentStatus(1);
+		details.setPaymentDate(null);
+		details.setOldTrxId("");
+		details.setPaymentAmountTl(new BigDecimal("0.00"));
 		details.setBusinesDate(null);
 		details.setBusinesDate(null);
 		if ("XS".equals(detail.getBsType())) {
 		if ("XS".equals(detail.getBsType())) {
 			details.setBsType("TKXS");
 			details.setBsType("TKXS");

+ 20 - 10
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/settlement/service/impl/SettlementServiceImpl.java

@@ -214,6 +214,11 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, PjSettl
 							pjOrder.setPaymentAmountTl(item.getThisAmount());
 							pjOrder.setPaymentAmountTl(item.getThisAmount());
 						}
 						}
 						thisAmount = thisAmount.add(item.getThisAmount());
 						thisAmount = thisAmount.add(item.getThisAmount());
+						if (pjOrder.getPaymentAmountTl().equals(pjOrder.getTotalMoney())) {
+							pjOrder.setActualPaymentStatus(2);
+						} else {
+							pjOrder.setActualPaymentStatus(3);
+						}
 					} else if ("TKXS".equals(item.getBusinesType()) || "TKCG".equals(item.getBusinesType())) {
 					} else if ("TKXS".equals(item.getBusinesType()) || "TKCG".equals(item.getBusinesType())) {
 						if (ObjectUtils.isNotNull(pjOrder.getPaymentAmountTl())) {
 						if (ObjectUtils.isNotNull(pjOrder.getPaymentAmountTl())) {
 							if (pjOrder.getPaymentAmountTl().add(item.getThisRefundAmount()).compareTo(pjOrder.getTotalMoney()) > 0) {
 							if (pjOrder.getPaymentAmountTl().add(item.getThisRefundAmount()).compareTo(pjOrder.getTotalMoney()) > 0) {
@@ -227,11 +232,11 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, PjSettl
 							pjOrder.setPaymentAmountTl(item.getThisRefundAmount());
 							pjOrder.setPaymentAmountTl(item.getThisRefundAmount());
 						}
 						}
 						thisAmount = thisAmount.subtract(item.getThisRefundAmount());
 						thisAmount = thisAmount.subtract(item.getThisRefundAmount());
-					}
-					if (pjOrder.getPaymentAmountTl().equals(pjOrder.getTotalMoney())) {
-						pjOrder.setActualPaymentStatus(2);
-					} else {
-						pjOrder.setActualPaymentStatus(3);
+						if (pjOrder.getPaymentAmountTl().equals(pjOrder.getReturnsAmount())) {
+							pjOrder.setActualPaymentStatus(2);
+						} else {
+							pjOrder.setActualPaymentStatus(3);
+						}
 					}
 					}
 				}
 				}
 				pjOrder.setUpdateTime(new Date());
 				pjOrder.setUpdateTime(new Date());
@@ -323,6 +328,11 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, PjSettl
 							pjOrder.setPaymentAmountTl(new BigDecimal("0.00"));
 							pjOrder.setPaymentAmountTl(new BigDecimal("0.00"));
 						}
 						}
 						thisAmount = thisAmount.add(item.getThisAmount());
 						thisAmount = thisAmount.add(item.getThisAmount());
+						if (pjOrder.getPaymentAmountTl().equals(new BigDecimal("0.00"))) {
+							pjOrder.setActualPaymentStatus(1);
+						} else {
+							pjOrder.setActualPaymentStatus(3);
+						}
 					} else if ("TKXS".equals(item.getBusinesType()) || "TKCG".equals(item.getBusinesType())) {
 					} else if ("TKXS".equals(item.getBusinesType()) || "TKCG".equals(item.getBusinesType())) {
 						if (ObjectUtils.isNotNull(pjOrder.getPaymentAmountTl())) {
 						if (ObjectUtils.isNotNull(pjOrder.getPaymentAmountTl())) {
 							pjOrder.setPaymentAmountTl(pjOrder.getPaymentAmountTl().subtract(item.getThisRefundAmount()));
 							pjOrder.setPaymentAmountTl(pjOrder.getPaymentAmountTl().subtract(item.getThisRefundAmount()));
@@ -330,11 +340,11 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, PjSettl
 							pjOrder.setPaymentAmountTl(new BigDecimal("0.00"));
 							pjOrder.setPaymentAmountTl(new BigDecimal("0.00"));
 						}
 						}
 						thisAmount = thisAmount.subtract(item.getThisRefundAmount());
 						thisAmount = thisAmount.subtract(item.getThisRefundAmount());
-					}
-					if (pjOrder.getPaymentAmountTl().equals(new BigDecimal("0.00"))) {
-						pjOrder.setActualPaymentStatus(1);
-					} else {
-						pjOrder.setActualPaymentStatus(3);
+						if (pjOrder.getPaymentAmountTl().equals(pjOrder.getReturnsAmount())) {
+							pjOrder.setActualPaymentStatus(2);
+						} else {
+							pjOrder.setActualPaymentStatus(3);
+						}
 					}
 					}
 				}
 				}
 				pjOrder.setUpdateTime(new Date());
 				pjOrder.setUpdateTime(new Date());

+ 43 - 30
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/ship/service/impl/ShipServiceImpl.java

@@ -538,10 +538,10 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 			baseMapper.updateById(ship);
 			baseMapper.updateById(ship);
 		}
 		}
 		// 保存订单明细
 		// 保存订单明细
+		List<PjShipItems> shipItemsList = new ArrayList<>();
+		List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
+		List<PjStockDesc> pjStockDescArrayList = new ArrayList<>();
 		if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
 		if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
-			List<PjShipItems> shipItemsList = new ArrayList<>();
-			List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
-			List<PjStockDesc> pjStockDescArrayList = new ArrayList<>();
 			List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
 			List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
 			List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
 			List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
 				.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
 				.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
@@ -689,6 +689,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 			if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
 			if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
 				throw new RuntimeException("单据已收货或申请售后中,操作失败");
 				throw new RuntimeException("单据已收货或申请售后中,操作失败");
 			}
 			}
+			order.setGrossProfit(pjOrderItemsList.stream().map(PjOrderItems::getProfit).reduce(BigDecimal.ZERO, BigDecimal::add));
+			order.setCost(pjOrderItemsList.stream().map(PjOrderItems::getCostprie).reduce(BigDecimal.ZERO, BigDecimal::add));
 			order.setShipType(ship.getShipType());
 			order.setShipType(ship.getShipType());
 			order.setLogisticsCorpId(ship.getLogisticsCorpId());
 			order.setLogisticsCorpId(ship.getLogisticsCorpId());
 			order.setLogisticsCorpName(ship.getLogisticsCorpName());
 			order.setLogisticsCorpName(ship.getLogisticsCorpName());
@@ -718,30 +720,11 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 		ship.setUpdateTime(new Date());
 		ship.setUpdateTime(new Date());
 		baseMapper.updateById(ship);
 		baseMapper.updateById(ship);
 		PjOrder order = orderMapper.selectById(ship.getOrdId());
 		PjOrder order = orderMapper.selectById(ship.getOrdId());
-		if (ObjectUtil.isNotEmpty(order)) {
-			PjOrder order1 = orderMapper.selectOne(new LambdaQueryWrapper<PjOrder>()
-				.eq(PjOrder::getTenantId, AuthUtil.getTenantId())
-				.eq(PjOrder::getIsDeleted, 0)
-				.eq(PjOrder::getSrcNo, order.getOrdNo()));
-			if (order1 != null && "待入库,已完成".contains(order1.getStatus())) {
-				throw new RuntimeException("已生成销售退货单据,撤销失败");
-			}
-			if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
-				throw new RuntimeException("单据已收货或申请售后中,操作失败");
-			}
-			order.setStatus(OrderTypeEnum.XSDFH.getType());
-			order.setXcxStatus(OrderTypeEnum.XSDFH.getType());
-			order.setDeliveryBusinesDate(null);
-			orderMapper.updateById(order);
-		} else {
-			throw new RuntimeException("数据异常请联系管理员");
-		}
-
 		// 保存订单明细
 		// 保存订单明细
+		List<PjShipItems> itemsList = new ArrayList<>();
+		List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
+		List<PjStockDesc> pjStockDescArrayList = new ArrayList<>();
 		if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
 		if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
-			List<PjShipItems> itemsList = new ArrayList<>();
-			List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
-			List<PjStockDesc> pjStockDescArrayList = new ArrayList<>();
 			List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
 			List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
 			List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
 			List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
 				.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
 				.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
@@ -861,6 +844,26 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 				baseMapper.updateById(rwShip);
 				baseMapper.updateById(rwShip);
 			}
 			}
 		}
 		}
+		if (ObjectUtil.isNotEmpty(order)) {
+			PjOrder order1 = orderMapper.selectOne(new LambdaQueryWrapper<PjOrder>()
+				.eq(PjOrder::getTenantId, AuthUtil.getTenantId())
+				.eq(PjOrder::getIsDeleted, 0)
+				.eq(PjOrder::getSrcNo, order.getOrdNo()));
+			if (order1 != null && "待入库,已完成".contains(order1.getStatus())) {
+				throw new RuntimeException("已生成销售退货单据,撤销失败");
+			}
+			if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
+				throw new RuntimeException("单据已收货或申请售后中,操作失败");
+			}
+			order.setGrossProfit(pjOrderItemsList.stream().map(PjOrderItems::getProfit).reduce(BigDecimal.ZERO, BigDecimal::add));
+			order.setCost(pjOrderItemsList.stream().map(PjOrderItems::getCostprie).reduce(BigDecimal.ZERO, BigDecimal::add));
+			order.setStatus(OrderTypeEnum.XSDFH.getType());
+			order.setXcxStatus(OrderTypeEnum.XSDFH.getType());
+			order.setDeliveryBusinesDate(null);
+			orderMapper.updateById(order);
+		} else {
+			throw new RuntimeException("数据异常请联系管理员");
+		}
 		//生成出库工单历史记录
 		//生成出库工单历史记录
 		saveHistory(ship.getId(), OrderTypeEnum.TOBESHIPPEDOUT.getType());
 		saveHistory(ship.getId(), OrderTypeEnum.TOBESHIPPEDOUT.getType());
 
 
@@ -2115,7 +2118,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 					}
 					}
 				}
 				}
 				item.setNumberRows(list.size());
 				item.setNumberRows(list.size());
-				item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO,BigDecimal::add));
+				item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO, BigDecimal::add));
 			}
 			}
 
 
 			//修改出库任务状态
 			//修改出库任务状态
@@ -2668,7 +2671,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 					shipItemsList.add(shipItems);
 					shipItemsList.add(shipItems);
 				}
 				}
 				item.setNumberRows(list.size());
 				item.setNumberRows(list.size());
-				item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO,BigDecimal::add));
+				item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO, BigDecimal::add));
 			}
 			}
 
 
 			//修改入库任务状态
 			//修改入库任务状态
@@ -2885,7 +2888,9 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 					stockDesc.setStoreInventory(item.getSendNum());
 					stockDesc.setStoreInventory(item.getSendNum());
 					stockDesc.setInventoryAmount(item.getSendNum().multiply(item.getPrice()));
 					stockDesc.setInventoryAmount(item.getSendNum().multiply(item.getPrice()));
 					if (stockDesc.getBalanceQuantity().compareTo(new BigDecimal("0")) != 0) {
 					if (stockDesc.getBalanceQuantity().compareTo(new BigDecimal("0")) != 0) {
-						stockDesc.setInventoryCostPrice(stockDesc.getInventoryAmount().divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
+						BigDecimal amount = ObjectUtils.isNotNull(orderItems.getCostprie()) ? orderItems.getCostprie() : stockDesc.getInventoryAmount();
+//						stockDesc.setInventoryCostPrice(stockDesc.getInventoryAmount().divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
+						stockDesc.setInventoryCostPrice(amount.divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
 					} else {
 					} else {
 						stockDesc.setInventoryCostPrice(item.getPrice());
 						stockDesc.setInventoryCostPrice(item.getPrice());
 					}
 					}
@@ -2899,7 +2904,9 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 					stockDesc.setInventoryAmount(item.getCostprie());
 					stockDesc.setInventoryAmount(item.getCostprie());
 					stockDesc.setInventoryAmount(stockDesc.getInventoryAmount().add(stockOne.getInventoryAmount()));
 					stockDesc.setInventoryAmount(stockDesc.getInventoryAmount().add(stockOne.getInventoryAmount()));
 					if (stockDesc.getBalanceQuantity().compareTo(new BigDecimal("0")) != 0) {
 					if (stockDesc.getBalanceQuantity().compareTo(new BigDecimal("0")) != 0) {
-						stockDesc.setInventoryCostPrice(stockDesc.getInventoryAmount().divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
+						BigDecimal amount = ObjectUtils.isNotNull(orderItems.getCostprie()) ? orderItems.getCostprie() : stockDesc.getInventoryAmount();
+//						stockDesc.setInventoryCostPrice(stockDesc.getInventoryAmount().divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
+						stockDesc.setInventoryCostPrice(amount.divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
 					}
 					}
 					stockDesc.setVersion(stockOne.getVersion());
 					stockDesc.setVersion(stockOne.getVersion());
 					pjStockDescArrayListUpdate.add(stockDesc);
 					pjStockDescArrayListUpdate.add(stockDesc);
@@ -3074,7 +3081,13 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 					if (new BigDecimal("0.00").compareTo(stockOne.getInventoryAmount()) == 0 && new BigDecimal("0.00").compareTo(stockOne.getBalanceQuantity()) == 0) {
 					if (new BigDecimal("0.00").compareTo(stockOne.getInventoryAmount()) == 0 && new BigDecimal("0.00").compareTo(stockOne.getBalanceQuantity()) == 0) {
 						stockOne.setInventoryCostPrice(new BigDecimal("0.00"));
 						stockOne.setInventoryCostPrice(new BigDecimal("0.00"));
 					} else {
 					} else {
-						stockOne.setInventoryCostPrice(stockOne.getInventoryAmount().divide(stockOne.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
+						PjOrderItems orderItems = pjOrderItems.stream().filter(e -> e.getId().equals(item.getSrcItemId())).findFirst().orElse(null);
+						if (orderItems != null) {
+							BigDecimal amount = ObjectUtils.isNotNull(orderItems.getCostprie()) ? orderItems.getCostprie() : stockOne.getInventoryAmount();
+							stockOne.setInventoryCostPrice(amount.divide(stockOne.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
+						} else {
+							throw new RuntimeException("数据异常请联系管理员");
+						}
 					}
 					}
 					stockOne.setVersion(stockOne.getVersion());
 					stockOne.setVersion(stockOne.getVersion());
 					/*R res = iStockDescService.updateByIdNew(stockOne);
 					/*R res = iStockDescService.updateByIdNew(stockOne);

+ 5 - 1
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/statistics/controller/StatisticsController.java

@@ -113,7 +113,11 @@ public class StatisticsController {
 	@GetMapping("/saleDetailExport")
 	@GetMapping("/saleDetailExport")
 	public void saleDetailExport(SaleDetail saleDetailDto, HttpServletResponse response) {
 	public void saleDetailExport(SaleDetail saleDetailDto, HttpServletResponse response) {
 		List<SaleDetailDto> saleDetailDtoList = statisticsService.saleDetailExport(saleDetailDto);
 		List<SaleDetailDto> saleDetailDtoList = statisticsService.saleDetailExport(saleDetailDto);
-		ExcelUtil.export(response, "统计销售明细", "统计销售明细", saleDetailDtoList, SaleDetailDto.class);
+		if ("XS,TKXS".equals(saleDetailDto.getBsType())){
+			ExcelUtil.export(response, "统计销售明细", "统计销售明细", saleDetailDtoList, SaleDetailDto.class);
+		}else{
+			ExcelUtil.export(response, "统计采购明细", "统计采购明细", saleDetailDtoList, SaleDetailDto.class);
+		}
 	}
 	}
 
 
 }
 }