mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-09-19 02:06:38 +08:00
仪表盘数据总览
This commit is contained in:
parent
31354de6f5
commit
331c0b78ef
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace app\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\model\Order;
|
||||
use think\facade\View;
|
||||
|
||||
class ConsoleController extends BaseController
|
||||
@ -24,6 +25,39 @@ class ConsoleController extends BaseController
|
||||
// 首页仪表盘
|
||||
public function console()
|
||||
{
|
||||
// 查询近32天的订单
|
||||
$orders = Order::where([['state', '=', 1], ['create_time', '>', date('Y-m-d 00:00:00', strtotime('-32 days'))]])->select();
|
||||
$income = $this->getRevenueData($orders);
|
||||
View::assign($income);
|
||||
return View::fetch();
|
||||
}
|
||||
// 获取收入数据总览
|
||||
private function getRevenueData($orders)
|
||||
{
|
||||
// 时间段
|
||||
$month_start = date('Y-m-01 00:00:00');
|
||||
$month_end = date('Y-m-d 23:59:59', strtotime('last day of this month'));
|
||||
$week_start = date('Y-m-d 00:00:00', strtotime('this monday'));
|
||||
$week_end = date('Y-m-d 23:59:59', strtotime('next monday') - 1);
|
||||
$yesterday_start = date('Y-m-d 00:00:00', strtotime('yesterday'));
|
||||
$yesterday_end = date('Y-m-d 23:59:59', strtotime('yesterday'));
|
||||
$today_start = date('Y-m-d 00:00:00');
|
||||
$today_end = date('Y-m-d 23:59:59');
|
||||
// 本月流水
|
||||
$month_income = $orders->whereBetween('create_time', [$month_start, $month_end])->column('really_price');
|
||||
// 本周流水
|
||||
$week_income = $orders->whereBetween('create_time', [$week_start, $week_end])->column('really_price');
|
||||
// 昨日流水
|
||||
$yesterday_income = $orders->whereBetween('create_time', [$yesterday_start, $yesterday_end])->column('really_price');
|
||||
// 今天流水
|
||||
$today_income = $orders->whereBetween('create_time', [$today_start, $today_end])->column('really_price');
|
||||
// 收入数据
|
||||
$income = [
|
||||
'month_income' => \array_sum($month_income),
|
||||
'week_income' => \array_sum($week_income),
|
||||
'yesterday_income' => \array_sum($yesterday_income),
|
||||
'today_income' => \array_sum($today_income),
|
||||
];
|
||||
return $income;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row layui-col-space5 index-card">
|
||||
<div class="layui-col-xs8 layui-col-md8 top-panel-number" style="color: #28333E;"
|
||||
id="value1">
|
||||
id="today_income">
|
||||
0
|
||||
</div>
|
||||
<div class="layui-col-xs4 layui-col-md4">
|
||||
@ -61,7 +61,7 @@
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row layui-col-space5 index-card">
|
||||
<div class="layui-col-xs8 layui-col-md8 top-panel-number" style="color: #28333E;"
|
||||
id="value2">
|
||||
id="yesterday_income">
|
||||
0
|
||||
</div>
|
||||
<div class="layui-col-xs4 layui-col-md4">
|
||||
@ -77,7 +77,7 @@
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row layui-col-space5 index-card">
|
||||
<div class="layui-col-xs8 layui-col-md8 top-panel-number" style="color: #28333E;"
|
||||
id="value3">
|
||||
id="week_income">
|
||||
0
|
||||
</div>
|
||||
<div class="layui-col-xs4 layui-col-md4">
|
||||
@ -93,7 +93,7 @@
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row layui-col-space5 index-card">
|
||||
<div class="layui-col-xs8 layui-col-md8 top-panel-number" style="color: #28333E;"
|
||||
id="value4">
|
||||
id="month_income">
|
||||
0
|
||||
</div>
|
||||
<div class="layui-col-xs4 layui-col-md4">
|
||||
@ -203,10 +203,10 @@
|
||||
count = layui.count,
|
||||
echarts = layui.echarts;
|
||||
|
||||
count.up("value1", { time: 4000, num: 440.34, bit: 2, regulator: 50 })
|
||||
count.up("value2", { time: 4000, num: 236.30, bit: 2, regulator: 50 })
|
||||
count.up("value3", { time: 4000, num: 634.43, bit: 2, regulator: 50 })
|
||||
count.up("value4", { time: 4000, bit: 2, num: 373.23, regulator: 50 })
|
||||
count.up("today_income", { time: 3000, num: parseFloat('<?php echo $today_income ?>'), bit: 2, regulator: 100 })
|
||||
count.up("yesterday_income", { time: 3000, num: parseFloat('<?php echo $yesterday_income ?>'), bit: 2, regulator: 100 })
|
||||
count.up("week_income", { time: 3000, num: parseFloat('<?php echo $week_income ?>'), bit: 2, regulator: 100 })
|
||||
count.up("month_income", { time: 3000, num: parseFloat('<?php echo $month_income ?>'), bit: 2, regulator: 100 })
|
||||
|
||||
var echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user