|
|
|
@ -7,6 +7,7 @@ import au.com.royalpay.payment.manage.analysis.core.DashboardService;
|
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ExchangeRateMapper;
|
|
|
|
@ -17,7 +18,6 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
|
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DurationFormatUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
@ -65,6 +65,9 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
|
|
|
|
|
@Resource
|
|
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientCustomersMapper clientCustomersMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -74,45 +77,86 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
|
|
|
|
|
if(commonAnalysis1 != null){
|
|
|
|
|
return commonAnalysis1;
|
|
|
|
|
}
|
|
|
|
|
JSONObject res = transactionAnalysisMapper.getClientTransaction(params);
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
if(params.getDate("end").after(new Date())){
|
|
|
|
|
if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){
|
|
|
|
|
res = transactionAnalysisMapper.getClientTransaction(params);
|
|
|
|
|
}else {
|
|
|
|
|
res = customerAndOrdersStatisticsMapper.getCommonCount(params);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
res = customerAndOrdersStatisticsMapper.getCommonCount(params);
|
|
|
|
|
}
|
|
|
|
|
stringRedisTemplate.boundValueOps("org_commonAnalysis1"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES);
|
|
|
|
|
return res;
|
|
|
|
|
// res.put("new_partners", clientAnalysisMapper.countNewClients(params));
|
|
|
|
|
// res.put("total_partners", clientAnalysisMapper.countClients(params));
|
|
|
|
|
// res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
|
|
|
|
|
// List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc")));
|
|
|
|
|
// if (!topOrders.isEmpty()) {
|
|
|
|
|
// res.put("top_amount_order", topOrders.get(0));
|
|
|
|
|
// }
|
|
|
|
|
// res.put("total_customers", transactionAnalysisMapper.countCustomers(params));
|
|
|
|
|
// //res.put("new_customers", transactionAnalysisMapper.countNewCustomers(params));
|
|
|
|
|
// res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getCommonAnalysis3(JSONObject params) {
|
|
|
|
|
String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis3"+ params.getString("org_id")+ params.getString("begin")).get();
|
|
|
|
|
JSONObject commonAnalysis3 = JSONObject.parseObject(jsonStr);
|
|
|
|
|
if(commonAnalysis3 != null){
|
|
|
|
|
return commonAnalysis3;
|
|
|
|
|
}
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
res.put("new_partners", clientAnalysisMapper.countNewClients(params));
|
|
|
|
|
res.put("total_partners", clientAnalysisMapper.countClients(params));
|
|
|
|
|
res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
|
|
|
|
|
stringRedisTemplate.boundValueOps("org_commonAnalysis3"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getCommonAnalysis2(JSONObject params) {
|
|
|
|
|
String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis2"+ params.getString("org_id")+ params.getString("begin")).get();
|
|
|
|
|
JSONObject commonAnalysis2 = JSONObject.parseObject(jsonStr);
|
|
|
|
|
if(commonAnalysis2 != null){
|
|
|
|
|
return commonAnalysis2;
|
|
|
|
|
}
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
if(params.getDate("end").after(new Date())){
|
|
|
|
|
if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){
|
|
|
|
|
res.put("total_customers", transactionAnalysisMapper.countCustomers(params));
|
|
|
|
|
res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params));
|
|
|
|
|
res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
|
|
|
|
|
}else {
|
|
|
|
|
res = getYesOrLasMonth(params);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
res = getYesOrLasMonth(params);
|
|
|
|
|
}
|
|
|
|
|
stringRedisTemplate.boundValueOps("org_commonAnalysis2"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
private JSONObject getYesOrLasMonth(JSONObject params){
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
res.put("traded_partners", clientCustomersMapper.countTradedClients(params));
|
|
|
|
|
res.put("total_customers", clientCustomersMapper.countTotalCustomers(params));
|
|
|
|
|
res.put("old_customers", clientCustomersMapper.countTotalOldCustomers(params));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getCommonAnalysis4(JSONObject params) {
|
|
|
|
|
String jsonStr = stringRedisTemplate.boundValueOps("org_commonAnalysis4"+ params.getString("org_id")+ params.getString("begin")).get();
|
|
|
|
|
JSONObject commonAnalysis4 = JSONObject.parseObject(jsonStr);
|
|
|
|
|
if(commonAnalysis4 != null){
|
|
|
|
|
return commonAnalysis4;
|
|
|
|
|
}
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
// res.put("new_partners", clientAnalysisMapper.countNewClients(params));
|
|
|
|
|
// res.put("total_partners", clientAnalysisMapper.countClients(params));
|
|
|
|
|
// res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
|
|
|
|
|
// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params));
|
|
|
|
|
// res.put("trade_count", transactionAnalysisMapper.getClientTransaction(params).getIntValue("trade_count"));
|
|
|
|
|
List<JSONObject> topOrders = transactionAnalysisMapper.getTopOrders(params, new PageBounds(1, 1, Order.formString("aud_fee.desc")));
|
|
|
|
|
if (!topOrders.isEmpty()) {
|
|
|
|
|
res.put("top_amount_order", topOrders.get(0));
|
|
|
|
|
}
|
|
|
|
|
res.put("total_customers", transactionAnalysisMapper.countCustomers(params));
|
|
|
|
|
//res.put("new_customers", transactionAnalysisMapper.countNewCustomers(params));
|
|
|
|
|
res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params));
|
|
|
|
|
stringRedisTemplate.boundValueOps("org_commonAnalysis4"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject getSevenOrMonth(JSONObject params, JSONObject today){
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
res.put("traded_partners", clientCustomersMapper.countTradedClients(params) + clientAnalysisMapper.countNewClients(today));
|
|
|
|
|
res.put("total_customers", clientCustomersMapper.countTotalCustomers(params) + clientAnalysisMapper.countClients(today));
|
|
|
|
|
res.put("old_customers", clientCustomersMapper.countTotalOldCustomers(params) + clientAnalysisMapper.countTradedPartners(params));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -469,7 +513,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
/* @Override
|
|
|
|
|
public JSONObject getPlatformAmount(JSONObject params) {
|
|
|
|
|
JSONObject resp = new JSONObject();
|
|
|
|
|
|
|
|
|
@ -493,8 +537,38 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
|
|
|
|
|
resp.put("aliOnlineAmount",transactionAnalysisMapper.getPlatformAmount(params).getBigDecimal("amount"));
|
|
|
|
|
resp.put("aliOnline_order_count",transactionAnalysisMapper.getPlatformAmount(params).getIntValue("order_count"));
|
|
|
|
|
return resp;
|
|
|
|
|
}*/
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getPlatformAmount(JSONObject params) {
|
|
|
|
|
String jsonStr = stringRedisTemplate.boundValueOps("org_ChannelAnalysis" + params.getString("begin")).get();
|
|
|
|
|
JSONObject channelAnalysis = JSONObject.parseObject(jsonStr);
|
|
|
|
|
if(channelAnalysis != null){
|
|
|
|
|
return channelAnalysis;
|
|
|
|
|
}else {
|
|
|
|
|
JSONObject resp;
|
|
|
|
|
if(params.getDate("end").compareTo(new Date()) > 0){
|
|
|
|
|
if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){
|
|
|
|
|
resp = getTodayChannelCount(params);
|
|
|
|
|
}else {
|
|
|
|
|
resp = customerAndOrdersStatisticsMapper.getChannelCommonCount(params);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
resp = customerAndOrdersStatisticsMapper.getChannelCommonCount(params);
|
|
|
|
|
}
|
|
|
|
|
stringRedisTemplate.boundValueOps("org_ChannelAnalysis"+ params.getString("begin")).set(resp.toJSONString(), 5, TimeUnit.MINUTES);
|
|
|
|
|
return resp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private JSONObject getTodayChannelCount(JSONObject params){
|
|
|
|
|
String[] channels = new String[]{"Bestpay","Wechat","Alipay","jd","AlipayOnline"};
|
|
|
|
|
JSONObject resp = new JSONObject();
|
|
|
|
|
for(String channel:channels) {
|
|
|
|
|
params.put("channel", channel);
|
|
|
|
|
resp.put(channel.toLowerCase()+"amount", transactionAnalysisMapper.getPlatformAmount(params).getBigDecimal("amount"));
|
|
|
|
|
resp.put(channel.toLowerCase()+"_order_count", transactionAnalysisMapper.getPlatformAmount(params).getIntValue("order_count"));
|
|
|
|
|
}
|
|
|
|
|
return resp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject getOrderAndCustomerPerDay(JSONObject partner, AnalysisBean partnerAnalysisBean) {
|
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
|