@@ -2,18 +2,17 @@ package com.ruoyi.job.service.impl;
import com.ruoyi.common.core.utils.DateUtils ;
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.CreditCardBill ;
import com.ruoyi.invest.domain.InstallmentHistoryDetail ;
import com.ruoyi.invest.domain.dto.AccountsDealRecordDto ;
import com.ruoyi.invest.domain.dto.BankCardLendDto ;
import com.ruoyi.invest.domain.dto.CreditCardBillDto ;
import com.ruoyi.invest.domain.vo.AccountsDealRecordV o ;
import com.ruoyi.invest.domain.vo.BankCardLendVo ;
import com.ruoyi.invest.domain.vo.CreditCardBillVo ;
import com.ruoyi.invest.mapper.AccountsDealRecordMapper ;
import com.ruoyi.invest.mapper.AccountsMapper ;
import com.ruoyi.invest.mapper.BankCardLendMapper ;
import com.ruoyi.invest.mapper.CreditCardBillMapper ;
import com.ruoyi.invest.domain.dto.InstallmentHistoryDetailDt o ;
import com.ruoyi.invest.domain.vo.* ;
import com.ruoyi.invest.mapper.* ;
import com.ruoyi.job.service.IInvestJobService ;
import org.springframework.stereotype.Service ;
@@ -23,6 +22,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar ;
import java.util.Date ;
import java.util.List ;
import java.util.concurrent.TimeUnit ;
/**
* 生成数据
@@ -44,6 +44,9 @@ public class InvestJobImpl implements IInvestJobService
@Resource
private CreditCardBillMapper creditCardBillMapper ;
@Resource
private InstallmentHistoryDetailMapper installmentHistoryDetailMapper ;
/**
* 生成数据
@@ -160,6 +163,64 @@ public class InvestJobImpl implements IInvestJobService
SimpleDateFormat sdf = new SimpleDateFormat ( " yyyy-MM-dd " ) ;
// 格式化日期为字符串
String formattedDate = sdf . format ( currentDate ) ;
InstallmentHistoryDetailDto installmentHistoryDetailDto = new InstallmentHistoryDetailDto ( ) ;
installmentHistoryDetailDto . setRepaymentEqualDate ( formattedDate ) ;
installmentHistoryDetailDto . setState ( " 0 " ) ;
List < InstallmentHistoryDetailVo > historyDetailList = installmentHistoryDetailMapper . selectInstallmentHistoryDetailList ( installmentHistoryDetailDto ) ;
//修改名称加卡号
for ( InstallmentHistoryDetailVo installmentHistoryDetail : historyDetailList ) {
installmentHistoryDetail . setPostingState ( " 1 " ) ;
InstallmentHistoryDetail detail = new InstallmentHistoryDetail ( ) ;
detail . setUpdateBy ( SecurityUtils . getUsername ( ) ) ;
detail . setUpdateTime ( DateUtils . getNowDate ( ) ) ;
detail . setId ( installmentHistoryDetail . getId ( ) ) ;
detail . setPostingState ( installmentHistoryDetail . getPostingState ( ) ) ;
installmentHistoryDetailMapper . updateInstallmentHistoryDetail ( detail ) ;
//如果是信用卡分期
if ( installmentHistoryDetail . getType ( ) . equals ( " 2 " ) ) {
//已入账
Calendar cal1 = Calendar . getInstance ( ) ;
cal1 . setTime ( installmentHistoryDetail . getRepaymentDate ( ) ) ;
Calendar cal2 = Calendar . getInstance ( ) ;
cal2 . setTime ( new Date ( ) ) ;
long diffInMillis = cal2 . getTimeInMillis ( ) - cal1 . getTimeInMillis ( ) ;
int daysDiff = Long . valueOf ( TimeUnit . MILLISECONDS . toDays ( diffInMillis ) ) . intValue ( ) ;
//入账日期小于一个月的
if ( " 1 " . equals ( installmentHistoryDetail . getPostingState ( ) ) & & daysDiff < 31 ) {
//信用卡账户余额计算
AccountsVo creditAccount = accountsMapper . selectAccountsById ( installmentHistoryDetail . getBankCardLendId ( ) ) ;
creditAccount . setBalance ( creditAccount . getBalance ( ) - installmentHistoryDetail . getInterest ( ) ) ;
creditAccount . setAvailableLimit ( creditAccount . getBalance ( ) + creditAccount . getCreditLimit ( ) ) ;
creditAccount . setUpdateTime ( installmentHistoryDetail . getUpdateTime ( ) ) ;
accountsMapper . updateAccounts ( creditAccount ) ;
//信用卡消费记录明细
AccountsDealRecord creditDeal = new AccountsDealRecord ( ) ;
creditDeal . setTransferRecordId ( installmentHistoryDetail . getId ( ) ) ;
creditDeal . setAccountId ( creditAccount . getAccountId ( ) ) ;
creditDeal . setId ( IdWorker . getId ( ) ) ;
//支出金额
creditDeal . setAmount ( installmentHistoryDetail . getInterest ( ) ) ;
//实时余额
creditDeal . setCurrentBalance ( creditAccount . getBalance ( ) ) ;
//1储蓄卡, 2 信用卡, 3 网贷, 4 人情, 5 投资账户
creditDeal . setType ( " 2 " ) ;
//1 收入, 2 支出, 3 转账, 4 借贷
creditDeal . setDealType ( " 2 " ) ;
//分期利息支出
creditDeal . setDealCategory ( " 10 " ) ;
creditDeal . setName ( creditAccount . getName ( ) + " ( " + StringUtils . getLastNumberChars ( 4 , creditAccount . getCode ( ) + " ) " ) ) ;
creditDeal . setRemark ( " 分期利息 " ) ;
creditDeal . setCreateBy ( SecurityUtils . getUsername ( ) ) ;
creditDeal . setCreateTime ( installmentHistoryDetail . getUpdateTime ( ) ) ;
accountsDealRecordMapper . insertAccountsDealRecord ( creditDeal ) ;
}
}
}
}