diff --git a/app/admin/view/default/index/init.html b/app/admin/view/default/index/init.html
index 28e4ca7e0..d354a947a 100755
--- a/app/admin/view/default/index/init.html
+++ b/app/admin/view/default/index/init.html
@@ -71,7 +71,7 @@
全部
{{/if}}
- {{include file="/index/stats_time" /}}
+ {{include file="/index/stats_where" /}}
@@ -178,6 +178,7 @@
订单成交金额走势
+
{{if !empty($time_data)}}
@@ -186,7 +187,7 @@
{{/foreach}}
{{/if}}
- {{include file="/index/stats_time" /}}
+ {{include file="/index/stats_where" /}}
@@ -197,6 +198,7 @@
订单交易走势
+
{{if !empty($time_data)}}
@@ -205,7 +207,7 @@
{{/foreach}}
{{/if}}
- {{include file="/index/stats_time" /}}
+ {{include file="/index/stats_where" /}}
@@ -218,6 +220,7 @@
热销商品
+
{{if !empty($time_data)}}
@@ -227,7 +230,7 @@
全部
{{/if}}
- {{include file="/index/stats_time" /}}
+ {{include file="/index/stats_where" /}}
@@ -238,6 +241,7 @@
支付方式
+
{{if !empty($time_data)}}
@@ -246,7 +250,7 @@
{{/foreach}}
{{/if}}
- {{include file="/index/stats_time" /}}
+ {{include file="/index/stats_where" /}}
@@ -259,6 +263,12 @@
订单地域分布
+
+
{{if !empty($time_data)}}
@@ -268,7 +278,7 @@
全部
{{/if}}
- {{include file="/index/stats_time" /}}
+ {{include file="/index/stats_where" /}}
diff --git a/app/admin/view/default/index/stats_time.html b/app/admin/view/default/index/stats_where.html
similarity index 94%
rename from app/admin/view/default/index/stats_time.html
rename to app/admin/view/default/index/stats_where.html
index bdf815d69..d82599942 100644
--- a/app/admin/view/default/index/stats_time.html
+++ b/app/admin/view/default/index/stats_where.html
@@ -1,4 +1,4 @@
-
+
-
diff --git a/app/service/StatisticalService.php b/app/service/StatisticalService.php
index 132526554..07d6d3ac3 100755
--- a/app/service/StatisticalService.php
+++ b/app/service/StatisticalService.php
@@ -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();
}
// 数据组装
diff --git a/public/static/admin/default/css/index.init.css b/public/static/admin/default/css/index.init.css
index 70ae96786..28e8dbcc4 100755
--- a/public/static/admin/default/css/index.init.css
+++ b/public/static/admin/default/css/index.init.css
@@ -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;
}
}
diff --git a/public/static/admin/default/js/index.init.js b/public/static/admin/default/js/index.init.js
index bd5db3386..88e2a90b8 100644
--- a/public/static/admin/default/js/index.init.js
+++ b/public/static/admin/default/js/index.init.js
@@ -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');
}
});