还款统计功能,新增关联人日期格式处理

master
shijie 4 years ago
parent 9ef519a95a
commit 36d006f42b
  1. 12
      dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CrmsCompanyPersonalController.java
  2. 6
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/AlRepaymentEntryController.java
  3. 5
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/mapper/AlRepaymentEntryMapper.java
  4. 107
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/AlRepaymentRes.java
  5. 2
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/IAlRepaymentEntryService.java
  6. 54
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/AlRepaymentEntryServiceImpl.java
  7. 14
      dq-financial-guarantee/src/main/resources/mapper/guarantee/AlRepaymentEntryMapper.xml
  8. 3
      dq-framework-model/src/main/java/com/daqing/framework/domain/guarantee/AlRepaymentEntry.java

@ -17,8 +17,11 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
@ -58,6 +61,15 @@ public class CrmsCompanyPersonalController {
@PostMapping("/insertCompanyPersonal")
@ApiOperation(value = "新增个人/企业关联人")
public ResponseResult insertCompanyPersonal(@RequestBody @Valid CrmsCompanyPersonal crmsCompanyPersonal) {
String dateStr = crmsCompanyPersonal.getRegisteredTime().toString();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = null;
try {
d = sdf.parse(dateStr);
} catch (ParseException e) {
e.printStackTrace();
}
crmsCompanyPersonal.setRegisteredTime(d);
boolean result = crmsCompanyPersonalService.save(crmsCompanyPersonal);
CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated();
crmsCustomerRelated.setRelatedId(crmsCompanyPersonal.getId().intValue());//关联人Id

@ -118,14 +118,14 @@ public class AlRepaymentEntryController {
/**
* 还款统计
* @param
* @param insuranceId 保后Id guaranteeAmount 担保额度
* @return
*/
@Log(detail = "还款统计",level = 4,operationUnit = OperationUnit.INSURANCE,operationType = OperationType.SELECT)
@GetMapping("/repaymentStatistics")
@ApiOperation(value = "还款统计")
public ResponseResult repaymentStatistics(){
Map map = alRepaymentEntryService.repaymentStatistics();
public ResponseResult repaymentStatistics(@RequestParam("insuranceId") Integer insuranceId,@RequestParam("guaranteeAmount") Double guaranteeAmount){
Map map = alRepaymentEntryService.repaymentStatistics(insuranceId,guaranteeAmount);
return ResponseResult.SUCCESS(map);
}

@ -3,9 +3,12 @@ package com.daqing.financial.guarantee.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daqing.financial.guarantee.model.response.AlRepaymentRes;
import com.daqing.framework.domain.guarantee.AlRepaymentEntry;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* <p>
* 还款记录表 Mapper 接口
@ -18,4 +21,6 @@ import org.apache.ibatis.annotations.Mapper;
public interface AlRepaymentEntryMapper extends BaseMapper<AlRepaymentEntry> {
IPage<AlRepaymentEntry> pageByCondition(Page page, String customerNumberOrName, Integer status);
List<AlRepaymentRes> selectListByIds(List<String> ids);
}

@ -0,0 +1,107 @@
package com.daqing.financial.guarantee.model.response;
import com.alibaba.excel.metadata.BaseRowModel;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* <p>
* 还款记录表
* </p>
*
* @author Qyq
* @since 2021-03-17
*/
@Data
@TableName("al_repayment_entry")
public class AlRepaymentRes extends BaseRowModel implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 保后外键id
*/
private Integer insuranceId;
/**
* 应还款日
*/
private Date repaymentDate;
/**
* 实际还款日
*/
private Date actualRepaymentDate;
/**
* 逾期天数
*/
private Integer overdueDays;
/**
* 还款总额
*/
private BigDecimal totalRepayment;
/**
* 本次还款
*/
private BigDecimal currentRepayment;
/**
* 利息
*/
private BigDecimal interest;
/**
* 其他费用
*/
private BigDecimal otherExpenses;
/**
* 减免金额
*/
private BigDecimal deductionAmount;
/**
* 还款备注
*/
private String repaymentNotes;
/**
* 还款状态1->待还款2->已还款3->已逾期4->未到期
*/
private Integer repaymentStatus;
/**
* 提交人id
*/
private Integer submitterId;
/**
* 提交人名称
*/
private String submitterName;
/**
* 创建时间
*/
@TableField(fill= FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(fill= FieldFill.INSERT_UPDATE)
private Date updateTime;
}

@ -32,5 +32,5 @@ public interface IAlRepaymentEntryService extends IService<AlRepaymentEntry> {
Boolean excelExport(List<String> ids, HttpServletResponse response);
Map repaymentStatistics();
Map repaymentStatistics(Integer insuranceId,Double guaranteeAmount);
}

@ -1,21 +1,26 @@
package com.daqing.financial.guarantee.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daqing.financial.guarantee.controller.DgApplyAmountInfoController;
import com.daqing.financial.guarantee.mapper.AlRepaymentEntryMapper;
import com.daqing.financial.guarantee.model.request.AlRepaymentEntryReq;
import com.daqing.financial.guarantee.model.response.AlRepaymentRes;
import com.daqing.financial.guarantee.service.IAlRepaymentEntryService;
import com.daqing.framework.domain.crms.response.CrmsCode;
import com.daqing.framework.domain.guarantee.AlRepaymentEntry;
import com.daqing.framework.exception.ExceptionCast;
import com.daqing.framework.utils.PageUtils;
import com.daqing.framework.utils.excel.ExcelUtil;
import io.swagger.models.auth.In;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -82,9 +87,10 @@ public class AlRepaymentEntryServiceImpl extends ServiceImpl<AlRepaymentEntryMap
@Override
public Boolean excelExport(List<String> ids, HttpServletResponse response) {
List<AlRepaymentEntry>repaymentList = this.baseMapper.selectBatchIds(ids);
List<AlRepaymentRes>repaymentList = this.baseMapper.selectListByIds(ids);
try {
ExcelUtil.writeExcelWithSheets(response, repaymentList, "还款记录一览表", "repaymentEntry", new AlRepaymentEntry())
ExcelUtil.writeExcelWithSheets(response, repaymentList, "还款记录一览表", "repaymentEntry", new AlRepaymentRes())
.finish();
return true;
} catch (Exception e) {
@ -94,8 +100,48 @@ public class AlRepaymentEntryServiceImpl extends ServiceImpl<AlRepaymentEntryMap
}
@Override
public Map repaymentStatistics() {
public Map repaymentStatistics(Integer insuranceId,Double guaranteeAmount) {
Map map = new HashMap();
//统计还款期数(统计状态为已还款期数)
int count1 = this.baseMapper.selectCount(new QueryWrapper<AlRepaymentEntry>()
.eq("repayment_status",2).eq("insurance_id",insuranceId));
map.put("repaymentSum",count1);
//统计逾期期数(统计状态为已逾期期数)
int count2 = this.baseMapper.selectCount(new QueryWrapper<AlRepaymentEntry>()
.eq("repayment_status",3).eq("insurance_id",insuranceId));
map.put("overdueSum",count2);
//统计逾期利息(计算状态为已逾期的所有利息的合计数)
List<AlRepaymentEntry> list = this.baseMapper.selectList(new QueryWrapper<AlRepaymentEntry>()
.eq("repayment_status", 3).eq("insurance_id",insuranceId));
Double interestSum = 0.00;
Double currentSum = 0.00;
for (AlRepaymentEntry entry:list) {
BigDecimal interest = entry.getInterest();
interestSum=interestSum+interest.doubleValue();
BigDecimal currentRepayment = entry.getCurrentRepayment();
currentSum=currentSum+currentRepayment.doubleValue();
}
map.put("overdueInterest",interestSum);
//统计逾期额度(元)(计算状态为已逾期的所有本次还款的合计数)
map.put("overdueSum",currentSum);
//统计还款额度(元)(统计状态为已还款的本次还款)
List<AlRepaymentEntry> list2 = this.baseMapper.selectList(new QueryWrapper<AlRepaymentEntry>()
.eq("repayment_status", 2).eq("insurance_id",insuranceId));
Double alreadyPaymentSum = 0.00;
for (AlRepaymentEntry entry:list2) {
BigDecimal currentRepayment = entry.getCurrentRepayment();
alreadyPaymentSum=alreadyPaymentSum+currentRepayment.doubleValue();
}
map.put("alreadyPaymentSum",alreadyPaymentSum);
//统计剩余额度(元)(担保额度-还款额度)
Double remainSum = guaranteeAmount-alreadyPaymentSum;
map.put("remainSum",remainSum);
return null;
return map;
}
}

@ -26,6 +26,20 @@
<if test="status != null">
repayment_status = #{status}
</if>
<if test="customerNumberOrName != null and customerNumberOrName != '' ">
AND repayment_date = #{customerNumberOrName}
</if>
</where>
order by create_time desc
</select>
<select id="selectListByIds" resultType="com.daqing.financial.guarantee.model.response.AlRepaymentRes">
select * from al_repayment_entry
<where>
id IN
<foreach collection="ids" open="(" separator="," close=")" item="id">
#{id}
</foreach>
</where>
order by create_time desc
</select>

@ -1,5 +1,6 @@
package com.daqing.framework.domain.guarantee;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
@ -18,7 +19,7 @@ import java.util.Date;
*/
@Data
@TableName("al_repayment_entry")
public class AlRepaymentEntry extends BaseRowModel implements Serializable {
public class AlRepaymentEntry implements Serializable {
private static final long serialVersionUID = 1L;

Loading…
Cancel
Save