mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
增加数据报单
This commit is contained in:
parent
4032ba0c4f
commit
2162191595
46
app/data/controller/total/Portal.php
Normal file
46
app/data/controller/total/Portal.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\data\controller\total;
|
||||
|
||||
use think\admin\Controller;
|
||||
|
||||
/**
|
||||
* 商城数据报表
|
||||
* Class Portal
|
||||
* @package app\data\controller\total
|
||||
*/
|
||||
class Portal extends Controller
|
||||
{
|
||||
/**
|
||||
* 商城数据报表
|
||||
* @auth true
|
||||
* @menu true
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->usersTotal = $this->app->db->name('DataUser')->cache(true, 60)->count();
|
||||
$this->goodsTotal = $this->app->db->name('ShopGoods')->cache(true, 60)->where(['deleted' => 0])->count();
|
||||
$this->orderTotal = $this->app->db->name('ShopOrder')->cache(true, 60)->whereRaw('status >= 4')->count();
|
||||
$this->amountTotal = $this->app->db->name('ShopOrder')->cache(true, 60)->whereRaw('status >= 4')->sum('amount_total');
|
||||
// 近七天用户及交易趋势
|
||||
$this->days = [];
|
||||
for ($i = 15; $i >= 0; $i--) {
|
||||
$date = date('Y-m-d', strtotime("-{$i}days"));
|
||||
$this->days[] = [
|
||||
date('m-d', strtotime("-{$i}days")),
|
||||
$this->app->db->name('DataUser')->cache(true, 60)->whereLike('create_at', "{$date}%")->count(),
|
||||
$this->app->db->name('ShopOrder')->cache(true, 60)->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->count(),
|
||||
$this->app->db->name('ShopOrder')->cache(true, 60)->whereLike('create_at', "{$date}%")->whereRaw('status>=4')->sum('amount_total'),
|
||||
$this->app->db->name('DataUserRebate')->cache(true, 60)->whereLike('create_at', "{$date}%")->sum('amount'),
|
||||
];
|
||||
}
|
||||
// 会员级别分布统计
|
||||
$levels = $this->app->db->name('BaseUserUpgrade')->where(['status' => 1])->order('number asc')->column('number code,name,0 count', 'number');
|
||||
foreach ($this->app->db->name('DataUser')->field('count(1) count,vip_code level')->group('vip_code')->cursor() as $vo) {
|
||||
$levels[$vo['level']]['count'] = isset($levels[$vo['level']]) ? $vo['count'] : 0;
|
||||
}
|
||||
$this->levels = array_values($levels);
|
||||
$this->fetch();
|
||||
}
|
||||
|
||||
}
|
198
app/data/view/total/portal/index.html
Normal file
198
app/data/view/total/portal/index.html
Normal file
@ -0,0 +1,198 @@
|
||||
{extend name="../../admin/view/main"}
|
||||
|
||||
{block name='content'}
|
||||
<div class="think-box-shadow portal-block-container notselect">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-sm6 layui-col-md3">
|
||||
<div class="portal-block-item nowrap" style="background:linear-gradient(-125deg,#57bdbf,#2f9de2)">
|
||||
<div>商品总量</div>
|
||||
<div>{$goodsTotal|default='0'}</div>
|
||||
<div>当前商品总数量</div>
|
||||
</div>
|
||||
<i class="portal-block-icon layui-icon layui-icon-app"></i>
|
||||
</div>
|
||||
<div class="layui-col-sm6 layui-col-md3">
|
||||
<div class="portal-block-item nowrap" style="background:linear-gradient(-125deg,#ff7d7d,#fb2c95)">
|
||||
<div>用户总量</div>
|
||||
<div>{$usersTotal|default='0'}</div>
|
||||
<div>当前用户总数量</div>
|
||||
</div>
|
||||
<i class="portal-block-icon layui-icon layui-icon-user"></i>
|
||||
</div>
|
||||
<div class="layui-col-sm6 layui-col-md3">
|
||||
<div class="portal-block-item nowrap" style="background:linear-gradient(-113deg,#c543d8,#925cc3)">
|
||||
<div>订单总量</div>
|
||||
<div>{$orderTotal|default='0'}</div>
|
||||
<div>已付款订单总数</div>
|
||||
</div>
|
||||
<i class="portal-block-icon layui-icon layui-icon-form"></i>
|
||||
</div>
|
||||
<div class="layui-col-sm6 layui-col-md3">
|
||||
<div class="portal-block-item nowrap" style="background:linear-gradient(-141deg,#ecca1b,#f39526)">
|
||||
<div>交易金额</div>
|
||||
<div>{$amountTotal|default='0'}</div>
|
||||
<div>已成交金额总数</div>
|
||||
</div>
|
||||
<i class="portal-block-icon layui-icon layui-icon-rmb"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="think-box-shadow margin-top-15">
|
||||
<div id="main1" style="width:100%;height:400px"></div>
|
||||
</div>
|
||||
|
||||
<div class="layui-row layui-col-space15 margin-top-10">
|
||||
<div class="layui-col-xs12 layui-col-md6">
|
||||
<div class="think-box-shadow">
|
||||
<div id="main2" style="width:100%;height:350px"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-md6">
|
||||
<div class="think-box-shadow">
|
||||
<div id="main3" style="width:100%;height:350px"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="layui-hide">
|
||||
<textarea id="jsondata1">{$days|json_encode}</textarea>
|
||||
<textarea id="jsondata2">{$levels|json_encode}</textarea>
|
||||
</label>
|
||||
|
||||
<script>
|
||||
|
||||
require(['echarts'], function (echarts) {
|
||||
var data1 = JSON.parse($('#jsondata1').html());
|
||||
var list1 = data1.map(function (item) {
|
||||
return item[0];
|
||||
});
|
||||
var chart1 = echarts.init(document.getElementById('main1'));
|
||||
window.addEventListener("resize", function () {
|
||||
chart1.resize()
|
||||
});
|
||||
|
||||
chart1.setOption({
|
||||
title: [
|
||||
{left: '12%', text: '近十天用户数量趋势'},
|
||||
{left: '45%', text: '近十天订单数量趋势'},
|
||||
{left: '78%', text: '近十天交易金额趋势'}
|
||||
],
|
||||
tooltip: {trigger: 'axis', show: true, axisPointer: {type: 'cross', label: {}}},
|
||||
xAxis: [
|
||||
{data: list1, gridIndex: 0},
|
||||
{data: list1, gridIndex: 1},
|
||||
{data: list1, gridIndex: 2}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
splitLine: {show: false}, gridIndex: 0, type: 'value', axisLabel: {
|
||||
formatter: '{value} 人'
|
||||
}
|
||||
},
|
||||
{
|
||||
splitLine: {show: false}, gridIndex: 1, type: 'value', axisLabel: {
|
||||
formatter: '{value} 单'
|
||||
}
|
||||
},
|
||||
{
|
||||
splitLine: {show: false}, gridIndex: 2, type: 'value', axisLabel: {
|
||||
formatter: '{value} 元'
|
||||
}
|
||||
}
|
||||
],
|
||||
grid: [
|
||||
{left: '04%', right: '67%', top: '25%'},
|
||||
{left: '37%', right: '34%', top: '25%'},
|
||||
{left: '70%', right: '01%', top: '25%'}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'line', showSymbol: true, xAxisIndex: 0, yAxisIndex: 0,
|
||||
label: {normal: {position: 'top', formatter: '{c} 人', show: true}},
|
||||
data: data1.map(function (item) {
|
||||
return item[1];
|
||||
}),
|
||||
},
|
||||
{
|
||||
type: 'line', showSymbol: true, xAxisIndex: 1, yAxisIndex: 1,
|
||||
label: {normal: {position: 'top', formatter: '{c} 单', show: true}},
|
||||
data: data1.map(function (item) {
|
||||
return item[2];
|
||||
}),
|
||||
},
|
||||
{
|
||||
type: 'line', showSymbol: true, xAxisIndex: 2, yAxisIndex: 2,
|
||||
label: {normal: {position: 'top', formatter: '{c} 元', show: true}},
|
||||
data: data1.map(function (item) {
|
||||
return item[3];
|
||||
}),
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var data2 = JSON.parse($('#jsondata2').html());
|
||||
var chart2 = echarts.init(document.getElementById('main2'));
|
||||
window.addEventListener("resize", function () {
|
||||
chart2.resize()
|
||||
});
|
||||
chart2.setOption({
|
||||
title: {text: '用户等级分布统计', left: 'center'},
|
||||
tooltip: {trigger: 'item', formatter: '{a} <br/>{b} : {c} 人 ( {d}% )'},
|
||||
legend: {
|
||||
type: 'scroll', orient: 'vertical', right: 10, top: 20, bottom: 20, data: data2.map(function (item) {
|
||||
return item.title;
|
||||
})
|
||||
},
|
||||
grid: [{'top': '30%'}],
|
||||
series: [
|
||||
{
|
||||
name: '等级',
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
center: ['40%', '50%'],
|
||||
data: data2.map(function (item) {
|
||||
return {name: item.name, value: item.count}
|
||||
}),
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var chart3 = echarts.init(document.getElementById('main3'));
|
||||
window.addEventListener("resize", function () {
|
||||
chart3.resize()
|
||||
});
|
||||
|
||||
chart3.setOption({
|
||||
title: [{left: 'center', text: '近十天代理收益统计'}],
|
||||
tooltip: {trigger: 'axis', show: true, axisPointer: {type: 'cross', label: {}}},
|
||||
xAxis: [{data: list1, gridIndex: 0}],
|
||||
yAxis: [
|
||||
{
|
||||
splitLine: {show: false}, gridIndex: 0, type: 'value', axisLabel: {
|
||||
formatter: '{value} 元'
|
||||
}
|
||||
}
|
||||
],
|
||||
grid: [{left: '10%', right: '3%', top: '25%'}],
|
||||
series: [
|
||||
{
|
||||
type: 'line', showSymbol: true, xAxisIndex: 0, yAxisIndex: 0,
|
||||
label: {normal: {position: 'top', formatter: '{c} 元', show: true}},
|
||||
data: data1.map(function (item) {
|
||||
return item[4];
|
||||
}),
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{/block}
|
Loading…
x
Reference in New Issue
Block a user