Commit d665b8dc authored by 陈宏杰's avatar 陈宏杰

数据分割

parent 883ea1d4
...@@ -155,9 +155,9 @@ public class ManualToolController { ...@@ -155,9 +155,9 @@ public class ManualToolController {
} }
@RequestMapping("/createFile") @RequestMapping("/createFile")
public String testD2Repost(String type, String startDate, String endDate, Integer daySpilt, String loanStartDateStr, String loanEndDateStr, String prefix){ public String testD2Repost(String type, String startDate, String endDate, Integer daySpilt, String loanStartDateStr, String loanEndDateStr, String prefix, String linkPointTimeStr){
try { try {
fileReportService.createReportFile(type,startDate,endDate,daySpilt,loanStartDateStr,loanEndDateStr,prefix); fileReportService.createReportFile(type,startDate,endDate,daySpilt,loanStartDateStr,loanEndDateStr,prefix,linkPointTimeStr);
return "SUCCESS"; return "SUCCESS";
}catch (Exception e){ }catch (Exception e){
return e.getMessage(); return e.getMessage();
......
...@@ -23,4 +23,6 @@ public class BaiHangTimeRecord { ...@@ -23,4 +23,6 @@ public class BaiHangTimeRecord {
private String loanEndTime; private String loanEndTime;
private String linkPointTime;
} }
...@@ -119,7 +119,7 @@ public class BaiHangFileReportService { ...@@ -119,7 +119,7 @@ public class BaiHangFileReportService {
* @param end 报送区间的截止时间 格式:"2019-05-07T00:00:00" * @param end 报送区间的截止时间 格式:"2019-05-07T00:00:00"
*/ */
@Async @Async
public void createReportFile(String type, String start, String end,int daySplitCount, String loanStartDateStr, String loanEndDateStr, String prefix) { public void createReportFile(String type, String start, String end,int daySplitCount, String loanStartDateStr, String loanEndDateStr, String prefix, String linkPointTimeStr) {
try { try {
if (!increment(Constant.QG_ZHU_DAI_CREATE_REPORT_FILE_LOCK_KEY)) { if (!increment(Constant.QG_ZHU_DAI_CREATE_REPORT_FILE_LOCK_KEY)) {
log.error("创建报送文件任务已经开始执行...请勿重复操作"); log.error("创建报送文件任务已经开始执行...请勿重复操作");
...@@ -132,16 +132,21 @@ public class BaiHangFileReportService { ...@@ -132,16 +132,21 @@ public class BaiHangFileReportService {
String encryptFileName = null; String encryptFileName = null;
List<String> encryptFileNameList = new LinkedList(); List<String> encryptFileNameList = new LinkedList();
daySplitCount = Objects.isNull(daySplitCount) ? 10 : daySplitCount; daySplitCount = Objects.isNull(daySplitCount) ? 10 : daySplitCount;
String dateFormat = "yyyyMMddHHmmss"; String dateFormat = "yyyy-MM-dd";
Date stepStartDate = DateUtils.parseDate(dateFormat,start); Date stepStartDate = DateUtils.parseDate(dateFormat,start);
if (StringUtils.equals("D3R",type) && StringUtils.isNotBlank(linkPointTimeStr)) {
// 新老还款数据衔接
stepStartDate = DateUtils.parseDate("yyyyMMddHHmmss",linkPointTimeStr);
}
Date stepEndDate = org.apache.commons.lang3.time.DateUtils.addDays(stepStartDate,daySplitCount); Date stepEndDate = org.apache.commons.lang3.time.DateUtils.addDays(stepStartDate,daySplitCount);
// D3 还款记录 防止漏期 // D3 还款记录 防止漏期
Date endDate = StringUtils.containsAny(type,"D3R","D3O","D3O30") ? org.apache.commons.lang3.time.DateUtils.addDays(new Date(),1) : DateUtils.parseDate(dateFormat,end); Date endDate = "D3R".equalsIgnoreCase(type) ? org.apache.commons.lang3.time.DateUtils.addDays(new Date(),1) : DateUtils.parseDate(dateFormat,end);
Date loanStartDate = StringUtils.isBlank(loanStartDateStr) ? new Date() : DateUtils.parseDate(dateFormat,loanStartDateStr); Date loanStartDate = StringUtils.isBlank(loanStartDateStr) ? new Date() : DateUtils.parseDate(dateFormat,loanStartDateStr);
Date loanEndDate = StringUtils.isBlank(loanEndDateStr) ? new Date() : DateUtils.parseDate(dateFormat,loanEndDateStr); Date loanEndDate = StringUtils.isBlank(loanEndDateStr) ? new Date() : DateUtils.parseDate(dateFormat,loanEndDateStr);
Date linkPointDate = StringUtils.isBlank(linkPointTimeStr) ? null : DateUtils.parseDate("yyyyMMddHHmmss",linkPointTimeStr);
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();
while (stepEndDate.getTime() <= endDate.getTime()){ while (stepEndDate.getTime() <= endDate.getTime()){
encryptFileName = createReportFile(type,stepStartDate,stepEndDate,loanStartDate,loanEndDate,prefix); encryptFileName = createReportFile(type,stepStartDate,stepEndDate,loanStartDate,loanEndDate,prefix,linkPointDate);
if (StringUtils.isNotBlank(encryptFileName)) { if (StringUtils.isNotBlank(encryptFileName)) {
encryptFileNameList.add(encryptFileName); encryptFileNameList.add(encryptFileName);
} }
...@@ -150,7 +155,7 @@ public class BaiHangFileReportService { ...@@ -150,7 +155,7 @@ public class BaiHangFileReportService {
} }
log.info("当前 {} -- {}--{} 任务执行结束 总耗时 : {}",type,start,end,stopwatch.elapsed(TimeUnit.MILLISECONDS)); log.info("当前 {} -- {}--{} 任务执行结束 总耗时 : {}",type,start,end,stopwatch.elapsed(TimeUnit.MILLISECONDS));
if (stepEndDate.getTime() > endDate.getTime()){ if (stepEndDate.getTime() > endDate.getTime()){
encryptFileName = createReportFile(type,stepStartDate,endDate,loanStartDate,loanEndDate,prefix); encryptFileName = createReportFile(type,stepStartDate,endDate,loanStartDate,loanEndDate,prefix,linkPointDate);
if (StringUtils.isNotBlank(encryptFileName)) { if (StringUtils.isNotBlank(encryptFileName)) {
encryptFileNameList.add(encryptFileName); encryptFileNameList.add(encryptFileName);
} }
...@@ -166,13 +171,14 @@ public class BaiHangFileReportService { ...@@ -166,13 +171,14 @@ public class BaiHangFileReportService {
} }
} }
private String createReportFile(String type, Date startDate, Date endDate, Date loanStartDate, Date loanEndDate, String prefix) { private String createReportFile(String type, Date startDate, Date endDate, Date loanStartDate, Date loanEndDate, String prefix, Date linkPointDate) {
String encryptFileName = null; String encryptFileName = null;
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();
String starTime = DateUtils.formatDate(startDate,"yyyy-MM-dd HH:mm:ss"); String starTime = DateUtils.formatDate(startDate,"yyyy-MM-dd HH:mm:ss");
String endTime = DateUtils.formatDate(endDate,"yyyy-MM-dd HH:mm:ss"); String endTime = DateUtils.formatDate(endDate,"yyyy-MM-dd HH:mm:ss");
String loanStartTime = DateUtils.formatDate(loanStartDate,"yyyy-MM-dd HH:mm:ss"); String loanStartTime = DateUtils.formatDate(loanStartDate,"yyyy-MM-dd HH:mm:ss");
String loanEndTime = DateUtils.formatDate(loanEndDate,"yyyy-MM-dd HH:mm:ss"); String loanEndTime = DateUtils.formatDate(loanEndDate,"yyyy-MM-dd HH:mm:ss");
String linkPointTime = Objects.nonNull(linkPointDate) ? DateUtils.formatDate(linkPointDate,"yyyy-MM-dd HH:mm:ss") : null;
if (!starTime.equals(endTime)) { if (!starTime.equals(endTime)) {
log.info("开始生成报送文件{}----- {} -- {}",type,starTime,endTime); log.info("开始生成报送文件{}----- {} -- {}",type,starTime,endTime);
if ("A1".equalsIgnoreCase(type)) { if ("A1".equalsIgnoreCase(type)) {
...@@ -185,11 +191,11 @@ public class BaiHangFileReportService { ...@@ -185,11 +191,11 @@ public class BaiHangFileReportService {
// encryptFileName = reportD3(starTime,endTime,prefix); // encryptFileName = reportD3(starTime,endTime,prefix);
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"暂不支持该类型数据报送"); throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"暂不支持该类型数据报送");
} else if ("D3O".equalsIgnoreCase(type)) { } else if ("D3O".equalsIgnoreCase(type)) {
encryptFileName = reportD3O(starTime,endTime,loanStartTime,loanEndTime,prefix); encryptFileName = reportD3O(starTime,endTime,loanStartTime,loanEndTime,prefix,linkPointTime);
} else if ("D3R".equalsIgnoreCase(type)) { } else if ("D3R".equalsIgnoreCase(type)) {
encryptFileName = reportD3R(starTime,endTime,loanStartTime,loanEndTime,prefix); encryptFileName = reportD3R(starTime,endTime,loanStartTime,loanEndTime,prefix,linkPointTime);
} else if ("D3O30".equalsIgnoreCase(type)) { } else if ("D3O30".equalsIgnoreCase(type)) {
encryptFileName = reportD3OFor30Day(starTime,endTime,loanStartTime,loanEndTime,prefix); encryptFileName = reportD3OFor30Day(starTime,endTime,loanStartTime,loanEndTime,prefix,linkPointTime);
} else { } else {
throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"报送类型不正确"); throw new QGException(COMMON_ILLEGAL_PARAM_TOAST,"报送类型不正确");
} }
...@@ -553,7 +559,7 @@ public class BaiHangFileReportService { ...@@ -553,7 +559,7 @@ public class BaiHangFileReportService {
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 截止时间 * @param endTime 截止时间
*/ */
private String reportD3O(String startTime, String endTime, String loanStartTime, String loanEndTime, String prefix) { private String reportD3O(String startTime, String endTime, String loanStartTime, String loanEndTime, String prefix, String linkPointTime) {
String encryptFileName = null; String encryptFileName = null;
List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY); List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY);
List<String> reportList = new ArrayList<>(D3_INITIAL_CAPACITY); List<String> reportList = new ArrayList<>(D3_INITIAL_CAPACITY);
...@@ -561,7 +567,7 @@ public class BaiHangFileReportService { ...@@ -561,7 +567,7 @@ public class BaiHangFileReportService {
Stopwatch sendWatch = Stopwatch.createStarted(); Stopwatch sendWatch = Stopwatch.createStarted();
try { try {
Stopwatch queryStopwatch = Stopwatch.createStarted(); Stopwatch queryStopwatch = Stopwatch.createStarted();
repaymentLoanInfos = repaymentLoanInfoMapper.queryOverdueRecordOfD3(BaiHangTimeRecord.builder().startTime(startTime).endTime(endTime).loanStartTime(loanStartTime).loanEndTime(loanEndTime).build()); repaymentLoanInfos = repaymentLoanInfoMapper.queryOverdueRecordOfD3(BaiHangTimeRecord.builder().startTime(startTime).endTime(endTime).loanStartTime(loanStartTime).loanEndTime(loanEndTime).linkPointTime(linkPointTime).build());
log.info("量化派助贷TO百行报送(D3)-逾期记录查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, repaymentLoanInfos.size(), (queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s"); log.info("量化派助贷TO百行报送(D3)-逾期记录查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, repaymentLoanInfos.size(), (queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
AtomicInteger atomicInteger = new AtomicInteger(); AtomicInteger atomicInteger = new AtomicInteger();
String id = ""; String id = "";
...@@ -607,7 +613,7 @@ public class BaiHangFileReportService { ...@@ -607,7 +613,7 @@ public class BaiHangFileReportService {
/** /**
* 应还款日次日起,每30天的次日报送一次逾期记录,直至结清或转出 * 应还款日次日起,每30天的次日报送一次逾期记录,直至结清或转出
*/ */
private String reportD3OFor30Day(String startTime, String endTime, String loanStartTime, String loanEndTime, String prefix) { private String reportD3OFor30Day(String startTime, String endTime, String loanStartTime, String loanEndTime, String prefix, String linkPointTime) {
String encryptFileName = null; String encryptFileName = null;
List<LoanApplicationHistoryIdInfo> idInfos = null; List<LoanApplicationHistoryIdInfo> idInfos = null;
LoanApplicationHistoryIdInfo idInfo = null; LoanApplicationHistoryIdInfo idInfo = null;
...@@ -621,24 +627,24 @@ public class BaiHangFileReportService { ...@@ -621,24 +627,24 @@ public class BaiHangFileReportService {
Stopwatch sendWatch = Stopwatch.createStarted(); Stopwatch sendWatch = Stopwatch.createStarted();
try { try {
Stopwatch queryStopwatch = Stopwatch.createStarted(); Stopwatch queryStopwatch = Stopwatch.createStarted();
idInfos = repaymentLoanInfoMapper.queryLoanApplicationHistoryIdInfo(BaiHangTimeRecord.builder().loanStartTime(loanStartTime).loanEndTime(loanEndTime).build()); idInfos = repaymentLoanInfoMapper.queryLoanApplicationHistoryIdInfo(BaiHangTimeRecord.builder().startTime(startTime).endTime(endTime).loanStartTime(loanStartTime).loanEndTime(loanEndTime).linkPointTime(linkPointTime).build());
log.info("量化派助贷TO百行报送(D3)-每30天逾期记录总数查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(idInfos) ? 0 : idInfos.size(), (queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s"); log.info("量化派助贷TO百行报送(D3)-每30天逾期记录总数查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, CollectionUtils.isEmpty(idInfos) ? 0 : idInfos.size(), (queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
for(int i = 0; i < idInfos.size(); i++) { for(int i = 0; i < idInfos.size(); i++) {
step = 1; step = 1;
idInfo = idInfos.get(i); idInfo = idInfos.get(i);
if (Objects.isNull(idInfo.getRepaymentReceivedAt()) || "2000-01-01".equals(DateUtils.formatDate(idInfo.getRepaymentReceivedAt(),"yyyy-MM-dd"))) { if (Objects.isNull(idInfo.getRepaymentReceivedAt()) || "2000-01-01".equals(DateUtils.formatDate(idInfo.getRepaymentReceivedAt(),"yyyy-MM-dd"))) {
idInfo.setRepaymentReceivedAt(DateUtils.parseDate("yyyy-MM-dd HH:mm:ss",endTime)); idInfo.setRepaymentReceivedAt(new Date());
} }
while (Boolean.TRUE) { while (Boolean.TRUE) {
stepEndDate = org.apache.commons.lang3.time.DateUtils.addDays(idInfo.getDeadline(),30*step); stepEndDate = org.apache.commons.lang3.time.DateUtils.addDays(idInfo.getDeadline(),30*step);
if (stepEndDate.compareTo(DateUtils.parseDate("yyyy-MM-dd HH:mm:ss",startTime))<0) { if (stepEndDate.compareTo(idInfo.getRepaymentReceivedAt())>0) {
break;
}
if (stepEndDate.compareTo(DateUtils.parseDate("yyyy-MM-dd HH:mm:ss",linkPointTime))<0) {
log.info("每30天逾期-跳过日期 {} , loanApplicationHistoryId = {}",DateUtils.parse(stepEndDate),idInfo.getLoanApplicationHistoryId()); log.info("每30天逾期-跳过日期 {} , loanApplicationHistoryId = {}",DateUtils.parse(stepEndDate),idInfo.getLoanApplicationHistoryId());
step++; step++;
continue; continue;
} }
if (stepEndDate.compareTo(idInfo.getRepaymentReceivedAt())>0) {
break;
}
tempRepaymentLoanInfos = repaymentLoanInfoMapper.queryD3OverdueRecordOf30Day(BaiHangTimeRecord.builder().loanApplicationHistoryId(idInfo.getLoanApplicationHistoryId()).endTime(DateUtils.formatDate(stepEndDate,"yyyy-MM-dd HH:mm:ss")).build()); tempRepaymentLoanInfos = repaymentLoanInfoMapper.queryD3OverdueRecordOf30Day(BaiHangTimeRecord.builder().loanApplicationHistoryId(idInfo.getLoanApplicationHistoryId()).endTime(DateUtils.formatDate(stepEndDate,"yyyy-MM-dd HH:mm:ss")).build());
repaymentLoanInfos.addAll(tempRepaymentLoanInfos); repaymentLoanInfos.addAll(tempRepaymentLoanInfos);
step++; step++;
...@@ -688,7 +694,7 @@ public class BaiHangFileReportService { ...@@ -688,7 +694,7 @@ public class BaiHangFileReportService {
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 截止时间 * @param endTime 截止时间
*/ */
private String reportD3R(String startTime, String endTime, String loanStartTime, String loanEndTime, String prefix) { private String reportD3R(String startTime, String endTime, String loanStartTime, String loanEndTime, String prefix, String linkPointTime) {
String encryptFileName = null; String encryptFileName = null;
List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY); List<RepaymentInfoZhuDai> repaymentLoanInfos = null,recordList = new ArrayList<>(D3_INITIAL_CAPACITY);
List<String> reportList = new ArrayList<>(D3_INITIAL_CAPACITY); List<String> reportList = new ArrayList<>(D3_INITIAL_CAPACITY);
...@@ -698,7 +704,7 @@ public class BaiHangFileReportService { ...@@ -698,7 +704,7 @@ public class BaiHangFileReportService {
Stopwatch sendWatch = Stopwatch.createStarted(); Stopwatch sendWatch = Stopwatch.createStarted();
try { try {
Stopwatch queryStopwatch = Stopwatch.createStarted(); Stopwatch queryStopwatch = Stopwatch.createStarted();
repaymentLoanInfos = repaymentLoanInfoMapper.queryRepayMentRecordOfD3(BaiHangTimeRecord.builder().startTime(startTime).endTime(endTime).loanStartTime(loanStartTime).loanEndTime(loanEndTime).build()); repaymentLoanInfos = repaymentLoanInfoMapper.queryRepayMentRecordOfD3(BaiHangTimeRecord.builder().startTime(startTime).endTime(endTime).loanStartTime(loanStartTime).loanEndTime(loanEndTime).linkPointTime(linkPointTime).build());
log.info("量化派助贷TO百行报送(D3)-还款记录查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, repaymentLoanInfos.size(), (queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s"); log.info("量化派助贷TO百行报送(D3)-还款记录查询结束, startTime: {} , endTime: {} , 大小: {} , 耗时: {} ", startTime, endTime, repaymentLoanInfos.size(), (queryStopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000) + ".s");
AtomicInteger atomicInteger = new AtomicInteger(); AtomicInteger atomicInteger = new AtomicInteger();
String id = ""; String id = "";
......
...@@ -990,13 +990,15 @@ ...@@ -990,13 +990,15 @@
from (select a.* from (select a.*
from xyqb.repayment_plan a from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
where (a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>=a.deadline)) where (a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>=a.deadline))
and b.funding_corp_id in (1080,100040,1030,100030) and b.funding_corp_id in (1080,100040,1030,100030)
and b.transaction_status in (2,5) and b.transaction_status in (2,5)
and b.contract_term not in (2,3) and b.contract_term not in (2,3)
and a.deadline >= #{startTime,jdbcType=VARCHAR} <if test="linkPointTime != null">
and a.deadline &lt; #{endTime,jdbcType=VARCHAR}) a and a.deadline >= #{linkPointTime,jdbcType=VARCHAR}
</if>
and a.deadline &lt; NOW()) a
left join xyqb_user.user_detail b on a.user_id=b.user_id left join xyqb_user.user_detail b on a.user_id=b.user_id
left join xyqb.loan_account_ext c on a.loan_application_history_id=c.loan_id left join xyqb.loan_account_ext c on a.loan_application_history_id=c.loan_id
left join xyqb.apply_quota_record d on c.order_no=d.order_no left join xyqb.apply_quota_record d on c.order_no=d.order_no
...@@ -1005,7 +1007,7 @@ ...@@ -1005,7 +1007,7 @@
,min(if(((a.repayment_status !=3 and (c.repayment_received_at is null or DATE_FORMAT(c.repayment_received_at,'%Y-%m-%d') = '2000-01-01' or a.deadline &lt;= c.repayment_received_at)) or (a.repayment_status =3 and a.deadline &lt;= c.repayment_received_at)),c.deadline,null)) min_deadline ,min(if(((a.repayment_status !=3 and (c.repayment_received_at is null or DATE_FORMAT(c.repayment_received_at,'%Y-%m-%d') = '2000-01-01' or a.deadline &lt;= c.repayment_received_at)) or (a.repayment_status =3 and a.deadline &lt;= c.repayment_received_at)),c.deadline,null)) min_deadline
from xyqb.repayment_plan a from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
left join xyqb.repayment_record g on a.id=g.repayment_plan_id left join xyqb.repayment_record g on a.id=g.repayment_plan_id
left join xyqb.plan_amount_detail h on a.id=h.plan_id left join xyqb.plan_amount_detail h on a.id=h.plan_id
left join xyqb.repayment_plan c on a.loan_application_history_id=c.loan_application_history_id left join xyqb.repayment_plan c on a.loan_application_history_id=c.loan_application_history_id
...@@ -1018,7 +1020,7 @@ ...@@ -1018,7 +1020,7 @@
,sum(if(g.repayment_status !=3 or (g.repayment_status =3 and if(TO_DAYS(IFNULL(a.repayment_received_at,NOW()))!=TO_DAYS(date(DATE_sub(a.deadline,INTERVAL 1 second))),a.deadline,a.repayment_received_at) &lt;= g.repayment_received_at),if(b.loan_paid_at>='2018-01-01',g.principal,h.principle),0)) dkye ,sum(if(g.repayment_status !=3 or (g.repayment_status =3 and if(TO_DAYS(IFNULL(a.repayment_received_at,NOW()))!=TO_DAYS(date(DATE_sub(a.deadline,INTERVAL 1 second))),a.deadline,a.repayment_received_at) &lt;= g.repayment_received_at),if(b.loan_paid_at>='2018-01-01',g.principal,h.principle),0)) dkye
from xyqb.repayment_plan a from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
left join xyqb.repayment_record g on a.loan_application_history_id=g.loan_application_history_id left join xyqb.repayment_record g on a.loan_application_history_id=g.loan_application_history_id
left join xyqb.plan_amount_detail h on a.id=h.plan_id left join xyqb.plan_amount_detail h on a.id=h.plan_id
where b.funding_corp_id in (1080,100040,1030,100030) where b.funding_corp_id in (1080,100040,1030,100030)
...@@ -1029,7 +1031,7 @@ ...@@ -1029,7 +1031,7 @@
if(TO_DAYS(IFNULL(a.repayment_received_at,NOW()))!=TO_DAYS(date(DATE_sub(a.deadline,INTERVAL 1 second))),a.deadline,a.repayment_received_at) received_at if(TO_DAYS(IFNULL(a.repayment_received_at,NOW()))!=TO_DAYS(date(DATE_sub(a.deadline,INTERVAL 1 second))),a.deadline,a.repayment_received_at) received_at
from xyqb.repayment_plan a from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
where b.funding_corp_id in (1080,100040,1030,100030) where b.funding_corp_id in (1080,100040,1030,100030)
group by a.loan_application_history_id,a.term_no group by a.loan_application_history_id,a.term_no
) z on a.loan_application_history_id=z.loan_application_history_id and a.term_no=z.term_no ) z on a.loan_application_history_id=z.loan_application_history_id and a.term_no=z.term_no
...@@ -1183,7 +1185,7 @@ ...@@ -1183,7 +1185,7 @@
select a.loan_application_history_id,max(a.repayment_received_at) as repaymentReceivedAt,max(a.deadline) as deadline select a.loan_application_history_id,max(a.repayment_received_at) as repaymentReceivedAt,max(a.deadline) as deadline
from xyqb.repayment_plan a from xyqb.repayment_plan a
left join xyqb.loan_application_manifest_history b left join xyqb.loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{loanStartTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{loanEndTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at >= #{startTime,jdbcType=VARCHAR} and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
where (a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>=a.deadline)) where (a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>=a.deadline))
and b.funding_corp_id in (1080,100040,1030,100030) and b.funding_corp_id in (1080,100040,1030,100030)
and b.transaction_status in (2,5) and b.transaction_status in (2,5)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment