|
|
|
@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.analysis.core.impls;
|
|
|
|
|
import au.com.royalpay.payment.manage.analysis.core.DailyReport;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.cashback.CashbackRecordsMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDCommissionConfigMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeLogMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.DailyReportMapper;
|
|
|
|
@ -10,7 +11,6 @@ import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.redpack.ActPartnerLMLogMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
|
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage;
|
|
|
|
@ -18,6 +18,7 @@ import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
@ -31,7 +32,10 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by yishuqian on 16/11/2017.
|
|
|
|
@ -59,7 +63,8 @@ public class DailyReportImp implements DailyReport {
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
@Resource
|
|
|
|
|
private TransactionMapper transactionMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private FinancialBDConfigMapper financialBDConfigMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void generateReport(String date, boolean sendMsg) {
|
|
|
|
@ -134,20 +139,22 @@ public class DailyReportImp implements DailyReport {
|
|
|
|
|
kpi.put("kpi_percent", p.getBigDecimal("month_amount").divide(kpi_amount, 4, BigDecimal.ROUND_HALF_DOWN).multiply(BigDecimal.valueOf(100)).toString().substring(0, 5) + "%");
|
|
|
|
|
for (JSONObject clientAmount : clientsAmount) {
|
|
|
|
|
if (clientAmount.getString("bd_group").equals(kpi.getString("bd_group"))) {
|
|
|
|
|
//查询该领队下所有BD
|
|
|
|
|
List<JSONObject> teamBDs = financialBDConfigMapper.listGroupBds(kpi.getString("bd_group"));
|
|
|
|
|
int bdMonthClientCount = 0;
|
|
|
|
|
int bdYesterdayClientCount = 0;
|
|
|
|
|
for (int i = 0; i < teamBDs.size(); i++) {
|
|
|
|
|
// sys_clients中查询出此bd创建并属于此bd的商户,并且时间是昨天和本月
|
|
|
|
|
JSONObject countByBd = clientMapper.findCountByBd(clientAmount.getString("bd_group"), DateUtils.truncate(DateUtils.addDays(dt, 1), Calendar.DATE), DateUtils.truncate(dt, Calendar.DATE), DateUtils.truncate(dt, Calendar.MONTH));
|
|
|
|
|
if (countByBd.getInteger("month_count") == null){
|
|
|
|
|
kpi.put("clients_month", 0);
|
|
|
|
|
}else {
|
|
|
|
|
kpi.put("clients_month", countByBd.getInteger("month_count"));
|
|
|
|
|
JSONObject countByBd = clientMapper.findCountByBd(teamBDs.get(i).getString("manager_id"), DateUtils.truncate(DateUtils.addDays(dt, 1), Calendar.DATE), DateUtils.truncate(dt, Calendar.DATE), DateUtils.truncate(dt, Calendar.MONTH));
|
|
|
|
|
if (countByBd.getInteger("month_count") != null) {
|
|
|
|
|
bdMonthClientCount += countByBd.getInteger("month_count");
|
|
|
|
|
}
|
|
|
|
|
if (countByBd.getInteger("yesterday_count") == null){
|
|
|
|
|
kpi.put("clients_yesterday", 0);
|
|
|
|
|
}else {
|
|
|
|
|
kpi.put("clients_yesterday", countByBd.getInteger("yesterday_count"));
|
|
|
|
|
if (countByBd.getInteger("yesterday_count") != null) {
|
|
|
|
|
bdYesterdayClientCount += countByBd.getInteger("yesterday_count");
|
|
|
|
|
}
|
|
|
|
|
// kpi.put("clients_month", clientAmount.getBigDecimal("clients_month"));
|
|
|
|
|
// kpi.put("clients_yesterday", clientAmount.getBigDecimal("clients_yesterday"));
|
|
|
|
|
}
|
|
|
|
|
kpi.put("clients_month", bdMonthClientCount);
|
|
|
|
|
kpi.put("clients_yesterday", bdYesterdayClientCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
total_kpi_amount = total_kpi_amount.add(kpi_amount);
|
|
|
|
@ -364,7 +371,6 @@ public class DailyReportImp implements DailyReport {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getReport(String reportId, String openid) {
|
|
|
|
|
JSONObject manager = managerMapper.findByWxOpenId(openid);
|
|
|
|
@ -382,6 +388,7 @@ public class DailyReportImp implements DailyReport {
|
|
|
|
|
report.put("report_date", report.getDate("report_date"));
|
|
|
|
|
return report;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void publishMessages(List<JSONObject> users, String reportId, String range) {
|
|
|
|
|
ArrayList<String> clean_users = new ArrayList<>();
|
|
|
|
|
String url = PlatformEnvironment.getEnv().concatUrl("/analysis/daily_reports/" + reportId);
|
|
|
|
|