add 商户类别交易趋势增加交易商户数数据

master
luoyang 5 years ago
parent a3b43675af
commit 57e46bc170

@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.4.13</version>
<version>1.4.14</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -27,6 +27,8 @@ public interface ClientAnalysisMapper {
// 统计所有的商户,包括禁用的
int countClientsAll(JSONObject params);
int countValidClientsAll(@Param("industry") String industry);
// 统计一段时期新增的商户数
List<JSONObject> listNewClients(JSONObject params);

@ -11,6 +11,8 @@ import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
@ -70,7 +72,14 @@ public class DataAnalysisServiceImpl implements DataAnalysisService {
@Override
public List<JSONObject> getRpIndustryEchartsData(String from, String to, String industry, String managerId) throws ParseException {
Date modifyTo = DateUtils.addDays(DateUtils.parseDate(to, "yyyy-MM-dd"), 1);
return transactionAnalysisMapper.getRpIndustryEchartsData(from, DateFormatUtils.format(modifyTo, "yyyy-MM-dd HH:mm:ss"), industry, managerId);
List<JSONObject> data = transactionAnalysisMapper.getRpIndustryEchartsData(from, DateFormatUtils.format(modifyTo, "yyyy-MM-dd HH:mm:ss"), industry, managerId);
BigDecimal totalClients = new BigDecimal(clientAnalysisMapper.countValidClientsAll(industry));
for (JSONObject detail : data) {
BigDecimal industryClients = detail.getBigDecimal("industry_trans_clients");
detail.put("total_client", totalClients.setScale(0, RoundingMode.DOWN));
detail.put("in_total_pcent", industryClients.divide(totalClients, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
}
return data;
}
@Override

@ -53,6 +53,21 @@
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
</select>
<!--显示所有的商户,包括禁用的-->
<select id="countValidClientsAll" resultType="java.lang.Integer">
SELECT count(client_id)
FROM sys_clients
WHERE
create_time &lt;= now() and (approve_result is null or approve_result !=0) and is_valid=1
<if test="industry != null and industry=='1'.toString()">
and (royalpayindustry = 1 or royalpayindustry like '100%')
</if>
<if test="industry != null and industry!='0'.toString() and industry!='1'.toString()">
<bind name="industry" value="industry+'%'"/>
AND royalpayindustry like #{industry}
</if>
</select>
<select id="listNewClients" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT count(client_id) new_clients,DATE_FORMAT(date(create_time),'%d/%m/%Y') create_times
@ -251,7 +266,7 @@
]]>
GROUP by c.sub_merchant_id
</select>
<select id="tradeSubMerchantIdBy60Days" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT COUNT(DISTINCT c.client_id) client_count,
@ -309,4 +324,4 @@
</where>
GROUP by c.clean_days
</select>
</mapper>
</mapper>

@ -1112,12 +1112,14 @@
sum(so.total) as total_amount,
sum(so.orders) as orders,
<if test="industry != null and industry=='1'.toString()">
count(Distinct IF((c.royalpayindustry =1 or c.royalpayindustry like '100%'), so.client_id,0)) as industry_trans_clients,
SUM(IF((c.royalpayindustry =1 or c.royalpayindustry like '100%'),so.total,0)) as industry_total_amount,
SUM(IF((c.royalpayindustry =1 or c.royalpayindustry like '100%'),so.orders,0)) as industry_orders,
convert(SUM(IF((c.royalpayindustry =1 or c.royalpayindustry like '100%'),so.total,0))/sum( so.total )*100,decimal(15,2)) as amount_pcent,
convert(SUM(IF((c.royalpayindustry =1 or c.royalpayindustry like '100%'),so.orders,0))/sum( so.orders )*100,decimal(15,2)) as order_pcent,
</if>
<if test="industry == null or industry=='0'.toString()">
count(Distinct so.client_id) as industry_trans_clients,
sum(so.total) as industry_total_amount,
sum(so.orders) as industry_orders,
100 as amount_pcent,
@ -1125,6 +1127,7 @@
</if>
<if test="industry != null and industry!='0'.toString()">
<bind name="industry" value="industry+'%'"/>
count(Distinct IF(c.royalpayindustry like #{industry}, so.client_id,0)) as industry_trans_clients,
SUM(IF(c.royalpayindustry like #{industry},so.total,0)) as industry_total_amount,
SUM(IF(c.royalpayindustry like #{industry},so.orders,0)) as industry_orders,
convert(SUM(IF(c.royalpayindustry like #{industry},so.total,0))/sum( so.total )*100,decimal(15,2)) as amount_pcent,
@ -1148,6 +1151,7 @@
order by trans_date asc
</select>
<select id="getTopRpIndustryData" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sum(so.total) as total_amount,

@ -624,7 +624,6 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts','echarts'], funct
}
]
};
var amountOption = {
chart: {
yAxis: {
@ -747,6 +746,120 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts','echarts'], funct
}
]
};
var partnerOption = {
chart: {
yAxis: {
splitLine: {show: true},
axisLine: {
lineStyle: {
color: '#000'
}
}
},
backgroundColor: '#fff',
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: '行业总商户数 : {c3}<br />' +
'行业产生交易商户数 : {c1}<br /> ' +
'占比 : {c0}%'
},
legend: {
data: ['行业总商户数', '行业产生交易商户数'],
textStyle: {
color: '#000'
}
}
},
xAxis: {
basic: {
axisLine: {
lineStyle: {
color: '#000'
}
}
},
key: 'trans_date'
},
series: [
{
basic: {
name: 'pcent',
type: 'pictorialBar',
symbol: 'rect',
itemStyle: {
color: '#fff'
},
symbolRepeat: true,
symbolSize: [12, 4],
symbolMargin: 1,
z: -10
},
column: {key: 'in_total_pcent'}
},
{
basic: {
label:{
normal: {
show: true,
position: 'right',
offset: [0, 0],
textStyle: {
fontSize: 15,
fontFamily: 'Arial'
}
}},
name: '行业产生交易商户数',
type: 'line',
smooth: true,
showAllSymbol: true,
symbol: 'emptyCircle',
symbolSize: 5
},
column: {key: 'industry_trans_clients'}
}, {
basic: {
name: '行业产生交易商户数',
type: 'bar',
barWidth: 10,
itemStyle: {
barBorderRadius: 5,
color: '#14c8d4'
}
},
column: {key: 'industry_trans_clients'}
},{
basic: {
name: '行业总商户数',
type: 'bar',
barGap: '-100%',
barWidth: 10,
z: -12,
itemStyle: {
color: '#fff'
}
},
column: {key: 'total_client'}
}, {
basic: {
name: '行业总商户数',
type: 'pictorialBar',
symbol: 'rect',
itemStyle: {
color: '#0f375f'
},
symbolRepeat: true,
symbolSize: [12, 4],
symbolMargin: 1,
z: -10
},
column: {key: 'total_client'}
}
]
};
$scope.doAnalysis = function () {
$scope.future_loading = true;
@ -762,13 +875,14 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts','echarts'], funct
$scope.analysisData = resp.data;
$scope.amountAnalysis = chartParser.parse(amountOption, resp.data);
$scope.ordersAnalysis = chartParser.parse(orderOption, resp.data);
$scope.partnerAnalysis = chartParser.parse(partnerOption, resp.data);
$scope.future_loading = false;
$scope.chooseDay = $filter('date')($scope.params.from, 'yyyy-MM-dd');
$scope.loadTopTransPartners(1);
});
};
$scope.thisMonth();
$scope.chooseLast7Days();
$scope.loadTopTransPartners = function (page) {
var requestParams = angular.copy($scope.params);
if (requestParams.from) {

@ -99,6 +99,9 @@
<div class="chart" echarts="ordersAnalysis" style="height: 300px"
chart-setter="choseDayEchart($chart)"
ng-class="{nodata:ordersAnalysis.nodata}"></div>
<div class="chart" echarts="partnerAnalysis" style="height: 300px"
chart-setter="choseDayEchart($chart)"
ng-class="{nodata:partnerAnalysis.nodata}"></div>
</div>
</div>
</div>

Loading…
Cancel
Save