fix estimate monday

master
luoyang 6 years ago
parent 3e814c663a
commit f885797ac4

@ -90,10 +90,12 @@ public class EstimateAnalysisServiceImpl implements EstimateAnalysisService {
if (week ==2) {
cal.add(Calendar.DATE, -3);
}
Date todayDate = cal.getTime();
Date todayDate = new Date();
Date todayClearDate = cal.getTime();
String dateStr = DateFormatUtils.format(todayDate, "yyyy/MM/dd");
if (estimateAnalysisMapper.checkDayIsCleanDay(dateStr) != null) {
JSONObject today = getDaySettleInfo(todayDate);
JSONObject todaySettle = getDaySettleInfo(todayDate);
JSONObject today = getDayClearInfo(todayClearDate, todaySettle);
try {
JSONObject realToday = todaySettleInfo(todayDate);
today.put("t1", realToday.getBigDecimal("t1"));
@ -175,6 +177,41 @@ public class EstimateAnalysisServiceImpl implements EstimateAnalysisService {
dayInfo.put("t1", 0);
}
//T2
maxDays = estimateAnalysisMapper.findLastCleanDays(end_date, 1);
end_date = maxDays.getString("date_str");
cleanDays = estimateAnalysisMapper.findLastCleanDays(start_date, 1);
start_date = cleanDays.getString("date_str");
JSONObject totalAmountT2 = estimateAnalysisMapper.findAllTransactionByDate(start_date, end_date, t2client);
if (totalAmountT2 != null) {
dayInfo.put("t2", totalAmountT2.getBigDecimal("total_amount"));
} else {
dayInfo.put("t2", 0);
}
//T3
maxDays = estimateAnalysisMapper.findLastCleanDays(end_date, 1);
end_date = maxDays.getString("date_str");
cleanDays = estimateAnalysisMapper.findLastCleanDays(start_date, 1);
start_date = cleanDays.getString("date_str");
JSONObject totalAmountT3 = estimateAnalysisMapper.findAllTransactionByDate(start_date, end_date, t3client);
if (totalAmountT3 != null) {
dayInfo.put("t3", totalAmountT3.getBigDecimal("total_amount"));
} else {
dayInfo.put("t3", 0);
}
dayInfo.put("estimate_date", endStr);
dayInfo.put("total", dayInfo.getBigDecimal("t1").add(dayInfo.getBigDecimal("t2")).add(dayInfo.getBigDecimal("t3")));
return dayInfo;
}
//把清算预估和到账金额分离
public JSONObject getDayClearInfo(Date date, JSONObject dayInfo) {
dayInfo.put("platformGetSettleFee", BigDecimal.ZERO);
String endStr = DateFormatUtils.format(date, "yyyy/MM/dd");
JSONObject maxDays = estimateAnalysisMapper.findMaxCleanDays(endStr);
String end_date = maxDays.getString("date_str");
JSONObject cleanDays = estimateAnalysisMapper.findLastCleanDays(endStr, 1);
List<JSONObject> tencentSettle = platformSettlementMapper.findBySettleDate(new Date(maxDays.getDate("date_str").getTime() - 86400000L), "Wechat");
if (tencentSettle != null && tencentSettle.size()>0) {
for (JSONObject logs : tencentSettle) {
@ -235,31 +272,6 @@ public class EstimateAnalysisServiceImpl implements EstimateAnalysisService {
}
cleanDays.clear();
//T2
maxDays = estimateAnalysisMapper.findLastCleanDays(end_date, 1);
end_date = maxDays.getString("date_str");
cleanDays = estimateAnalysisMapper.findLastCleanDays(start_date, 1);
start_date = cleanDays.getString("date_str");
JSONObject totalAmountT2 = estimateAnalysisMapper.findAllTransactionByDate(start_date, end_date, t2client);
if (totalAmountT2 != null) {
dayInfo.put("t2", totalAmountT2.getBigDecimal("total_amount"));
} else {
dayInfo.put("t2", 0);
}
//T3
maxDays = estimateAnalysisMapper.findLastCleanDays(end_date, 1);
end_date = maxDays.getString("date_str");
cleanDays = estimateAnalysisMapper.findLastCleanDays(start_date, 1);
start_date = cleanDays.getString("date_str");
JSONObject totalAmountT3 = estimateAnalysisMapper.findAllTransactionByDate(start_date, end_date, t3client);
if (totalAmountT3 != null) {
dayInfo.put("t3", totalAmountT3.getBigDecimal("total_amount"));
} else {
dayInfo.put("t3", 0);
}
dayInfo.put("estimate_date", endStr);
dayInfo.put("total", dayInfo.getBigDecimal("t1").add(dayInfo.getBigDecimal("t2")).add(dayInfo.getBigDecimal("t3")));
return dayInfo;
}

Loading…
Cancel
Save