fix: 记账管理相关功能优化,可删除编辑数据。
This commit is contained in:
@@ -1,30 +1,23 @@
|
|||||||
package com.ruoyi.invest.controller;
|
package com.ruoyi.invest.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
import java.io.IOException;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import javax.annotation.Resource;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
import com.ruoyi.invest.domain.AccountsTransferRecord;
|
import com.ruoyi.invest.domain.AccountsTransferRecord;
|
||||||
import com.ruoyi.invest.domain.vo.AccountsTransferRecordVo;
|
|
||||||
import com.ruoyi.invest.domain.dto.AccountsTransferRecordDto;
|
import com.ruoyi.invest.domain.dto.AccountsTransferRecordDto;
|
||||||
|
import com.ruoyi.invest.domain.vo.AccountsTransferRecordVo;
|
||||||
import com.ruoyi.invest.service.IAccountsTransferRecordService;
|
import com.ruoyi.invest.service.IAccountsTransferRecordService;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账户转账记录Controller
|
* 账户转账记录Controller
|
||||||
|
|||||||
@@ -65,4 +65,7 @@ public class AccountsDealRecordDto extends BaseEntity implements Serializable
|
|||||||
@ApiModelProperty(value="交易子类别")
|
@ApiModelProperty(value="交易子类别")
|
||||||
private String childCategory;
|
private String childCategory;
|
||||||
|
|
||||||
|
/** 转账记录id */
|
||||||
|
private Long transferRecordId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ public class AccountsDealRecordServiceImpl implements IAccountsDealRecordService
|
|||||||
AccountsDealRecord lastOneAccountsDealRecord=accountsDealRecordMapper.getLastOneAccountsDealRecordByMap(lastMap);
|
AccountsDealRecord lastOneAccountsDealRecord=accountsDealRecordMapper.getLastOneAccountsDealRecordByMap(lastMap);
|
||||||
if(lastOneAccountsDealRecord==null){
|
if(lastOneAccountsDealRecord==null){
|
||||||
lastOneAccountsDealRecord=new AccountsDealRecord();
|
lastOneAccountsDealRecord=new AccountsDealRecord();
|
||||||
lastOneAccountsDealRecord.setCurrentBalance(0d);
|
AccountsVo accountsVo=accountsMapper.selectAccountsById(accountsDealRecord.getAccountId());
|
||||||
|
lastOneAccountsDealRecord.setCurrentBalance(accountsVo.getBalance());
|
||||||
}
|
}
|
||||||
//收入
|
//收入
|
||||||
if(accountsDealRecord.getDealType().equals("1")){
|
if(accountsDealRecord.getDealType().equals("1")){
|
||||||
@@ -159,9 +160,16 @@ public class AccountsDealRecordServiceImpl implements IAccountsDealRecordService
|
|||||||
@Override
|
@Override
|
||||||
public int updateAccountsDealRecord(AccountsDealRecord accountsDealRecord)
|
public int updateAccountsDealRecord(AccountsDealRecord accountsDealRecord)
|
||||||
{
|
{
|
||||||
|
//编辑时,先物理删除数据,再插入一条新数据,否则计算太繁琐,简单处理
|
||||||
|
long id=accountsDealRecord.getId();
|
||||||
|
updateDeleteDealRecord(id);
|
||||||
|
accountsDealRecordMapper.deleteAccountsDealRecordById(id);
|
||||||
|
//删除后,将id设置为空,进行插入操作
|
||||||
|
accountsDealRecord.setId(null);
|
||||||
accountsDealRecord.setUpdateBy(SecurityUtils.getUsername());
|
accountsDealRecord.setUpdateBy(SecurityUtils.getUsername());
|
||||||
accountsDealRecord.setUpdateTime(DateUtils.getNowDate());
|
accountsDealRecord.setUpdateTime(DateUtils.getNowDate());
|
||||||
return accountsDealRecordMapper.updateAccountsDealRecord(accountsDealRecord);
|
//插入更新后的数据
|
||||||
|
return insertAccountsDealRecord(accountsDealRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -200,9 +208,11 @@ public class AccountsDealRecordServiceImpl implements IAccountsDealRecordService
|
|||||||
lastMap.put("startDateTime", accountsDealRecord.getCreateTime());
|
lastMap.put("startDateTime", accountsDealRecord.getCreateTime());
|
||||||
lastMap.put("accountId", accountsDealRecord.getAccountId());
|
lastMap.put("accountId", accountsDealRecord.getAccountId());
|
||||||
AccountsDealRecord lastOneAccountsDealRecord=accountsDealRecordMapper.getLastOneAccountsDealRecordByMap(lastMap);
|
AccountsDealRecord lastOneAccountsDealRecord=accountsDealRecordMapper.getLastOneAccountsDealRecordByMap(lastMap);
|
||||||
|
//如果沒有记录,取最新的账户数据
|
||||||
if(lastOneAccountsDealRecord==null){
|
if(lastOneAccountsDealRecord==null){
|
||||||
lastOneAccountsDealRecord=new AccountsDealRecord();
|
lastOneAccountsDealRecord=new AccountsDealRecord();
|
||||||
lastOneAccountsDealRecord.setCurrentBalance(0d);
|
AccountsVo accountsVo=accountsMapper.selectAccountsById(accountsDealRecord.getAccountId());
|
||||||
|
lastOneAccountsDealRecord.setCurrentBalance(accountsVo.getAvailableLimit());
|
||||||
}
|
}
|
||||||
//收入
|
//收入
|
||||||
if(accountsDealRecord.getDealType().equals("1")){
|
if(accountsDealRecord.getDealType().equals("1")){
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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.AccountsDealRecord;
|
import com.ruoyi.invest.domain.AccountsDealRecord;
|
||||||
import com.ruoyi.invest.domain.AccountsTransferRecord;
|
import com.ruoyi.invest.domain.AccountsTransferRecord;
|
||||||
|
import com.ruoyi.invest.domain.dto.AccountsDealRecordDto;
|
||||||
import com.ruoyi.invest.domain.dto.AccountsTransferRecordDto;
|
import com.ruoyi.invest.domain.dto.AccountsTransferRecordDto;
|
||||||
import com.ruoyi.invest.domain.vo.*;
|
import com.ruoyi.invest.domain.vo.*;
|
||||||
import com.ruoyi.invest.mapper.*;
|
import com.ruoyi.invest.mapper.*;
|
||||||
@@ -60,6 +61,14 @@ public class AccountsTransferRecordServiceImpl implements IAccountsTransferRecor
|
|||||||
vo.setInAccountId(vo.getOutAccountId());
|
vo.setInAccountId(vo.getOutAccountId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(vo.getPosId()!=null){
|
||||||
|
|
||||||
|
PosMachineVo pos=posMachineMapper.selectPosMachineById(vo.getPosId());
|
||||||
|
//存入数据时,按实际来,需要重新计算下
|
||||||
|
BigDecimal bg = BigDecimal.valueOf(pos.getRate());
|
||||||
|
vo.setRate(bg.multiply(new BigDecimal(100)).doubleValue());
|
||||||
|
vo.setRatePlus(pos.getRatePlus());
|
||||||
|
}
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,9 +129,16 @@ public class AccountsTransferRecordServiceImpl implements IAccountsTransferRecor
|
|||||||
@Override
|
@Override
|
||||||
public int updateAccountsTransferRecord(AccountsTransferRecord accountsTransferRecord)
|
public int updateAccountsTransferRecord(AccountsTransferRecord accountsTransferRecord)
|
||||||
{
|
{
|
||||||
|
//先删除,再进行插入操作
|
||||||
|
Long[] ids=new Long[1];
|
||||||
|
ids[0]=accountsTransferRecord.getId();
|
||||||
|
deleteAccountsTransferRecordByIds(ids);
|
||||||
|
|
||||||
|
//删除后,将id设置为空,进行插入操作
|
||||||
|
accountsTransferRecord.setId(null);
|
||||||
accountsTransferRecord.setUpdateBy(SecurityUtils.getUsername());
|
accountsTransferRecord.setUpdateBy(SecurityUtils.getUsername());
|
||||||
accountsTransferRecord.setUpdateTime(DateUtils.getNowDate());
|
accountsTransferRecord.setUpdateTime(DateUtils.getNowDate());
|
||||||
return accountsTransferRecordMapper.updateAccountsTransferRecord(accountsTransferRecord);
|
return insertAccountsTransferRecord(accountsTransferRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,9 +150,72 @@ public class AccountsTransferRecordServiceImpl implements IAccountsTransferRecor
|
|||||||
@Override
|
@Override
|
||||||
public int deleteAccountsTransferRecordByIds(Long[] ids)
|
public int deleteAccountsTransferRecordByIds(Long[] ids)
|
||||||
{
|
{
|
||||||
|
//遍历转账记录,获取对应的交易记录,再进行遍历删除
|
||||||
|
for (Long id : ids) {
|
||||||
|
AccountsDealRecordDto accountsDealRecordDto=new AccountsDealRecordDto();
|
||||||
|
accountsDealRecordDto.setTransferRecordId(id);
|
||||||
|
//获取对应的交易记录
|
||||||
|
List<AccountsDealRecordVo> list=accountsDealRecordMapper.selectAccountsDealRecordList(accountsDealRecordDto);
|
||||||
|
//遍历交易记录进行数据更新
|
||||||
|
for (AccountsDealRecordVo accountDeal : list) {
|
||||||
|
updateDeleteDealRecord(accountDeal.getId());
|
||||||
|
}
|
||||||
|
//更新完成后,根据转账记录id进行物理删除
|
||||||
|
accountsDealRecordMapper.deleteAccountsDealRecordByTransferId(id);
|
||||||
|
}
|
||||||
|
//全部删除后,对记录进行删除
|
||||||
return accountsTransferRecordMapper.removeAccountsTransferRecordByIds(ids);
|
return accountsTransferRecordMapper.removeAccountsTransferRecordByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void updateDeleteDealRecord(Long id){
|
||||||
|
//获取交易记录,删除的话,收入需要减回去,支出需要加回来。
|
||||||
|
AccountsDealRecordVo accountsDealRecord=accountsDealRecordMapper.selectAccountsDealRecordById(id);
|
||||||
|
//获取最新一条记录的数据,计算余额
|
||||||
|
Map<String, Object> lastMap = new HashMap<>();
|
||||||
|
lastMap.put("startDateTime", accountsDealRecord.getCreateTime());
|
||||||
|
lastMap.put("accountId", accountsDealRecord.getAccountId());
|
||||||
|
AccountsDealRecord lastOneAccountsDealRecord=accountsDealRecordMapper.getLastOneAccountsDealRecordByMap(lastMap);
|
||||||
|
if(lastOneAccountsDealRecord==null){
|
||||||
|
lastOneAccountsDealRecord=new AccountsDealRecord();
|
||||||
|
AccountsVo accountsVo=accountsMapper.selectAccountsById(accountsDealRecord.getAccountId());
|
||||||
|
lastOneAccountsDealRecord.setCurrentBalance(accountsVo.getBalance());
|
||||||
|
}
|
||||||
|
//收入
|
||||||
|
if(accountsDealRecord.getDealType().equals("1")){
|
||||||
|
//收入账户余额计算
|
||||||
|
AccountsVo inAccount=accountsMapper.selectAccountsById(accountsDealRecord.getAccountId());
|
||||||
|
inAccount.setBalance(inAccount.getBalance()-accountsDealRecord.getAmount());
|
||||||
|
inAccount.setAvailableLimit(inAccount.getAvailableLimit()-accountsDealRecord.getAmount());
|
||||||
|
accountsDealRecord.setCurrentBalance(lastOneAccountsDealRecord.getCurrentBalance()-accountsDealRecord.getAmount());
|
||||||
|
accountsMapper.updateAccounts(inAccount);
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("startDateTime", accountsDealRecord.getCreateTime());
|
||||||
|
map.put("accountId", accountsDealRecord.getAccountId());
|
||||||
|
map.put("currentBalance", accountsDealRecord.getAmount());
|
||||||
|
|
||||||
|
accountsDealRecordMapper.batchMinusCurrentBalance(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
//支出
|
||||||
|
if(accountsDealRecord.getDealType().equals("2")){
|
||||||
|
//支出余额计算
|
||||||
|
AccountsVo outAccount=accountsMapper.selectAccountsById(accountsDealRecord.getAccountId());
|
||||||
|
outAccount.setBalance(outAccount.getBalance()+accountsDealRecord.getAmount());
|
||||||
|
outAccount.setAvailableLimit(outAccount.getAvailableLimit()+accountsDealRecord.getAmount());
|
||||||
|
accountsDealRecord.setCurrentBalance(lastOneAccountsDealRecord.getCurrentBalance()+accountsDealRecord.getAmount());
|
||||||
|
accountsMapper.updateAccounts(outAccount);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("startDateTime", accountsDealRecord.getCreateTime());
|
||||||
|
map.put("accountId", accountsDealRecord.getAccountId());
|
||||||
|
map.put("currentBalance", accountsDealRecord.getAmount());
|
||||||
|
|
||||||
|
accountsDealRecordMapper.batchPlusCurrentBalance(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除账户转账记录信息
|
* 删除账户转账记录信息
|
||||||
*
|
*
|
||||||
@@ -146,6 +225,7 @@ public class AccountsTransferRecordServiceImpl implements IAccountsTransferRecor
|
|||||||
@Override
|
@Override
|
||||||
public int deleteAccountsTransferRecordById(Long id)
|
public int deleteAccountsTransferRecordById(Long id)
|
||||||
{
|
{
|
||||||
|
|
||||||
return accountsTransferRecordMapper.removeAccountsTransferRecordById(id);
|
return accountsTransferRecordMapper.removeAccountsTransferRecordById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +270,7 @@ public class AccountsTransferRecordServiceImpl implements IAccountsTransferRecor
|
|||||||
//信用卡账户余额计算
|
//信用卡账户余额计算
|
||||||
AccountsVo creditAccount=accountsMapper.selectAccountsById(creditVo.getId());
|
AccountsVo creditAccount=accountsMapper.selectAccountsById(creditVo.getId());
|
||||||
creditAccount.setBalance(creditAccount.getBalance()-accountsTransferRecord.getAmount());
|
creditAccount.setBalance(creditAccount.getBalance()-accountsTransferRecord.getAmount());
|
||||||
creditAccount.setAvailableLimit(creditAccount.getBalance()+creditAccount.getCreditLimit());
|
creditAccount.setAvailableLimit(creditAccount.getAvailableLimit()-accountsTransferRecord.getAmount());
|
||||||
creditAccount.setUpdateTime(accountsTransferRecord.getCreateTime());
|
creditAccount.setUpdateTime(accountsTransferRecord.getCreateTime());
|
||||||
accountsMapper.updateAccounts(creditAccount);
|
accountsMapper.updateAccounts(creditAccount);
|
||||||
//信用卡消费记录明细
|
//信用卡消费记录明细
|
||||||
@@ -292,7 +372,8 @@ public class AccountsTransferRecordServiceImpl implements IAccountsTransferRecor
|
|||||||
//信用卡账户余额计算
|
//信用卡账户余额计算
|
||||||
AccountsVo creditAccount=accountsMapper.selectAccountsById(creditVo.getId());
|
AccountsVo creditAccount=accountsMapper.selectAccountsById(creditVo.getId());
|
||||||
creditAccount.setBalance(creditAccount.getBalance()+accountsTransferRecord.getAmount());
|
creditAccount.setBalance(creditAccount.getBalance()+accountsTransferRecord.getAmount());
|
||||||
creditAccount.setAvailableLimit(creditAccount.getBalance()+creditAccount.getCreditLimit());
|
//可用额度,等于之前的可用额度加上还款后的额度
|
||||||
|
creditAccount.setAvailableLimit(creditAccount.getAvailableLimit()+accountsTransferRecord.getAmount());
|
||||||
creditAccount.setUpdateTime(accountsTransferRecord.getCreateTime());
|
creditAccount.setUpdateTime(accountsTransferRecord.getCreateTime());
|
||||||
accountsMapper.updateAccounts(creditAccount);
|
accountsMapper.updateAccounts(creditAccount);
|
||||||
//信用卡消费记录明细
|
//信用卡消费记录明细
|
||||||
|
|||||||
@@ -241,7 +241,15 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
|
|||||||
map.put("lastMonthUsedLimit",decimalFormat.format(lastMonthUsedLimit));
|
map.put("lastMonthUsedLimit",decimalFormat.format(lastMonthUsedLimit));
|
||||||
|
|
||||||
|
|
||||||
map.put("lastMonthUsedRate",decimalFormat.format(lastMonthUsedLimit*100/creditLimit));
|
//使用率
|
||||||
|
double lastMonthUsedRate;
|
||||||
|
if (creditLimit != 0) {
|
||||||
|
lastMonthUsedRate= ((lastMonthUsedLimit) * 100) /creditLimit;
|
||||||
|
}else {
|
||||||
|
lastMonthUsedRate= 0;
|
||||||
|
}
|
||||||
|
map.put("lastMonthUsedRate", decimalFormat.format(lastMonthUsedRate));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//近6个月月信用卡账单
|
//近6个月月信用卡账单
|
||||||
@@ -258,7 +266,14 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
|
|||||||
double lastSixMonthUsedLimit = creditCardBillList.stream().mapToDouble(CreditCardBillVo::getBillAmount).sum();
|
double lastSixMonthUsedLimit = creditCardBillList.stream().mapToDouble(CreditCardBillVo::getBillAmount).sum();
|
||||||
map.put("lastSixMonthUsedLimit",decimalFormat.format(lastSixMonthUsedLimit/6));
|
map.put("lastSixMonthUsedLimit",decimalFormat.format(lastSixMonthUsedLimit/6));
|
||||||
//近6个月月信用卡使用率
|
//近6个月月信用卡使用率
|
||||||
map.put("lastSixMonthUsedRate",decimalFormat.format(lastSixMonthUsedLimit*100/(6*creditLimit)));
|
double lastSixMonthUsedRate;
|
||||||
|
if (creditLimit != 0) {
|
||||||
|
lastSixMonthUsedRate= lastSixMonthUsedLimit*100/(6*creditLimit);
|
||||||
|
}else {
|
||||||
|
lastSixMonthUsedRate= 0;
|
||||||
|
}
|
||||||
|
map.put("lastSixMonthUsedRate", decimalFormat.format(lastSixMonthUsedRate));
|
||||||
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
a.del_flag='0'
|
a.del_flag='0'
|
||||||
<if test="name != null and name != ''"> and (a2."name" like '%'|| #{name}||'%' or a2."code" like '%'|| #{name}||'%')</if>
|
<if test="name != null and name != ''"> and (a2."name" like '%'|| #{name}||'%' or a2."code" like '%'|| #{name}||'%')</if>
|
||||||
<if test="type != null and type != ''"> and a.type = #{type}</if>
|
<if test="type != null and type != ''"> and a.type = #{type}</if>
|
||||||
|
<if test="transferRecordId != null and transferRecordId != ''"> and a.transfer_record_id = #{transferRecordId}</if>
|
||||||
<if test="accountId != null and accountId != ''"> and a.account_id = #{accountId}</if>
|
<if test="accountId != null and accountId != ''"> and a.account_id = #{accountId}</if>
|
||||||
<if test="dealType != null and dealType != ''"> and a.deal_type = #{dealType}</if>
|
<if test="dealType != null and dealType != ''"> and a.deal_type = #{dealType}</if>
|
||||||
<if test="dealCategory != null and dealCategory != ''"> and a.deal_category = #{dealCategory}</if>
|
<if test="dealCategory != null and dealCategory != ''"> and a.deal_category = #{dealCategory}</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user