fix:分期历史,增加计算利率。

This commit is contained in:
tianyongbao
2024-04-30 10:58:58 +08:00
parent 3e733a83d6
commit 848b15e0ee
4 changed files with 83 additions and 22 deletions

View File

@@ -103,6 +103,11 @@ public class InstallmentHistory extends BaseEntity
/** 删除标志0代表存在 1代表删除 */
private String delFlag;
/** 计算利率 */
@ApiModelProperty(value="计算利率")
@Excel(name = "计算利率")
private String calculateInterestRate;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -127,6 +132,7 @@ public class InstallmentHistory extends BaseEntity
.append("delFlag", getDelFlag())
.append("remark", getRemark())
.append("balance", getBalance())
.append("calculateInterestRate", getCalculateInterestRate())
.toString();
}
}

View File

@@ -6,7 +6,9 @@ import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.invest.domain.InstallmentHistory;
import com.ruoyi.invest.domain.InstallmentHistoryDetail;
import com.ruoyi.invest.domain.dto.InstallmentHistoryDetailDto;
import com.ruoyi.invest.domain.dto.InstallmentHistoryDto;
import com.ruoyi.invest.domain.vo.InstallmentHistoryDetailVo;
import com.ruoyi.invest.domain.vo.InstallmentHistoryVo;
import com.ruoyi.invest.mapper.InstallmentHistoryDetailMapper;
import com.ruoyi.invest.mapper.InstallmentHistoryMapper;
@@ -57,12 +59,24 @@ public class InstallmentHistoryServiceImpl implements IInstallmentHistoryService
{
List<InstallmentHistoryVo> installmentHistoryVoList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto);
//修改名称加卡号
DecimalFormat decimalFormat = new DecimalFormat("#.##");
for (InstallmentHistoryVo installmentHistory : installmentHistoryVoList) {
if(installmentHistory.getBankCode()!=null){
installmentHistory.setBankNameCode(installmentHistory.getBankName()+""+ StringUtils.getLastNumberChars(4,installmentHistory.getBankCode()+""));
}else {
installmentHistory.setBankNameCode(installmentHistory.getBankName());
}
double interest=installmentHistory.getTotalInterest();
double interestRate=0;
if(interest>0){
interestRate=interest/installmentHistory.getInstallmentAmount();
if(installmentHistory.getPeriod()!=null){
interestRate=interestRate*12/installmentHistory.getPeriod();
}
}
interestRate=interestRate*100;
String calculateInterestRate= decimalFormat.format(interestRate)+"%";
installmentHistory.setCalculateInterestRate(calculateInterestRate);
}
return installmentHistoryVoList;
}
@@ -173,13 +187,45 @@ public class InstallmentHistoryServiceImpl implements IInstallmentHistoryService
installmentHistory.setCloseDate(calendarStart.getTime());
}
}
//// //插入分期明细
// insertInstallmentHistoryDetail(installmentHistory);
//更新利率信息
updateInterestRate(installmentHistory);
}
}
return installmentHistoryMapper.updateInstallmentHistory(installmentHistory);
}
/**
* 更新利率
*
* @param
*/
public void updateInterestRate(InstallmentHistory installmentHistory)
{
DecimalFormat decimalFormat = new DecimalFormat("#.##");
InstallmentHistoryDetailDto installmentHistoryDetailDto=new InstallmentHistoryDetailDto();
installmentHistoryDetailDto.setInstallmentHistoryId(installmentHistory.getId());
List<InstallmentHistoryDetailVo> detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(installmentHistoryDetailDto);
double interest =0;
double interestRate=0;
if(detailList.size()>0){
interest = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getInterest).sum();
}
if(interest==0){
interest=installmentHistory.getTotalInterest();
}
if(interest>0){
interestRate=interest/installmentHistory.getInstallmentAmount();
if(installmentHistory.getPeriod()!=null){
interestRate=interestRate*12/installmentHistory.getPeriod();
}
}
interestRate=interestRate*100;
String calculateInterestRate= decimalFormat.format(interestRate)+"%";
installmentHistory.setCalculateInterestRate(calculateInterestRate);
}
/**
* 批量删除网贷及分期历史
*

View File

@@ -107,10 +107,10 @@ public class InvestJobImpl implements IInvestJobService
accountsDealRecordDto.setEndDateTime(endDate);
//获取所有交易记录
List<AccountsDealRecordVo> accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(accountsDealRecordDto);
//支出转为负数
//收入转为负数
for (AccountsDealRecordVo vo:accountsDealRecordVoList
) {
if(vo.getDealType().equals("2")){
if(vo.getDealType().equals("1")){
vo.setAmount(vo.getAmount()*(-1));
}
}
@@ -129,10 +129,15 @@ public class InvestJobImpl implements IInvestJobService
creditCardBill.setUpdateTime(DateUtils.getNowDate());
creditCardBill.setId(creditCardBillVo.getId());
creditCardBill.setBillAmount(billAmount);
//如果账单日与当前日期相同,将账单修改为已出账
if(billDateStr.equals(formatter.format(new Date()))){
creditCardBill.setBillState("1");
}
//更新未出账单
creditCardBillMapper.updateCreditCardBill(creditCardBill);
}else {
//如果账单日大于当前日期,未出账,进行插入操作
if(billDateStr.compareTo(formatter.format(new Date()))==1){
CreditCardBill creditCardBill=new CreditCardBill();
try {
creditCardBill.setBillDate(formatter.parse(billDateStr));
@@ -150,6 +155,7 @@ public class InvestJobImpl implements IInvestJobService
//插入未出账单
creditCardBillMapper.insertCreditCardBill(creditCardBill);
}
}
}
}

View File

@@ -29,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="bankName" column="bank_name" />
<result property="bankCode" column="bank_code" />
<result property="repaymentDate" column="repayment_date" />
<result property="calculateInterestRate" column="calculate_interest_rate" />
</resultMap>
<sql id="selectInstallmentHistoryVo">
@@ -41,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.installment_amount,
a.installment_date,
a.period,
a.calculate_interest_rate,
(
select
CASE
@@ -129,7 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="delFlag != null">del_flag,</if>
<if test="remark != null">remark,</if>
<if test="balance != null">balance,</if>
<if test="calculateInterestRate != null">calculate_interest_rate,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@@ -153,7 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="delFlag != null">#{delFlag},</if>
<if test="remark != null">#{remark},</if>
<if test="balance != null">#{balance},</if>
<if test="calculateInterestRate != null">#{calculateInterestRate},</if>
</trim>
</insert>
@@ -180,6 +182,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="balance != null">balance = #{balance},</if>
<if test="calculateInterestRate != null">calculate_interest_rate = #{calculateInterestRate},</if>
</trim>
where id = #{id}
</update>