|
@@ -14,7 +14,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.account.controller.utils.DateUtils;
|
|
|
import com.fjhx.account.entity.account.po.AccountManagement;
|
|
|
+import com.fjhx.account.entity.account.po.AccountRequestFundsDetail;
|
|
|
+import com.fjhx.account.entity.account.vo.AccountRequestFundsDetailVo;
|
|
|
import com.fjhx.account.service.account.AccountManagementService;
|
|
|
+import com.fjhx.account.service.account.AccountRequestFundsDetailService;
|
|
|
import com.fjhx.area.service.SetCustomizeAreaId;
|
|
|
import com.fjhx.area.utils.CustomizeAreaUtil;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
@@ -124,6 +127,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
@Autowired
|
|
|
private ClaimContractService claimContractService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AccountRequestFundsDetailService accountRequestFundsDetailService;
|
|
|
+
|
|
|
/**
|
|
|
* 分页
|
|
|
*
|
|
@@ -189,9 +195,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<ContractBudgetVo> getProfitBudgetPage(ContractSelectDto dto) {
|
|
|
- if(StringUtils.isEmpty(SecurityUtils.getTenantId())){
|
|
|
- throw new ServiceException("租户ID不能为空");
|
|
|
- }
|
|
|
IWrapper<Contract> wrapper = getWrapper();
|
|
|
wrapper.orderByDesc("t1", Contract::getCreateTime);
|
|
|
wrapper.between("t1", Contract::getStatus, FlowStatusEnum.PASS.getKey(), FlowStatusEnum.CANCELLATION.getKey() - 1);
|
|
@@ -291,9 +294,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<ContractBudgetVo> getProfitClearingPage(ContractSelectDto dto) {
|
|
|
- if(StringUtils.isEmpty(SecurityUtils.getTenantId())){
|
|
|
- throw new ServiceException("租户ID不能为空");
|
|
|
- }
|
|
|
IWrapper<Contract> wrapper = getWrapper();
|
|
|
wrapper.orderByDesc("t1", Contract::getCreateTime);
|
|
|
wrapper.between("t1", Contract::getStatus, FlowStatusEnum.PASS.getKey(), FlowStatusEnum.CANCELLATION.getKey() - 1);
|
|
@@ -313,6 +313,8 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
Map<String,BigDecimal> defaultCurrencyRateMap = defaultCurrencyRateList.stream().collect(Collectors.toMap(CurrencyRate::getType,CurrencyRate::getRate));
|
|
|
for(ContractBudgetVo v : list){
|
|
|
v.setRefundableAmount(BigDecimal.ZERO);//暂时先设置退税金额为0
|
|
|
+ v.setOtherIncomeAmount(BigDecimal.ZERO);//暂时先设置其他收入为0
|
|
|
+ v.setAccountPaid(BigDecimal.ZERO);//暂时先设置已付货款为0
|
|
|
// 赋值客户名称
|
|
|
customerService.attributeAssign(list, Contract::getBuyCorporationId, (item, customer) -> {
|
|
|
item.setCustomerName(customer.getName());
|
|
@@ -321,18 +323,41 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
//取出汇率
|
|
|
List<CurrencyRate> assignCurrencyRatesList = JSON.parseArray(v.getCurrencyRateJson(), CurrencyRate.class);
|
|
|
Map<String,BigDecimal> assignCurrencyRatesMap = assignCurrencyRatesList.stream().collect(Collectors.toMap(CurrencyRate::getType,CurrencyRate::getRate));
|
|
|
- v.setEhsdSumAmount(v.getAmount().multiply(assignCurrencyRatesMap.getOrDefault(v.getCurrency(),BigDecimal.ONE)));//计算汇算人民币
|
|
|
+ v.setRmbContractAmount(v.getAmount().multiply(assignCurrencyRatesMap.getOrDefault(v.getCurrency(),BigDecimal.ONE)));//计算汇算人民币
|
|
|
//到账金额
|
|
|
v.setSumClaimMoney(this.getSumClaimMoney(v,assignCurrencyRatesMap));
|
|
|
//采购合同总金额
|
|
|
v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v,assignCurrencyRatesMap));
|
|
|
+ //支出费用
|
|
|
+ this.getGroupTypeMoney(v,assignCurrencyRatesMap);
|
|
|
}else{//没有取默认的汇率
|
|
|
- v.setEhsdSumAmount(v.getAmount().multiply(defaultCurrencyRateMap.getOrDefault(v.getCurrency(),BigDecimal.ONE)));//计算汇算人民币
|
|
|
+ v.setRmbContractAmount(v.getAmount().multiply(defaultCurrencyRateMap.getOrDefault(v.getCurrency(),BigDecimal.ONE)));//计算汇算人民币
|
|
|
//到账金额
|
|
|
v.setSumClaimMoney(this.getSumClaimMoney(v,defaultCurrencyRateMap));
|
|
|
//采购合同总金额
|
|
|
v.setSumPurchaseContractMoney(this.getSumPurchaseContractMoney(v,defaultCurrencyRateMap));
|
|
|
+ //支出费用
|
|
|
+ this.getGroupTypeMoney(v,defaultCurrencyRateMap);
|
|
|
}
|
|
|
+ //计算收入总计=合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币)
|
|
|
+ v.setIncomeAmount(v.getRmbContractAmount()==null?BigDecimal.ZERO:v.getRmbContractAmount().add(v.getRefundableAmount()).add(v.getOtherIncomeAmount()));
|
|
|
+ //计算支出总计 除合同金额(转人民币)+应退税金额(转人民币)+其他收入(转人民币) 其他金额相加
|
|
|
+ v.setExpenditureAmount(v.getTrailerFee().add
|
|
|
+ (v.getCustomsFee()).add
|
|
|
+ (v.getPortMixedFee()).add
|
|
|
+ (v.getInspectionRedPack()).add
|
|
|
+ (v.getCommission()).add
|
|
|
+ (v.getOther()).add
|
|
|
+ (v.getCheckout()).add
|
|
|
+ (v.getInspectionCharge()).add
|
|
|
+ (v.getFreight()).add
|
|
|
+ (v.getCertificateOfOrigin()).add
|
|
|
+ (v.getAccountPaid()).add
|
|
|
+ (v.getProfitAgencyFee()));
|
|
|
+ //计算毛利 收入-支出
|
|
|
+ v.setGross(v.getIncomeAmount().subtract(v.getExpenditureAmount()));
|
|
|
+ //计算毛利率 毛利/收入
|
|
|
+ v.setGrossRate(v.getGross().divide(v.getIncomeAmount(), RoundingMode.CEILING));
|
|
|
|
|
|
}
|
|
|
return page;
|
|
@@ -961,7 +986,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
BigDecimal sumClaimMOney = BigDecimal.ZERO;
|
|
|
if(CollectionUtils.isNotEmpty(claimContractList)){
|
|
|
for(ClaimContract c:claimContractList){
|
|
|
- sumClaimMOney.add(c.getMoney().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ sumClaimMOney = sumClaimMOney.add(c.getMoney().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
}
|
|
|
return sumClaimMOney;
|
|
|
}else{
|
|
@@ -980,7 +1005,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
BigDecimal sumPurchaseContractMoney = BigDecimal.ZERO;
|
|
|
if(CollectionUtils.isNotEmpty(list)){
|
|
|
for(EhsdPurchaseProductVo c:list){
|
|
|
- sumPurchaseContractMoney.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ sumPurchaseContractMoney = sumPurchaseContractMoney.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
}
|
|
|
return sumPurchaseContractMoney;
|
|
|
}else{
|
|
@@ -988,4 +1013,109 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 统计支出各种费用
|
|
|
+ * @param v
|
|
|
+ * @param currencyRatesMap 汇率JSON
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void getGroupTypeMoney(ContractBudgetVo v,Map<String,BigDecimal> currencyRatesMap){
|
|
|
+ List<AccountRequestFundsDetailVo> list = accountRequestFundsDetailService.getListByContractId(v.getContractId());
|
|
|
+ /**
|
|
|
+ * 拖车费
|
|
|
+ */
|
|
|
+ BigDecimal trailerFee = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报关费
|
|
|
+ */
|
|
|
+ BigDecimal customsFee = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 港杂费
|
|
|
+ */
|
|
|
+ BigDecimal portMixedFee = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验货红包
|
|
|
+ */
|
|
|
+ BigDecimal inspectionRedPack = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 佣金
|
|
|
+ */
|
|
|
+ BigDecimal commission = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检验费
|
|
|
+ */
|
|
|
+ BigDecimal checkout = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验货费
|
|
|
+ */
|
|
|
+ BigDecimal inspectionCharge = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 运费
|
|
|
+ */
|
|
|
+ BigDecimal freight = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 产地证费
|
|
|
+ */
|
|
|
+ BigDecimal certificateOfOrigin = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 其他费用
|
|
|
+ */
|
|
|
+ BigDecimal other = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ for(AccountRequestFundsDetailVo c:list){
|
|
|
+ switch (c.getCostType()){
|
|
|
+ case "1"://拖车费
|
|
|
+ trailerFee = trailerFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ case "2"://报关费
|
|
|
+ customsFee = customsFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ case "3"://港杂费
|
|
|
+ portMixedFee = portMixedFee.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ case "4"://验收红包
|
|
|
+ inspectionRedPack = inspectionRedPack.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ case "5"://佣金
|
|
|
+ commission = commission.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ case "6"://检测费
|
|
|
+ checkout = checkout.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ case "7"://验货费
|
|
|
+ inspectionCharge = inspectionCharge.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ case "8"://运费
|
|
|
+ freight = freight.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ case "9"://产地证费
|
|
|
+ certificateOfOrigin = certificateOfOrigin.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ other = other.add(c.getAmount().multiply(currencyRatesMap.getOrDefault(c.getCurrency(),BigDecimal.ONE)));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ v.setTrailerFee(trailerFee);
|
|
|
+ v.setCustomsFee(customsFee);
|
|
|
+ v.setPortMixedFee(portMixedFee);
|
|
|
+ v.setInspectionRedPack(inspectionRedPack);
|
|
|
+ v.setCommission(commission);
|
|
|
+ v.setCheckout(checkout);
|
|
|
+ v.setInspectionCharge(inspectionCharge);
|
|
|
+ v.setFreight(freight);
|
|
|
+ v.setCertificateOfOrigin(certificateOfOrigin);
|
|
|
+ v.setOther(other);
|
|
|
+ }
|
|
|
}
|