|
@@ -181,6 +181,16 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Override
|
|
|
public Page<ContractVo> getContractAndSamplePage(ContractSelectDto dto) {
|
|
|
IWrapper<Contract> wrapper = getWrapper();
|
|
|
+ if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
+ //归属公司
|
|
|
+ List<Long> corporationIds = corporationService.listObject(Corporation::getId, q -> q.like(Corporation::getName, dto.getKeyword()));
|
|
|
+ List<Long> customerIds = customerService.listObject(Customer::getId, q -> q.like(Customer::getName, dto.getKeyword()));
|
|
|
+ wrapper.and(q -> q
|
|
|
+ .like("t1", Contract::getCode, dto.getKeyword())
|
|
|
+ .or().in("t1", Contract::getSellCorporationId, corporationIds)
|
|
|
+ .or().in("t1", Contract::getBuyCorporationId, customerIds)
|
|
|
+ );
|
|
|
+ }
|
|
|
Page<ContractVo> contractAndSamplePage = baseMapper.getContractAndSamplePagez(dto.getPage(), wrapper);
|
|
|
List<ContractVo> records = contractAndSamplePage.getRecords();
|
|
|
//赋值原卖方公司名称 多公司
|
|
@@ -350,13 +360,12 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
List<PurchaseDetailVo> otherAmountList = purchaseDetailService.getSumCountInDataResourceIds(contractIds);
|
|
|
Map<Long, String> otherAmountMap = otherAmountList.stream().collect(Collectors.toMap(PurchaseDetailVo::getDataResourceId, PurchaseDetailVo::getSumAmountCurrency));
|
|
|
//取出默认汇率
|
|
|
- List<CurrencyRate> currencyRateList = currencyRateService.getList();
|
|
|
- Map<String, BigDecimal> currencyRateMap = currencyRateList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
|
|
|
+// List<CurrencyRate> currencyRateList = currencyRateService.getList();
|
|
|
+// Map<String, BigDecimal> currencyRateMap = currencyRateList.stream().collect(Collectors.toMap(CurrencyRate::getType, CurrencyRate::getRate));
|
|
|
for (ContractBudgetVo v : list) {
|
|
|
if (StringUtils.isNotEmpty(v.getCurrencyRateJson())) {//如果此条合同有汇率了
|
|
|
List<ContractCurrencyRate> contractCurrencyRates = JSON.parseArray(v.getCurrencyRateJson(), ContractCurrencyRate.class);
|
|
|
Map<String, BigDecimal> map = contractCurrencyRates.stream().collect(Collectors.toMap(ContractCurrencyRate::getType, ContractCurrencyRate::getRate));
|
|
|
- v.setRefundableAmount(BigDecimal.ZERO);//暂时先设置退税金额为0
|
|
|
if (MapUtils.isNotEmpty(ehsdAmountMap)) { //计算EHSD租户应付货款
|
|
|
String concatAmountCurrency = ehsdAmountMap.getOrDefault(v.getContractId(), null);
|
|
|
if (StringUtils.isNotEmpty(concatAmountCurrency)) {
|
|
@@ -380,31 +389,36 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
(v.getOther() == null ? BigDecimal.ZERO : v.getOther().multiply(new BigDecimal(map.getOrDefault(v.getOtherCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
(v.getEhsdSumAmount() == null ? BigDecimal.ZERO : v.getEhsdSumAmount()).add
|
|
|
(v.getOtherSumAmount() == null ? BigDecimal.ZERO : v.getOtherSumAmount()));
|
|
|
- } else {//没有汇率取默认汇率
|
|
|
v.setRefundableAmount(BigDecimal.ZERO);//暂时先设置退税金额为0
|
|
|
+ v.setRmbContractAmount(v.getAmount().multiply(new BigDecimal(map.getOrDefault(v.getCurrency(), BigDecimal.ONE).toString())));
|
|
|
+ } else {//没有汇率取默认汇率
|
|
|
+ BigDecimal rate = v.getRate();
|
|
|
if (MapUtils.isNotEmpty(ehsdAmountMap)) { //计算EHSD租户应付货款
|
|
|
String concatAmountCurrency = ehsdAmountMap.getOrDefault(v.getContractId(), null);
|
|
|
if (StringUtils.isNotEmpty(concatAmountCurrency)) {
|
|
|
BigDecimal amount = new BigDecimal(concatAmountCurrency.split("-")[0]);
|
|
|
- String currency = concatAmountCurrency.split("-")[1];
|
|
|
- BigDecimal rate = currencyRateMap.getOrDefault(currency, BigDecimal.ONE);
|
|
|
+// String currency = concatAmountCurrency.split("-")[1];
|
|
|
+// BigDecimal rate = v.getRate();
|
|
|
v.setEhsdSumAmount(amount.multiply(rate));
|
|
|
} else {
|
|
|
v.setEhsdSumAmount(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
//计算收入总计=合同金额(转人民币)+应退税金额(转人民币)
|
|
|
- v.setIncomeAmount(v.getAmount().multiply(currencyRateMap.getOrDefault(v.getContractId(), new BigDecimal("1"))).add(v.getRefundableAmount()));
|
|
|
+ v.setIncomeAmount(v.getAmount().multiply(rate).add(v.getRefundableAmount()));
|
|
|
//计算支出总计 除合同金额(转人民币)+应退税金额(转人民币) 其他金额相加
|
|
|
- v.setExpenditureAmount(v.getTrailerFee() == null ? BigDecimal.ZERO : v.getTrailerFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getTrailerFeeCurrency(), BigDecimal.ONE).toString())).add
|
|
|
- (v.getCustomsFee() == null ? BigDecimal.ZERO : v.getCustomsFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getCustomsFeeCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
- (v.getAgencyFee() == null ? BigDecimal.ZERO : v.getAgencyFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getAgencyFeeCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
- (v.getPortMixedFee() == null ? BigDecimal.ZERO : v.getPortMixedFee().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getPortMixedFeeCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
- (v.getInspectionRedPack() == null ? BigDecimal.ZERO : v.getInspectionRedPack().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getInspectionRedPackCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
- (v.getCommission() == null ? BigDecimal.ZERO : v.getCommission().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getCommissionCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
- (v.getOther() == null ? BigDecimal.ZERO : v.getOther().multiply(new BigDecimal(currencyRateMap.getOrDefault(v.getOtherCurrency(), BigDecimal.ONE).toString()))).add
|
|
|
+ v.setExpenditureAmount(
|
|
|
+ v.getTrailerFee() == null ? BigDecimal.ZERO : v.getTrailerFee().multiply(rate).add
|
|
|
+ (v.getCustomsFee() == null ? BigDecimal.ZERO : v.getCustomsFee().multiply(rate)).add
|
|
|
+ (v.getAgencyFee() == null ? BigDecimal.ZERO : v.getAgencyFee().multiply(rate)).add
|
|
|
+ (v.getPortMixedFee() == null ? BigDecimal.ZERO : v.getPortMixedFee().multiply(rate)).add
|
|
|
+ (v.getInspectionRedPack() == null ? BigDecimal.ZERO : v.getInspectionRedPack().multiply(rate)).add
|
|
|
+ (v.getCommission() == null ? BigDecimal.ZERO : v.getCommission().multiply(rate)).add
|
|
|
+ (v.getOther() == null ? BigDecimal.ZERO : v.getOther().multiply(rate)).add
|
|
|
(v.getEhsdSumAmount() == null ? BigDecimal.ZERO : v.getEhsdSumAmount()).add
|
|
|
(v.getOtherSumAmount() == null ? BigDecimal.ZERO : v.getOtherSumAmount()));
|
|
|
+ v.setRefundableAmount(BigDecimal.ZERO);//暂时先设置退税金额为0
|
|
|
+ v.setRmbContractAmount(v.getAmount().multiply(rate));
|
|
|
}
|
|
|
//计算毛利 收入-支出
|
|
|
v.setGross(v.getIncomeAmount().subtract(v.getExpenditureAmount()));
|