package com.nova.sankuai.domain.api.yangqianguan.vo; import cn.hutool.core.date.DateUtil; import com.fasterxml.jackson.annotation.JsonProperty; import com.nova.sankuai.domain.api.yixin.vo.YxpkgListVo; import com.nova.sankuai.infra.utils.ConstantsUtil; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.apache.commons.lang.StringUtils; import java.util.List; @ApiModel(value = "还款详情") @Data public class RepayDetailPlanVo { @ApiModelProperty(value = "当期状态-未到期") public static final Integer STATUS_NORMAL = 0; @ApiModelProperty(value = "当期状态-已还款") public static final Integer STATUS_REPAID = 1; @ApiModelProperty(value = "当期状态-已逾期") public static final Integer STATUS_OVERDUE = 2; @ApiModelProperty(value = "当期状态-还款中") public static final Integer STATUS_REPAY_PROCESS = 3; @ApiModelProperty(value = "期数") @JsonProperty("period_no") private Integer periodNo; @ApiModelProperty(value = "最早还款日") @JsonProperty("can_repay_time") private Long canRepayTime; @ApiModelProperty(value = "最晚还款日") @JsonProperty("due_time") private Long dueTime; @ApiModelProperty(value = "应还金额 用户当期应还金额(若出现部分还款,则为当期应还金额总额,非剩余待还金额)") private Double amount; @ApiModelProperty(value = "应还本金 用户当期应还本金(若出现部分还款,则为当期应还本金总额,非剩余待还本金)") private Double principal; @ApiModelProperty(value = "应还利息 用户当期应还利息(若出现部分还款,则为当期应还利息总额,非剩余待还利息)") private Double interest; @ApiModelProperty(value = "应还服务费 用户当期应还服务费(若出现部分还款,则为当期应还服务费总额,非剩余待还服务费)") @JsonProperty("service_fee") private Double serviceFee; @ApiModelProperty(value = "应还罚息 用户当期应还罚息(若出现部分还款,则为当期应还罚息总额,非剩余待还罚息)") @JsonProperty("overdue_interest") private Double overdueInterest; @ApiModelProperty(value = "应还其他费用 用户当期应还其他费用(若出现部分还款,则为当期应还其他费用总额,非剩余待还其他费用)") @JsonProperty("other_fee") private Double otherFee; @ApiModelProperty(value = "已还金额 用户当期的已还金额") @JsonProperty("paid_amount") private Double paidAmount; @ApiModelProperty(value = "已还本金 用户当期已还本金") @JsonProperty("paid_principal") private Double paidPrincipal; @ApiModelProperty(value = "已还利息 用户当期已还利息") @JsonProperty("paid_interest") private Double paidInterest; @ApiModelProperty(value = "已还服务费 用户当期已还服务费") @JsonProperty("paid_service_fee") private Double paidServiceFee; @ApiModelProperty(value = "已还罚息 用户当期已还罚息") @JsonProperty("paid_overdue_interest") private Double paidOverdueInterest; @ApiModelProperty(value = "已还其他费用 用户当期已还其他费用") @JsonProperty("paid_other_fee") private Double paidOtherFee; @ApiModelProperty(value = "特殊情况 0:无 1:线下减免") private Integer tag; @ApiModelProperty(value = "减免金额 tag为1时必填") @JsonProperty("reduce_fee") private Double reduceFee; @ApiModelProperty(value = "当期状态 0:未到期(未逾期) 1:已还款 2:已逾期 3:还款中(已扣款,未出结果)") @JsonProperty("bill_status") private Integer billStatus; @ApiModelProperty(value = "当期成功还款时间 用户当期成功还款的时间 已还款下不能为空") @JsonProperty("success_time") private Long successTime; @ApiModelProperty(value = "当期还款金额组成 当期还款金额的组成,加起来为当期还款金额") private String remark; public Double calculateAmount() { Double amount = this.principal + this.interest + this.serviceFee + this.overdueInterest + this.otherFee; return amount; } public Double calculatePaidAmount() { Double paidAmount = this.paidPrincipal + this.paidInterest + this.paidServiceFee + this.paidOverdueInterest + this.paidOtherFee; return paidAmount; } public String parseRemark() { StringBuilder sb = new StringBuilder(); sb.append("本金" + this.principal + "元"); sb.append("利息" + this.interest + "元"); if (this.serviceFee != null) { sb.append("服务费" + this.serviceFee + "元"); } if (this.overdueInterest != null) { sb.append("罚息" + this.overdueInterest + "元"); } if (this.otherFee != null) { sb.append("其他费用" + this.otherFee + "元"); } return sb.toString(); } public static RepayDetailPlanVo parseVo(YxpkgListVo yxpkgListVo, List periodNoList) { RepayDetailPlanVo repayDetailPlanVo = new RepayDetailPlanVo(); repayDetailPlanVo.setCanRepayTime(DateUtil.parse(yxpkgListVo.getRepayDate()).getTime()); repayDetailPlanVo.setPeriodNo(Integer.valueOf(yxpkgListVo.getRepayTerm())); repayDetailPlanVo.setDueTime(DateUtil.parse(yxpkgListVo.getRepayDate()).getTime()); repayDetailPlanVo.setPrincipal(ConstantsUtil.formatPrice(yxpkgListVo.getTermRetPrin())); repayDetailPlanVo.setInterest(ConstantsUtil.formatPrice(yxpkgListVo.getTermRetInt())); repayDetailPlanVo.setServiceFee(ConstantsUtil.formatPrice(yxpkgListVo.getServiceReFee())); repayDetailPlanVo.setOverdueInterest(ConstantsUtil.formatPrice(yxpkgListVo.getTermRetFint())); repayDetailPlanVo.setOtherFee(ConstantsUtil.formatPrice(yxpkgListVo.getGuarantorReAmt()) + ConstantsUtil.formatPrice(yxpkgListVo.getSpeaccountRe())); repayDetailPlanVo.setPaidAmount(ConstantsUtil.formatPrice(yxpkgListVo.getPrinAmt())); repayDetailPlanVo.setPaidPrincipal(ConstantsUtil.formatPrice(yxpkgListVo.getPrinAmt())); repayDetailPlanVo.setPaidInterest(ConstantsUtil.formatPrice(yxpkgListVo.getIntAmt())); repayDetailPlanVo.setPaidServiceFee(ConstantsUtil.formatPrice(yxpkgListVo.getServiceFee())); repayDetailPlanVo.setPaidOverdueInterest(ConstantsUtil.formatPrice(yxpkgListVo.getTermFintFinish())); repayDetailPlanVo.setPaidOtherFee(ConstantsUtil.formatPrice(yxpkgListVo.getGuarantorAmt()) + ConstantsUtil.formatPrice(yxpkgListVo.getSpeaccount())); repayDetailPlanVo.setTag(0); Integer status = yxpkgListVo.parseYqgStatus(); if (!RepayDetailPlanVo.STATUS_REPAID.equals(status) && periodNoList.contains(yxpkgListVo.getRepayTerm())) { status = RepayDetailPlanVo.STATUS_REPAY_PROCESS; } repayDetailPlanVo.setBillStatus(status); if (StringUtils.isNotEmpty(yxpkgListVo.getDatePay())) { repayDetailPlanVo.setSuccessTime(DateUtil.parse(yxpkgListVo.getDatePay()).getTime()); } repayDetailPlanVo.setRemark(repayDetailPlanVo.parseRemark()); repayDetailPlanVo.setPaidAmount(repayDetailPlanVo.calculatePaidAmount()); repayDetailPlanVo.setAmount(repayDetailPlanVo.calculateAmount()); return repayDetailPlanVo; } }