Browse Source

2024年2月1日14:01:04

纪新园 1 year ago
parent
commit
3ff92b7b7a
13 changed files with 530 additions and 79 deletions
  1. 2 2
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/customsDeclaration/entity/CustomsDeclaration.java
  2. 25 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/FinAccBills.java
  3. 15 3
      blade-service/blade-los/src/main/java/org/springblade/los/business/customsDeclaration/controller/CustomsDeclarationGoodsController.java
  4. 6 0
      blade-service/blade-los/src/main/java/org/springblade/los/business/customsDeclaration/service/ICustomsDeclarationGoodsService.java
  5. 78 3
      blade-service/blade-los/src/main/java/org/springblade/los/business/customsDeclaration/service/impl/CustomsDeclarationGoodsServiceImpl.java
  6. 8 4
      blade-service/blade-los/src/main/java/org/springblade/los/business/customsDeclaration/service/impl/CustomsDeclarationServiceImpl.java
  7. 1 1
      blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/PreContainersServiceImpl.java
  8. 4 0
      blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/controller/FinAccBillsController.java
  9. 340 64
      blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FeeCenterServiceImpl.java
  10. 1 1
      blade-service/blade-pay/src/main/java/org/springblade/pay/tonglianPayment/service/impl/PaymentServiceImpl.java
  11. 8 0
      blade-service/blade-stock/src/main/java/org/springblade/stock/mapper/StockGoodsMapper.java
  12. 40 0
      blade-service/blade-stock/src/main/java/org/springblade/stock/mapper/StockGoodsMapper.xml
  13. 2 1
      blade-service/blade-stock/src/main/java/org/springblade/stock/service/impl/StockGoodsServiceImpl.java

+ 2 - 2
blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/customsDeclaration/entity/CustomsDeclaration.java

@@ -97,9 +97,9 @@ public class CustomsDeclaration implements Serializable {
 	@ApiModelProperty(value = "修改时间")
 	private Date updateTime;
 	/**
-	 * 业务类型, SE=海运报关 SI=海运报关 AE=空运报关 AI=空运报关
+	 * 业务类型, BGSE=海运报关 BGSI=海运报关 BGAE=空运报关 BGAI=空运报关
 	 */
-	@ApiModelProperty(value = "业务类型, SE=海运报关 SI=海运报关 AE=空运报关 AI=空运报关")
+	@ApiModelProperty(value = "业务类型, BGSE=海运报关 BGSI=海运报关 BGAE=空运报关 BGAI=空运报关")
 	private String businessType;
 	/**
 	 * 进出口, E=出口 I=进口

+ 25 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/FinAccBills.java

@@ -698,11 +698,36 @@ public class FinAccBills implements Serializable {
 	@ApiModelProperty(value = "入库日期")
 	private Date warehousingDate;
 
+
+	/**
+	 * 入库日期
+	 */
+	@TableField(exist = false)
+	private Date warehousingDateStart;
+
+	/**
+	 * 入库日期
+	 */
+	@TableField(exist = false)
+	private Date warehousingDateEnd;
+
 	/**
 	 * 出库日期
 	 */
 	@ApiModelProperty(value = "出库日期")
 	private Date outboundDate;
 
+	/**
+	 * 出库日期
+	 */
+	@TableField(exist = false)
+	private Date outboundDateStart;
+
+	/**
+	 * 出库日期
+	 */
+	@TableField(exist = false)
+	private Date outboundDateEnd;
+
 
 }

+ 15 - 3
blade-service/blade-los/src/main/java/org/springblade/los/business/customsDeclaration/controller/CustomsDeclarationGoodsController.java

@@ -34,6 +34,8 @@ import org.springblade.los.business.customsDeclaration.vo.CustomsDeclarationGood
 import org.springblade.los.business.customsDeclaration.service.ICustomsDeclarationGoodsService;
 import org.springblade.core.boot.ctrl.BladeController;
 
+import java.util.List;
+
 /**
  * 业务-报关货物明细 控制器
  *
@@ -108,10 +110,20 @@ public class CustomsDeclarationGoodsController extends BladeController {
 	@ApiOperationSupport(order = 6)
 	@ApiOperation(value = "新增或修改", notes = "传入customsDeclarationGoods")
 	public R submit(@Valid @RequestBody CustomsDeclarationGoods customsDeclarationGoods) {
-		return R.status(customsDeclarationGoodsService.saveOrUpdate(customsDeclarationGoods));
+		return customsDeclarationGoodsService.submit(customsDeclarationGoods);
 	}
 
-	
+	/**
+	 * 新增或修改 业务-报关货物明细List
+	 */
+	@PostMapping("/submitList")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入customsDeclarationGoods")
+	public R submitList(@Valid @RequestBody List<CustomsDeclarationGoods> customsDeclarationGoods) {
+		return customsDeclarationGoodsService.submitList(customsDeclarationGoods);
+	}
+
+
 	/**
 	 * 删除 业务-报关货物明细
 	 */
@@ -122,5 +134,5 @@ public class CustomsDeclarationGoodsController extends BladeController {
 		return R.status(customsDeclarationGoodsService.removeByIds(Func.toLongList(ids)));
 	}
 
-	
+
 }

+ 6 - 0
blade-service/blade-los/src/main/java/org/springblade/los/business/customsDeclaration/service/ICustomsDeclarationGoodsService.java

@@ -16,11 +16,14 @@
  */
 package org.springblade.los.business.customsDeclaration.service;
 
+import org.springblade.core.tool.api.R;
 import org.springblade.los.business.customsDeclaration.entity.CustomsDeclarationGoods;
 import org.springblade.los.business.customsDeclaration.vo.CustomsDeclarationGoodsVO;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import java.util.List;
+
 /**
  * 业务-报关货物明细 服务类
  *
@@ -38,4 +41,7 @@ public interface ICustomsDeclarationGoodsService extends IService<CustomsDeclara
 	 */
 	IPage<CustomsDeclarationGoodsVO> selectCustomsDeclarationGoodsPage(IPage<CustomsDeclarationGoodsVO> page, CustomsDeclarationGoodsVO customsDeclarationGoods);
 
+    R submit(CustomsDeclarationGoods customsDeclarationGoods);
+
+	R submitList(List<CustomsDeclarationGoods> customsDeclarationGoods);
 }

+ 78 - 3
blade-service/blade-los/src/main/java/org/springblade/los/business/customsDeclaration/service/impl/CustomsDeclarationGoodsServiceImpl.java

@@ -16,13 +16,22 @@
  */
 package org.springblade.los.business.customsDeclaration.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.AllArgsConstructor;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.los.Util.IDeptUtils;
 import org.springblade.los.business.customsDeclaration.entity.CustomsDeclarationGoods;
-import org.springblade.los.business.customsDeclaration.vo.CustomsDeclarationGoodsVO;
 import org.springblade.los.business.customsDeclaration.mapper.CustomsDeclarationGoodsMapper;
 import org.springblade.los.business.customsDeclaration.service.ICustomsDeclarationGoodsService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.los.business.customsDeclaration.vo.CustomsDeclarationGoodsVO;
+import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.util.Date;
+import java.util.List;
 
 /**
  * 业务-报关货物明细 服务实现类
@@ -31,11 +40,77 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
  * @since 2024-01-31
  */
 @Service
+@AllArgsConstructor
 public class CustomsDeclarationGoodsServiceImpl extends ServiceImpl<CustomsDeclarationGoodsMapper, CustomsDeclarationGoods> implements ICustomsDeclarationGoodsService {
 
+
+	private final ISysClient sysClient;
+
+	private final IDeptUtils deptUtils;
+
 	@Override
 	public IPage<CustomsDeclarationGoodsVO> selectCustomsDeclarationGoodsPage(IPage<CustomsDeclarationGoodsVO> page, CustomsDeclarationGoodsVO customsDeclarationGoods) {
 		return page.setRecords(baseMapper.selectCustomsDeclarationGoodsPage(page, customsDeclarationGoods));
 	}
 
+	@Override
+	public R submit(CustomsDeclarationGoods customsDeclarationGoods) {
+		String deptId = "";
+		String deptName = "";
+		//获取部门ids对应中文名
+		if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+			deptId = AuthUtil.getDeptId();
+			R<List<String>> res = sysClient.getDeptNames(AuthUtil.getDeptId());
+			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+				deptName = String.join(",", res.getData());
+			}
+		}
+		if (customsDeclarationGoods.getId() == null) {
+			customsDeclarationGoods.setCreateTime(new Date());
+			customsDeclarationGoods.setCreateUser(AuthUtil.getUserId());
+			customsDeclarationGoods.setCreateUserName(AuthUtil.getUserName());
+			if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+				customsDeclarationGoods.setCreateDept(deptId);
+				customsDeclarationGoods.setCreateDeptName(deptName);
+			}
+		} else {
+			customsDeclarationGoods.setUpdateUser(AuthUtil.getUserId());
+			customsDeclarationGoods.setUpdateTime(new Date());
+			customsDeclarationGoods.setUpdateUserName(AuthUtil.getUserName());
+		}
+		this.saveOrUpdate(customsDeclarationGoods);
+		return R.data(customsDeclarationGoods);
+	}
+
+	@Override
+	public R submitList(List<CustomsDeclarationGoods> list) {
+		String deptId = "";
+		String deptName = "";
+		//获取部门ids对应中文名
+		if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+			deptId = AuthUtil.getDeptId();
+			R<List<String>> res = sysClient.getDeptNames(AuthUtil.getDeptId());
+			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+				deptName = String.join(",", res.getData());
+			}
+		}
+		for (CustomsDeclarationGoods customsDeclarationGoods : list) {
+			if (customsDeclarationGoods.getId() == null) {
+				customsDeclarationGoods.setCreateTime(new Date());
+				customsDeclarationGoods.setCreateUser(AuthUtil.getUserId());
+				customsDeclarationGoods.setCreateUserName(AuthUtil.getUserName());
+				if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+					customsDeclarationGoods.setCreateDept(deptId);
+					customsDeclarationGoods.setCreateDeptName(deptName);
+				}
+			} else {
+				customsDeclarationGoods.setUpdateUser(AuthUtil.getUserId());
+				customsDeclarationGoods.setUpdateTime(new Date());
+				customsDeclarationGoods.setUpdateUserName(AuthUtil.getUserName());
+			}
+		}
+		this.saveOrUpdateBatch(list);
+		return R.data(list);
+	}
+
 }

+ 8 - 4
blade-service/blade-los/src/main/java/org/springblade/los/business/customsDeclaration/service/impl/CustomsDeclarationServiceImpl.java

@@ -31,7 +31,6 @@ import org.springblade.los.basic.business.service.IBusinessTypeService;
 import org.springblade.los.basic.cur.service.IBCurrencyService;
 import org.springblade.los.billno.entity.BusinessBillNo;
 import org.springblade.los.billno.service.IBusinessBillNoService;
-import org.springblade.los.business.aea.entity.AeaBills;
 import org.springblade.los.business.customsDeclaration.entity.CustomsDeclaration;
 import org.springblade.los.business.customsDeclaration.entity.CustomsDeclarationGoods;
 import org.springblade.los.business.customsDeclaration.mapper.CustomsDeclarationMapper;
@@ -55,10 +54,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -191,6 +188,13 @@ public class CustomsDeclarationServiceImpl extends ServiceImpl<CustomsDeclaratio
 			customsDeclaration.setUpdateUserName(AuthUtil.getUserName());
 		}
 		this.saveOrUpdate(customsDeclaration);
+		//报关货物明细
+		if (ObjectUtils.isNotNull(customsDeclaration.getCustomsDeclarationGoodsList())) {
+			for (CustomsDeclarationGoods item : customsDeclaration.getCustomsDeclarationGoodsList()) {
+				item.setPid(customsDeclaration.getId());
+			}
+			customsDeclarationGoodsService.submitList(customsDeclaration.getCustomsDeclarationGoodsList());
+		}
 		/**-------------费用计算---------*/
 		BigDecimal amountDr = new BigDecimal("0.00");
 		BigDecimal amountCr = new BigDecimal("0.00");
@@ -378,7 +382,7 @@ public class CustomsDeclarationServiceImpl extends ServiceImpl<CustomsDeclaratio
 		customsDeclaration.setStatus(3);
 		customsDeclaration.setBillStatus(2);
 		baseMapper.updateById(customsDeclaration);
-		List<FeeCenter> feeCenterList  = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
+		List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
 			.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
 			.eq(FeeCenter::getIsDeleted, 0)
 			.eq(FeeCenter::getAccStatus, 0)

+ 1 - 1
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/PreContainersServiceImpl.java

@@ -219,7 +219,7 @@ public class PreContainersServiceImpl extends ServiceImpl<PreContainersMapper, P
 			bills.setUpdateUser(AuthUtil.getUserId());
 			bills.setUpdateTime(new Date());
 			bills.setUpdateUserName(AuthUtil.getUserName());
-			bills.setTeu(bills.getPreContainersList().stream().map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add).intValue());
+			bills.setTeu(preContainersList.stream().map(PreContainers::getTeu).reduce(BigDecimal.ZERO, BigDecimal::add).intValue());
 			billsMapper.updateById(bills);
 		}
 		List<Containers> containersList = new ArrayList<>();

+ 4 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/controller/FinAccBillsController.java

@@ -128,6 +128,10 @@ public class FinAccBillsController extends BladeController {
 		lambdaQueryWrapper.le(ObjectUtils.isNotNull(finAccBills.getVoucherDateEnd()), FinAccBills::getVoucherDate, finAccBills.getVoucherDateEnd());
 		lambdaQueryWrapper.ge(ObjectUtils.isNotNull(finAccBills.getApprovedDateStart()), FinAccBills::getApprovedDate, finAccBills.getApprovedDateStart());
 		lambdaQueryWrapper.le(ObjectUtils.isNotNull(finAccBills.getApprovedDateEnd()), FinAccBills::getApprovedDate, finAccBills.getApprovedDateEnd());
+		lambdaQueryWrapper.le(ObjectUtils.isNotNull(finAccBills.getWarehousingDateStart()), FinAccBills::getWarehousingDate, finAccBills.getWarehousingDateStart());
+		lambdaQueryWrapper.le(ObjectUtils.isNotNull(finAccBills.getWarehousingDateEnd()), FinAccBills::getWarehousingDate, finAccBills.getWarehousingDateEnd());
+		lambdaQueryWrapper.le(ObjectUtils.isNotNull(finAccBills.getOutboundDateStart()), FinAccBills::getOutboundDate, finAccBills.getOutboundDateStart());
+		lambdaQueryWrapper.le(ObjectUtils.isNotNull(finAccBills.getOutboundDateEnd()), FinAccBills::getOutboundDate, finAccBills.getOutboundDateEnd());
 		lambdaQueryWrapper.orderByDesc(FinAccBills::getCreateTime);
 		IPage<FinAccBills> pages = finAccBillsService.page(Condition.getPage(query), lambdaQueryWrapper);
 		/*String accBillNo = "";

+ 340 - 64
blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FeeCenterServiceImpl.java

@@ -35,6 +35,8 @@ import org.springblade.los.business.aea.entity.AeaBills;
 import org.springblade.los.business.aea.mapper.AeaBillsMapper;
 import org.springblade.los.business.amends.entity.Amends;
 import org.springblade.los.business.amends.mapper.AmendsMapper;
+import org.springblade.los.business.customsDeclaration.entity.CustomsDeclaration;
+import org.springblade.los.business.customsDeclaration.mapper.CustomsDeclarationMapper;
 import org.springblade.los.business.sea.entity.Bills;
 import org.springblade.los.business.sea.entity.PreContainers;
 import org.springblade.los.business.sea.mapper.BillsMapper;
@@ -43,7 +45,6 @@ import org.springblade.los.finance.fee.entity.FeeCenter;
 import org.springblade.los.finance.fee.mapper.FeeCenterMapper;
 import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.los.finance.fee.vo.FeeCenterVO;
-import org.springblade.system.entity.Dept;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -73,6 +74,8 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 
 	private final AeaBillsMapper aeaBillsMapper;
 
+	private final CustomsDeclarationMapper customsDeclarationMapper;
+
 	private final AmendsMapper amendsMapper;
 
 	private final IBCurrencyService bCurrencyService;
@@ -90,7 +93,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 	public R submit(FeeCenter feeCenter) {
 		String deptId = "";
 		String deptName = "";
-		String branchId = deptUtils.getDeptPid()+"";
+		String branchId = deptUtils.getDeptPid() + "";
 		//获取部门ids对应中文名
 		if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
 			deptId = AuthUtil.getDeptId();
@@ -175,7 +178,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
 	public R<List<FeeCenter>> templateImport(LosBFeesTemplate losBFeesTemplate) {
 		List<FeeCenter> list = new ArrayList<>();
-		if ("HYCK".equals(losBFeesTemplate.getType()) || "HYJK".equals(losBFeesTemplate.getType())){
+		if ("HYCK".equals(losBFeesTemplate.getType()) || "HYJK".equals(losBFeesTemplate.getType())) {
 			Bills bills = billsMapper.selectById(losBFeesTemplate.getBillNoId());
 			if (bills == null) {
 				throw new RuntimeException("未找到主表信息");
@@ -351,7 +354,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				}
 			}
 			this.saveOrUpdateBatch(list);
-		}else if ("KYCK".equals(losBFeesTemplate.getType()) || "KYJK".equals(losBFeesTemplate.getType())){
+		} else if ("KYCK".equals(losBFeesTemplate.getType()) || "KYJK".equals(losBFeesTemplate.getType())) {
 			AeaBills bills = aeaBillsMapper.selectById(losBFeesTemplate.getBillNoId());
 			if (bills == null) {
 				throw new RuntimeException("未找到主表信息");
@@ -406,7 +409,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 							}
 						}
 					}
-					 if ("2".equals(items.getQuantityRule())) {
+					if ("2".equals(items.getQuantityRule())) {
 						if ("JOB".equals(items.getUnitNo())) {
 							feeCenter.setQuantity(new BigDecimal("1"));
 							feeCenter.setAmount(items.getPrice().multiply(new BigDecimal("1")));
@@ -420,7 +423,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 						} else {
 							continue;
 						}
-					}else if ("5".equals(items.getQuantityRule())) {
+					} else if ("5".equals(items.getQuantityRule())) {
 						if ("CBM".equals(items.getUnitNo())) {
 							feeCenter.setQuantity(bills.getMeasurement());
 							feeCenter.setAmount(items.getPrice().multiply(bills.getMeasurement()));
@@ -444,7 +447,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 	public R submitList(List<FeeCenter> list) {
 		String deptId = "";
 		String deptName = "";
-		String branchId = deptUtils.getDeptPid()+"";
+		String branchId = deptUtils.getDeptPid() + "";
 		//获取部门ids对应中文名
 		if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
 			deptId = AuthUtil.getDeptId();
@@ -454,68 +457,341 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 			}
 		}
 		List<FeeCenter> feeCenterList = new ArrayList<>();
-		for (FeeCenter feeCenter : list) {
-			if (feeCenter.getId() == null) {
-				feeCenter.setCreateTime(new Date());
-				feeCenter.setCreateUser(AuthUtil.getUserId());
-				feeCenter.setCreateUserName(AuthUtil.getUserName());
-				if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
-					feeCenter.setCreateDept(deptId);
-					feeCenter.setBranchId(branchId);
-					feeCenter.setCreateDeptName(deptName);
+		if (ObjectUtils.isNotNull(list) && list.size() > 0) {
+			for (FeeCenter feeCenter : list) {
+				if (feeCenter.getId() == null) {
+					feeCenter.setCreateTime(new Date());
+					feeCenter.setCreateUser(AuthUtil.getUserId());
+					feeCenter.setCreateUserName(AuthUtil.getUserName());
+					if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+						feeCenter.setCreateDept(deptId);
+						feeCenter.setBranchId(branchId);
+						feeCenter.setCreateDeptName(deptName);
+					}
+				} else {
+					feeCenter.setUpdateUser(AuthUtil.getUserId());
+					feeCenter.setUpdateTime(new Date());
+					feeCenter.setUpdateUserName(AuthUtil.getUserName());
 				}
-			} else {
-				feeCenter.setUpdateUser(AuthUtil.getUserId());
-				feeCenter.setUpdateTime(new Date());
-				feeCenter.setUpdateUserName(AuthUtil.getUserName());
+
+				/** --------------------金额计算-------------------------**/
+				// 去税金额 = 数量quantity * 单价price
+				BigDecimal amountNet = new BigDecimal("0.00");
+				// 税额 = 去税金额amountNet * 税率taxRateSum
+				BigDecimal amountTax = new BigDecimal("0.00");
+				// 金额,amountTax + 去税金额amountNet - 折扣金额amountDiscount
+				BigDecimal amount = new BigDecimal("0.00");
+				//总税率  = 税率taxRate + 附加税率surchargeRate
+				BigDecimal taxRate = new BigDecimal("0.00");
+				// 税率 = 总税率/100
+				BigDecimal taxRateSum = new BigDecimal("0.00");
+
+				//计算字段null值处理
+				feeCenter.setQuantity(ObjectUtils.isNotNull(feeCenter.getQuantity()) ? feeCenter.getQuantity() : new BigDecimal("0.00"));
+				feeCenter.setPrice(ObjectUtils.isNotNull(feeCenter.getPrice()) ? feeCenter.getPrice() : new BigDecimal("0.00"));
+				feeCenter.setSurchargeRate(ObjectUtils.isNotNull(feeCenter.getSurchargeRate()) ? feeCenter.getSurchargeRate() : new BigDecimal("0.00"));
+				feeCenter.setTaxRate(ObjectUtils.isNotNull(feeCenter.getTaxRate()) ? feeCenter.getTaxRate() : new BigDecimal("0.00"));
+				feeCenter.setAmountDiscount(ObjectUtils.isNotNull(feeCenter.getAmountDiscount()) ? feeCenter.getAmountDiscount() : new BigDecimal("0.00"));
+				feeCenter.setStlTtlAmount(ObjectUtils.isNotNull(feeCenter.getStlTtlAmount()) ? feeCenter.getStlTtlAmount() : new BigDecimal("0.00"));
+
+				amountNet = amountNet.add(feeCenter.getQuantity().multiply(feeCenter.getPrice()))
+					.setScale(2, RoundingMode.HALF_UP);
+				taxRate = taxRate.add(feeCenter.getTaxRate()).add(feeCenter.getSurchargeRate());
+				taxRateSum = taxRateSum.add(taxRate.divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP));
+				amountTax = amountTax.add(amountNet.multiply(taxRateSum)).setScale(2, RoundingMode.HALF_UP);
+				amount = amount.add(amountNet.add(amountTax).subtract(feeCenter.getAmountDiscount()));
+
+				//判断是否是本位币
+				if ("CNY".equals(feeCenter.getCurCode())) {
+					feeCenter.setAmountNetLoc(amountNet);
+					feeCenter.setAmountTaxLoc(amountTax);
+					feeCenter.setAmountLoc(amount);
+					feeCenter.setAmountDiscountLoc(amount);
+				} else {
+					feeCenter.setAmountNetLoc(bCurrencyService.converterCny(feeCenter.getCurCode(), amountNet, ""));
+					feeCenter.setAmountTaxLoc(bCurrencyService.converterCny(feeCenter.getCurCode(), amountTax, ""));
+					feeCenter.setAmountLoc(bCurrencyService.converterCny(feeCenter.getCurCode(), amount, ""));
+					feeCenter.setAmountDiscountLoc(bCurrencyService.converterCny(feeCenter.getCurCode(), amount, ""));
+				}
+				feeCenter.setAmountNet(amountNet);
+				feeCenter.setAmountTax(amountTax);
+				feeCenter.setAmount(amount);
+				feeCenter.setUnsettledAmount(feeCenter.getAmount().subtract(feeCenter.getStlTtlAmount()));
+				feeCenterList.add(feeCenter);
 			}
+			this.saveOrUpdateBatch(feeCenterList);
+
+			BigDecimal amountDr = new BigDecimal("0.00");
+			BigDecimal amountCr = new BigDecimal("0.00");
+			BigDecimal amountProfit = new BigDecimal("0.00");
+			BigDecimal amountDrUsd = new BigDecimal("0.00");
+			BigDecimal amountCrUsd = new BigDecimal("0.00");
+			BigDecimal amountProfitUsd = new BigDecimal("0.00");
+			BigDecimal amountDrLoc = new BigDecimal("0.00");
+			BigDecimal amountCrLoc = new BigDecimal("0.00");
+			BigDecimal amountProfitLoc = new BigDecimal("0.00");
+			amountDr = list.stream().filter(e -> "D".equals(e.getDc()) && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+			amountDrUsd = list.stream().filter(e -> "D".equals(e.getDc()) && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+			amountCr = list.stream().filter(e -> "C".equals(e.getDc()) && "CNY".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+			amountCrUsd = list.stream().filter(e -> "C".equals(e.getDc()) && "USD".equals(e.getCurCode())).map(FeeCenter::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+			if ("SE".equals(list.get(0).getBusinessType()) || "SI".equals(list.get(0).getBusinessType())) {
+				Bills bills = billsMapper.selectById(list.get(0).getPid());
+				//主单应加上分单费用
+				if ("MM".equals(bills.getBillType())) {
+					List<Bills> details = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
+						.eq(Bills::getTenantId, AuthUtil.getTenantId())
+						.eq(Bills::getIsDeleted, 0)
+						.eq(Bills::getMasterId, bills.getId()));
+					if (details.size() > 0) {
+						amountDr = amountDr.add(details.stream().map(Bills::getAmountDr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountCr = amountCr.add(details.stream().map(Bills::getAmountCr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountDrUsd = amountDrUsd.add(details.stream().map(Bills::getAmountDrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountCrUsd = amountCrUsd.add(details.stream().map(Bills::getAmountCrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountDrLoc = amountDrLoc.add(details.stream().map(Bills::getAmountDrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountCrLoc = amountCrLoc.add(details.stream().map(Bills::getAmountCrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+
+					}
+				} else if ("MH".equals(bills.getBillType())) {
+					Bills details = billsMapper.selectById(bills.getMasterId());
+					//重新计算主单合计
+					if (details != null) {
+						BigDecimal amountDrM = new BigDecimal("0.00");
+						BigDecimal amountCrM = new BigDecimal("0.00");
+						BigDecimal amountProfitM = new BigDecimal("0.00");
+						BigDecimal amountDrUsdM = new BigDecimal("0.00");
+						BigDecimal amountCrUsdM = new BigDecimal("0.00");
+						BigDecimal amountProfitUsdM = new BigDecimal("0.00");
+						BigDecimal amountDrLocM = new BigDecimal("0.00");
+						BigDecimal amountCrLocM = new BigDecimal("0.00");
+						BigDecimal amountProfitLocM = new BigDecimal("0.00");
+						BigDecimal quantityM = new BigDecimal("0.00");
+						BigDecimal grossWeightM = new BigDecimal("0.00");
+						BigDecimal measurementM = new BigDecimal("0.00");
+						List<FeeCenter> feeCenters = baseMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
+							.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
+							.eq(FeeCenter::getIsDeleted, 0)
+							.eq(FeeCenter::getPid, details.getId()));
+						for (FeeCenter item : feeCenters) {
+							if ("C".equals(item.getDc())) {
+								if ("USD".equals(item.getCurCode())) {
+									amountCrUsdM = amountCrUsdM.add(item.getAmount());
+								} else if ("CNY".equals(item.getCurCode())) {
+									amountCrM = amountCrM.add(item.getAmount());
+								} else {
+									BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
+									amountCrUsdM = amountCrUsdM.add(usd);
+								}
+							} else {
+								if ("USD".equals(item.getCurCode())) {
+									amountDrUsdM = amountDrUsdM.add(item.getAmount());
+								} else if ("CNY".equals(item.getCurCode())) {
+									amountDrM = amountDrM.add(item.getAmount());
+								} else {
+									BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
+									amountDrUsdM = amountDrUsdM.add(usd);
+								}
+							}
+						}
+						List<Bills> billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
+							.eq(Bills::getTenantId, AuthUtil.getTenantId())
+							.eq(Bills::getIsDeleted, 0)
+							.eq(Bills::getMasterId, details.getId()));
+						List<Bills> billsLists = billsList.stream().filter(e -> !e.getId().equals(bills.getId())).collect(Collectors.toList());
+						if (billsLists.size() > 0) {
+							amountDrM = amountDrM.add(billsLists.stream().map(Bills::getAmountDr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountCrM = amountCrM.add(billsLists.stream().map(Bills::getAmountCr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountDrUsdM = amountDrUsdM.add(billsLists.stream().map(Bills::getAmountDrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountCrUsdM = amountCrUsdM.add(billsLists.stream().map(Bills::getAmountCrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountDrLocM = amountDrLocM.add(billsLists.stream().map(Bills::getAmountDrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountCrLocM = amountCrLocM.add(billsLists.stream().map(Bills::getAmountCrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							quantityM = quantityM.add(billsLists.stream().map(Bills::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							grossWeightM = grossWeightM.add(billsLists.stream().map(Bills::getGrossWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							measurementM = measurementM.add(billsLists.stream().map(Bills::getMeasurement).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						}
+						amountDrM = amountDrM.add(amountDr);
+						amountCrM = amountCrM.add(amountCr);
+						amountDrUsdM = amountDrUsdM.add(amountDrUsd);
+						amountCrUsdM = amountCrUsdM.add(amountCrUsd);
+						amountDrLocM = amountDrLocM.add(amountDrLoc);
+						amountCrLocM = amountCrLocM.add(amountCrLoc);
+						//利润 = 收 - 付
+						amountProfitM = amountDrM.subtract(amountCrM);
+						amountProfitUsdM = amountDrUsdM.subtract(amountCrUsdM);
+						amountDrLocM = amountDrLocM.add(bCurrencyService.converterCny("USD", amountDrUsdM, "D")).add(amountDrM);
+						amountCrLocM = amountCrLocM.add(bCurrencyService.converterCny("USD", amountCrUsdM, "C")).add(amountCrM);
+						amountProfitLocM = amountDrLocM.subtract(amountCrLocM);
+						details.setAmountDr(amountDrM);
+						details.setAmountCr(amountCrM);
+						details.setAmountProfit(amountProfitM);
+						details.setAmountDrUsd(amountDrUsdM);
+						details.setAmountCrUsd(amountCrUsdM);
+						details.setAmountProfitUsd(amountProfitUsdM);
+						details.setAmountDrLoc(amountDrLocM);
+						details.setAmountCrLoc(amountCrLocM);
+						details.setAmountProfitLoc(amountProfitLocM);
+						details.setQuantity(quantityM);
+						details.setGrossWeight(grossWeightM);
+						details.setMeasurement(measurementM);
+						billsMapper.updateById(details);
+					}
+				}
+				//利润 = 收 - 付
+				amountProfit = amountDr.subtract(amountCr);
+				amountProfitUsd = amountDrUsd.subtract(amountCrUsd);
+				amountDrLoc = amountDrLoc.add(bCurrencyService.converterCny("USD", amountDrUsd, "D")).add(amountDr);
+				amountCrLoc = amountCrLoc.add(bCurrencyService.converterCny("USD", amountCrUsd, "C")).add(amountCr);
+				amountProfitLoc = amountDrLoc.subtract(amountCrLoc);
+				bills.setAmountDr(amountDr);
+				bills.setAmountCr(amountCr);
+				bills.setAmountProfit(amountProfit);
+				bills.setAmountDrUsd(amountDrUsd);
+				bills.setAmountCrUsd(amountCrUsd);
+				bills.setAmountProfitUsd(amountProfitUsd);
+				bills.setAmountDrLoc(amountDrLoc);
+				bills.setAmountCrLoc(amountCrLoc);
+				bills.setAmountProfitLoc(amountProfitLoc);
+				billsMapper.updateById(bills);
+			} else if ("AE".equals(list.get(0).getBusinessType()) || "AI".equals(list.get(0).getBusinessType())) {
+				AeaBills aeaBills = aeaBillsMapper.selectById(list.get(0).getPid());
+				//主单应加上分单费用
+				if ("MM".equals(aeaBills.getBillType())) {
+					List<AeaBills> details = aeaBillsMapper.selectList(new LambdaQueryWrapper<AeaBills>()
+						.eq(AeaBills::getTenantId, AuthUtil.getTenantId())
+						.eq(AeaBills::getIsDeleted, 0)
+						.eq(AeaBills::getMasterId, aeaBills.getId()));
+					if (details.size() > 0) {
+						amountDr = amountDr.add(details.stream().map(AeaBills::getAmountDr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountCr = amountCr.add(details.stream().map(AeaBills::getAmountCr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountDrUsd = amountDrUsd.add(details.stream().map(AeaBills::getAmountDrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountCrUsd = amountCrUsd.add(details.stream().map(AeaBills::getAmountCrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountDrLoc = amountDrLoc.add(details.stream().map(AeaBills::getAmountDrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						amountCrLoc = amountCrLoc.add(details.stream().map(AeaBills::getAmountCrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 
-			/** --------------------金额计算-------------------------**/
-			// 去税金额 = 数量quantity * 单价price
-			BigDecimal amountNet = new BigDecimal("0.00");
-			// 税额 = 去税金额amountNet * 税率taxRateSum
-			BigDecimal amountTax = new BigDecimal("0.00");
-			// 金额,amountTax + 去税金额amountNet - 折扣金额amountDiscount
-			BigDecimal amount = new BigDecimal("0.00");
-			//总税率  = 税率taxRate + 附加税率surchargeRate
-			BigDecimal taxRate = new BigDecimal("0.00");
-			// 税率 = 总税率/100
-			BigDecimal taxRateSum = new BigDecimal("0.00");
-
-			//计算字段null值处理
-			feeCenter.setQuantity(ObjectUtils.isNotNull(feeCenter.getQuantity()) ? feeCenter.getQuantity() : new BigDecimal("0.00"));
-			feeCenter.setPrice(ObjectUtils.isNotNull(feeCenter.getPrice()) ? feeCenter.getPrice() : new BigDecimal("0.00"));
-			feeCenter.setSurchargeRate(ObjectUtils.isNotNull(feeCenter.getSurchargeRate()) ? feeCenter.getSurchargeRate() : new BigDecimal("0.00"));
-			feeCenter.setTaxRate(ObjectUtils.isNotNull(feeCenter.getTaxRate()) ? feeCenter.getTaxRate() : new BigDecimal("0.00"));
-			feeCenter.setAmountDiscount(ObjectUtils.isNotNull(feeCenter.getAmountDiscount()) ? feeCenter.getAmountDiscount() : new BigDecimal("0.00"));
-			feeCenter.setStlTtlAmount(ObjectUtils.isNotNull(feeCenter.getStlTtlAmount()) ? feeCenter.getStlTtlAmount() : new BigDecimal("0.00"));
-
-			amountNet = amountNet.add(feeCenter.getQuantity().multiply(feeCenter.getPrice()))
-				.setScale(2, RoundingMode.HALF_UP);
-			taxRate = taxRate.add(feeCenter.getTaxRate()).add(feeCenter.getSurchargeRate());
-			taxRateSum = taxRateSum.add(taxRate.divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP));
-			amountTax = amountTax.add(amountNet.multiply(taxRateSum)).setScale(2, RoundingMode.HALF_UP);
-			amount = amount.add(amountNet.add(amountTax).subtract(feeCenter.getAmountDiscount()));
-
-			//判断是否是本位币
-			if ("CNY".equals(feeCenter.getCurCode())) {
-				feeCenter.setAmountNetLoc(amountNet);
-				feeCenter.setAmountTaxLoc(amountTax);
-				feeCenter.setAmountLoc(amount);
-				feeCenter.setAmountDiscountLoc(amount);
-			} else {
-				feeCenter.setAmountNetLoc(bCurrencyService.converterCny(feeCenter.getCurCode(), amountNet, ""));
-				feeCenter.setAmountTaxLoc(bCurrencyService.converterCny(feeCenter.getCurCode(), amountTax, ""));
-				feeCenter.setAmountLoc(bCurrencyService.converterCny(feeCenter.getCurCode(), amount, ""));
-				feeCenter.setAmountDiscountLoc(bCurrencyService.converterCny(feeCenter.getCurCode(), amount, ""));
+					}
+				} else if ("MH".equals(aeaBills.getBillType())) {
+					AeaBills details = aeaBillsMapper.selectById(aeaBills.getMasterId());
+					//重新计算主单合计
+					if (details != null) {
+						BigDecimal amountDrM = new BigDecimal("0.00");
+						BigDecimal amountCrM = new BigDecimal("0.00");
+						BigDecimal amountProfitM = new BigDecimal("0.00");
+						BigDecimal amountDrUsdM = new BigDecimal("0.00");
+						BigDecimal amountCrUsdM = new BigDecimal("0.00");
+						BigDecimal amountProfitUsdM = new BigDecimal("0.00");
+						BigDecimal amountDrLocM = new BigDecimal("0.00");
+						BigDecimal amountCrLocM = new BigDecimal("0.00");
+						BigDecimal amountProfitLocM = new BigDecimal("0.00");
+						BigDecimal quantityM = new BigDecimal("0.00");
+						BigDecimal grossWeightM = new BigDecimal("0.00");
+						BigDecimal measurementM = new BigDecimal("0.00");
+						List<FeeCenter> feeCenters = baseMapper.selectList(new LambdaQueryWrapper<FeeCenter>()
+							.eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
+							.eq(FeeCenter::getIsDeleted, 0)
+							.eq(FeeCenter::getPid, details.getId()));
+						for (FeeCenter item : feeCenters) {
+							if ("C".equals(item.getDc())) {
+								if ("USD".equals(item.getCurCode())) {
+									amountCrUsdM = amountCrUsdM.add(item.getAmount());
+								} else if ("CNY".equals(item.getCurCode())) {
+									amountCrM = amountCrM.add(item.getAmount());
+								} else {
+									BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
+									amountCrUsdM = amountCrUsdM.add(usd);
+								}
+							} else {
+								if ("USD".equals(item.getCurCode())) {
+									amountDrUsdM = amountDrUsdM.add(item.getAmount());
+								} else if ("CNY".equals(item.getCurCode())) {
+									amountDrM = amountDrM.add(item.getAmount());
+								} else {
+									BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
+									amountDrUsdM = amountDrUsdM.add(usd);
+								}
+							}
+						}
+						List<AeaBills> billsList = aeaBillsMapper.selectList(new LambdaQueryWrapper<AeaBills>()
+							.eq(AeaBills::getTenantId, AuthUtil.getTenantId())
+							.eq(AeaBills::getIsDeleted, 0)
+							.eq(AeaBills::getMasterId, details.getId()));
+						List<AeaBills> billsLists = billsList.stream().filter(e -> !e.getId().equals(aeaBills.getId())).collect(Collectors.toList());
+						if (billsLists.size() > 0) {
+							amountDrM = amountDrM.add(billsLists.stream().map(AeaBills::getAmountDr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountCrM = amountCrM.add(billsLists.stream().map(AeaBills::getAmountCr).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountDrUsdM = amountDrUsdM.add(billsLists.stream().map(AeaBills::getAmountDrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountCrUsdM = amountCrUsdM.add(billsLists.stream().map(AeaBills::getAmountCrUsd).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountDrLocM = amountDrLocM.add(billsLists.stream().map(AeaBills::getAmountDrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							amountCrLocM = amountCrLocM.add(billsLists.stream().map(AeaBills::getAmountCrLoc).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							quantityM = quantityM.add(billsLists.stream().map(AeaBills::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							grossWeightM = grossWeightM.add(billsLists.stream().map(AeaBills::getGrossWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+							measurementM = measurementM.add(billsLists.stream().map(AeaBills::getMeasurement).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+						}
+						amountDrM = amountDrM.add(amountDr);
+						amountCrM = amountCrM.add(amountCr);
+						amountDrUsdM = amountDrUsdM.add(amountDrUsd);
+						amountCrUsdM = amountCrUsdM.add(amountCrUsd);
+						amountDrLocM = amountDrLocM.add(amountDrLoc);
+						amountCrLocM = amountCrLocM.add(amountCrLoc);
+						//利润 = 收 - 付
+						amountProfitM = amountDrM.subtract(amountCrM);
+						amountProfitUsdM = amountDrUsdM.subtract(amountCrUsdM);
+						amountDrLocM = amountDrLocM.add(bCurrencyService.converterCny("USD", amountDrUsdM, "D")).add(amountDrM);
+						amountCrLocM = amountCrLocM.add(bCurrencyService.converterCny("USD", amountCrUsdM, "C")).add(amountCrM);
+						amountProfitLocM = amountDrLocM.subtract(amountCrLocM);
+						details.setAmountDr(amountDrM);
+						details.setAmountCr(amountCrM);
+						details.setAmountProfit(amountProfitM);
+						details.setAmountDrUsd(amountDrUsdM);
+						details.setAmountCrUsd(amountCrUsdM);
+						details.setAmountProfitUsd(amountProfitUsdM);
+						details.setAmountDrLoc(amountDrLocM);
+						details.setAmountCrLoc(amountCrLocM);
+						details.setAmountProfitLoc(amountProfitLocM);
+						details.setQuantity(quantityM);
+						details.setGrossWeight(grossWeightM);
+						details.setMeasurement(measurementM);
+						aeaBillsMapper.updateById(details);
+					}
+				}
+				//利润 = 收 - 付
+				amountProfit = amountDr.subtract(amountCr);
+				amountProfitUsd = amountDrUsd.subtract(amountCrUsd);
+				amountDrLoc = amountDrLoc.add(bCurrencyService.converterCny("USD", amountDrUsd, "D")).add(amountDr);
+				amountCrLoc = amountCrLoc.add(bCurrencyService.converterCny("USD", amountCrUsd, "C")).add(amountCr);
+				amountProfitLoc = amountDrLoc.subtract(amountCrLoc);
+				aeaBills.setAmountDr(amountDr);
+				aeaBills.setAmountCr(amountCr);
+				aeaBills.setAmountProfit(amountProfit);
+				aeaBills.setAmountDrUsd(amountDrUsd);
+				aeaBills.setAmountCrUsd(amountCrUsd);
+				aeaBills.setAmountProfitUsd(amountProfitUsd);
+				aeaBills.setAmountDrLoc(amountDrLoc);
+				aeaBills.setAmountCrLoc(amountCrLoc);
+				aeaBills.setAmountProfitLoc(amountProfitLoc);
+				aeaBillsMapper.updateById(aeaBills);
+			} else if ("BGSE".equals(list.get(0).getBusinessType()) || "BGSI".equals(list.get(0).getBusinessType())
+				|| "BGAE".equals(list.get(0).getBusinessType()) || "BGAI".equals(list.get(0).getBusinessType())) {
+				CustomsDeclaration customsDeclaration = customsDeclarationMapper.selectById(list.get(0).getPid());
+				//利润 = 收 - 付
+				amountProfit = amountDr.subtract(amountCr);
+				amountProfitUsd = amountDrUsd.subtract(amountCrUsd);
+				amountDrLoc = amountDrLoc.add(bCurrencyService.converterCny("USD", amountDrUsd, "D")).add(amountDr);
+				amountCrLoc = amountCrLoc.add(bCurrencyService.converterCny("USD", amountCrUsd, "C")).add(amountCr);
+				amountProfitLoc = amountDrLoc.subtract(amountCrLoc);
+				customsDeclaration.setAmountDr(amountDr);
+				customsDeclaration.setAmountCr(amountCr);
+				customsDeclaration.setAmountProfit(amountProfit);
+				customsDeclaration.setAmountDrUsd(amountDrUsd);
+				customsDeclaration.setAmountCrUsd(amountCrUsd);
+				customsDeclaration.setAmountProfitUsd(amountProfitUsd);
+				customsDeclaration.setAmountDrLoc(amountDrLoc);
+				customsDeclaration.setAmountCrLoc(amountCrLoc);
+				customsDeclaration.setAmountProfitLoc(amountProfitLoc);
+				customsDeclarationMapper.updateById(customsDeclaration);
 			}
-			feeCenter.setAmountNet(amountNet);
-			feeCenter.setAmountTax(amountTax);
-			feeCenter.setAmount(amount);
-			feeCenter.setUnsettledAmount(feeCenter.getAmount().subtract(feeCenter.getStlTtlAmount()));
-			feeCenterList.add(feeCenter);
+		} else {
+			R.fail("请选择明细");
 		}
-		this.saveOrUpdateBatch(feeCenterList);
 		return R.data(feeCenterList);
 	}
 

+ 1 - 1
blade-service/blade-pay/src/main/java/org/springblade/pay/tonglianPayment/service/impl/PaymentServiceImpl.java

@@ -646,7 +646,6 @@ public class PaymentServiceImpl implements IPaymentService {
 						String serialNumber = re.getData().get(0).getSrcOrdNo();
 						BigDecimal amount = new BigDecimal("0.00");
 						for (PjOrder selectOrder : re.getData()) {
-							amount = amount.add(selectOrder.getPaymentAmountTl());
 							selectOrder.setActualPaymentStatus(2);
 							selectOrder.setOldTrxId(AnalysisMapUtils.getString("trxid", params));
 							selectOrder.setPaymentAmountTl(selectOrder.getTotalMoney());
@@ -655,6 +654,7 @@ public class PaymentServiceImpl implements IPaymentService {
 							wechatMark.setBillNo(selectOrder.getOrdNo());
 							wechatMark.setSalesCompanyId(selectOrder.getSalesCompanyId());
 							wechatMark.setSalesCompanyName(selectOrder.getSalesCompanyName());
+							amount = amount.add(selectOrder.getPaymentAmountTl());
 							ipjOrderClient.updateBySrcOrgId(selectOrder.getId() + "");
 							LocalDateTime now = LocalDateTime.now();
 							DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

+ 8 - 0
blade-service/blade-stock/src/main/java/org/springblade/stock/mapper/StockGoodsMapper.java

@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
 import org.springblade.core.tenant.annotation.TenantIgnore;
+import org.springblade.purchase.sales.vo.OrderVO;
 import org.springblade.stock.entity.StockGoods;
 import org.springblade.stock.vo.AppStockPartsVO;
 import org.springblade.stock.vo.AppStockVO;
@@ -69,4 +70,11 @@ public interface StockGoodsMapper extends BaseMapper<StockGoods> {
 	AppStockPartsVO stockPartsDetails(@Param("stock") AppStockPartsVO appStockPartsVO);
 
     List<AppStockPartsVO> selectAppStockPartsList( @Param("stock") AppStockPartsVO appStockPartsVO);
+
+    List<OrderVO> orderInventoryList(@Param("tenantId") String tenantId,
+									 @Param("tradeType") String tradeType,
+									 @Param("billType") String billType,
+									 @Param("itemId") Long itemId,
+									 @Param("corpId") Long corpId,
+									 @Param("storageId") Long storageId);
 }

+ 40 - 0
blade-service/blade-stock/src/main/java/org/springblade/stock/mapper/StockGoodsMapper.xml

@@ -642,6 +642,46 @@
             </if>
         </where>
     </select>
+    <select id="orderInventoryList" resultType="org.springblade.purchase.sales.vo.OrderVO">
+        SELECT
+        bo.id,
+        bo.order_no,
+        bo.busines_date,
+        item.corp_id,
+        sum(item.order_quantity) as orderQuantity
+        FROM
+        business_order bo
+        LEFT JOIN business_order_items item ON bo.id = item.pid
+        WHERE
+        bo.is_deleted = '0'
+        AND bo.`status` != '0'
+        AND item.is_deleted = '0'
+        AND bo.tenant_id = #{tenantId}
+        AND bo.trade_type = #{tradeType}
+        AND bo.bill_type = #{billType}
+        <if test='storageId != null'>
+            and item.storage_id = #{storageId}
+        </if>
+        <if test='itemId != null'>
+            and item.item_id = #{itemId}
+        </if>
+        <if test='corpId != null'>
+            and item.corp_id = #{corpId}
+        </if>
+        <if test='tenantId != null and tenantId != "" and tenantId == "681169"'>
+            and bo.actual_delivery_date is NULL
+            AND bo.order_status NOT IN ('录入')
+        </if>
+        <if test='tenantId != null and tenantId != "" and tenantId == "941197"'>
+            and bo.actual_delivery_date is NULL
+            AND bo.order_status NOT IN ('录入')
+        </if>
+        GROUP BY bo.id,
+        bo.actual_delivery_date,
+        bo.order_no,
+        bo.busines_date,
+        item.corp_id
+    </select>
     <update id="updateStockGoods" parameterType="org.springblade.stock.entity.StockGoods">
         UPDATE business_stock_goods
         SET surplus_route_quantity = #{surplusRouteQuantity},

+ 2 - 1
blade-service/blade-stock/src/main/java/org/springblade/stock/service/impl/StockGoodsServiceImpl.java

@@ -467,7 +467,8 @@ public class StockGoodsServiceImpl extends ServiceImpl<StockGoodsMapper, StockGo
 			.eq(StockGoods::getTenantId, AuthUtil.getTenantId())
 			.eq(StockGoods::getIsDeleted, 0));
 		for (StockGoods stockGoods : list) {
-			List<OrderVO> orderVOList = orderDescClient.orderInventoryList("XS", stockGoods.getGoodsId(), stockGoods.getCorpId(), stockGoods.getStorageId());
+			List<OrderVO> orderVOList = baseMapper.orderInventoryList(AuthUtil.getTenantId(),"GN","XS", stockGoods.getGoodsId(), stockGoods.getCorpId(), stockGoods.getStorageId());
+//				List<OrderVO> orderVOList = orderDescClient.orderInventoryList("XS", stockGoods.getGoodsId(), stockGoods.getCorpId(), stockGoods.getStorageId());
 			if (ObjectUtils.isNull(orderVOList) || orderVOList.size() == 0) {
 				stockGoods.setLockingQuantity(new BigDecimal("0"));
 				stockGoods.setSurplusRouteQuantity(stockGoods.getBalanceQuantity().subtract(stockGoods.getLockingQuantity()));