From 3cac9b30647b4fd93ba7ef8060f0fbca2d6ab494 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Wed, 24 Jul 2024 14:45:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A6=96=E9=A1=B5=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=8C=E5=96=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StatisticAnalysisController.java | 62 +- .../ruoyi/invest/domain/dto/AccountsDto.java | 4 + .../service/IStatisticAnalysisService.java | 12 +- .../service/impl/StatisticAnalysisImpl.java | 643 ++++++++++++------ .../mapper/invest/AccountsMapper.xml | 1 + 5 files changed, 488 insertions(+), 234 deletions(-) diff --git a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/controller/StatisticAnalysisController.java b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/controller/StatisticAnalysisController.java index 71612f8..3f0dac0 100644 --- a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/controller/StatisticAnalysisController.java +++ b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/controller/StatisticAnalysisController.java @@ -1,5 +1,6 @@ package com.ruoyi.invest.controller; +import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.invest.domain.dto.AnalysisDto; import com.ruoyi.invest.service.IStatisticAnalysisService; @@ -19,42 +20,55 @@ import java.util.Map; @Api(tags = "统计分析") @RestController @RequestMapping("/analysis") -public class StatisticAnalysisController { +public class StatisticAnalysisController extends BaseController { @Autowired private IStatisticAnalysisService iStatisticAnalysisService; - @ApiOperation("账户总览-基础信息") - @GetMapping("/accountAnalysis/getIncomeInfo") - public Map getIncomeInfo(){ - Map resultMap = iStatisticAnalysisService.getIncomeInfo(); + @ApiOperation("账户总览-POS机信息") + @GetMapping("/getPosAccountsInfo") + public Map getPosAccountsInfo(){ + Map resultMap = iStatisticAnalysisService.getPosAccountsInfo(); return AjaxResult.success(resultMap); } - @ApiOperation("账户总览-基础信息") - @GetMapping("/accountAnalysis/getBaseAccountInfo") - public Map getBaseAccountInfo(){ - Map resultMap = iStatisticAnalysisService.getBaseAccountInfo(); - return AjaxResult.success(resultMap); - } - - - - @ApiOperation("账户总览-负债信息") - @GetMapping("/accountAnalysis/getDebetInfo") - public Map getDebetInfo(){ - Map resultMap = iStatisticAnalysisService.getDebetInfo(); - return AjaxResult.success(resultMap); - } - @ApiOperation("账户总览-信用卡信息") - @GetMapping("/accountAnalysis/getCreditInfo") - public Map getCreditInfo(){ - Map resultMap = iStatisticAnalysisService.getCreditInfo(); + @GetMapping("/getCreditAccountsInfo") + public Map getCreditAccountsInfo(){ + Map resultMap = iStatisticAnalysisService.getCreditAccountsInfo(); return AjaxResult.success(resultMap); } + @ApiOperation("账户总览-储蓄账户信息") + @GetMapping("/getDebitAccountsInfo") + public Map getDebitAccountsInfo(){ + Map resultMap = iStatisticAnalysisService.getDebitAccountsInfo(); + return AjaxResult.success(resultMap); + } + + @ApiOperation("账户总览-投资账户信息") + @GetMapping("/getInvestAccountsInfo") + public Map getInvestAccountsInfo(){ + Map resultMap = iStatisticAnalysisService.getInvestAccountsInfo(); + return AjaxResult.success(resultMap); + } + + + @ApiOperation("账户总览-借贷账户信息") + @GetMapping("/getLendAccountsInfo") + public Map getLendAccountsInfo(){ + Map resultMap = iStatisticAnalysisService.getLendAccountsInfo(); + return AjaxResult.success(resultMap); + } + + @ApiOperation("账户总览-征信报告信息") + @GetMapping("/getCreditReportInfo") + public AjaxResult getCreditReportInfo(){ + return success(iStatisticAnalysisService.getCreditReportInfo()); + } + + @ApiOperation("信用卡统计分析") @GetMapping("/creditAnalysis") diff --git a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/domain/dto/AccountsDto.java b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/domain/dto/AccountsDto.java index 8206184..116b746 100644 --- a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/domain/dto/AccountsDto.java +++ b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/domain/dto/AccountsDto.java @@ -38,4 +38,8 @@ public class AccountsDto extends BaseEntity implements Serializable @ApiModelProperty(value="账户状态") private String status; + /** 储蓄卡类型 */ + @ApiModelProperty(value="储蓄卡类型") + private String debitType; + } diff --git a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/service/IStatisticAnalysisService.java b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/service/IStatisticAnalysisService.java index 2ac19a3..093c97e 100644 --- a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/service/IStatisticAnalysisService.java +++ b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/service/IStatisticAnalysisService.java @@ -1,6 +1,7 @@ package com.ruoyi.invest.service; import com.ruoyi.invest.domain.dto.AnalysisDto; +import com.ruoyi.invest.domain.vo.CreditReportAnalysisVO; import java.util.Map; @@ -8,15 +9,18 @@ import java.util.Map; * @author 22077662 */ public interface IStatisticAnalysisService { + public Map getPosAccountsInfo(); - public Map getIncomeInfo(); + public Map getCreditAccountsInfo(); - public Map getBaseAccountInfo(); + public Map getDebitAccountsInfo(); - public Map getDebetInfo(); + public Map getInvestAccountsInfo(); + public Map getLendAccountsInfo(); + + public CreditReportAnalysisVO getCreditReportInfo(); - public Map getCreditInfo(); public Map getCreditAnalysis(AnalysisDto analysisDto); diff --git a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/service/impl/StatisticAnalysisImpl.java b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/service/impl/StatisticAnalysisImpl.java index 6fcfb3b..49c4404 100644 --- a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/service/impl/StatisticAnalysisImpl.java +++ b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/service/impl/StatisticAnalysisImpl.java @@ -55,42 +55,8 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService { @Resource private AccountsDealRecordMapper accountsDealRecordMapper; - @Override - public Map getIncomeInfo() { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - //期货收益 - FutureStocksBillDto futureStocksBillDto=new FutureStocksBillDto(); - futureStocksBillDto.setType("1"); - List futureStocksBillList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); - double futuresIncome = futureStocksBillList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).sum(); - map.put("futuresIncome",decimalFormat.format(futuresIncome)); - //股票收益 - futureStocksBillDto.setType("2"); - futureStocksBillList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); - double stocksIncome = futureStocksBillList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).sum(); - map.put("stocksIncome",decimalFormat.format(stocksIncome)); - AccountsDto dto=new AccountsDto(); - dto.setState("1"); - //投资账户余额 - dto.setType("5"); - List accountsList=accountsMapper.selectAccountsList(dto); - double investBalance =0; - if(accountsList.size()>0){ - investBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("investBalance",decimalFormat.format(investBalance)); - //总收益 - map.put("totalIncome",decimalFormat.format(futuresIncome+stocksIncome)); - - return map; - } - - - @Override - public Map getBaseAccountInfo() { + public Map getPosAccountsInfo() { //返回数据 HashMap map = new HashMap<>(); //Pos机 @@ -98,194 +64,79 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService { //状态为正常使用 posMachineDto.setStatus("1"); map.put("posCount",posMachineMapper.selectPosMachineList(posMachineDto).size()); - BankCardLendDto bankCardLendDto=new BankCardLendDto(); - //状态为正常使用 - bankCardLendDto.setStatus("1"); - bankCardLendDto.setType("2"); - //信用卡 - map.put("creditCount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); - bankCardLendDto.setType("1"); - //储蓄卡 - map.put("debitCount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); - bankCardLendDto.setType("1"); - bankCardLendDto.setDebitType("1"); - //I类储蓄卡 - map.put("debitICount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); - bankCardLendDto.setDebitType("2"); - //II类储蓄卡 - map.put("debitIICount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); - bankCardLendDto.setDebitType(""); - bankCardLendDto.setType("3"); - bankCardLendDto.setLendType("1"); - //网贷 - map.put("onlineLendCount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); - //人情 - bankCardLendDto.setLendType("2"); - - map.put("peopleLendCount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); - FutureStocksDto futureStocksDto=new FutureStocksDto(); - //状态为正常使用 - futureStocksDto.setStatus("1"); - futureStocksDto.setType("1"); - //期货 - map.put("futuresCount",futureStocksMapper.selectFutureStocksList(futureStocksDto).size()); - //股票 - futureStocksDto.setType("2"); - map.put("stocksCount",futureStocksMapper.selectFutureStocksList(futureStocksDto).size()); - return map; - } - - @Override - public Map getDebetInfo() { - //返回数据 - HashMap map = new HashMap<>(); DecimalFormat decimalFormat = new DecimalFormat("#.##"); - AccountsDto dto=new AccountsDto(); - //状态正常,不隐藏 - dto.setStatus("1"); - dto.setState("1"); - //储蓄卡 + AccountsTransferRecordDto dto=new AccountsTransferRecordDto(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + //当前日期 + Date queryDate=DateUtils.getNowDate(); + + Calendar calendarStart = Calendar.getInstance(); + calendarStart.add(Calendar.MONTH, 0); + calendarStart.set(Calendar.DAY_OF_MONTH, 1);//1:本月第一天 + //获取数据 + dto.setEndTime(dateFormat.format(queryDate)); + dto.setStartTime(dateFormat.format(calendarStart.getTime())); dto.setType("1"); - List accountsList=accountsMapper.selectAccountsList(dto); - double debetBalance =0; - if(accountsList.size()>0){ - debetBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + List transferList=accountsTransferRecordMapper.selectAccountsTransferRecordList(dto); + + double currentMonthAmount =0; + double currentMonthCommission =0; + int currentMonthCount =0; + double actualAmount =0; + if(transferList.size()>0){ + currentMonthCommission=transferList.stream().mapToDouble(AccountsTransferRecordVo::getCommission).sum(); + currentMonthAmount=transferList.stream().mapToDouble(AccountsTransferRecordVo::getAmount).sum(); } - map.put("debetBalance",decimalFormat.format(debetBalance)); + currentMonthCount=transferList.size(); + map.put("currentMonthAmount",decimalFormat.format(currentMonthAmount)); + map.put("currentMonthCommission",decimalFormat.format(currentMonthCommission)); + map.put("currentMonthCount",currentMonthCount); + calendarStart= Calendar.getInstance(); + calendarStart.set(Calendar.DAY_OF_YEAR, 1);//本年的第一天 + dto.setStartTime(dateFormat.format(calendarStart.getTime())); + transferList=accountsTransferRecordMapper.selectAccountsTransferRecordList(dto); - //信用卡 - dto.setType("2"); - accountsList=accountsMapper.selectAccountsList(dto); - double creditBalance =0; - if(accountsList.size()>0){ - creditBalance=accountsList.stream().mapToDouble(AccountsVo::getBalance).sum()*(-1); + double currentYearAmount =0; + double currentYearCommission =0; + int currentYearCount =0; + if(transferList.size()>0){ + currentYearCommission=transferList.stream().mapToDouble(AccountsTransferRecordVo::getCommission).sum(); + currentYearAmount=transferList.stream().mapToDouble(AccountsTransferRecordVo::getAmount).sum(); } - map.put("creditBalance",decimalFormat.format(creditBalance)); - dto.setState("1"); - //投资账户余额 - dto.setType("5"); - accountsList=accountsMapper.selectAccountsList(dto); - double investBalance =0; - if(accountsList.size()>0){ - investBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + currentYearCount=transferList.size(); + map.put("currentYearAmount",decimalFormat.format(currentYearAmount)); + map.put("currentYearCommission",decimalFormat.format(currentYearCommission)); + map.put("currentYearCount",currentYearCount); + dto.setStartTime(""); + transferList=accountsTransferRecordMapper.selectAccountsTransferRecordList(dto); + + double accumulateAmount =0; + double accumulateCommission =0; + int accumulateCount =0; + if(transferList.size()>0){ + accumulateCommission=transferList.stream().mapToDouble(AccountsTransferRecordVo::getCommission).sum(); + accumulateAmount=transferList.stream().mapToDouble(AccountsTransferRecordVo::getAmount).sum(); } - map.put("investBalance",decimalFormat.format(investBalance)); - - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); - //未结清网贷数据 - InstallmentHistoryDto installmentHistoryDto=new InstallmentHistoryDto(); - InstallmentHistoryDetailDto detailDto=new InstallmentHistoryDetailDto(); - detailDto.setType("3"); - detailDto.setState("0"); - List detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double unClearedOnlineDebt = 0; - double unClearedOnlineDebtPrinciple = 0; - double unClearedOnlineDebtInterest = 0; - if(detailList.size()>0){ - unClearedOnlineDebtPrinciple=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getPrincipal).sum(); - unClearedOnlineDebtInterest=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getInterest).sum(); - unClearedOnlineDebt=unClearedOnlineDebtPrinciple+unClearedOnlineDebtInterest; - } - map.put("unClearedOnlineDebt",decimalFormat.format(unClearedOnlineDebt)); - map.put("unClearedOnlineDebtPrinciple",decimalFormat.format(unClearedOnlineDebtPrinciple)); - map.put("unClearedOnlineDebtInterest",decimalFormat.format(unClearedOnlineDebtInterest)); - - //信用卡分期账单 - detailDto.setType("2"); - detailDto.setState("0"); - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double creditInstallmentHistory =0; - if(detailList.size()>0){ - creditInstallmentHistory = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - } - map.put("creditInstallmentHistory",decimalFormat.format(creditInstallmentHistory)); - - - //人情 - installmentHistoryDto.setType("4"); - installmentHistoryDto.setState("0"); - List installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - double peopleLendHistory =0; - if(installmentHistoryList.size()>0){ - peopleLendHistory = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getInstallmentAmount).sum(); - } - map.put("peopleLendHistory",decimalFormat.format(peopleLendHistory)); - - //总负债 - map.put("totalDebt",decimalFormat.format(unClearedOnlineDebt+creditBalance+peopleLendHistory)); - //净资产 - map.put("netAsset",decimalFormat.format(investBalance+debetBalance-unClearedOnlineDebt-creditBalance-peopleLendHistory)); - - //未结清账户数 - installmentHistoryDto.setState("0"); - installmentHistoryDto.setType("3"); - installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - int unclearedOnlineDebtCount = installmentHistoryList.size(); - map.put("unclearedOnlineDebtCount",unclearedOnlineDebtCount); - - //已结清账户数 - installmentHistoryDto.setState("1"); - installmentHistoryDto.setType("3"); - installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - int clearedOnlineDebtCount = installmentHistoryList.size(); - map.put("clearedOnlineDebtCount",clearedOnlineDebtCount); - - //已结清网贷数据 - installmentHistoryDto.setState("1"); - installmentHistoryDto.setType("3"); - installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - double clearedOnlineDebt =0; - double clearedOnlineDebtPrinciple =0; - double clearedOnlineDebtInterest =0; - if(installmentHistoryList.size()>0){ - clearedOnlineDebtPrinciple = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getInstallmentAmount).sum(); - clearedOnlineDebtInterest = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getTotalInterest).sum(); - clearedOnlineDebt=clearedOnlineDebtPrinciple+clearedOnlineDebtInterest; - } - map.put("clearedOnlineDebt",decimalFormat.format(clearedOnlineDebt)); - map.put("clearedOnlineDebtPrinciple",decimalFormat.format(clearedOnlineDebtPrinciple)); - map.put("clearedOnlineDebtInterest",decimalFormat.format(clearedOnlineDebtInterest)); - //网贷当月应还款 - - detailDto.setRepaymentMonth(formatterMonth.format(new Date())); - detailDto.setState(""); - detailDto.setType("3"); - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double dueOnlineDebt =0; - if(detailList.size()>0){ - dueOnlineDebt = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - } - map.put("dueOnlineDebt",decimalFormat.format(dueOnlineDebt)); - - //网贷当月已还款 - detailDto.setState("1"); - detailDto.setRepaymentMonth(formatterMonth.format(new Date())); - detailDto.setType("3"); - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double repaidOnlineDebt =0; - if(detailList.size()>0){ - repaidOnlineDebt = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - } - map.put("repaidOnlineDebt",decimalFormat.format(repaidOnlineDebt)); - - //网贷剩余还款 - map.put("leftOnlineDebt",decimalFormat.format(dueOnlineDebt-repaidOnlineDebt)); + accumulateCount=transferList.size(); + map.put("accumulateAmount",decimalFormat.format(accumulateAmount)); + map.put("accumulateCommission",decimalFormat.format(accumulateCommission)); + map.put("accumulateCount",accumulateCount); return map; } @Override - public Map getCreditInfo() { + public Map getCreditAccountsInfo() { //返回数据 HashMap map = new HashMap<>(); DecimalFormat decimalFormat = new DecimalFormat("#.##"); SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); + //当月信用卡账单 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单"); CreditCardBillDto creditCardBillDto=new CreditCardBillDto(); @@ -347,11 +198,16 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService { //信用卡额度 BankCardLendDto bankCardLendDto=new BankCardLendDto(); + + //状态为正常使用 + bankCardLendDto.setStatus("1"); bankCardLendDto.setType("2"); - List bankCardLendVoList=statisticAnalysisMapper.selectBankCardLendList(bankCardLendDto); + + List bankCardLendVoList=bankCardLendMapper.selectBankCardLendList(bankCardLendDto); + //信用卡 + map.put("creditCount",bankCardLendVoList.size()); int creditLimit = bankCardLendVoList.stream().mapToInt(BankCardLendVo::getCreditLimit).sum(); map.put("creditLimit",creditLimit); - AccountsDto dto=new AccountsDto(); //正常使用 dto.setStatus("1"); @@ -401,13 +257,388 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService { creditCardBillList=creditCardBillMapper.selectCreditCardBillList(creditCardBillDto); double lastSixMonthUsedLimit = creditCardBillList.stream().mapToDouble(CreditCardBillVo::getBillAmount).sum(); map.put("lastSixMonthUsedLimit",decimalFormat.format(lastSixMonthUsedLimit/6)); - //近6个月月信用卡使用率 + //近6个月月信用卡使用率 map.put("lastSixMonthUsedRate",decimalFormat.format(lastSixMonthUsedLimit*100/(6*creditLimit))); return map; } + @Override + public Map getDebitAccountsInfo() { + //返回数据 + HashMap map = new HashMap<>(); + DecimalFormat decimalFormat = new DecimalFormat("#.##"); + + AccountsDto dto=new AccountsDto(); + //状态正常,不隐藏 + dto.setStatus("1"); + //储蓄卡 + dto.setType("1"); + + //I类储蓄卡 + dto.setDebitType("1"); + List accountsList=accountsMapper.selectAccountsList(dto); + double debitIBalance =0; + Integer debitICount =0; + if(accountsList.size()>0){ + debitIBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + } + //I类储蓄卡数量 + debitICount=accountsList.size(); + map.put("debitICount",debitICount); + //I类储蓄卡余额 + map.put("debitIBalance",decimalFormat.format(debitIBalance)); + //II类储蓄卡 + dto.setDebitType("2"); + accountsList=accountsMapper.selectAccountsList(dto); + double debitIIBalance =0; + Integer debitIICount =0; + if(accountsList.size()>0){ + debitIIBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + } + //II类储蓄卡余额 + map.put("debitIIBalance",decimalFormat.format(debitIIBalance)); + //II类储蓄卡数量 + debitIICount=accountsList.size(); + map.put("debitICount",debitICount); + map.put("debitIICount",debitIICount); + //储蓄卡数量 + map.put("debitCount",debitICount+debitIICount); + //储蓄卡余额=I类储蓄卡余额+II类储蓄卡余额 + map.put("debitBalance",decimalFormat.format(debitIBalance+debitIIBalance)); + //网络账户余额 + dto.setDebitType("3"); + accountsList=accountsMapper.selectAccountsList(dto); + double debitOnlineBalance =0; + if(accountsList.size()>0){ + debitOnlineBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + } + map.put("debitOnlineBalance",decimalFormat.format(debitOnlineBalance)); + map.put("debitOnlineCount",accountsList.size()); + //储值卡余额 + dto.setDebitType("4"); + accountsList=accountsMapper.selectAccountsList(dto); + double storedValueCardBalance =0; + if(accountsList.size()>0){ + storedValueCardBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + } + //储值卡总数 + map.put("storedValueCardCount",accountsList.size()); + //储值卡余额 + map.put("storedValueCardBalance",decimalFormat.format(storedValueCardBalance)); + //住房公积金余额 + dto.setDebitType("5"); + accountsList=accountsMapper.selectAccountsList(dto); + double housingFundBalance =0; + if(accountsList.size()>0){ + housingFundBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + } + map.put("housingFundBalance",decimalFormat.format(housingFundBalance)); + + //职工医保余额 + dto.setDebitType("6"); + accountsList=accountsMapper.selectAccountsList(dto); + double medicalBalance =0; + if(accountsList.size()>0){ + medicalBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + } + map.put("medicalBalance",decimalFormat.format(medicalBalance)); + + //个人养老金余额 + dto.setDebitType("7"); + accountsList=accountsMapper.selectAccountsList(dto); + double personalPensionBalance =0; + if(accountsList.size()>0){ + personalPensionBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + } + map.put("personalPensionBalance",decimalFormat.format(personalPensionBalance)); + + //其他余额 + dto.setDebitType("8"); + accountsList=accountsMapper.selectAccountsList(dto); + double otherDebitBalance =0; + if(accountsList.size()>0){ + otherDebitBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + } + map.put("otherDebitBalance",decimalFormat.format(otherDebitBalance)); + map.put("otherDebitCount",accountsList.size()); + //储蓄账户总余额 + map.put("debitTotalBalance",decimalFormat.format(debitIBalance+debitIIBalance+debitOnlineBalance+housingFundBalance+storedValueCardBalance+medicalBalance+personalPensionBalance+otherDebitBalance)); + + + return map; + } + + @Override + public Map getInvestAccountsInfo() { + //返回数据 + HashMap map = new HashMap<>(); + DecimalFormat decimalFormat = new DecimalFormat("#.##"); + //期货收益 + FutureStocksBillDto futureStocksBillDto=new FutureStocksBillDto(); + futureStocksBillDto.setType("1"); + List futureStocksBillList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); + double futuresIncome = futureStocksBillList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).sum(); + map.put("futuresIncome",decimalFormat.format(futuresIncome)); + //股票收益 + futureStocksBillDto.setType("2"); + futureStocksBillList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); + double stocksIncome = futureStocksBillList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).sum(); + map.put("stocksIncome",decimalFormat.format(stocksIncome)); + AccountsDto dto=new AccountsDto(); + dto.setState("1"); + //投资账户余额 + dto.setType("5"); + List accountsList=accountsMapper.selectAccountsList(dto); + double investBalance =0; + if(accountsList.size()>0){ + investBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); + } + map.put("investBalance",decimalFormat.format(investBalance)); + //总收益 + map.put("totalIncome",decimalFormat.format(futuresIncome+stocksIncome)); + + FutureStocksDto futureStocksDto=new FutureStocksDto(); + //状态为正常使用 + futureStocksDto.setStatus("1"); + futureStocksDto.setType("1"); + //期货 + map.put("futuresCount",futureStocksMapper.selectFutureStocksList(futureStocksDto).size()); + //股票 + futureStocksDto.setType("2"); + map.put("stocksCount",futureStocksMapper.selectFutureStocksList(futureStocksDto).size()); + AccountsDealRecordDto dealDto=new AccountsDealRecordDto(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + //当前日期 + Date queryDate=DateUtils.getNowDate(); + + Calendar calendarStart = Calendar.getInstance(); + calendarStart.add(Calendar.MONTH, 0); + calendarStart.set(Calendar.DAY_OF_MONTH, 1);//1:本月第一天 + //获取数据 + dealDto.setEndTime(dateFormat.format(queryDate)); + dealDto.setStartTime(dateFormat.format(calendarStart.getTime())); + dealDto.setType("5"); + dealDto.setDealCategory("2"); + List accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(dealDto); + double income =0; + double expenses =0; + for (AccountsDealRecordVo vo:accountsDealRecordVoList + ) { + + if(vo.getDealType().equals("1")){ + income+=vo.getAmount(); + } + //支出 + if(vo.getDealType().equals("2")){ + expenses+=vo.getAmount(); + } + } + //交易金额 + map.put("currentMonthInvest",decimalFormat.format(income-expenses)); + //收入 + map.put("currentMonthIncome",decimalFormat.format(income)); + + //支出 + map.put("currentMonthExpenses",decimalFormat.format(expenses)); + + return map; + } + + @Override + public Map getLendAccountsInfo() { + //返回数据 + HashMap map = new HashMap<>(); + DecimalFormat decimalFormat = new DecimalFormat("#.##"); + BankCardLendDto bankCardLendDto=new BankCardLendDto(); + //状态为正常使用 + bankCardLendDto.setStatus("1"); + bankCardLendDto.setType("3"); + bankCardLendDto.setLendType("1"); + //网贷 + map.put("onlineLendCount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); + //人情 + bankCardLendDto.setLendType("2"); + map.put("peopleLendCount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); + //未结清网贷数据 + InstallmentHistoryDto installmentHistoryDto=new InstallmentHistoryDto(); + InstallmentHistoryDetailDto detailDto=new InstallmentHistoryDetailDto(); + detailDto.setType("3"); + detailDto.setState("0"); + List detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); + double unClearedOnlineDebt = 0; + double unClearedOnlineDebtPrinciple = 0; + double unClearedOnlineDebtInterest = 0; + if(detailList.size()>0){ + unClearedOnlineDebtPrinciple=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getPrincipal).sum(); + unClearedOnlineDebtInterest=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getInterest).sum(); + unClearedOnlineDebt=unClearedOnlineDebtPrinciple+unClearedOnlineDebtInterest; + } + map.put("unClearedOnlineDebt",decimalFormat.format(unClearedOnlineDebt)); + map.put("unClearedOnlineDebtPrinciple",decimalFormat.format(unClearedOnlineDebtPrinciple)); + map.put("unClearedOnlineDebtInterest",decimalFormat.format(unClearedOnlineDebtInterest)); + + //信用卡分期账单 + detailDto.setType("2"); + detailDto.setState("0"); + detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); + double creditInstallmentHistory =0; + if(detailList.size()>0){ + creditInstallmentHistory = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); + } + map.put("creditInstallmentHistory",decimalFormat.format(creditInstallmentHistory)); + + + //人情 + installmentHistoryDto.setType("4"); + installmentHistoryDto.setState("0"); + List installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); + double peopleLendHistory =0; + if(installmentHistoryList.size()>0){ + peopleLendHistory = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getInstallmentAmount).sum(); + } + map.put("peopleLendHistory",decimalFormat.format(peopleLendHistory)); + + //未结清账户数 + installmentHistoryDto.setState("0"); + installmentHistoryDto.setType("3"); + installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); + int unclearedOnlineDebtCount = installmentHistoryList.size(); + map.put("unclearedOnlineDebtCount",unclearedOnlineDebtCount); + + //已结清账户数 + installmentHistoryDto.setState("1"); + installmentHistoryDto.setType("3"); + installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); + int clearedOnlineDebtCount = installmentHistoryList.size(); + map.put("clearedOnlineDebtCount",clearedOnlineDebtCount); + + //已结清网贷数据 + installmentHistoryDto.setState("1"); + installmentHistoryDto.setType("3"); + installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); + double clearedOnlineDebt =0; + double clearedOnlineDebtPrinciple =0; + double clearedOnlineDebtInterest =0; + if(installmentHistoryList.size()>0){ + clearedOnlineDebtPrinciple = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getInstallmentAmount).sum(); + clearedOnlineDebtInterest = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getTotalInterest).sum(); + clearedOnlineDebt=clearedOnlineDebtPrinciple+clearedOnlineDebtInterest; + } + map.put("clearedOnlineDebt",decimalFormat.format(clearedOnlineDebt)); + map.put("clearedOnlineDebtPrinciple",decimalFormat.format(clearedOnlineDebtPrinciple)); + map.put("clearedOnlineDebtInterest",decimalFormat.format(clearedOnlineDebtInterest)); + //网贷当月应还款 + + detailDto.setRepaymentMonth(formatterMonth.format(new Date())); + detailDto.setState(""); + detailDto.setType("3"); + detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); + double dueOnlineDebt =0; + if(detailList.size()>0){ + dueOnlineDebt = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); + } + map.put("dueOnlineDebt",decimalFormat.format(dueOnlineDebt)); + + //网贷当月已还款 + detailDto.setState("1"); + detailDto.setRepaymentMonth(formatterMonth.format(new Date())); + detailDto.setType("3"); + detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); + double repaidOnlineDebt =0; + if(detailList.size()>0){ + repaidOnlineDebt = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); + } + map.put("repaidOnlineDebt",decimalFormat.format(repaidOnlineDebt)); + + //网贷剩余还款 + map.put("leftOnlineDebt",decimalFormat.format(dueOnlineDebt-repaidOnlineDebt)); + + return map; + } + + @Override + public CreditReportAnalysisVO getCreditReportInfo() { + + CreditReportQueryRecordDto dto =new CreditReportQueryRecordDto(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + Date queryDate=DateUtils.getNowDate(); + if(dto.getQueryDateStart()!=null){ + try { + queryDate=formatter.parse(dto.getQueryDateStart()); + dto.setQueryDateEnd(dto.getQueryDateStart()); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + CreditReportAnalysisVO analysisVO=new CreditReportAnalysisVO(); + dto.setQueryType("1"); + + Calendar calendarStart = Calendar.getInstance(); + calendarStart.setTime(queryDate); + calendarStart.add(Calendar.MONTH, -1); + dto.setQueryDateStart(formatter.format(calendarStart.getTime())); + analysisVO.setLastOneMonths(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + calendarStart.setTime(queryDate); + calendarStart.add(Calendar.MONTH, -2); + dto.setQueryDateStart(formatter.format(calendarStart.getTime())); + analysisVO.setLastTwoMonths(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + calendarStart.setTime(queryDate); + calendarStart.add(Calendar.MONTH, -3); + dto.setQueryDateStart(formatter.format(calendarStart.getTime())); + analysisVO.setLastThreeMonths(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + calendarStart.setTime(queryDate); + calendarStart.add(Calendar.MONTH, -6); + dto.setQueryDateStart(formatter.format(calendarStart.getTime())); + analysisVO.setLastSixMonths(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + + calendarStart.setTime(queryDate); + calendarStart.add(Calendar.MONTH, -12); + dto.setQueryDateStart(formatter.format(calendarStart.getTime())); + analysisVO.setLastOneYears(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + + calendarStart.setTime(queryDate); + calendarStart.add(Calendar.MONTH, -24); + dto.setQueryDateStart(formatter.format(calendarStart.getTime())); + analysisVO.setLastTwoYears(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + + dto.setQueryDateStart(""); + analysisVO.setLastAllYears(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + + calendarStart.setTime(queryDate); + calendarStart.add(Calendar.MONTH, -6); + dto.setQueryDateStart(formatter.format(calendarStart.getTime())); + dto.setType("5"); + dto.setQueryType("2"); + analysisVO.setLastSixMonthQueryCount(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + calendarStart.setTime(queryDate); + calendarStart.add(Calendar.MONTH, -6); + dto.setQueryDateStart(formatter.format(calendarStart.getTime())); + dto.setType("4"); + analysisVO.setLastSixMonthsAfterLoan(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + calendarStart.setTime(queryDate); + calendarStart.add(Calendar.MONTH, -24); + dto.setQueryDateStart(formatter.format(calendarStart.getTime())); + dto.setType("4"); + analysisVO.setLastTwoYearsAfterLoan(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + + dto.setQueryDateStart(""); + dto.setType("4"); + analysisVO.setTotalAfterLoan(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); + return analysisVO; + } @Override public Map getCreditAnalysis(AnalysisDto analysisDto) { diff --git a/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/AccountsMapper.xml b/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/AccountsMapper.xml index 45c8522..e0a5028 100644 --- a/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/AccountsMapper.xml +++ b/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/AccountsMapper.xml @@ -61,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" a.del_flag='0' and a.name like '%'|| #{name}||'%' and a.type = #{type} + and bcl.debit_type = #{debitType} and a.state = #{state} and a.status = #{status} and a.account_id = #{accountId}