diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CrmsCompanyPersonalController.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CrmsCompanyPersonalController.java index 0d3adebd..303c6c66 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CrmsCompanyPersonalController.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CrmsCompanyPersonalController.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 diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/AlRepaymentEntryController.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/AlRepaymentEntryController.java index 233b6aa3..53330e4b 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/AlRepaymentEntryController.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/controller/AlRepaymentEntryController.java @@ -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); } diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/mapper/AlRepaymentEntryMapper.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/mapper/AlRepaymentEntryMapper.java index 913f2f53..d854b895 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/mapper/AlRepaymentEntryMapper.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/mapper/AlRepaymentEntryMapper.java @@ -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; + /** *

* 还款记录表 Mapper 接口 @@ -18,4 +21,6 @@ import org.apache.ibatis.annotations.Mapper; public interface AlRepaymentEntryMapper extends BaseMapper { IPage pageByCondition(Page page, String customerNumberOrName, Integer status); + + List selectListByIds(List ids); } diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/AlRepaymentRes.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/AlRepaymentRes.java new file mode 100644 index 00000000..7b6794e6 --- /dev/null +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/model/response/AlRepaymentRes.java @@ -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; + +/** + *

+ * 还款记录表 + *

+ * + * @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; +} diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/IAlRepaymentEntryService.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/IAlRepaymentEntryService.java index 4aee8c34..815edda7 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/IAlRepaymentEntryService.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/IAlRepaymentEntryService.java @@ -32,5 +32,5 @@ public interface IAlRepaymentEntryService extends IService { Boolean excelExport(List ids, HttpServletResponse response); - Map repaymentStatistics(); + Map repaymentStatistics(Integer insuranceId,Double guaranteeAmount); } diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/AlRepaymentEntryServiceImpl.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/AlRepaymentEntryServiceImpl.java index d5a8dffb..53e92e5d 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/AlRepaymentEntryServiceImpl.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/AlRepaymentEntryServiceImpl.java @@ -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 ids, HttpServletResponse response) { - ListrepaymentList = this.baseMapper.selectBatchIds(ids); + + ListrepaymentList = 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() + .eq("repayment_status",2).eq("insurance_id",insuranceId)); + map.put("repaymentSum",count1); + + //统计逾期期数(统计状态为已逾期期数) + int count2 = this.baseMapper.selectCount(new QueryWrapper() + .eq("repayment_status",3).eq("insurance_id",insuranceId)); + map.put("overdueSum",count2); + + //统计逾期利息(计算状态为已逾期的所有利息的合计数) + List list = this.baseMapper.selectList(new QueryWrapper() + .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 list2 = this.baseMapper.selectList(new QueryWrapper() + .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; } } diff --git a/dq-financial-guarantee/src/main/resources/mapper/guarantee/AlRepaymentEntryMapper.xml b/dq-financial-guarantee/src/main/resources/mapper/guarantee/AlRepaymentEntryMapper.xml index 6a78ffe4..ecde8296 100644 --- a/dq-financial-guarantee/src/main/resources/mapper/guarantee/AlRepaymentEntryMapper.xml +++ b/dq-financial-guarantee/src/main/resources/mapper/guarantee/AlRepaymentEntryMapper.xml @@ -26,6 +26,20 @@ repayment_status = #{status} + + AND repayment_date = #{customerNumberOrName} + + + order by create_time desc + + + diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/guarantee/AlRepaymentEntry.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/guarantee/AlRepaymentEntry.java index cb399fd0..30286d3a 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/guarantee/AlRepaymentEntry.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/guarantee/AlRepaymentEntry.java @@ -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;