fix: 贷款账单,功能完善,新增时插入数据,修改明细时也进行自动转账。

This commit is contained in:
tianyongbao
2025-10-19 12:34:21 +08:00
parent 52a07b2165
commit 49c91e45a9
7 changed files with 73 additions and 5 deletions

View File

@@ -74,9 +74,9 @@ public class InstallmentHistoryDetail extends BaseEntity
/** 还款期数 */
@ApiModelProperty(value="还款期数")
@Excel(name = "还款期数")
@Excel(name = "还款期数")
private Integer periods;
private Long repaymentAccountId;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -96,6 +96,7 @@ public class InstallmentHistoryDetail extends BaseEntity
.append("remark", getRemark())
.append("type", getType())
.append("periods", getPeriods())
.append("repaymentAccountId", getRepaymentAccountId())
.toString();
}
}

View File

@@ -15,6 +15,6 @@ public class InstallmentHistoryDetailVo extends InstallmentHistoryDetail
{
private String bankCardLendName;
private String repaymentAccountName;
}

View File

@@ -46,5 +46,8 @@ public class InstallmentHistoryVo extends InstallmentHistory
@ApiModelProperty(value="收款账户卡号")
private String receivingAccountCode;
@ApiModelProperty(value="收款账户名称卡号")
private String receivingAccountNameCode;
}

View File

@@ -759,7 +759,7 @@ public class AccountsTransferRecordServiceImpl implements IAccountsTransferRecor
}
AccountsDealRecord dealInterest=new AccountsDealRecord();
dealInterest.setTransferRecordId(accountsTransferRecord.getId());
dealInterest.setAccountId(debitAccount.getAccountId());
dealInterest.setId(IdWorker.getId());
//支出金额

View File

@@ -5,6 +5,7 @@ import com.intc.common.core.utils.IdWorker;
import com.intc.common.core.utils.StringUtils;
import com.intc.common.security.utils.SecurityUtils;
import com.intc.invest.domain.AccountsDealRecord;
import com.intc.invest.domain.AccountsTransferRecord;
import com.intc.invest.domain.InstallmentHistory;
import com.intc.invest.domain.InstallmentHistoryDetail;
import com.intc.invest.domain.dto.InstallmentHistoryDetailDto;
@@ -15,6 +16,7 @@ import com.intc.invest.mapper.AccountsDealRecordMapper;
import com.intc.invest.mapper.AccountsMapper;
import com.intc.invest.mapper.InstallmentHistoryDetailMapper;
import com.intc.invest.mapper.InstallmentHistoryMapper;
import com.intc.invest.service.IAccountsTransferRecordService;
import com.intc.invest.service.IInstallmentHistoryDetailService;
import org.springframework.stereotype.Service;
@@ -43,6 +45,9 @@ public class InstallmentHistoryDetailServiceImpl implements IInstallmentHistoryD
@Resource
private InstallmentHistoryMapper installmentHistoryMapper;
@Resource
private IAccountsTransferRecordService transferRecordService;
/**
* 查询分期历史明细
*
@@ -171,6 +176,21 @@ public class InstallmentHistoryDetailServiceImpl implements IInstallmentHistoryD
}
}
//如果是贷款
if(installmentHistoryDetail.getType().equals("3")){
AccountsTransferRecord transferRecord=new AccountsTransferRecord();
transferRecord.setOutAccountId(installmentHistoryDetail.getBankCardLendId());
transferRecord.setInAccountId(installmentHistoryDetail.getRepaymentAccountId());
transferRecord.setAmount(installmentHistoryDetail.getPrincipal());
transferRecord.setCommission(installmentHistoryDetail.getInterest());
transferRecord.setId(IdWorker.getId());
transferRecord.setCreateTime(new Date());
//借贷
transferRecord.setType("5");
//还款
transferRecord.setDealType("2");
transferRecordService.insertAccountsTransferRecord(transferRecord);
}
//应还款金额=本金加利息
installmentHistoryDetail.setCurrentAmount(installmentHistoryDetail.getPrincipal()+installmentHistoryDetail.getInterest());
return installmentHistoryDetailMapper.updateInstallmentHistoryDetail(installmentHistoryDetail);

View File

@@ -4,6 +4,7 @@ import com.intc.common.core.utils.DateUtils;
import com.intc.common.core.utils.IdWorker;
import com.intc.common.core.utils.StringUtils;
import com.intc.common.security.utils.SecurityUtils;
import com.intc.invest.domain.AccountsTransferRecord;
import com.intc.invest.domain.InstallmentHistory;
import com.intc.invest.domain.InstallmentHistoryDetail;
import com.intc.invest.domain.dto.InstallmentHistoryDetailDto;
@@ -12,6 +13,8 @@ import com.intc.invest.domain.vo.InstallmentHistoryDetailVo;
import com.intc.invest.domain.vo.InstallmentHistoryVo;
import com.intc.invest.mapper.InstallmentHistoryDetailMapper;
import com.intc.invest.mapper.InstallmentHistoryMapper;
import com.intc.invest.service.IAccountsTransferRecordService;
import com.intc.invest.service.ICreditCardBillService;
import com.intc.invest.service.IInstallmentHistoryService;
import org.springframework.stereotype.Service;
@@ -37,6 +40,10 @@ public class InstallmentHistoryServiceImpl implements IInstallmentHistoryService
@Resource
private InstallmentHistoryDetailMapper installmentHistoryDetailMapper;
@Resource
private IAccountsTransferRecordService transferRecordService;
/**
* 查询网贷及分期历史
*
@@ -82,6 +89,13 @@ public class InstallmentHistoryServiceImpl implements IInstallmentHistoryService
interestRate=interestRate*12/installmentHistory.getPeriod();
}
}
if(installmentHistory.getReceivingAccountCode()!=null){
installmentHistory.setReceivingAccountNameCode(installmentHistory.getReceivingAccountName()+""+ StringUtils.getLastNumberChars(4,installmentHistory.getReceivingAccountCode()+""));
}else {
installmentHistory.setReceivingAccountNameCode(installmentHistory.getReceivingAccountName());
}
interestRate=interestRate*100;
String calculateInterestRate= decimalFormat.format(interestRate)+"%";
installmentHistory.setCalculateInterestRate(calculateInterestRate);
@@ -121,6 +135,22 @@ public class InstallmentHistoryServiceImpl implements IInstallmentHistoryService
}
//插入分期明细
insertInstallmentHistoryDetail(installmentHistory);
//如果是信贷账户,需要生成一条借贷信息记录
if(installmentHistory.getType().equals("3")){
AccountsTransferRecord transferRecord=new AccountsTransferRecord();
transferRecord.setOutAccountId(installmentHistory.getBankCardLendId());
transferRecord.setInAccountId(installmentHistory.getReceivingAccountId());
transferRecord.setAmount(installmentHistory.getInstallmentAmount());
transferRecord.setId(IdWorker.getId());
transferRecord.setCreateTime(installmentHistory.getCreateTime());
//借贷
transferRecord.setType("5");
//借款
transferRecord.setDealType("1");
transferRecordService.insertAccountsTransferRecord(transferRecord);
}
}
}
return installmentHistoryMapper.insertInstallmentHistory(installmentHistory);
@@ -169,6 +199,7 @@ public class InstallmentHistoryServiceImpl implements IInstallmentHistoryService
detail.setCreateBy(SecurityUtils.getUsername());
detail.setCreateTime(DateUtils.getNowDate());
detail.setRepaymentAccountId(installmentHistory.getReceivingAccountId());
installmentHistoryDetailMapper.insertInstallmentHistoryDetail(detail);
}

View File

@@ -22,6 +22,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="type" column="type" />
<result property="periods" column="periods" />
<result property="bankCardLendName" column="bank_card_lend_name" />
<result property="repaymentAccountId" column="repayment_account_id" />
<result property="repaymentAccountName" column="repayment_account_name" />
</resultMap>
<sql id="selectInstallmentHistoryDetailVo">
@@ -42,16 +44,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.remark,
a.type,
a.periods,
a.repayment_account_id,
CONCAT(bcl."name",
'',
right(bcl.code,
4),
'') as bank_card_lend_name
'') as bank_card_lend_name,
CONCAT(debit."name",
'',
right(debit.code,
4),
'') as repayment_account_name
from
installment_history_detail a
left join bank_card_lend bcl on
bcl.id = a.bank_card_lend_id
left join installment_history ih on ih.id=a.installment_history_id
left join bank_card_lend debit on
debit.id = a.repayment_account_id
</sql>
<select id="selectInstallmentHistoryDetailList" parameterType="InstallmentHistoryDetailDto" resultMap="InstallmentHistoryDetailResult">
@@ -108,6 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
<if test="type != null">type,</if>
<if test="periods != null">periods,</if>
<if test="repaymentAccountId != null">repayment_account_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@@ -126,6 +137,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if>
<if test="type != null">#{type},</if>
<if test="periods != null">#{periods},</if>
<if test="repaymentAccountId != null">#{repaymentAccountId},</if>
</trim>
</insert>
@@ -147,6 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark = #{remark},</if>
<if test="type != null">type = #{type},</if>
<if test="periods != null">periods = #{periods},</if>
<if test="repaymentAccountId != null">repayment_account_id = #{repaymentAccountId},</if>
</trim>
where id = #{id}
</update>