联查合同接口开发;
This commit is contained in:
+369
-17
@@ -663,7 +663,8 @@ public class BillingStatementApplicationService {
|
||||
}
|
||||
Long settlementCustomersId = settlementCustomers.getSettlementCustomersId();
|
||||
SettlementCustomersParameters settlementCustomersParameters = settlementCustomersParametersMapper.selectOne(new LambdaQueryWrapper<SettlementCustomersParameters>()
|
||||
.eq(SettlementCustomersParameters::getSettlementEntityId, settlementCustomersId));
|
||||
.eq(SettlementCustomersParameters::getSettlementEntityId, settlementCustomersId)
|
||||
.eq(SettlementCustomersParameters::getParametersName, "干仓计费配置"));
|
||||
if (ObjectUtil.isNull(settlementCustomersParameters)) {
|
||||
//结算对象未配置参数
|
||||
return;
|
||||
@@ -683,16 +684,42 @@ public class BillingStatementApplicationService {
|
||||
}
|
||||
|
||||
if (!isMerge) {
|
||||
List<BusinessDocument> list = businessDocumentService.list(new LambdaQueryWrapper<BusinessDocument>()
|
||||
.eq(BusinessDocument::getIsPush, 1)
|
||||
.eq(BusinessDocument::getSettlementCustomersId, settlementCustomersId)
|
||||
.eq(BusinessDocument::getBusinessState, 3)
|
||||
.eq(BusinessDocument::getDelFlag, 1));
|
||||
Map<String, List<BusinessDocument>> groupedMap = list.stream()
|
||||
.collect(Collectors.groupingBy(BusinessDocument::getOriginalBusinessNum));
|
||||
for (Map.Entry<String, List<BusinessDocument>> entry : groupedMap.entrySet()) {
|
||||
List<BusinessDocument> groupList = entry.getValue();
|
||||
String originalBusinessNum = entry.getKey();
|
||||
//按入仓单和收费事项分开计费
|
||||
if ("warehouse_receipt".equals(zfycl) && "fee_item".equals(fjfykpcl)) {
|
||||
calcReceiptAndItemSeparately(settlementCustomersId);
|
||||
}
|
||||
//按合同和收费事项分开计费
|
||||
else if ("project_monthly".equals(zfycl) && "fee_item".equals(fjfykpcl)) {
|
||||
calcContractAndItemSeparately(settlementCustomersId);
|
||||
}
|
||||
} else {
|
||||
//按入仓单和收费事项合并计费
|
||||
if ("warehouse_receipt".equals(zfycl) && "fee_item".equals(fjfykpcl)) {
|
||||
mergeCalcByReceiptAndItem(settlementCustomersId);
|
||||
}
|
||||
//按合同和收费事项合并计费
|
||||
else if ("project_monthly".equals(zfycl) && "fee_item".equals(fjfykpcl)) {
|
||||
mergeCalcByContractAndItem(settlementCustomersId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 按入仓单和收费事项分开计费
|
||||
* */
|
||||
public void calcReceiptAndItemSeparately(Long settlementCustomersId) {
|
||||
List<BusinessDocument> list = businessDocumentService.list(new LambdaQueryWrapper<BusinessDocument>()
|
||||
.eq(BusinessDocument::getBelongModuleCode, "干仓")
|
||||
.eq(BusinessDocument::getSettlementCustomersId, settlementCustomersId)
|
||||
.eq(BusinessDocument::getBusinessState, 3)
|
||||
.eq(BusinessDocument::getDelFlag, 1));
|
||||
Map<String, List<BusinessDocument>> groupedMap = list.stream()
|
||||
.collect(Collectors.groupingBy(BusinessDocument::getFirstSubjectCode));
|
||||
for (Map.Entry<String, List<BusinessDocument>> entry : groupedMap.entrySet()) {
|
||||
List<BusinessDocument> groupList = entry.getValue();
|
||||
String firstSubject = entry.getKey();
|
||||
if ("0D01".equals(firstSubject)) {
|
||||
//主费用
|
||||
for (BusinessDocument businessDocument : groupList) {
|
||||
String businessFlow = businessDocument.getBusinessFlow();
|
||||
List<BillingStatement> billingStatements = billingStatementService.list(new LambdaQueryWrapper<BillingStatement>()
|
||||
@@ -704,21 +731,19 @@ public class BillingStatementApplicationService {
|
||||
List<String> billingStatementIdList = new ArrayList<>();
|
||||
BigDecimal allAmount = BigDecimal.ZERO;
|
||||
BigDecimal allFreeFee = BigDecimal.ZERO;
|
||||
String settlementCurrency = "MOP";
|
||||
String settlementCurrency = "CNY";
|
||||
for (BillingStatement billingStatement : billingStatements) {
|
||||
settlementCurrency = billingStatement.getSettlementCurrency();
|
||||
String firstSubjectCode = billingStatement.getFirstSubjectCode();
|
||||
String firstSubjectName = billingStatement.getFirstSubjectName();
|
||||
Long organizationId = billingStatement.getOrganizationId();
|
||||
Map<String, Object> taxRateMap = billingStatementMapper.getTaxRate(organizationId, firstSubjectCode, firstSubjectName);
|
||||
//未找到费用科目
|
||||
if (taxRateMap == null) continue;
|
||||
Double taxRate = (Double) taxRateMap.get("taxRate");
|
||||
Long billingStatementId = billingStatement.getBillingStatementId();
|
||||
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
|
||||
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
|
||||
billingStatementDTO.setAuditOperation(1);
|
||||
//审核通过
|
||||
reviewBilling(billingStatementDTO);
|
||||
|
||||
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
|
||||
@@ -747,13 +772,340 @@ public class BillingStatementApplicationService {
|
||||
billingStatementDTO1.setTaxFreeFee(allFreeFee);
|
||||
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
|
||||
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
|
||||
//生成账单
|
||||
generateBills(billingStatementDTO1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
//附加费用
|
||||
List<String> businessFlowList = groupList.stream().map(BusinessDocument::getBusinessFlow).collect(Collectors.toList());
|
||||
List<BillingStatement> billingStatementList = billingStatementService.list(new LambdaQueryWrapper<BillingStatement>()
|
||||
.in(BillingStatement::getBusinessFlow, businessFlowList)
|
||||
.eq(BillingStatement::getBillingState, 1)
|
||||
.eq(BillingStatement::getDelFlag, 1));
|
||||
if (billingStatementList != null && billingStatementList.size() > 0) {
|
||||
List<BillingStatementADDVO> billingStatementADDVOS = new ArrayList<>();
|
||||
List<String> billingStatementIdList = new ArrayList<>();
|
||||
BigDecimal allAmount = BigDecimal.ZERO;
|
||||
BigDecimal allFreeFee = BigDecimal.ZERO;
|
||||
String settlementCurrency = "CNY";
|
||||
for (BillingStatement billingStatement : billingStatementList) {
|
||||
settlementCurrency = billingStatement.getSettlementCurrency();
|
||||
String firstSubjectCode = billingStatement.getFirstSubjectCode();
|
||||
String firstSubjectName = billingStatement.getFirstSubjectName();
|
||||
Long organizationId = billingStatement.getOrganizationId();
|
||||
Map<String, Object> taxRateMap = billingStatementMapper.getTaxRate(organizationId, firstSubjectCode, firstSubjectName);
|
||||
if (taxRateMap == null) continue;
|
||||
Double taxRate = (Double) taxRateMap.get("taxRate");
|
||||
Long billingStatementId = billingStatement.getBillingStatementId();
|
||||
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
|
||||
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
|
||||
billingStatementDTO.setAuditOperation(1);
|
||||
reviewBilling(billingStatementDTO);
|
||||
|
||||
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
|
||||
BigDecimal amount = billingStatementDTO.getBillingAmount();
|
||||
BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))), 10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal taxFreeFee = amount.subtract(taxAmount);
|
||||
allAmount.add(amount);
|
||||
allFreeFee.add(taxFreeFee);
|
||||
billingStatementADDVO.setBillingStatementId(String.valueOf(billingStatementId));
|
||||
billingStatementADDVO.setTaxRate(taxRate);
|
||||
billingStatementADDVO.setTaxAmount(taxAmount);
|
||||
billingStatementADDVO.setTaxFreeFee(taxFreeFee);
|
||||
billingStatementADDVO.setFeeType(billingStatement.getServiceItemsName());
|
||||
billingStatementADDVO.setInvoiceItem(billingStatement.getFirstSubjectCode());
|
||||
billingStatementADDVO.setInvoiceItemName(billingStatement.getFirstSubjectName());
|
||||
billingStatementADDVOS.add(billingStatementADDVO);
|
||||
|
||||
billingStatementIdList.add(String.valueOf(billingStatementId));
|
||||
}
|
||||
String ids = String.join(",", billingStatementIdList);
|
||||
BillingStatementDTO billingStatementDTO1 = new BillingStatementDTO();
|
||||
billingStatementDTO1.setBillingStatementIds(ids);
|
||||
billingStatementDTO1.setBelongModuleCode("wms");
|
||||
billingStatementDTO1.setTaxAmount(allAmount);
|
||||
billingStatementDTO1.setBillingAmount(allAmount);
|
||||
billingStatementDTO1.setTaxFreeFee(allFreeFee);
|
||||
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
|
||||
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
|
||||
generateBills(billingStatementDTO1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 按入仓单和收费事项合并计费
|
||||
* */
|
||||
public void mergeCalcByReceiptAndItem(Long settlementCustomersId) {
|
||||
List<BusinessDocument> list = businessDocumentService.list(new LambdaQueryWrapper<BusinessDocument>()
|
||||
.eq(BusinessDocument::getBelongModuleCode, "干仓")
|
||||
.eq(BusinessDocument::getSettlementCustomersId, settlementCustomersId)
|
||||
.eq(BusinessDocument::getBusinessState, 3)
|
||||
.eq(BusinessDocument::getDelFlag, 1));
|
||||
Map<String, List<BusinessDocument>> groupedMap = list.stream()
|
||||
.collect(Collectors.groupingBy(BusinessDocument::getOriginalBusinessNum));
|
||||
for (Map.Entry<String, List<BusinessDocument>> entry : groupedMap.entrySet()) {
|
||||
List<BusinessDocument> groupList = entry.getValue();
|
||||
String originalBusinessNum = entry.getKey();
|
||||
List<String> businessFlowList = groupList.stream().map(BusinessDocument::getBusinessFlow).collect(Collectors.toList());
|
||||
List<BillingStatement> billingStatementList = billingStatementService.list(new LambdaQueryWrapper<BillingStatement>()
|
||||
.in(BillingStatement::getBusinessFlow, businessFlowList)
|
||||
.eq(BillingStatement::getBillingState, 1)
|
||||
.eq(BillingStatement::getDelFlag, 1));
|
||||
if (billingStatementList != null && billingStatementList.size() > 0) {
|
||||
List<BillingStatementADDVO> billingStatementADDVOS = new ArrayList<>();
|
||||
List<String> billingStatementIdList = new ArrayList<>();
|
||||
BigDecimal allAmount = BigDecimal.ZERO;
|
||||
BigDecimal allFreeFee = BigDecimal.ZERO;
|
||||
String settlementCurrency = "CNY";
|
||||
for (BillingStatement billingStatement : billingStatementList) {
|
||||
settlementCurrency = billingStatement.getSettlementCurrency();
|
||||
String firstSubjectCode = billingStatement.getFirstSubjectCode();
|
||||
String firstSubjectName = billingStatement.getFirstSubjectName();
|
||||
Long organizationId = billingStatement.getOrganizationId();
|
||||
Map<String, Object> taxRateMap = billingStatementMapper.getTaxRate(organizationId, firstSubjectCode, firstSubjectName);
|
||||
if (taxRateMap == null) continue;
|
||||
Double taxRate = (Double) taxRateMap.get("taxRate");
|
||||
Long billingStatementId = billingStatement.getBillingStatementId();
|
||||
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
|
||||
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
|
||||
billingStatementDTO.setAuditOperation(1);
|
||||
reviewBilling(billingStatementDTO);
|
||||
|
||||
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
|
||||
BigDecimal amount = billingStatementDTO.getBillingAmount();
|
||||
BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))), 10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal taxFreeFee = amount.subtract(taxAmount);
|
||||
allAmount.add(amount);
|
||||
allFreeFee.add(taxFreeFee);
|
||||
billingStatementADDVO.setBillingStatementId(String.valueOf(billingStatementId));
|
||||
billingStatementADDVO.setTaxRate(taxRate);
|
||||
billingStatementADDVO.setTaxAmount(taxAmount);
|
||||
billingStatementADDVO.setTaxFreeFee(taxFreeFee);
|
||||
billingStatementADDVO.setFeeType(billingStatement.getServiceItemsName());
|
||||
billingStatementADDVO.setInvoiceItem(billingStatement.getFirstSubjectCode());
|
||||
billingStatementADDVO.setInvoiceItemName(billingStatement.getFirstSubjectName());
|
||||
billingStatementADDVOS.add(billingStatementADDVO);
|
||||
|
||||
billingStatementIdList.add(String.valueOf(billingStatementId));
|
||||
}
|
||||
String ids = String.join(",", billingStatementIdList);
|
||||
BillingStatementDTO billingStatementDTO1 = new BillingStatementDTO();
|
||||
billingStatementDTO1.setBillingStatementIds(ids);
|
||||
billingStatementDTO1.setBelongModuleCode("wms");
|
||||
billingStatementDTO1.setTaxAmount(allAmount);
|
||||
billingStatementDTO1.setBillingAmount(allAmount);
|
||||
billingStatementDTO1.setTaxFreeFee(allFreeFee);
|
||||
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
|
||||
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
|
||||
generateBills(billingStatementDTO1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 按合同和收费事项分开计费
|
||||
* */
|
||||
public void calcContractAndItemSeparately(Long settlementCustomersId) {
|
||||
List<BusinessDocument> list = businessDocumentService.list(new LambdaQueryWrapper<BusinessDocument>()
|
||||
.eq(BusinessDocument::getBelongModuleCode, "干仓")
|
||||
.eq(BusinessDocument::getSettlementCustomersId, settlementCustomersId)
|
||||
.eq(BusinessDocument::getBusinessState, 3)
|
||||
.eq(BusinessDocument::getDelFlag, 1));
|
||||
Map<String, List<BusinessDocument>> groupedMap = list.stream()
|
||||
.collect(Collectors.groupingBy(BusinessDocument::getFirstSubjectCode));
|
||||
for (Map.Entry<String, List<BusinessDocument>> entry : groupedMap.entrySet()) {
|
||||
List<BusinessDocument> groupList = entry.getValue();
|
||||
String firstSubject = entry.getKey();
|
||||
if ("0D01".equals(firstSubject)) {
|
||||
//主费用
|
||||
List<String> businessFlowList = groupList.stream().map(BusinessDocument::getBusinessFlow).collect(Collectors.toList());
|
||||
List<BillingStatement> billingStatementList = billingStatementService.list(new LambdaQueryWrapper<BillingStatement>()
|
||||
.in(BillingStatement::getBusinessFlow, businessFlowList)
|
||||
.eq(BillingStatement::getBillingState, 1)
|
||||
.eq(BillingStatement::getDelFlag, 1));
|
||||
if (billingStatementList != null && billingStatementList.size() > 0) {
|
||||
Map<Long, List<BillingStatement>> contractManageIdMap = billingStatementList.stream()
|
||||
.collect(Collectors.groupingBy(BillingStatement::getContractManageId));
|
||||
for (Map.Entry<Long, List<BillingStatement>> contractManageIdEntry : contractManageIdMap.entrySet()) {
|
||||
Long contractManageId = contractManageIdEntry.getKey();
|
||||
List<BillingStatement> billingContractStatementList = contractManageIdEntry.getValue();
|
||||
|
||||
List<BillingStatementADDVO> billingStatementADDVOS = new ArrayList<>();
|
||||
BillingStatementDTO billingStatementDTO1 = new BillingStatementDTO();
|
||||
List<String> billingStatementIdList = new ArrayList<>();
|
||||
BigDecimal allAmount = BigDecimal.ZERO;
|
||||
BigDecimal allFreeFee = BigDecimal.ZERO;
|
||||
String settlementCurrency = "CNY";
|
||||
for (BillingStatement billingStatement : billingContractStatementList) {
|
||||
settlementCurrency = billingStatement.getSettlementCurrency();
|
||||
String firstSubjectCode = billingStatement.getFirstSubjectCode();
|
||||
String firstSubjectName = billingStatement.getFirstSubjectName();
|
||||
Long organizationId = billingStatement.getOrganizationId();
|
||||
Map<String, Object> taxRateMap = billingStatementMapper.getTaxRate(organizationId, firstSubjectCode, firstSubjectName);
|
||||
if (taxRateMap == null) continue;
|
||||
Double taxRate = (Double) taxRateMap.get("taxRate");
|
||||
Long billingStatementId = billingStatement.getBillingStatementId();
|
||||
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
|
||||
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
|
||||
billingStatementDTO.setAuditOperation(1);
|
||||
reviewBilling(billingStatementDTO);
|
||||
|
||||
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
|
||||
BigDecimal amount = billingStatementDTO.getBillingAmount();
|
||||
BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))), 10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal taxFreeFee = amount.subtract(taxAmount);
|
||||
allAmount.add(amount);
|
||||
allFreeFee.add(taxFreeFee);
|
||||
billingStatementADDVO.setBillingStatementId(String.valueOf(billingStatementId));
|
||||
billingStatementADDVO.setTaxRate(taxRate);
|
||||
billingStatementADDVO.setTaxAmount(taxAmount);
|
||||
billingStatementADDVO.setTaxFreeFee(taxFreeFee);
|
||||
billingStatementADDVO.setFeeType(billingStatement.getServiceItemsName());
|
||||
billingStatementADDVO.setInvoiceItem(billingStatement.getFirstSubjectCode());
|
||||
billingStatementADDVO.setInvoiceItemName(billingStatement.getFirstSubjectName());
|
||||
billingStatementADDVOS.add(billingStatementADDVO);
|
||||
|
||||
billingStatementIdList.add(String.valueOf(billingStatementId));
|
||||
}
|
||||
String ids = String.join(",", billingStatementIdList);
|
||||
billingStatementDTO1.setBillingStatementIds(ids);
|
||||
billingStatementDTO1.setBelongModuleCode("wms");
|
||||
billingStatementDTO1.setTaxAmount(allAmount);
|
||||
billingStatementDTO1.setBillingAmount(allAmount);
|
||||
billingStatementDTO1.setTaxFreeFee(allFreeFee);
|
||||
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
|
||||
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
|
||||
generateBills(billingStatementDTO1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//附加费用
|
||||
List<String> businessFlowList = groupList.stream().map(BusinessDocument::getBusinessFlow).collect(Collectors.toList());
|
||||
List<BillingStatement> billingStatementList = billingStatementService.list(new LambdaQueryWrapper<BillingStatement>()
|
||||
.in(BillingStatement::getBusinessFlow, businessFlowList)
|
||||
.eq(BillingStatement::getBillingState, 1)
|
||||
.eq(BillingStatement::getDelFlag, 1));
|
||||
if (billingStatementList != null && billingStatementList.size() > 0) {
|
||||
List<BillingStatementADDVO> billingStatementADDVOS = new ArrayList<>();
|
||||
List<String> billingStatementIdList = new ArrayList<>();
|
||||
BigDecimal allAmount = BigDecimal.ZERO;
|
||||
BigDecimal allFreeFee = BigDecimal.ZERO;
|
||||
String settlementCurrency = "CNY";
|
||||
for (BillingStatement billingStatement : billingStatementList) {
|
||||
settlementCurrency = billingStatement.getSettlementCurrency();
|
||||
String firstSubjectCode = billingStatement.getFirstSubjectCode();
|
||||
String firstSubjectName = billingStatement.getFirstSubjectName();
|
||||
Long organizationId = billingStatement.getOrganizationId();
|
||||
Map<String, Object> taxRateMap = billingStatementMapper.getTaxRate(organizationId, firstSubjectCode, firstSubjectName);
|
||||
if (taxRateMap == null) continue;
|
||||
Double taxRate = (Double) taxRateMap.get("taxRate");
|
||||
Long billingStatementId = billingStatement.getBillingStatementId();
|
||||
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
|
||||
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
|
||||
billingStatementDTO.setAuditOperation(1);
|
||||
reviewBilling(billingStatementDTO);
|
||||
|
||||
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
|
||||
BigDecimal amount = billingStatementDTO.getBillingAmount();
|
||||
BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))), 10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal taxFreeFee = amount.subtract(taxAmount);
|
||||
allAmount.add(amount);
|
||||
allFreeFee.add(taxFreeFee);
|
||||
billingStatementADDVO.setBillingStatementId(String.valueOf(billingStatementId));
|
||||
billingStatementADDVO.setTaxRate(taxRate);
|
||||
billingStatementADDVO.setTaxAmount(taxAmount);
|
||||
billingStatementADDVO.setTaxFreeFee(taxFreeFee);
|
||||
billingStatementADDVO.setFeeType(billingStatement.getServiceItemsName());
|
||||
billingStatementADDVO.setInvoiceItem(billingStatement.getFirstSubjectCode());
|
||||
billingStatementADDVO.setInvoiceItemName(billingStatement.getFirstSubjectName());
|
||||
billingStatementADDVOS.add(billingStatementADDVO);
|
||||
|
||||
billingStatementIdList.add(String.valueOf(billingStatementId));
|
||||
}
|
||||
String ids = String.join(",", billingStatementIdList);
|
||||
BillingStatementDTO billingStatementDTO1 = new BillingStatementDTO();
|
||||
billingStatementDTO1.setBillingStatementIds(ids);
|
||||
billingStatementDTO1.setBelongModuleCode("wms");
|
||||
billingStatementDTO1.setTaxAmount(allAmount);
|
||||
billingStatementDTO1.setBillingAmount(allAmount);
|
||||
billingStatementDTO1.setTaxFreeFee(allFreeFee);
|
||||
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
|
||||
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
|
||||
generateBills(billingStatementDTO1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 按合同和收费事项合并计费
|
||||
* */
|
||||
public void mergeCalcByContractAndItem(Long settlementCustomersId) {
|
||||
List<BusinessDocument> list = businessDocumentService.list(new LambdaQueryWrapper<BusinessDocument>()
|
||||
.eq(BusinessDocument::getBelongModuleCode, "干仓")
|
||||
.eq(BusinessDocument::getSettlementCustomersId, settlementCustomersId)
|
||||
.eq(BusinessDocument::getBusinessState, 3)
|
||||
.eq(BusinessDocument::getDelFlag, 1));
|
||||
Map<Long, List<BusinessDocument>> groupedMap = list.stream()
|
||||
.collect(Collectors.groupingBy(BusinessDocument::getContractManageId));
|
||||
for (Map.Entry<Long, List<BusinessDocument>> entry : groupedMap.entrySet()) {
|
||||
List<BusinessDocument> groupList = entry.getValue();
|
||||
Long contractManageId = entry.getKey();
|
||||
List<String> businessFlowList = groupList.stream().map(BusinessDocument::getBusinessFlow).collect(Collectors.toList());
|
||||
List<BillingStatement> billingStatementList = billingStatementService.list(new LambdaQueryWrapper<BillingStatement>()
|
||||
.in(BillingStatement::getBusinessFlow, businessFlowList)
|
||||
.eq(BillingStatement::getBillingState, 1)
|
||||
.eq(BillingStatement::getDelFlag, 1));
|
||||
if (billingStatementList != null && billingStatementList.size() > 0) {
|
||||
List<BillingStatementADDVO> billingStatementADDVOS = new ArrayList<>();
|
||||
List<String> billingStatementIdList = new ArrayList<>();
|
||||
BigDecimal allAmount = BigDecimal.ZERO;
|
||||
BigDecimal allFreeFee = BigDecimal.ZERO;
|
||||
String settlementCurrency = "CNY";
|
||||
for (BillingStatement billingStatement : billingStatementList) {
|
||||
settlementCurrency = billingStatement.getSettlementCurrency();
|
||||
String firstSubjectCode = billingStatement.getFirstSubjectCode();
|
||||
String firstSubjectName = billingStatement.getFirstSubjectName();
|
||||
Long organizationId = billingStatement.getOrganizationId();
|
||||
Map<String, Object> taxRateMap = billingStatementMapper.getTaxRate(organizationId, firstSubjectCode, firstSubjectName);
|
||||
if (taxRateMap == null) continue;
|
||||
Double taxRate = (Double) taxRateMap.get("taxRate");
|
||||
Long billingStatementId = billingStatement.getBillingStatementId();
|
||||
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
|
||||
billingStatementDTO.setBillingStatementIds(String.valueOf(billingStatementId));
|
||||
billingStatementDTO.setAuditOperation(1);
|
||||
reviewBilling(billingStatementDTO);
|
||||
|
||||
BillingStatementADDVO billingStatementADDVO = new BillingStatementADDVO();
|
||||
BigDecimal amount = billingStatementDTO.getBillingAmount();
|
||||
BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))), 10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal taxFreeFee = amount.subtract(taxAmount);
|
||||
allAmount.add(amount);
|
||||
allFreeFee.add(taxFreeFee);
|
||||
billingStatementADDVO.setBillingStatementId(String.valueOf(billingStatementId));
|
||||
billingStatementADDVO.setTaxRate(taxRate);
|
||||
billingStatementADDVO.setTaxAmount(taxAmount);
|
||||
billingStatementADDVO.setTaxFreeFee(taxFreeFee);
|
||||
billingStatementADDVO.setFeeType(billingStatement.getServiceItemsName());
|
||||
billingStatementADDVO.setInvoiceItem(billingStatement.getFirstSubjectCode());
|
||||
billingStatementADDVO.setInvoiceItemName(billingStatement.getFirstSubjectName());
|
||||
billingStatementADDVOS.add(billingStatementADDVO);
|
||||
|
||||
billingStatementIdList.add(String.valueOf(billingStatementId));
|
||||
}
|
||||
String ids = String.join(",", billingStatementIdList);
|
||||
BillingStatementDTO billingStatementDTO1 = new BillingStatementDTO();
|
||||
billingStatementDTO1.setBillingStatementIds(ids);
|
||||
billingStatementDTO1.setBelongModuleCode("wms");
|
||||
billingStatementDTO1.setTaxAmount(allAmount);
|
||||
billingStatementDTO1.setBillingAmount(allAmount);
|
||||
billingStatementDTO1.setTaxFreeFee(allFreeFee);
|
||||
billingStatementDTO1.setSettlementCurrency(settlementCurrency);
|
||||
billingStatementDTO1.setBillingStatementList(billingStatementADDVOS);
|
||||
generateBills(billingStatementDTO1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user