| | |
| | | SysConfig sysConfig = sysConfigMapper.selectConfig(new SysConfig() {{ |
| | | setConfigKey("sys.hk.rmb.rate"); |
| | | }}); |
| | | // 计算总应收金额 |
| | | BigDecimal totalReceivableAmount = receivableFeeList.stream() |
| | | .map(ReceivableFeeManagement::getReceivableAmount) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 计算总应收金额(按币种分别计算) |
| | | BigDecimal totalAmountRmb = BigDecimal.ZERO; |
| | | BigDecimal totalAmountHkd = BigDecimal.ZERO; |
| | | |
| | | |
| | | // 获取所有应收费用明细,按币种汇总 |
| | | if (!receivableFeeList.isEmpty()) { |
| | | // 获取所有应收费用ID |
| | | Integer[] feeIds = receivableFeeList.stream() |
| | | .map(ReceivableFeeManagement::getId) |
| | | .toArray(Integer[]::new); |
| | | |
| | | // 查询所有明细记录 |
| | | List<ReceivableFeeDetail> allDetails = receivableFeeDetailService.selectReceivableFeeDetailByReceivableFeeIds(feeIds); |
| | | |
| | | // 按币种汇总金额 |
| | | for (ReceivableFeeDetail detail : allDetails) { |
| | | if (detail.getBillingAmount() != null && detail.getCurrency() != null) { |
| | | if ("RMB".equals(detail.getCurrency())) { |
| | | totalAmountRmb = totalAmountRmb.add(detail.getBillingAmount()); |
| | | } else if ("HKD".equals(detail.getCurrency())) { |
| | | totalAmountHkd = totalAmountHkd.add(detail.getBillingAmount()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | BigDecimal exchangeRate = new BigDecimal(sysConfig.getConfigValue()); |
| | | BigDecimal totalAmountHkd = totalReceivableAmount.divide(exchangeRate, 2, RoundingMode.HALF_UP); |
| | | |
| | | // 计算人民币总金额(人民币金额 + 港币换算成人民币) |
| | | BigDecimal totalAmountRmbWithConversion = totalAmountRmb.add( |
| | | totalAmountHkd.multiply(exchangeRate).setScale(2, RoundingMode.HALF_UP) |
| | | ); |
| | | |
| | | // 计算港币总金额(港币金额 + 人民币换算成港币) |
| | | BigDecimal totalAmountHkdWithConversion = totalAmountHkd.add( |
| | | totalAmountRmb.divide(exchangeRate, 2, RoundingMode.HALF_UP) |
| | | ); |
| | | |
| | | |
| | | // 组装返回结果 |
| | | ReceivableFeeStatisticsVo result = new ReceivableFeeStatisticsVo(); |
| | | result.setDocumentCount(documentCount); |
| | | result.setRate(exchangeRate); |
| | | result.setTotalReceivableAmount(totalReceivableAmount); |
| | | result.setTotalAmountRmb(totalReceivableAmount); |
| | | result.setTotalAmountHkd(totalAmountHkd); |
| | | result.setTotalReceivableAmount(totalAmountRmbWithConversion); // 默认使用人民币总金额 |
| | | result.setTotalAmountRmb(totalAmountRmbWithConversion); |
| | | result.setTotalAmountHkd(totalAmountHkdWithConversion); |
| | | result.setIds(ids); |
| | | |
| | | return result; |
| | |
| | | |
| | | // 根据币种显示对应的货币名称 |
| | | String currency = entry.getKey(); |
| | | if ("CNY".equals(currency)) { |
| | | if ("RMB".equals(currency)) { |
| | | sb.append("人民币"); |
| | | } else if ("HKD".equals(currency)) { |
| | | sb.append("港币"); |