master
yuan 7 years ago
parent a1b2ff0474
commit 56a6497dbb

@ -82,13 +82,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){ if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){
res = transactionAnalysisMapper.getClientTransaction(params); res = transactionAnalysisMapper.getClientTransaction(params);
}else { }else {
JSONObject today = new JSONObject(); res = customerAndOrdersStatisticsMapper.getCommonCount(params);
today.put("end",params.getDate("end"));
today.put("begin", DateUtils.addDays(params.getDate("end"), -1));
JSONObject isToday = transactionAnalysisMapper.getClientTransaction(params);
JSONObject isNotToday = customerAndOrdersStatisticsMapper.getCommonCount(today);
res.put("trade_count",isToday.getIntValue("trade_count") + isNotToday.getIntValue("trade_count"));
res.put("trade_amount",isToday.getBigDecimal("trade_amount").add(isNotToday.getBigDecimal("trade_amount")));
} }
}else { }else {
res = customerAndOrdersStatisticsMapper.getCommonCount(params); res = customerAndOrdersStatisticsMapper.getCommonCount(params);
@ -126,17 +120,19 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params)); res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params));
res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params)); res.put("traded_partners", clientAnalysisMapper.countTradedPartners(params));
}else { }else {
JSONObject today = new JSONObject(); res = getYesOrLasMonth(params);
today.put("end",params.getDate("end"));
today.put("begin", DateUtils.addDays(params.getDate("end"), -1));
res = getSevenOrMonth(params,today);
} }
}else { }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("traded_partners", clientCustomersMapper.countTradedClients(params));
res.put("total_customers", clientCustomersMapper.countTotalCustomers(params)); res.put("total_customers", clientCustomersMapper.countTotalCustomers(params));
res.put("old_customers", clientCustomersMapper.countTotalOldCustomers(params)); res.put("old_customers", clientCustomersMapper.countTotalOldCustomers(params));
}
stringRedisTemplate.boundValueOps("org_commonAnalysis2"+params.getString("org_id")+params.getString("begin")).set(res.toJSONString(), 5, TimeUnit.MINUTES);
return res; return res;
} }
@ -554,10 +550,7 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){ if(params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){
resp = getTodayChannelCount(params); resp = getTodayChannelCount(params);
}else { }else {
JSONObject today = new JSONObject(); resp = customerAndOrdersStatisticsMapper.getChannelCommonCount(params);
today.put("end",params.getDate("end"));
today.put("begin", DateUtils.addDays(params.getDate("end"), -1));
resp = getChannelSevenOrMonth(params,today);
} }
}else { }else {
resp = customerAndOrdersStatisticsMapper.getChannelCommonCount(params); resp = customerAndOrdersStatisticsMapper.getChannelCommonCount(params);
@ -576,19 +569,6 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
} }
return resp; return resp;
} }
private JSONObject getChannelSevenOrMonth(JSONObject params,JSONObject today){
JSONObject channelCount = customerAndOrdersStatisticsMapper.getChannelCommonCount(params);
String[] channels = new String[]{"Bestpay","Wechat","Alipay","jd","AlipayOnline"};
JSONObject resp = new JSONObject();
for(String channel:channels) {
today.put("channel", channel);
JSONObject channelAna = transactionAnalysisMapper.getPlatformAmount(today);
resp.put(channel.toLowerCase()+"amount", channelAna.getBigDecimal("amount").add(channelCount.getBigDecimal(channel.toLowerCase()+"amount")));
resp.put(channel.toLowerCase()+"_order_count", channelAna.getIntValue("order_count") + channelCount.getIntValue(channel.toLowerCase()+"_order_count"));
}
return resp;
}
@Override @Override
public JSONObject getOrderAndCustomerPerDay(JSONObject partner, AnalysisBean partnerAnalysisBean) { public JSONObject getOrderAndCustomerPerDay(JSONObject partner, AnalysisBean partnerAnalysisBean) {
String timezone = partner.getJSONObject("client").getString("timezone"); String timezone = partner.getJSONObject("client").getString("timezone");

@ -316,21 +316,11 @@
ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.total ELSE 0 END),0) alipayonlineamount, ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.total ELSE 0 END),0) alipayonlineamount,
ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.orders ELSE 0 END),0) alipayonline_order_count ifnull(sum(CASE WHEN s.channel = 'AlipayOnline' THEN s.orders ELSE 0 END),0) alipayonline_order_count
FROM statistics_customer_order s FROM statistics_customer_order s
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
]]> ]]>
<where> <where>
s.client_id != 0 s.client_id != 0
<if test="client_ids!=null">
AND s.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
#{client_id}
</foreach>
</if>
<if test="client_ids==null and client_id != null">
and s.client_id=#{client_id}
</if>
<if test="begin!=null">and s.date &gt;= #{begin}</if> <if test="begin!=null">and s.date &gt;= #{begin}</if>
<if test="end!=null">and s.date &lt; #{end}</if> <if test="end!=null">and s.date &lt;= #{end}</if>
<if test="org_id!=null and org_ids==null">and c.org_id=#{org_id}</if> <if test="org_id!=null and org_ids==null">and c.org_id=#{org_id}</if>
<if test="org_ids!=null">and c.org_id in <if test="org_ids!=null">and c.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>

@ -45,25 +45,25 @@
</update> </update>
<select id="countTradedClients" resultType="java.lang.Integer"> <select id="countTradedClients" resultType="java.lang.Integer">
select COUNT(DISTINCT client_id) traded_partners select COUNT(DISTINCT client_id) traded_clients
FROM sys_clients_customers FROM sys_clients_customers
<where> <where>
<if test="begin!=null">and last_payment_time &gt;= #{begin}</if> <if test="begin!=null">and last_payment_time &gt;= #{begin}</if>
<if test="end!=null">and last_payment_time &lt; #{end}</if> <if test="end!=null">and last_payment_time &lt;= #{end}</if>
</where> </where>
</select> </select>
<select id="countTotalCustomers" resultType="java.lang.Integer"> <select id="countTotalCustomers" resultType="java.lang.Integer">
select COUNT(DISTINCT customer_id) traded_partners select COUNT(DISTINCT customer_id) total_customers
FROM sys_clients_customers FROM sys_clients_customers
<where> <where>
<if test="begin!=null">and last_payment_time &gt;= #{begin}</if> <if test="begin!=null">and last_payment_time &gt;= #{begin}</if>
<if test="end!=null">and last_payment_time &lt; #{end}</if> <if test="end!=null">and last_payment_time &lt;= #{end}</if>
</where> </where>
</select> </select>
<select id="countTotalOldCustomers" resultType="java.lang.Integer"> <select id="countTotalOldCustomers" resultType="java.lang.Integer">
select COUNT(DISTINCT customer_id) traded_partners select COUNT(DISTINCT customer_id) total_old_customers
FROM sys_clients_customers FROM sys_clients_customers
<where> <where>
<if test="begin!=null">and update_time &lt; #{begin} AND last_payment_time &gt; #{begin}</if> <if test="begin!=null">and update_time &lt; #{begin} AND last_payment_time &gt; #{begin}</if>

@ -77,7 +77,7 @@ define(['angular', 'uiRouter', 'uiBootstrap', 'angularEcharts'], function (angul
var end = $filter('date')(date-oneDay, 'yyyyMMdd'); var end = $filter('date')(date-oneDay, 'yyyyMMdd');
var date2 = new Date(); var date2 = new Date();
date2.setMonth(date2.getMonth() - 2); date2.setMonth(date2.getMonth() - 1);
date2 = date2.setDate(1); date2 = date2.setDate(1);
var begin = $filter('date')(date2, 'yyyyMMdd'); var begin = $filter('date')(date2, 'yyyyMMdd');
return { return {

Loading…
Cancel
Save