feat: 账户收支统计,新功能开发。
This commit is contained in:
@@ -116,6 +116,13 @@ public class StatisticAnalysisController {
|
|||||||
return AjaxResult.success(resultMap);
|
return AjaxResult.success(resultMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("收支统计分析")
|
||||||
|
@GetMapping("/accountsOutInAnalysis")
|
||||||
|
public Map<String,Object> getAccountsOutInAnalysis(AnalysisDto analysisDto){
|
||||||
|
Map<String, Object> resultMap = iStatisticAnalysisService.getAccountsOutInAnalysis(analysisDto);
|
||||||
|
return AjaxResult.success(resultMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ public class AccountsDealRecordVo extends AccountsDealRecord
|
|||||||
/** 账户 */
|
/** 账户 */
|
||||||
private String accountName;
|
private String accountName;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String nameCode;
|
||||||
|
|
||||||
|
|
||||||
private String dealCategoryName;
|
private String dealCategoryName;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.ruoyi.invest.mapper;
|
package com.ruoyi.invest.mapper;
|
||||||
|
|
||||||
import com.ruoyi.common.datascope.annotation.DataScope;
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
||||||
|
import com.ruoyi.invest.domain.dto.AccountsDealRecordDto;
|
||||||
import com.ruoyi.invest.domain.dto.BankCardLendDto;
|
import com.ruoyi.invest.domain.dto.BankCardLendDto;
|
||||||
|
import com.ruoyi.invest.domain.vo.AccountsDealRecordVo;
|
||||||
import com.ruoyi.invest.domain.vo.BankCardLendVo;
|
import com.ruoyi.invest.domain.vo.BankCardLendVo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -19,5 +21,13 @@ public interface StatisticAnalysisMapper {
|
|||||||
@DataScope(businessAlias = "a")
|
@DataScope(businessAlias = "a")
|
||||||
public List<BankCardLendVo> selectBankCardLendList(BankCardLendDto bankCardLendDto);
|
public List<BankCardLendVo> selectBankCardLendList(BankCardLendDto bankCardLendDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询收支记录
|
||||||
|
*
|
||||||
|
* @param accountsDealRecordDto
|
||||||
|
* @return 收支集合
|
||||||
|
*/
|
||||||
|
@DataScope(businessAlias = "a")
|
||||||
|
public List<AccountsDealRecordVo> selectAccountsOutInList(AccountsDealRecordDto accountsDealRecordDto);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,4 +36,6 @@ public interface IStatisticAnalysisService {
|
|||||||
|
|
||||||
public Map<String, Object> getAccountsDealAnalysis(AnalysisDto analysisDto);
|
public Map<String, Object> getAccountsDealAnalysis(AnalysisDto analysisDto);
|
||||||
|
|
||||||
|
public Map<String, Object> getAccountsOutInAnalysis(AnalysisDto analysisDto);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,8 +240,8 @@ public class AccountsTransferRecordServiceImpl implements IAccountsTransferRecor
|
|||||||
creditDeal.setType("1");
|
creditDeal.setType("1");
|
||||||
//1 收入,2 支出,3 转账,4 借贷
|
//1 收入,2 支出,3 转账,4 借贷
|
||||||
creditDeal.setDealType("2");
|
creditDeal.setDealType("2");
|
||||||
//POS机刷卡
|
//POS机刷卡手续费
|
||||||
creditDeal.setDealCategory("5");
|
creditDeal.setDealCategory("13");
|
||||||
//POS机名称+信用卡+商户名称
|
//POS机名称+信用卡+商户名称
|
||||||
creditDeal.setName(pos.getName()+"-"+creditAccount.getName()+"("+ StringUtils.getLastNumberChars(3,creditAccount.getCode())+")"+"-"+pos.getMerchantName());
|
creditDeal.setName(pos.getName()+"-"+creditAccount.getName()+"("+ StringUtils.getLastNumberChars(3,creditAccount.getCode())+")"+"-"+pos.getMerchantName());
|
||||||
creditDeal.setRemark("刷卡手续费");
|
creditDeal.setRemark("刷卡手续费");
|
||||||
@@ -595,26 +595,53 @@ public class AccountsTransferRecordServiceImpl implements IAccountsTransferRecor
|
|||||||
//储蓄卡消费记录明细,支出
|
//储蓄卡消费记录明细,支出
|
||||||
dealRecord.setAccountId(debitAccount.getAccountId());
|
dealRecord.setAccountId(debitAccount.getAccountId());
|
||||||
dealRecord.setId(IdWorker.getId());
|
dealRecord.setId(IdWorker.getId());
|
||||||
//支出金额
|
//支出本金金额
|
||||||
dealRecord.setAmount(accountsTransferRecord.getActualAmount());
|
dealRecord.setAmount(accountsTransferRecord.getAmount());
|
||||||
//实时余额
|
|
||||||
dealRecord.setCurrentBalance(debitAccount.getBalance());
|
|
||||||
//1储蓄卡,2 信用卡,3 网贷,4 人情,5 投资账户
|
//1储蓄卡,2 信用卡,3 网贷,4 人情,5 投资账户
|
||||||
dealRecord.setType("3");
|
dealRecord.setType("3");
|
||||||
//1 收入,2 支出,3 转账,4 借贷
|
//1 收入,2 支出,3 转账,4 借贷
|
||||||
//1表示借款,2表示还款
|
//1表示借款,2表示还款
|
||||||
if(accountsTransferRecord.getDealType().equals("1")){
|
if(accountsTransferRecord.getDealType().equals("1")){
|
||||||
dealRecord.setDealType("1");
|
dealRecord.setDealType("1");
|
||||||
|
//实时余额
|
||||||
|
dealRecord.setCurrentBalance(debitAccount.getBalance());
|
||||||
dealRecord.setRemark("借贷记账借款。");
|
dealRecord.setRemark("借贷记账借款。");
|
||||||
//投资账户账至储蓄卡转
|
//投资账户账至储蓄卡转
|
||||||
dealRecord.setName(lendVo.getName()+"("+StringUtils.getLastNumberChars(3,lendVo.getCode())+")借款至"+debitCardVo.getName()+"("+StringUtils.getLastNumberChars(3,debitCardVo.getCode())+")");
|
dealRecord.setName(lendVo.getName()+"("+StringUtils.getLastNumberChars(3,lendVo.getCode())+")借款至"+debitCardVo.getName()+"("+StringUtils.getLastNumberChars(3,debitCardVo.getCode())+")");
|
||||||
}else if(accountsTransferRecord.getDealType().equals("2")){
|
}else if(accountsTransferRecord.getDealType().equals("2")){
|
||||||
dealRecord.setDealType("2");
|
dealRecord.setDealType("2");
|
||||||
dealRecord.setRemark("借贷记账还款,本息合计。");
|
//实时余额
|
||||||
|
dealRecord.setCurrentBalance(debitAccount.getBalance()-accountsTransferRecord.getCommission());
|
||||||
|
dealRecord.setRemark("借贷记账还款,本金。");
|
||||||
//储蓄卡还款至投资账户
|
//储蓄卡还款至投资账户
|
||||||
dealRecord.setName(debitCardVo.getName()+"("+StringUtils.getLastNumberChars(3,debitCardVo.getCode())+")还款至"+lendVo.getName()+"("+StringUtils.getLastNumberChars(3,lendVo.getCode())+")");
|
dealRecord.setName(debitCardVo.getName()+"("+StringUtils.getLastNumberChars(3,debitCardVo.getCode())+")还款至"+lendVo.getName()+"("+StringUtils.getLastNumberChars(3,lendVo.getCode())+")");
|
||||||
|
|
||||||
|
|
||||||
|
AccountsDealRecord dealInterest=new AccountsDealRecord();
|
||||||
|
|
||||||
|
dealInterest.setAccountId(debitAccount.getAccountId());
|
||||||
|
dealInterest.setId(IdWorker.getId());
|
||||||
|
//支出金额
|
||||||
|
dealInterest.setAmount(accountsTransferRecord.getCommission());
|
||||||
|
//实时余额
|
||||||
|
dealInterest.setCurrentBalance(debitAccount.getBalance());
|
||||||
|
//1储蓄卡,2 信用卡,3 网贷,4 人情,5 投资账户
|
||||||
|
dealInterest.setType("3");
|
||||||
|
dealInterest.setDealType("2");
|
||||||
|
//实时余额
|
||||||
|
dealInterest.setCurrentBalance(debitAccount.getBalance()-accountsTransferRecord.getCommission());
|
||||||
|
dealInterest.setRemark("借贷记账还款,利息。");
|
||||||
|
//储蓄卡还款至投资账户
|
||||||
|
dealInterest.setName(debitCardVo.getName()+"("+StringUtils.getLastNumberChars(3,debitCardVo.getCode())+")还款至"+lendVo.getName()+"("+StringUtils.getLastNumberChars(3,lendVo.getCode())+")");
|
||||||
|
//借贷账户转账利息
|
||||||
|
dealInterest.setDealCategory("15");
|
||||||
|
|
||||||
|
dealInterest.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
dealInterest.setCreateTime(accountsTransferRecord.getCreateTime());
|
||||||
|
insertAccountsDealRecord(dealInterest);
|
||||||
}
|
}
|
||||||
//投资账户转账
|
//借贷账户转账
|
||||||
dealRecord.setDealCategory("9");
|
dealRecord.setDealCategory("9");
|
||||||
|
|
||||||
dealRecord.setCreateBy(SecurityUtils.getUsername());
|
dealRecord.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import com.ruoyi.common.core.utils.DateUtils;
|
|||||||
import com.ruoyi.common.core.utils.IdWorker;
|
import com.ruoyi.common.core.utils.IdWorker;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.invest.domain.Accounts;
|
||||||
import com.ruoyi.invest.domain.PosMachine;
|
import com.ruoyi.invest.domain.PosMachine;
|
||||||
import com.ruoyi.invest.domain.dto.PosMachineDto;
|
import com.ruoyi.invest.domain.dto.PosMachineDto;
|
||||||
import com.ruoyi.invest.domain.vo.PosMachineVo;
|
import com.ruoyi.invest.domain.vo.PosMachineVo;
|
||||||
|
import com.ruoyi.invest.mapper.AccountsMapper;
|
||||||
import com.ruoyi.invest.mapper.PosMachineMapper;
|
import com.ruoyi.invest.mapper.PosMachineMapper;
|
||||||
import com.ruoyi.invest.service.IPosMachineService;
|
import com.ruoyi.invest.service.IPosMachineService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -26,6 +28,9 @@ public class PosMachineServiceImpl implements IPosMachineService
|
|||||||
@Resource
|
@Resource
|
||||||
private PosMachineMapper posMachineMapper;
|
private PosMachineMapper posMachineMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AccountsMapper accountsMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询pos机信息
|
* 查询pos机信息
|
||||||
*
|
*
|
||||||
@@ -68,6 +73,24 @@ public class PosMachineServiceImpl implements IPosMachineService
|
|||||||
posMachine.setCreateBy(SecurityUtils.getUsername());
|
posMachine.setCreateBy(SecurityUtils.getUsername());
|
||||||
posMachine.setCreateTime(DateUtils.getNowDate());
|
posMachine.setCreateTime(DateUtils.getNowDate());
|
||||||
posMachine.setId(IdWorker.getId());
|
posMachine.setId(IdWorker.getId());
|
||||||
|
|
||||||
|
//记账账户信息插入
|
||||||
|
Accounts accounts=new Accounts();
|
||||||
|
accounts.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
accounts.setCreateTime(DateUtils.getNowDate());
|
||||||
|
accounts.setId(IdWorker.getId());
|
||||||
|
accounts.setAccountId(accounts.getId());
|
||||||
|
accounts.setBalance(0.0);
|
||||||
|
accounts.setId(posMachine.getId());
|
||||||
|
accounts.setAccountId(posMachine.getId());
|
||||||
|
accounts.setName(posMachine.getName());
|
||||||
|
accounts.setType("6");
|
||||||
|
accounts.setCreditLimit(0);
|
||||||
|
accounts.setCode(posMachine.getCode());
|
||||||
|
accounts.setAvailableLimit(0d);
|
||||||
|
accounts.setState("1");
|
||||||
|
accountsMapper.insertAccounts(accounts);
|
||||||
|
|
||||||
return posMachineMapper.insertPosMachine(posMachine);
|
return posMachineMapper.insertPosMachine(posMachine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1895,4 +1895,274 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getAccountsOutInAnalysis(AnalysisDto analysisDto) {
|
||||||
|
//返回数据
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat("#.###");
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
SimpleDateFormat dateFormatSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM");
|
||||||
|
//月查询
|
||||||
|
if(analysisDto.getType().equals("2")){
|
||||||
|
if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){
|
||||||
|
String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),0));
|
||||||
|
String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-24));
|
||||||
|
analysisDto.setStartTime(startTime);
|
||||||
|
analysisDto.setEndTime(endTime);
|
||||||
|
}else {
|
||||||
|
analysisDto.setStartTime(analysisDto.getStartTime()+"-01");
|
||||||
|
if(analysisDto.getEndTime().equals(formatterMonth.format(new Date()))){
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("dd");
|
||||||
|
analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date()));
|
||||||
|
}else {
|
||||||
|
analysisDto.setEndTime(analysisDto.getEndTime()+"-31");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//年查询
|
||||||
|
}else if(analysisDto.getType().equals("3")){
|
||||||
|
if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){
|
||||||
|
String endTime=dateFormat.format(DateUtils.getNowDate());
|
||||||
|
String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5));
|
||||||
|
analysisDto.setStartTime(startTime);
|
||||||
|
analysisDto.setEndTime(endTime);
|
||||||
|
}else {
|
||||||
|
analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01");
|
||||||
|
SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
|
||||||
|
if(analysisDto.getEndTime().equals(sdfYear.format(new Date()))){
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
|
||||||
|
analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date()));
|
||||||
|
}else {
|
||||||
|
analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AccountsDealRecordDto dto=new AccountsDealRecordDto();
|
||||||
|
//获取数据
|
||||||
|
dto.setEndTime(analysisDto.getEndTime());
|
||||||
|
dto.setStartTime(analysisDto.getStartTime());
|
||||||
|
dto.setDealCategory(analysisDto.getDealCategory());
|
||||||
|
List<AccountsDealRecordVo> accountsDealRecordVoList=statisticAnalysisMapper.selectAccountsOutInList(dto);
|
||||||
|
//修改名称加卡号
|
||||||
|
for (AccountsDealRecordVo accounts : accountsDealRecordVoList) {
|
||||||
|
|
||||||
|
if(accounts.getCode()!=null){
|
||||||
|
accounts.setNameCode(accounts.getAccountName()+"("+ StringUtils.getLastNumberChars(4,accounts.getCode()+")"));
|
||||||
|
}else {
|
||||||
|
accounts.setNameCode(accounts.getAccountName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//收支差额
|
||||||
|
double balance =0;
|
||||||
|
//支出总额
|
||||||
|
double totalOutcome =0;
|
||||||
|
//收益总额
|
||||||
|
double totalIncome =0;
|
||||||
|
//刷卡手续费 13
|
||||||
|
double posExpenses =0;
|
||||||
|
//信用卡分期利息 14
|
||||||
|
double creditInterest =0;
|
||||||
|
//网贷利息 15
|
||||||
|
double onLineInterest=0;
|
||||||
|
//日常支出 1
|
||||||
|
double dailyExpenses=0;
|
||||||
|
//投资收益 2
|
||||||
|
double investIncome=0;
|
||||||
|
//工资收入 11
|
||||||
|
double salaryIncome=0;
|
||||||
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||||
|
) {
|
||||||
|
if(vo.getDealType().equals("1")){
|
||||||
|
totalIncome+=vo.getAmount();
|
||||||
|
if(vo.getDealCategory().equals("11")){
|
||||||
|
salaryIncome+=vo.getAmount();
|
||||||
|
}
|
||||||
|
if(vo.getDealCategory().equals("2")){
|
||||||
|
investIncome+=vo.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//支出
|
||||||
|
if(vo.getDealType().equals("2")){
|
||||||
|
totalOutcome+=vo.getAmount();
|
||||||
|
if(vo.getDealCategory().equals("1")){
|
||||||
|
dailyExpenses+=vo.getAmount();
|
||||||
|
}
|
||||||
|
if(vo.getDealCategory().equals("2")){
|
||||||
|
investIncome-=vo.getAmount();
|
||||||
|
}
|
||||||
|
if(vo.getDealCategory().equals("13")){
|
||||||
|
posExpenses+=vo.getAmount();
|
||||||
|
}
|
||||||
|
if(vo.getDealCategory().equals("14")){
|
||||||
|
creditInterest+=vo.getAmount();
|
||||||
|
}
|
||||||
|
if(vo.getDealCategory().equals("15")){
|
||||||
|
onLineInterest+=vo.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//收支差额
|
||||||
|
map.put("balance",decimalFormat.format(totalIncome-totalOutcome));
|
||||||
|
//支出总额
|
||||||
|
map.put("totalOutcome",decimalFormat.format(totalOutcome));
|
||||||
|
//收益总额
|
||||||
|
map.put("totalIncome",decimalFormat.format(totalIncome));
|
||||||
|
//刷卡手续费 13
|
||||||
|
map.put("posExpenses",decimalFormat.format(posExpenses));
|
||||||
|
//信用卡分期利息 14
|
||||||
|
map.put("creditInterest",decimalFormat.format(creditInterest));
|
||||||
|
//网贷利息 15
|
||||||
|
map.put("onLineInterest",decimalFormat.format(onLineInterest));
|
||||||
|
//日常支出 1
|
||||||
|
map.put("dailyExpenses",decimalFormat.format(dailyExpenses));
|
||||||
|
//投资收益 2
|
||||||
|
map.put("investIncome",decimalFormat.format(investIncome));
|
||||||
|
//工资收入 11
|
||||||
|
map.put("salaryIncome",decimalFormat.format(salaryIncome));
|
||||||
|
//非日常支出 1
|
||||||
|
map.put("notDailyExpenses",decimalFormat.format(totalOutcome-dailyExpenses));
|
||||||
|
|
||||||
|
List<AccountsDealRecordVo> queryList =new ArrayList<>();
|
||||||
|
|
||||||
|
if("1".equals(analysisDto.getType())){
|
||||||
|
//日列表
|
||||||
|
List <String> staticsTimeList=new ArrayList<>();
|
||||||
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||||
|
) {
|
||||||
|
if (null != vo.getDealCategory()) {
|
||||||
|
vo.setDealCategoryName(DictUtils.getDictLabel("deal_category", vo.getDealCategory().toString()));
|
||||||
|
}
|
||||||
|
String dayString=dateFormat.format(vo.getCreateTime());
|
||||||
|
|
||||||
|
if(!staticsTimeList.contains(dayString)){
|
||||||
|
staticsTimeList.add(dayString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String staticsTime :staticsTimeList
|
||||||
|
) {
|
||||||
|
double actualCreditBillDay=0;
|
||||||
|
String details="";
|
||||||
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||||
|
) {
|
||||||
|
String dayString=dateFormat.format(vo.getCreateTime());
|
||||||
|
|
||||||
|
if(staticsTime.equals(dayString)){
|
||||||
|
if(vo.getDealType().equals("1")){
|
||||||
|
actualCreditBillDay+=vo.getAmount();
|
||||||
|
details+=vo.getNameCode()+"于"+dateFormatSecond.format(vo.getCreateTime())+"因交易类别【"+vo.getDealCategoryName()+"】收入"+vo.getAmount()+";<br/>";
|
||||||
|
}
|
||||||
|
if(vo.getDealType().equals("2")){
|
||||||
|
actualCreditBillDay-=vo.getAmount();
|
||||||
|
details+=vo.getNameCode()+"于"+dateFormatSecond.format(vo.getCreateTime())+"因交易类别【"+vo.getDealCategoryName()+"】支出"+vo.getAmount()+";<br/>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AccountsDealRecordVo analysisVo=new AccountsDealRecordVo();
|
||||||
|
analysisVo.setAmount(actualCreditBillDay);
|
||||||
|
analysisVo.setRemark(staticsTime);
|
||||||
|
analysisVo.setName(details);
|
||||||
|
queryList.add(analysisVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
//年查询
|
||||||
|
}
|
||||||
|
else if("2".equals(analysisDto.getType())){
|
||||||
|
//月列表
|
||||||
|
List <String> staticsTimeList=new ArrayList<>();
|
||||||
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||||
|
) {
|
||||||
|
String monthString=dateFormat.format(vo.getCreateTime()).substring(0,7);
|
||||||
|
|
||||||
|
if(!staticsTimeList.contains(monthString)){
|
||||||
|
staticsTimeList.add(monthString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String staticsTime :staticsTimeList
|
||||||
|
) {
|
||||||
|
double actualCreditBillMonth=0;
|
||||||
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||||
|
) {
|
||||||
|
String monthString=dateFormat.format(vo.getCreateTime()).substring(0,7);
|
||||||
|
|
||||||
|
if(staticsTime.equals(monthString)){
|
||||||
|
if(vo.getDealType().equals("1")){
|
||||||
|
actualCreditBillMonth+=vo.getAmount();
|
||||||
|
}
|
||||||
|
if(vo.getDealType().equals("2")){
|
||||||
|
actualCreditBillMonth-=vo.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AccountsDealRecordVo analysisVo=new AccountsDealRecordVo();
|
||||||
|
analysisVo.setAmount(actualCreditBillMonth);
|
||||||
|
analysisVo.setRemark(staticsTime);
|
||||||
|
queryList.add(analysisVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
//年查询
|
||||||
|
}else if("3".equals(analysisDto.getType())){
|
||||||
|
List <String> staticsTimeList=new ArrayList<>();
|
||||||
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||||
|
) {
|
||||||
|
String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4);
|
||||||
|
|
||||||
|
if(!staticsTimeList.contains(yearString)){
|
||||||
|
staticsTimeList.add(yearString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String staticsTime :staticsTimeList
|
||||||
|
) {
|
||||||
|
double actualCreditBillYear=0;
|
||||||
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||||
|
) {
|
||||||
|
String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4);
|
||||||
|
if(staticsTime.equals(yearString)){
|
||||||
|
if(vo.getDealType().equals("1")){
|
||||||
|
actualCreditBillYear+=vo.getAmount();
|
||||||
|
}
|
||||||
|
if(vo.getDealType().equals("2")){
|
||||||
|
actualCreditBillYear-=vo.getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AccountsDealRecordVo analysisVo=new AccountsDealRecordVo();
|
||||||
|
analysisVo.setAmount(actualCreditBillYear);
|
||||||
|
analysisVo.setRemark(staticsTime);
|
||||||
|
queryList.add(analysisVo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<Map<String, Object>> acccountsList = new ArrayList<>();
|
||||||
|
ArrayList<Map<String, Object>> tableAccountsList = new ArrayList<>();
|
||||||
|
for (AccountsDealRecordVo vo:queryList
|
||||||
|
) {
|
||||||
|
Map<String, Object> datamap = new HashMap<>();
|
||||||
|
datamap.put("time", vo.getRemark());
|
||||||
|
datamap.put("value", decimalFormat.format(vo.getAmount()));
|
||||||
|
datamap.put("detail", vo.getName());
|
||||||
|
tableAccountsList.add(datamap);
|
||||||
|
}
|
||||||
|
Collections.reverse(queryList);
|
||||||
|
for (AccountsDealRecordVo vo:queryList
|
||||||
|
) {
|
||||||
|
Map<String, Object> datamap = new HashMap<>();
|
||||||
|
datamap.put("time", vo.getRemark());
|
||||||
|
datamap.put("value", decimalFormat.format(vo.getAmount()));
|
||||||
|
acccountsList.add(datamap);
|
||||||
|
}
|
||||||
|
//列表
|
||||||
|
map.put("acccountsList",acccountsList);
|
||||||
|
map.put("tableAccountsList",tableAccountsList);
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,13 +225,13 @@ public class InvestJobImpl implements IInvestJobService
|
|||||||
//支出金额
|
//支出金额
|
||||||
creditDeal.setAmount(installmentHistoryDetail.getInterest());
|
creditDeal.setAmount(installmentHistoryDetail.getInterest());
|
||||||
//实时余额
|
//实时余额
|
||||||
creditDeal.setCurrentBalance(creditAccount.getBalance());
|
creditDeal.setCurrentBalance(creditAccount.getBalance()-installmentHistoryDetail.getPrincipal());
|
||||||
//1储蓄卡,2 信用卡,3 网贷,4 人情,5 投资账户
|
//1储蓄卡,2 信用卡,3 网贷,4 人情,5 投资账户
|
||||||
creditDeal.setType("2");
|
creditDeal.setType("2");
|
||||||
//1 收入,2 支出,3 转账,4 借贷
|
//1 收入,2 支出,3 转账,4 借贷
|
||||||
creditDeal.setDealType("2");
|
creditDeal.setDealType("2");
|
||||||
//分期利息支出
|
//分期利息支出
|
||||||
creditDeal.setDealCategory("10");
|
creditDeal.setDealCategory("14");
|
||||||
creditDeal.setName(creditAccount.getName()+"("+ StringUtils.getLastNumberChars(4,creditAccount.getCode()+")"));
|
creditDeal.setName(creditAccount.getName()+"("+ StringUtils.getLastNumberChars(4,creditAccount.getCode()+")"));
|
||||||
creditDeal.setRemark("分期利息");
|
creditDeal.setRemark("分期利息");
|
||||||
creditDeal.setCreateBy(creditAccount.getCreateBy());
|
creditDeal.setCreateBy(creditAccount.getCreateBy());
|
||||||
|
|||||||
@@ -49,4 +49,102 @@
|
|||||||
${params.dataScope}
|
${params.dataScope}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<resultMap type="AccountsDealRecordVo" id="AccountsDealRecordResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="name" column="name" />
|
||||||
|
<result property="code" column="code" />
|
||||||
|
<result property="type" column="type" />
|
||||||
|
<result property="accountId" column="account_id" />
|
||||||
|
<result property="amount" column="amount" />
|
||||||
|
<result property="dealType" column="deal_type" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="delFlag" column="del_flag" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="dealCategory" column="deal_category" />
|
||||||
|
<result property="accountName" column="account_name" />
|
||||||
|
<result property="transferRecordId" column="transfer_record_id" />
|
||||||
|
<result property="currentBalance" column="current_balance" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectAccountsOutInList" parameterType="AccountsDealRecordDto" resultMap="AccountsDealRecordResult">
|
||||||
|
select
|
||||||
|
a.*
|
||||||
|
from
|
||||||
|
(
|
||||||
|
select
|
||||||
|
atr.id ,
|
||||||
|
'13' as deal_category,
|
||||||
|
'2' as deal_type,
|
||||||
|
atr.commission as amount,
|
||||||
|
atr.create_time ,
|
||||||
|
atr.pos_id as account_id ,
|
||||||
|
atr.create_by,
|
||||||
|
p."name" as account_name ,
|
||||||
|
p.code
|
||||||
|
from
|
||||||
|
accounts_transfer_record atr
|
||||||
|
left join accounts p on
|
||||||
|
p.id = atr.pos_id
|
||||||
|
where
|
||||||
|
atr."type" = '1'
|
||||||
|
and atr.del_flag = '0'
|
||||||
|
union
|
||||||
|
select
|
||||||
|
ihd.id ,
|
||||||
|
case
|
||||||
|
when ihd."type" = '2' then '14'
|
||||||
|
when ihd."type" = '3' then '15'
|
||||||
|
end as deal_category,
|
||||||
|
'2' as deal_type,
|
||||||
|
ihd.interest as amount,
|
||||||
|
ihd.repayment_date as create_time,
|
||||||
|
ihd.bank_card_lend_id as account_id ,
|
||||||
|
ihd.create_by,
|
||||||
|
a."name" as account_name ,
|
||||||
|
a.code
|
||||||
|
from
|
||||||
|
installment_history_detail ihd
|
||||||
|
left join accounts a on
|
||||||
|
a.id = ihd.bank_card_lend_id
|
||||||
|
where
|
||||||
|
ihd.del_flag = '0'
|
||||||
|
union
|
||||||
|
select
|
||||||
|
adr.id ,
|
||||||
|
adr.deal_category,
|
||||||
|
adr.deal_type,
|
||||||
|
adr.amount,
|
||||||
|
adr.create_time ,
|
||||||
|
adr.account_id ,
|
||||||
|
adr.create_by,
|
||||||
|
a."name" as account_name ,
|
||||||
|
a.code
|
||||||
|
from
|
||||||
|
accounts_deal_record adr
|
||||||
|
left join accounts a on
|
||||||
|
a.id = adr.account_id
|
||||||
|
where
|
||||||
|
adr.del_flag = '0'
|
||||||
|
and adr.deal_category = '1'
|
||||||
|
or adr.deal_category = '2'
|
||||||
|
or adr.deal_category = '11'
|
||||||
|
) a
|
||||||
|
<where>
|
||||||
|
1=1
|
||||||
|
<if test="endTime!=null and endTime !=''">
|
||||||
|
and #{endTime}>=to_char(a.create_time, 'yyyy-MM-dd')
|
||||||
|
</if>
|
||||||
|
<if test="startTime!=null and startTime !=''">
|
||||||
|
and to_char(a.create_time, 'yyyy-MM-dd')>=#{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="dealCategory != null and dealCategory != ''"> and a.deal_category = #{dealCategory}</if>
|
||||||
|
</where>
|
||||||
|
<!-- 数据范围过滤 -->
|
||||||
|
${params.dataScope}
|
||||||
|
order by a.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user