fix: 定时job修改,信用卡分期已入账后修改主表已还期数。

This commit is contained in:
tianyongbao
2024-05-13 13:11:00 +08:00
parent ba154d8e32
commit 422395d49b
2 changed files with 64 additions and 8 deletions

View File

@@ -5,13 +5,16 @@ import com.ruoyi.common.core.utils.IdWorker;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.invest.domain.AccountsDealRecord;
import com.ruoyi.invest.domain.InstallmentHistory;
import com.ruoyi.invest.domain.InstallmentHistoryDetail;
import com.ruoyi.invest.domain.dto.InstallmentHistoryDetailDto;
import com.ruoyi.invest.domain.vo.AccountsVo;
import com.ruoyi.invest.domain.vo.InstallmentHistoryDetailVo;
import com.ruoyi.invest.domain.vo.InstallmentHistoryVo;
import com.ruoyi.invest.mapper.AccountsDealRecordMapper;
import com.ruoyi.invest.mapper.AccountsMapper;
import com.ruoyi.invest.mapper.InstallmentHistoryDetailMapper;
import com.ruoyi.invest.mapper.InstallmentHistoryMapper;
import com.ruoyi.invest.service.IInstallmentHistoryDetailService;
import org.springframework.stereotype.Service;
@@ -37,6 +40,9 @@ public class InstallmentHistoryDetailServiceImpl implements IInstallmentHistoryD
@Resource
private AccountsDealRecordMapper accountsDealRecordMapper;
@Resource
private InstallmentHistoryMapper installmentHistoryMapper;
/**
* 查询分期历史明细
*
@@ -89,6 +95,16 @@ public class InstallmentHistoryDetailServiceImpl implements IInstallmentHistoryD
{
installmentHistoryDetail.setUpdateBy(SecurityUtils.getUsername());
installmentHistoryDetail.setUpdateTime(DateUtils.getNowDate());
//如果是已入账,更新主表已还期数。
if("1".equals(installmentHistoryDetail.getPostingState())){
//更新主表已还期数
InstallmentHistoryVo historyVo=installmentHistoryMapper.selectInstallmentHistoryById(installmentHistoryDetail.getInstallmentHistoryId());
InstallmentHistory his=new InstallmentHistory();
his.setRepaidPeriod(historyVo.getRepaidPeriod()+1);
his.setId(historyVo.getId());
his.setUpdateTime(new Date());
installmentHistoryMapper.updateInstallmentHistory(his);
}
//如果是信用卡分期
if(installmentHistoryDetail.getType().equals("2")){
//已入账

View File

@@ -6,6 +6,7 @@ import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.invest.domain.AccountsDealRecord;
import com.ruoyi.invest.domain.CreditCardBill;
import com.ruoyi.invest.domain.InstallmentHistory;
import com.ruoyi.invest.domain.InstallmentHistoryDetail;
import com.ruoyi.invest.domain.dto.AccountsDealRecordDto;
import com.ruoyi.invest.domain.dto.BankCardLendDto;
@@ -20,9 +21,7 @@ import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
@@ -47,7 +46,8 @@ public class InvestJobImpl implements IInvestJobService
@Resource
private InstallmentHistoryDetailMapper installmentHistoryDetailMapper;
@Resource
private InstallmentHistoryMapper installmentHistoryMapper;
/**
* 生成数据
@@ -201,7 +201,13 @@ public class InvestJobImpl implements IInvestJobService
int daysDiff = Long.valueOf(TimeUnit.MILLISECONDS.toDays(diffInMillis)).intValue();
//入账日期小于一个月的
if("1".equals(installmentHistoryDetail.getPostingState())&&daysDiff<31){
//更新主表已还期数
InstallmentHistoryVo historyVo=installmentHistoryMapper.selectInstallmentHistoryById(installmentHistoryDetail.getInstallmentHistoryId());
InstallmentHistory his=new InstallmentHistory();
his.setRepaidPeriod(historyVo.getRepaidPeriod()+1);
his.setId(historyVo.getId());
his.setUpdateTime(new Date());
installmentHistoryMapper.updateInstallmentHistory(his);
//信用卡账户余额计算
AccountsVo creditAccount=accountsMapper.selectAccountsById(installmentHistoryDetail.getBankCardLendId());
creditAccount.setBalance(creditAccount.getBalance()-installmentHistoryDetail.getInterest());
@@ -229,8 +235,8 @@ public class InvestJobImpl implements IInvestJobService
creditDeal.setRemark("分期利息");
creditDeal.setCreateBy(SecurityUtils.getUsername());
creditDeal.setCreateTime(new Date());
accountsDealRecordMapper.insertAccountsDealRecord(creditDeal);
// accountsDealRecordMapper.insertAccountsDealRecord(creditDeal);
insertAccountsDealRecord(creditDeal);
}
//信用卡消费记录明细,应还本金
AccountsDealRecord creditDealPrinciple=new AccountsDealRecord();
@@ -251,7 +257,8 @@ public class InvestJobImpl implements IInvestJobService
creditDealPrinciple.setRemark("应还本金");
creditDealPrinciple.setCreateBy(SecurityUtils.getUsername());
creditDealPrinciple.setCreateTime(new Date());
accountsDealRecordMapper.insertAccountsDealRecord(creditDealPrinciple);
// accountsDealRecordMapper.insertAccountsDealRecord(creditDealPrinciple);
insertAccountsDealRecord(creditDealPrinciple);
}
@@ -260,5 +267,38 @@ public class InvestJobImpl implements IInvestJobService
}
public int insertAccountsDealRecord(AccountsDealRecord accountsDealRecord)
{
accountsDealRecord.setCreateBy(SecurityUtils.getUsername());
accountsDealRecord.setId(IdWorker.getId());
//获取最新一条记录的数据,计算余额
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();
lastOneAccountsDealRecord.setCurrentBalance(0d);
}
//收入
if(accountsDealRecord.getDealType().equals("1")){
Map<String, Object> map = new HashMap<>();
map.put("startDateTime", accountsDealRecord.getCreateTime());
map.put("accountId", accountsDealRecord.getAccountId());
map.put("currentBalance", accountsDealRecord.getAmount());
accountsDealRecordMapper.batchPlusCurrentBalance(map);
}
//支出
if(accountsDealRecord.getDealType().equals("2")){
Map<String, Object> map = new HashMap<>();
map.put("startDateTime", accountsDealRecord.getCreateTime());
map.put("accountId", accountsDealRecord.getAccountId());
map.put("currentBalance", accountsDealRecord.getAmount());
accountsDealRecordMapper.batchMinusCurrentBalance(map);
}
return accountsDealRecordMapper.insertAccountsDealRecord(accountsDealRecord);
}
}