后台挂历首页新增收益走势

This commit is contained in:
devil 2020-08-15 12:05:18 +08:00
parent f4f59e4b9f
commit 2204c24760
4 changed files with 132 additions and 9 deletions

View File

@ -86,6 +86,10 @@ class Index extends Common
$order_complete_money = StatisticalService::OrderCompleteMoneyYesterdayTodayTotal();
$this->assign('order_complete_money', $order_complete_money['data']);
// 近30日成交金额走势
$order_profit_chart = StatisticalService::OrderProfitSevenTodayTotal();
$this->assign('order_profit_chart', $order_profit_chart['data']);
// 近15日订单交易走势
$order_trading_trend = StatisticalService::OrderTradingTrendSevenTodayTotal();
$this->assign('order_trading_trend', $order_trading_trend['data']);

View File

@ -37,7 +37,7 @@
<span>今日</span>
<span class="animation-count-to" data-to="{{$order_number.today_count}}" data-speed="1500">0</span>
</div>
<i class="am-icon-list-alt am-icon-lg bg-icon"></i>
<i class="am-icon-pie-chart am-icon-lg bg-icon"></i>
</div>
</li>
<li>
@ -67,12 +67,20 @@
<span>今日</span>
<span class="animation-count-to" data-to="{{$order_complete_money.today_count}}" data-speed="1500" data-decimals="2">0.00</span>
</div>
<i class="am-icon-gift am-icon-lg bg-icon"></i>
<i class="am-icon-line-chart am-icon-lg bg-icon"></i>
</div>
</li>
</ul>
</div>
<!-- 近30日成交金额走势 -->
<div class="echarts-container">
<div class="echarts-title">
<span class="icon"></span>
<span class="title">近30日成交金额走势</span>
</div>
<div id="echarts-order-profit"></div>
</div>
<!-- 近30日订单交易走势 -->
<div class="echarts-container">
@ -159,6 +167,53 @@
<script type="text/javascript">
$(function()
{
// 近30日成交金额走势
var order_profit_chart = echarts.init(document.getElementById('echarts-order-profit'), 'macarons');
var option = {
tooltip : {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
legend: {
data: {{:json_encode($order_profit_chart.title_arr)}}
},
toolbox: {
show : {{if IsMobile()}}false{{else}}true{{/if}},
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
restore : {show: true},
saveAsImage : {name:'近30日订单交易走势', show: true}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
boundaryGap : false,
data : {{:json_encode($order_profit_chart.name_arr)}}
}
],
yAxis : [
{
type : 'value'
}
],
series : {{:json_encode($order_profit_chart.data)}}
};
order_profit_chart.setOption(option);
// 近30日订单交易走势
var order_trading_chart = echarts.init(document.getElementById('echarts-order-trading'), 'macarons');
var option = {
@ -292,6 +347,7 @@ $(function()
{
order_pay_type_chart.resize();
goods_hot_chart.resize();
order_profit_chart.resize();
order_trading_chart.resize();
};
});

View File

@ -288,6 +288,68 @@ class StatisticalService
return DataReturn('处理成功', 0, $result);
}
/**
* 订单收益趋势, 30天数据
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-06T21:31:53+0800
* @param [array] $params [输入参数]
*/
public static function OrderProfitSevenTodayTotal($params = [])
{
// 初始化
self::Init($params);
// 订单状态列表
$order_status_list = lang('common_order_user_status');
$status_arr = array_column($order_status_list, 'id');
// 循环获取统计数据
$data = [];
$value_arr = [];
$name_arr = [];
if(!empty($status_arr))
{
foreach(self::$nearly_thirty_days as $day)
{
// 当前日期名称
$name_arr[] = $day['name'];
// 根据支付名称获取数量
foreach($status_arr as $status)
{
// 获取订单
$where = [
['status', '=', $status],
['add_time', '>=', $day['start_time']],
['add_time', '<=', $day['end_time']],
];
$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);
}
/**
* 订单交易趋势, 30天数据
* @author Devil
@ -307,7 +369,7 @@ class StatisticalService
// 循环获取统计数据
$data = [];
$count_arr = [];
$value_arr = [];
$name_arr = [];
if(!empty($status_arr))
{
@ -325,7 +387,7 @@ class StatisticalService
['add_time', '>=', $day['start_time']],
['add_time', '<=', $day['end_time']],
];
$count_arr[$status][] = Db::name('Order')->where($where)->count();
$value_arr[$status][] = Db::name('Order')->where($where)->count();
}
}
}
@ -335,9 +397,9 @@ class StatisticalService
{
$data[] = [
'name' => $order_status_list[$status]['name'],
'type' => 'line',
'type' => ($status == 4) ? 'bar' : 'line',
'tiled' => '总量',
'data' => empty($count_arr[$status]) ? [] : $count_arr[$status],
'data' => empty($value_arr[$status]) ? [] : $value_arr[$status],
];
}
@ -372,7 +434,7 @@ class StatisticalService
// 循环获取统计数据
$data = [];
$count_arr = [];
$value_arr = [];
$name_arr = [];
if(!empty($pay_name_arr))
{
@ -390,7 +452,7 @@ class StatisticalService
['add_time', '>=', $day['start_time']],
['add_time', '<=', $day['end_time']],
];
$count_arr[$payment][] = Db::name('PayLog')->where($where)->count();
$value_arr[$payment][] = Db::name('PayLog')->where($where)->count();
}
}
}
@ -403,7 +465,7 @@ class StatisticalService
'type' => 'line',
'stack' => '总量',
'areaStyle' => (object) [],
'data' => empty($count_arr[$payment]) ? [] : $count_arr[$payment],
'data' => empty($value_arr[$payment]) ? [] : $value_arr[$payment],
];
}

View File

@ -152,6 +152,7 @@ html, body {
/**
* 订单交易
*/
#echarts-order-profit,
#echarts-order-trading {
margin-top: 10px;
height: 400px;