mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-03 04:19:37 +08:00
后台数据统计订单地域新增维度选择
This commit is contained in:
parent
87e7da2c51
commit
7e58e5c383
@ -71,7 +71,7 @@
|
||||
<a href="javascript:;" data-start="" data-end="">全部</a>
|
||||
</span>
|
||||
{{/if}}
|
||||
{{include file="/index/stats_time" /}}
|
||||
{{include file="/index/stats_where" /}}
|
||||
</div>
|
||||
</div>
|
||||
<ul class="{{if isset($is_income) and $is_income eq true}}am-avg-sm-2 am-avg-lg-4{{else /}}am-avg-sm-1 am-avg-lg-3{{/if}}">
|
||||
@ -178,6 +178,7 @@
|
||||
<div class="block-title echarts-title">
|
||||
<span class="icon"></span>
|
||||
<span class="title">订单成交金额走势</span>
|
||||
<a href="javascript:;" class="am-icon-question-circle am-text-warning" data-am-popover="{content: '所有订单', trigger: 'hover focus', theme: 'sm'}"></a>
|
||||
<div class="am-fr right-operate" data-type="order-profit" data-init="1">
|
||||
{{if !empty($time_data)}}
|
||||
<span class="quick-time">
|
||||
@ -186,7 +187,7 @@
|
||||
{{/foreach}}
|
||||
</span>
|
||||
{{/if}}
|
||||
{{include file="/index/stats_time" /}}
|
||||
{{include file="/index/stats_where" /}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="echarts-order-profit"></div>
|
||||
@ -197,6 +198,7 @@
|
||||
<div class="block-title echarts-title">
|
||||
<span class="icon"></span>
|
||||
<span class="title">订单交易走势</span>
|
||||
<a href="javascript:;" class="am-icon-question-circle am-text-warning" data-am-popover="{content: '所有订单', trigger: 'hover focus', theme: 'sm'}"></a>
|
||||
<div class="am-fr right-operate" data-type="order-trading" data-init="1">
|
||||
{{if !empty($time_data)}}
|
||||
<span class="quick-time">
|
||||
@ -205,7 +207,7 @@
|
||||
{{/foreach}}
|
||||
</span>
|
||||
{{/if}}
|
||||
{{include file="/index/stats_time" /}}
|
||||
{{include file="/index/stats_where" /}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="echarts-order-trading"></div>
|
||||
@ -218,6 +220,7 @@
|
||||
<div class="block-title echarts-title">
|
||||
<span class="icon"></span>
|
||||
<span class="title">热销商品</span>
|
||||
<a href="javascript:;" class="am-icon-question-circle am-text-warning" data-am-popover="{content: '不含取消关闭的订单', trigger: 'hover focus', theme: 'sm'}"></a>
|
||||
<div class="am-fr right-operate" data-type="goods-hot" data-init="1" data-empty-time="1">
|
||||
{{if !empty($time_data)}}
|
||||
<span class="quick-time">
|
||||
@ -227,7 +230,7 @@
|
||||
<a href="javascript:;" data-start="" data-end="">全部</a>
|
||||
</span>
|
||||
{{/if}}
|
||||
{{include file="/index/stats_time" /}}
|
||||
{{include file="/index/stats_where" /}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="echarts-goods-hot"></div>
|
||||
@ -238,6 +241,7 @@
|
||||
<div class="block-title echarts-title">
|
||||
<span class="icon"></span>
|
||||
<span class="title">支付方式</span>
|
||||
<a href="javascript:;" class="am-icon-question-circle am-text-warning" data-am-popover="{content: '所有订单', trigger: 'hover focus', theme: 'sm'}"></a>
|
||||
<div class="am-fr right-operate" data-type="pay-type" data-init="1">
|
||||
{{if !empty($time_data)}}
|
||||
<span class="quick-time">
|
||||
@ -246,7 +250,7 @@
|
||||
{{/foreach}}
|
||||
</span>
|
||||
{{/if}}
|
||||
{{include file="/index/stats_time" /}}
|
||||
{{include file="/index/stats_where" /}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="echarts-pay-type"></div>
|
||||
@ -259,6 +263,12 @@
|
||||
<div class="block-title echarts-title">
|
||||
<span class="icon"></span>
|
||||
<span class="title">订单地域分布</span>
|
||||
<a href="javascript:;" class="am-icon-question-circle am-text-warning" data-am-popover="{content: '默认维度(省)', trigger: 'hover focus', theme: 'sm'}"></a>
|
||||
<select name="value" data-am-selected="{btnWidth: '50px', btnSize: 'xs'}">
|
||||
<option value="0" selected>省</option>
|
||||
<option value="1">市</option>
|
||||
<option value="2">区/县</option>
|
||||
</select>
|
||||
<div class="am-fr right-operate" data-type="order-whole-country" data-init="1" data-empty-time="1">
|
||||
{{if !empty($time_data)}}
|
||||
<span class="quick-time">
|
||||
@ -268,7 +278,7 @@
|
||||
<a href="javascript:;" data-start="" data-end="">全部</a>
|
||||
</span>
|
||||
{{/if}}
|
||||
{{include file="/index/stats_time" /}}
|
||||
{{include file="/index/stats_where" /}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="echarts-map-whole-country"></div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<span class="am-form echarts-where-time">
|
||||
<span class="am-form echarts-where">
|
||||
<input type="text" autocomplete="off" name="time_start" class="Wdate am-radius" placeholder="开始时间" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="{{if !empty($time_data) and !empty($default_day) and isset($time_data[$default_day])}}{{$time_data[$default_day]['start']}}{{/if}}" />
|
||||
<span class="join">-</span>
|
||||
<input type="text" autocomplete="off" class="Wdate am-radius" placeholder="结束时间" name="time_end" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="{{if !empty($time_data) and !empty($default_day) and isset($time_data[$default_day])}}{{$time_data[$default_day]['end']}}{{/if}}" />
|
@ -559,66 +559,6 @@ class StatisticalService
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单收益趋势
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-06T21:31:53+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function OrderProfitTotal($params = [])
|
||||
{
|
||||
// 订单状态列表
|
||||
$order_status_list = MyConst('common_order_status');
|
||||
$status_arr = array_column($order_status_list, 'id');
|
||||
|
||||
// 循环获取统计数据
|
||||
$data = [];
|
||||
$value_arr = [];
|
||||
$name_arr = [];
|
||||
if(!empty($status_arr))
|
||||
{
|
||||
$date = self::DayCreate($params['start'], $params['end']);
|
||||
foreach($date as $day)
|
||||
{
|
||||
// 当前日期名称
|
||||
$name_arr[] = date('Y-m-d', $day['start']);
|
||||
|
||||
// 根据状态获取数量
|
||||
foreach($status_arr as $status)
|
||||
{
|
||||
// 获取订单
|
||||
$where = [
|
||||
['status', '=', $status],
|
||||
['add_time', '>=', $day['start']],
|
||||
['add_time', '<=', $day['end']],
|
||||
];
|
||||
$value_arr[$status][] = Db::name('Order')->where($where)->sum('pay_price');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 数据格式组装
|
||||
foreach($status_arr as $status)
|
||||
{
|
||||
$data[] = [
|
||||
'name' => $order_status_list[$status]['name'],
|
||||
'type' => ($status == 4) ? 'line' : 'bar',
|
||||
'tiled' => '总量',
|
||||
'data' => empty($value_arr[$status]) ? [] : $value_arr[$status],
|
||||
];
|
||||
}
|
||||
|
||||
// 数据组装
|
||||
$result = [
|
||||
'title_arr' => array_column($order_status_list, 'name'),
|
||||
'name_arr' => $name_arr,
|
||||
'data' => $data,
|
||||
];
|
||||
return DataReturn('处理成功', 0, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单交易趋势
|
||||
* @author Devil
|
||||
@ -679,6 +619,66 @@ class StatisticalService
|
||||
return DataReturn('处理成功', 0, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单收益趋势
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-06T21:31:53+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function OrderProfitTotal($params = [])
|
||||
{
|
||||
// 订单状态列表
|
||||
$order_status_list = MyConst('common_order_status');
|
||||
$status_arr = array_column($order_status_list, 'id');
|
||||
|
||||
// 循环获取统计数据
|
||||
$data = [];
|
||||
$value_arr = [];
|
||||
$name_arr = [];
|
||||
if(!empty($status_arr))
|
||||
{
|
||||
$date = self::DayCreate($params['start'], $params['end']);
|
||||
foreach($date as $day)
|
||||
{
|
||||
// 当前日期名称
|
||||
$name_arr[] = date('Y-m-d', $day['start']);
|
||||
|
||||
// 根据状态获取数量
|
||||
foreach($status_arr as $status)
|
||||
{
|
||||
// 获取订单
|
||||
$where = [
|
||||
['status', '=', $status],
|
||||
['add_time', '>=', $day['start']],
|
||||
['add_time', '<=', $day['end']],
|
||||
];
|
||||
$value_arr[$status][] = Db::name('Order')->where($where)->sum('pay_price');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 数据格式组装
|
||||
foreach($status_arr as $status)
|
||||
{
|
||||
$data[] = [
|
||||
'name' => $order_status_list[$status]['name'],
|
||||
'type' => ($status == 4) ? 'line' : 'bar',
|
||||
'tiled' => '总量',
|
||||
'data' => empty($value_arr[$status]) ? [] : $value_arr[$status],
|
||||
];
|
||||
}
|
||||
|
||||
// 数据组装
|
||||
$result = [
|
||||
'title_arr' => array_column($order_status_list, 'name'),
|
||||
'name_arr' => $name_arr,
|
||||
'data' => $data,
|
||||
];
|
||||
return DataReturn('处理成功', 0, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 热销商品
|
||||
* @author Devil
|
||||
@ -808,6 +808,10 @@ class StatisticalService
|
||||
*/
|
||||
public static function OrderWholeCountryTotal($params = [])
|
||||
{
|
||||
// 维度默认省
|
||||
$region_arr = ['province_name', 'city_name', 'county_name'];
|
||||
$region_name = (empty($params['value']) || !array_key_exists($params['value'], $region_arr)) ? $region_arr[0] : $region_arr[$params['value']];
|
||||
|
||||
// 获取订单id
|
||||
$where = [
|
||||
['status', '<=', 4],
|
||||
@ -828,7 +832,7 @@ class StatisticalService
|
||||
{
|
||||
$data = [];
|
||||
} else {
|
||||
$data = Db::name('OrderAddress')->field('province_name as name, count(*) AS value')->where('order_id', 'IN', $order_ids)->group('province_name')->order('value asc')->select()->toArray();
|
||||
$data = Db::name('OrderAddress')->field($region_name.' as name, count(*) AS value')->where('order_id', 'IN', $order_ids)->group($region_name)->order('value asc')->limit(30)->select()->toArray();
|
||||
}
|
||||
|
||||
// 数据组装
|
||||
|
@ -44,7 +44,7 @@ html, body {
|
||||
.right-operate .quick-time a:hover {
|
||||
color: #095f8a;
|
||||
}
|
||||
.right-operate .echarts-where-time input {
|
||||
.right-operate .echarts-where input {
|
||||
display: -webkit-inline-box !important;
|
||||
width: 155px !important;
|
||||
border-color: #eee;
|
||||
@ -60,7 +60,7 @@ html, body {
|
||||
background-color: #3bb4f2;
|
||||
border-color: #3bb4f2;
|
||||
}
|
||||
.right-operate .echarts-where-time .join {
|
||||
.right-operate .echarts-where .join {
|
||||
color: #ccc;
|
||||
}
|
||||
.block-container .echarts-title{
|
||||
@ -73,16 +73,21 @@ html, body {
|
||||
float: none;
|
||||
}
|
||||
.block-combination-container-2 .right-operate .quick-time,
|
||||
.block-combination-container-2 .right-operate .echarts-where-time {
|
||||
.block-combination-container-2 .right-operate .echarts-where {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.block-combination-container-2 .right-operate .quick-time {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.block-combination-container-2 .right-operate .echarts-where-time input {
|
||||
width: calc(50% - 46px) !important;
|
||||
}
|
||||
.block-combination-container-2 .right-operate .echarts-where input {
|
||||
width: calc(50% - 46px) !important;
|
||||
}
|
||||
.block-container .am-dropdown .am-selected-btn {
|
||||
padding: 0.3em 1em 0.3em 0.3em;
|
||||
border-radius: 3px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
@media only screen and (min-width: 641px) {
|
||||
.block-combination-container-2 {
|
||||
margin-bottom: 20px;
|
||||
@ -114,14 +119,14 @@ html, body {
|
||||
float: none;
|
||||
}
|
||||
.right-operate .quick-time,
|
||||
.right-operate .echarts-where-time {
|
||||
.right-operate .echarts-where {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.right-operate .quick-time {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.right-operate .echarts-where-time input {
|
||||
.right-operate .echarts-where input {
|
||||
width: calc(50% - 46px) !important;
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ function EchartsOrderMapWholeCountry(name_arr, data)
|
||||
var option = {
|
||||
title: {
|
||||
text: '',
|
||||
subtext: ''
|
||||
subtext: '仅显示30条数据'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
@ -355,7 +355,6 @@ function EchartsOrderMapWholeCountry(name_arr, data)
|
||||
data: []
|
||||
},
|
||||
grid: {
|
||||
top: '5%',
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
@ -379,13 +378,13 @@ function EchartsOrderMapWholeCountry(name_arr, data)
|
||||
// 定制颜色显示(按顺序)
|
||||
// 超出定制颜色则返回随机
|
||||
color: function(params) {
|
||||
var colorList = ['#C33531','#EFE42A','#64BD3D','#EE9201','#29AAE3', '#B74AE5','#0AAF9F','#E89589','#16A085','#4A235A','#C39BD3 ','#F9E79F','#BA4A00','#ECF0F1','#616A6B','#EAF2F8','#4A235A','#3498DB', '#00BCD4', '#FF9800', '#E63A75', '#3F51B5'];
|
||||
var colorList = ['#C33531','#EFE42A','#64BD3D','#EE9201','#29AAE3','#B74AE5','#0AAF9F','#E89589','#16A085','#4A235A','#C39BD3','#F9E79F','#BA4A00','#ECF0F1','#616A6B','#EAF2F8','#4A235A','#3498DB','#00BCD4','#FF9800','#E63A75','#3F51B5','#1CC0A0','#795548','#CDDC39'];
|
||||
if(colorList[params.dataIndex] == undefined)
|
||||
{
|
||||
return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);
|
||||
} else {
|
||||
return colorList[params.dataIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -409,8 +408,8 @@ var chart_object = [];
|
||||
function EchartsInit(e)
|
||||
{
|
||||
// 类型
|
||||
var $parent = e.parents('.right-operate');
|
||||
var type = $parent.data('type');
|
||||
var type = e.parents('.right-operate').data('type');
|
||||
var value = e.parents('.echarts-title').find('select[name="value"]').val() || '';
|
||||
|
||||
// 时间
|
||||
var $time = e.parent();
|
||||
@ -425,7 +424,7 @@ function EchartsInit(e)
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
timeout: 30000,
|
||||
data: {"type":type, "start":start, "end":end},
|
||||
data: {"type":type, "start":start, "end":end, "value": value},
|
||||
success: function(res)
|
||||
{
|
||||
e.button('reset');
|
||||
@ -593,6 +592,12 @@ $(function()
|
||||
}
|
||||
});
|
||||
|
||||
// 基础条件值改变事件
|
||||
$('.echarts-title select[name="value"]').on('change', function()
|
||||
{
|
||||
$(this).parent().find('button.echarts-where-submit').trigger('click');
|
||||
});
|
||||
|
||||
// 条件确认
|
||||
$('.echarts-where-submit').on('click', function()
|
||||
{
|
||||
@ -618,7 +623,7 @@ $(function()
|
||||
{
|
||||
$time.find('input[name="time_start"]').val(start);
|
||||
$time.find('input[name="time_end"]').val(end);
|
||||
$time.find('button').trigger('click');
|
||||
$time.find('button.echarts-where-submit').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user