|
@@ -76,20 +76,11 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
private PayDetailService payDetailService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ClaimService claimService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private PurchaseDetailService purchaseDetailService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private PurchaseService purchaseService;
|
|
|
|
|
|
@Autowired
|
|
|
private AccountRequestFundsDetailService accountRequestFundsDetailService;
|
|
|
- @Autowired
|
|
|
- private AccountRequestFundsService accountRequestFundsService;
|
|
|
- @Autowired
|
|
|
- private AccountPaymentService accountPaymentService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Page<ProfitSettlementVo> getProfitSettlement(ProfitSettlementDto dto) {
|
|
@@ -109,19 +100,10 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
});
|
|
|
// 获取默认税率
|
|
|
Map<String, BigDecimal> defaultRateMap = new HashMap<>();
|
|
|
-
|
|
|
- // 获取税率明细
|
|
|
- Map<Long, Map<String, BigDecimal>> detailsRateMap = getDetailsRateMap(records, defaultRateMap);
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
//赋值合同到账金额、退税金额、采购金额
|
|
|
setContractArrivalAndRefundMoney(list);
|
|
|
-
|
|
|
-// // 赋值采购合同金额和支付货款
|
|
|
-// setPurchaseAmountAndPayForGoods(list, detailsRateMap);
|
|
|
-
|
|
|
// 计算
|
|
|
calculation(list);
|
|
|
-
|
|
|
// 转page
|
|
|
return toPage(contractPage, list);
|
|
|
}
|
|
@@ -218,63 +200,9 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
* 赋值合同到账金额、退税金额、采购金额
|
|
|
*/
|
|
|
private void setContractArrivalAndRefundMoney(List<ProfitSettlementVo> list) {
|
|
|
+ List<CurrencyRate> currencyRateList = currencyRateService.list();
|
|
|
|
|
|
-// // 合同id
|
|
|
-// List<Long> contractIdList = list.stream().map(ProfitSettlementVo::getContractId).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// // 根据合同id获取到账认领明细列表
|
|
|
-// List<ClaimContract> claimContractList = claimContractService.list(q ->
|
|
|
-// q.in(ClaimContract::getContractId, contractIdList));
|
|
|
-//
|
|
|
-// if (claimContractList.size() == 0) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 到账认领明细id列表
|
|
|
-// List<Long> claimIdList = claimContractList.stream()
|
|
|
-// .map(ClaimContract::getClaimId).distinct().collect(Collectors.toList());
|
|
|
-//
|
|
|
-// // 到账认领列表
|
|
|
-// List<Claim> claimList = claimService.listByIds(claimIdList);
|
|
|
-//
|
|
|
-// // 到账认领id 币种 map
|
|
|
-// Map<Long, String> claimIdCurrencyMap = claimList.stream()
|
|
|
-// .collect(Collectors.toMap(BaseIdPo::getId, Claim::getCurrency));
|
|
|
-//
|
|
|
-// // 合同id 到账认领明细列表 map
|
|
|
-// Map<Long, List<ClaimContract>> contractIdClaimContractListMap =
|
|
|
-// claimContractList.stream().collect(Collectors.groupingBy(ClaimContract::getContractId));
|
|
|
-//
|
|
|
-// for (ProfitSettlementVo profitSettlementVo : list) {
|
|
|
-//
|
|
|
-// // 合同id
|
|
|
-// Long contractId = profitSettlementVo.getContractId();
|
|
|
-//
|
|
|
-// // 到账认领
|
|
|
-// List<ClaimContract> itemClaimContractList = contractIdClaimContractListMap.getOrDefault(contractId, new ArrayList<>());
|
|
|
-//
|
|
|
-// // 汇率币种map
|
|
|
-// Map<String, BigDecimal> map = detailsRateMap.get(contractId);
|
|
|
-//
|
|
|
-// BigDecimal contractArrival = itemClaimContractList.stream().map(claimContract -> {
|
|
|
-//
|
|
|
-// // 根据到账认领id获取币种
|
|
|
-// String currency = claimIdCurrencyMap.get(claimContract.getClaimId());
|
|
|
-//
|
|
|
-// // 根据币种获取汇率
|
|
|
-// BigDecimal rate = map.getOrDefault(currency, BigDecimal.ONE);
|
|
|
-//
|
|
|
-// // 获取认领金额
|
|
|
-// BigDecimal money = claimContract.getMoney();
|
|
|
-//
|
|
|
-// // 返回兑人民币后金额
|
|
|
-// return rate.multiply(money);
|
|
|
-//
|
|
|
-// }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
-//
|
|
|
-// profitSettlementVo.setContractArrival(contractArrival);
|
|
|
-//
|
|
|
-// }
|
|
|
+ List<String> currencyList = new ArrayList<>();
|
|
|
// 合同id
|
|
|
List<Long> contractIdList = list.stream().map(ProfitSettlementVo::getContractId).collect(Collectors.toList());
|
|
|
//通过合同ID查询到账认领合同的数据
|
|
@@ -290,6 +218,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
Map<Long, List<Purchase>> purchaseMap = purchaseList.stream().collect(Collectors.groupingBy(Purchase::getDataResourceId));
|
|
|
|
|
|
for (ProfitSettlementVo p : list) {
|
|
|
+ currencyList.add(p.getCurrency());
|
|
|
if (StringUtil.isNotEmpty(p.getCurrencyRateJson())) {//取设置的汇率
|
|
|
List<CurrencyRate> assignCurrencyRatesList = JSON.parseArray(p.getCurrencyRateJson(), CurrencyRate.class);
|
|
|
Map<String, BigDecimal> assignCurrencyRatesMap = assignCurrencyRatesList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
|
|
@@ -310,6 +239,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(cList, ClaimContract::getCreateUser, ClaimContract::setUserName);
|
|
|
p.setClaimList(cList);
|
|
|
+ currencyList.addAll(cList.stream().map(ClaimContract::getCurrency).collect(Collectors.toList()));
|
|
|
}
|
|
|
/**
|
|
|
* 处理退税金额
|
|
@@ -328,6 +258,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(rList, TaxRefundDetails::getCreateUser, TaxRefundDetails::setUserName);
|
|
|
p.setTaxReturnList(rList);
|
|
|
+ currencyList.addAll(rList.stream().map(TaxRefundDetails::getCurrency).collect(Collectors.toList()));
|
|
|
}
|
|
|
/**
|
|
|
* 处理采购金额
|
|
@@ -345,6 +276,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setPurchaseAmount(purchaseAmount);
|
|
|
p.setPurchaseList(pList);
|
|
|
+ currencyList.addAll(pList.stream().map(Purchase::getCurrency).collect(Collectors.toList()));
|
|
|
/**
|
|
|
* 处理支付款金额
|
|
|
*/
|
|
@@ -363,6 +295,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(payList, Pay::getCreateUser, Pay::setUserName);
|
|
|
p.setPayList(payList);
|
|
|
+ currencyList.addAll(payList.stream().map(Pay::getCurrency).collect(Collectors.toList()));
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
@@ -382,6 +315,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(accountRequestFundsDetailVos, AccountRequestFundsDetailVo::getCreateUser, AccountRequestFundsDetailVo::setUserName);
|
|
|
p.setAccountRequestFundsDetailList(accountRequestFundsDetailVos);
|
|
|
+ currencyList.addAll(accountRequestFundsDetailVos.stream().map(AccountRequestFundsDetailVo::getCurrency).collect(Collectors.toList()));
|
|
|
}
|
|
|
} else {//取数据汇率
|
|
|
/**
|
|
@@ -405,6 +339,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(cList, ClaimContract::getCreateUser, ClaimContract::setUserName);
|
|
|
p.setClaimList(cList);
|
|
|
+ currencyList.addAll(cList.stream().map(ClaimContract::getCurrency).collect(Collectors.toList()));
|
|
|
}
|
|
|
/**
|
|
|
* 处理退税金额
|
|
@@ -423,6 +358,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(rList, TaxRefundDetails::getCreateUser, TaxRefundDetails::setUserName);
|
|
|
p.setTaxReturnList(rList);
|
|
|
+ currencyList.addAll(rList.stream().map(TaxRefundDetails::getCurrency).collect(Collectors.toList()));
|
|
|
}
|
|
|
/**
|
|
|
* 处理采购金额
|
|
@@ -440,6 +376,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
p.setPurchaseAmount(purchaseAmount);
|
|
|
p.setPurchaseList(pList);
|
|
|
+ currencyList.addAll(pList.stream().map(Purchase::getCurrency).collect(Collectors.toList()));
|
|
|
/**
|
|
|
* 处理支付款金额
|
|
|
*/
|
|
@@ -458,6 +395,7 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(payList, Pay::getCreateUser, Pay::setUserName);
|
|
|
p.setPayList(payList);
|
|
|
+ currencyList.addAll(payList.stream().map(Pay::getCurrency).collect(Collectors.toList()));
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
@@ -477,8 +415,12 @@ public class SaleStatementServiceImpl implements SaleStatementService {
|
|
|
// 赋值业务员名称
|
|
|
UserUtil.assignmentNickName(accountRequestFundsDetailVos, AccountRequestFundsDetailVo::getCreateUser, AccountRequestFundsDetailVo::setUserName);
|
|
|
p.setAccountRequestFundsDetailList(accountRequestFundsDetailVos);
|
|
|
+ currencyList.addAll(accountRequestFundsDetailVos.stream().map(AccountRequestFundsDetailVo::getCurrency).collect(Collectors.toList()));
|
|
|
}
|
|
|
}
|
|
|
+ p.setCurrencyList(currencyRateList.stream()
|
|
|
+ .filter((CurrencyRate c) ->currencyList.contains(c.getType()))
|
|
|
+ .collect(Collectors.toList()));
|
|
|
}
|
|
|
}
|
|
|
|