feat: 新增大量服务类图标及相关接口配置
- 新增20+家电维修类图标(电视、空调、冰箱等) - 新增短信发送、微信手机号登录接口 - 新增服务规格查询接口 - 更新后台配置与菜单结构 - 移除支付插件相关配置
这个提交包含在:
@@ -2,83 +2,17 @@
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\Admin;
|
||||
use app\admin\model\User;
|
||||
use app\common\controller\Backend;
|
||||
use app\common\model\Attachment;
|
||||
use fast\Date;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 控制台
|
||||
*
|
||||
* @icon fa fa-dashboard
|
||||
* @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
|
||||
* 控制台重定向与兼容转发
|
||||
*/
|
||||
class Dashboard extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
\think\Db::execute("SET @@sql_mode='';");
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
$column = [];
|
||||
$starttime = Date::unixtime('day', -6);
|
||||
$endtime = Date::unixtime('day', 0, 'end');
|
||||
$joinlist = Db("user")->where('jointime', 'between time', [$starttime, $endtime])
|
||||
->field('jointime, status, COUNT(*) AS nums, DATE_FORMAT(FROM_UNIXTIME(jointime), "%Y-%m-%d") AS join_date')
|
||||
->group('join_date')
|
||||
->select();
|
||||
for ($time = $starttime; $time <= $endtime;) {
|
||||
$column[] = date("Y-m-d", $time);
|
||||
$time += 86400;
|
||||
}
|
||||
$userlist = array_fill_keys($column, 0);
|
||||
foreach ($joinlist as $k => $v) {
|
||||
$userlist[$v['join_date']] = $v['nums'];
|
||||
}
|
||||
|
||||
$dbTableList = Db::query("SHOW TABLE STATUS");
|
||||
$addonList = get_addon_list();
|
||||
$totalworkingaddon = 0;
|
||||
$totaladdon = count($addonList);
|
||||
foreach ($addonList as $index => $item) {
|
||||
if ($item['state']) {
|
||||
$totalworkingaddon += 1;
|
||||
}
|
||||
}
|
||||
$this->view->assign([
|
||||
'totaluser' => User::count(),
|
||||
'totaladdon' => $totaladdon,
|
||||
'totaladmin' => Admin::count(),
|
||||
'totalcategory' => \app\common\model\Category::count(),
|
||||
'todayusersignup' => User::whereTime('jointime', 'today')->count(),
|
||||
'todayuserlogin' => User::whereTime('logintime', 'today')->count(),
|
||||
'sevendau' => User::whereTime('jointime|logintime|prevtime', '-7 days')->count(),
|
||||
'thirtydau' => User::whereTime('jointime|logintime|prevtime', '-30 days')->count(),
|
||||
'threednu' => User::whereTime('jointime', '-3 days')->count(),
|
||||
'sevendnu' => User::whereTime('jointime', '-7 days')->count(),
|
||||
'dbtablenums' => count($dbTableList),
|
||||
'dbsize' => array_sum(array_map(function ($item) {
|
||||
return $item['Data_length'] + $item['Index_length'];
|
||||
}, $dbTableList)),
|
||||
'totalworkingaddon' => $totalworkingaddon,
|
||||
'attachmentnums' => Attachment::count(),
|
||||
'attachmentsize' => Attachment::sum('filesize'),
|
||||
'picturenums' => Attachment::where('mimetype', 'like', 'image/%')->count(),
|
||||
'picturesize' => Attachment::where('mimetype', 'like', 'image/%')->sum('filesize'),
|
||||
]);
|
||||
|
||||
$this->assignconfig('column', array_keys($userlist));
|
||||
$this->assignconfig('userdata', array_values($userlist));
|
||||
|
||||
return $this->view->fetch();
|
||||
// 兼容转发至全新数据大盘首页
|
||||
$controller = new Home();
|
||||
return $controller->index();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\model\Appeal;
|
||||
use app\admin\model\Master;
|
||||
use app\admin\model\Merchant;
|
||||
use app\admin\model\Order;
|
||||
use app\admin\model\Service;
|
||||
use app\admin\model\User;
|
||||
use app\admin\model\Withdraw;
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 优匠优服数字化运营指挥中心(数据大盘首页)
|
||||
*
|
||||
* @icon fa fa-tachometer
|
||||
* @remark 平台核心业务数据大屏,实时监控订单履约、资金流水、运力健康度与待办预警
|
||||
*/
|
||||
class Home extends Backend
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
Db::execute("SET @@sql_mode='';");
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
// 1. 时间范围定义
|
||||
$todayStart = strtotime(date('Y-m-d 00:00:00'));
|
||||
$todayEnd = strtotime(date('Y-m-d 23:59:59'));
|
||||
$monthStart = strtotime(date('Y-m-01 00:00:00'));
|
||||
|
||||
// 2. 核心经营 KPI (真实数据聚合)
|
||||
$totalOrder = Order::count();
|
||||
$totalGmv = (float)(Order::sum('pay_amount') ?: 0);
|
||||
$avgTicket = $totalOrder > 0 ? round($totalGmv / $totalOrder, 2) : 0;
|
||||
|
||||
$todayOrderCount = Order::whereBetween('createtime', [$todayStart, $todayEnd])->count();
|
||||
$todayGmv = (float)(Order::whereBetween('pay_time', [$todayStart, $todayEnd])->sum('pay_amount') ?: 0);
|
||||
$monthGmv = (float)(Order::whereBetween('pay_time', [$monthStart, $todayEnd])->sum('pay_amount') ?: 0);
|
||||
|
||||
// 运力与商户统计
|
||||
$totalMaster = Master::where('verify_status', 'pass')->count();
|
||||
$onlineMaster = Master::where('work_status', 'on')->count();
|
||||
$totalMerchant = Merchant::where('verify_status', 'pass')->count();
|
||||
$totalUser = User::count();
|
||||
|
||||
// 3. 订单状态分布与履约漏斗
|
||||
$statusCounts = Order::field('status, count(*) as cnt')
|
||||
->group('status')
|
||||
->select();
|
||||
$statusCountMap = [];
|
||||
foreach ($statusCounts as $s) {
|
||||
$statusCountMap[$s['status']] = (int)$s['cnt'];
|
||||
}
|
||||
|
||||
$unpaidCount = $statusCountMap[0] ?? 0;
|
||||
$waitDispatchCount = $statusCountMap[1] ?? 0;
|
||||
$inServiceCount = ($statusCountMap[3] ?? 0) + ($statusCountMap[6] ?? 0);
|
||||
$doneCount = $statusCountMap[8] ?? 0;
|
||||
$afterSaleCount = $statusCountMap[10] ?? 0;
|
||||
|
||||
// 4. 实时待办预警与风控中心
|
||||
$pendingMaster = Master::where('verify_status', 'pending')->count();
|
||||
$waitingAppeal = Appeal::where('status', 'wait')->count();
|
||||
$waitingWithdraw = Withdraw::where('status', 'wait')->count();
|
||||
$pendingDispatch = $waitDispatchCount;
|
||||
|
||||
// 5. 近 7 天订单趋势与 GMV 流水 (双轴图表数据)
|
||||
$dateColumns = [];
|
||||
$orderCounts = [];
|
||||
$orderAmounts = [];
|
||||
for ($i = 6; $i >= 0; $i--) {
|
||||
$date = date('Y-m-d', strtotime("-$i days"));
|
||||
$dateColumns[] = date('m-d', strtotime("-$i days"));
|
||||
$dayStart = strtotime($date . ' 00:00:00');
|
||||
$dayEnd = strtotime($date . ' 23:59:59');
|
||||
|
||||
$cnt = Order::whereBetween('createtime', [$dayStart, $dayEnd])->count();
|
||||
$amt = Order::whereBetween('createtime', [$dayStart, $dayEnd])->sum('pay_amount') ?: 0;
|
||||
|
||||
$orderCounts[] = (int)$cnt;
|
||||
$orderAmounts[] = round((float)$amt, 2);
|
||||
}
|
||||
|
||||
// 6. 服务品类与运力健康指标
|
||||
$masterAvg = Db::name('master')
|
||||
->where('verify_status', 'pass')
|
||||
->field('ROUND(AVG(score), 1) as avg_score, ROUND(AVG(accept_rate), 1) as avg_accept, ROUND(AVG(ontime_rate), 1) as avg_ontime')
|
||||
->find();
|
||||
|
||||
$totalService = Service::count();
|
||||
$totalCategory = Db::name('service_cat')->count();
|
||||
|
||||
// 7. 环形状态分布数据
|
||||
$statusDisplayNames = [
|
||||
0 => '待支付',
|
||||
1 => '待接单',
|
||||
2 => '报价中',
|
||||
3 => '已接单',
|
||||
4 => '待上门',
|
||||
5 => '已到达',
|
||||
6 => '服务中',
|
||||
7 => '待验收',
|
||||
8 => '已完成',
|
||||
9 => '已取消',
|
||||
10 => '售后中',
|
||||
];
|
||||
$statusChartData = [];
|
||||
foreach ($statusCountMap as $stKey => $val) {
|
||||
$statusChartData[] = [
|
||||
'name' => $statusDisplayNames[$stKey] ?? ('状态' . $stKey),
|
||||
'value' => $val,
|
||||
];
|
||||
}
|
||||
|
||||
// 8. 最新动态订单
|
||||
$recentOrders = Db::name('order')
|
||||
->alias('o')
|
||||
->join('user u', 'o.user_id = u.id', 'LEFT')
|
||||
->field('o.id, o.order_no, o.service_name, o.pay_amount, o.status, o.createtime, u.nickname as user_name')
|
||||
->order('o.id', 'desc')
|
||||
->limit(6)
|
||||
->select();
|
||||
|
||||
$this->view->assign([
|
||||
'totalOrder' => $totalOrder,
|
||||
'totalGmv' => number_format($totalGmv, 2, '.', ','),
|
||||
'avgTicket' => number_format($avgTicket, 2, '.', ''),
|
||||
'todayOrderCount' => $todayOrderCount,
|
||||
'todayGmv' => number_format($todayGmv, 2, '.', ','),
|
||||
'monthGmv' => number_format($monthGmv, 2, '.', ','),
|
||||
|
||||
'totalMaster' => $totalMaster,
|
||||
'onlineMaster' => $onlineMaster,
|
||||
'totalMerchant' => $totalMerchant,
|
||||
'totalUser' => $totalUser,
|
||||
|
||||
'unpaidCount' => $unpaidCount,
|
||||
'waitDispatchCount' => $waitDispatchCount,
|
||||
'inServiceCount' => $inServiceCount,
|
||||
'doneCount' => $doneCount,
|
||||
'afterSaleCount' => $afterSaleCount,
|
||||
|
||||
'pendingMaster' => $pendingMaster,
|
||||
'waitingAppeal' => $waitingAppeal,
|
||||
'waitingWithdraw' => $waitingWithdraw,
|
||||
'pendingDispatch' => $pendingDispatch,
|
||||
|
||||
'masterAvgScore' => $masterAvg['avg_score'] ?: '5.0',
|
||||
'masterAvgAccept' => $masterAvg['avg_accept'] ?: '100',
|
||||
'masterAvgOntime' => $masterAvg['avg_ontime'] ?: '100',
|
||||
|
||||
'totalService' => $totalService,
|
||||
'totalCategory' => $totalCategory,
|
||||
'recentOrders' => $recentOrders,
|
||||
'systemClock' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
// ECharts 配置注入
|
||||
$this->assignconfig('dateColumns', $dateColumns);
|
||||
$this->assignconfig('orderCounts', $orderCounts);
|
||||
$this->assignconfig('orderAmounts', $orderAmounts);
|
||||
$this->assignconfig('statusChartData', $statusChartData);
|
||||
$this->assignconfig('totalOrder', $totalOrder);
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\general;
|
||||
|
||||
use app\admin\model\Admin;
|
||||
use app\admin\model\User;
|
||||
use app\common\controller\Backend;
|
||||
use app\common\model\Attachment;
|
||||
use fast\Date;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 控制台(原系统控制台)
|
||||
*
|
||||
* @icon fa fa-dashboard
|
||||
* @remark 原系统控制台,现已平移至常规管理,用于展示底层系统资源、插件运行与技术指标
|
||||
*/
|
||||
class Dashboard extends Backend
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
Db::execute("SET @@sql_mode='';");
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
$column = [];
|
||||
$starttime = Date::unixtime('day', -6);
|
||||
$endtime = Date::unixtime('day', 0, 'end');
|
||||
$joinlist = Db("user")->where('jointime', 'between time', [$starttime, $endtime])
|
||||
->field('jointime, status, COUNT(*) AS nums, DATE_FORMAT(FROM_UNIXTIME(jointime), "%Y-%m-%d") AS join_date')
|
||||
->group('join_date')
|
||||
->select();
|
||||
for ($time = $starttime; $time <= $endtime;) {
|
||||
$column[] = date("Y-m-d", $time);
|
||||
$time += 86400;
|
||||
}
|
||||
$userlist = array_fill_keys($column, 0);
|
||||
foreach ($joinlist as $k => $v) {
|
||||
$userlist[$v['join_date']] = $v['nums'];
|
||||
}
|
||||
|
||||
$dbTableList = Db::query("SHOW TABLE STATUS");
|
||||
$addonList = get_addon_list();
|
||||
$totalworkingaddon = 0;
|
||||
$totaladdon = count($addonList);
|
||||
foreach ($addonList as $index => $item) {
|
||||
if ($item['state']) {
|
||||
$totalworkingaddon += 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->assign([
|
||||
'totaluser' => User::count(),
|
||||
'totaladdon' => $totaladdon,
|
||||
'totaladmin' => Admin::count(),
|
||||
'totalcategory' => Db::name('category')->count(),
|
||||
'todayusersignup' => User::whereTime('jointime', 'today')->count(),
|
||||
'todayuserlogin' => User::whereTime('logintime', 'today')->count(),
|
||||
'sevendau' => User::whereTime('jointime|logintime|prevtime', '-7 days')->count(),
|
||||
'thirtydau' => User::whereTime('jointime|logintime|prevtime', '-30 days')->count(),
|
||||
'threednu' => User::whereTime('jointime', '-3 days')->count(),
|
||||
'sevendnu' => User::whereTime('jointime', '-7 days')->count(),
|
||||
'dbtablenums' => count($dbTableList),
|
||||
'dbsize' => array_sum(array_map(function ($item) {
|
||||
return $item['Data_length'] + $item['Index_length'];
|
||||
}, $dbTableList)),
|
||||
'totalworkingaddon' => $totalworkingaddon,
|
||||
'attachmentnums' => Attachment::count(),
|
||||
'attachmentsize' => Attachment::sum('filesize'),
|
||||
'picturenums' => Attachment::where('mimetype', 'like', 'image/%')->count(),
|
||||
'picturesize' => Attachment::where('mimetype', 'like', 'image/%')->sum('filesize'),
|
||||
]);
|
||||
|
||||
$this->assignconfig('column', array_keys($userlist));
|
||||
$this->assignconfig('userdata', array_values($userlist));
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\general;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use app\common\model\Attachment;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 系统监控与运维概况
|
||||
*
|
||||
* @icon fa fa-server
|
||||
* @remark 用于展示服务器软硬件环境、数据库状态、系统资源占用及开发扩展统计
|
||||
*/
|
||||
class System extends Backend
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
Db::execute("SET @@sql_mode='';");
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
// 数据库状态
|
||||
$dbTableList = Db::query("SHOW TABLE STATUS");
|
||||
$dbsize = array_sum(array_map(function ($item) {
|
||||
return $item['Data_length'] + $item['Index_length'];
|
||||
}, $dbTableList));
|
||||
|
||||
// 插件统计
|
||||
$addonList = get_addon_list();
|
||||
$totalworkingaddon = 0;
|
||||
$totaladdon = count($addonList);
|
||||
foreach ($addonList as $item) {
|
||||
if (!empty($item['state'])) {
|
||||
$totalworkingaddon += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 附件统计
|
||||
$attachmentnums = Attachment::count();
|
||||
$attachmentsize = Attachment::sum('filesize');
|
||||
$picturenums = Attachment::where('mimetype', 'like', 'image/%')->count();
|
||||
$picturesize = Attachment::where('mimetype', 'like', 'image/%')->sum('filesize');
|
||||
|
||||
// 服务器与运行环境信息
|
||||
$serverInfo = [
|
||||
'os' => PHP_OS . ' (' . php_uname('r') . ')',
|
||||
'php_version' => PHP_VERSION,
|
||||
'sapi' => php_sapi_name(),
|
||||
'server_soft' => $_SERVER['SERVER_SOFTWARE'] ?? 'Nginx / PHP',
|
||||
'upload_max' => ini_get('upload_max_filesize'),
|
||||
'post_max' => ini_get('post_max_size'),
|
||||
'max_exec_time' => ini_get('max_execution_time') . 's',
|
||||
'memory_limit' => ini_get('memory_limit'),
|
||||
'mysql_version' => Db::query("SELECT VERSION() as v")[0]['v'] ?? '5.7',
|
||||
'server_time' => date('Y-m-d H:i:s'),
|
||||
'timezone' => date_default_timezone_get(),
|
||||
];
|
||||
|
||||
$this->view->assign([
|
||||
'dbtablenums' => count($dbTableList),
|
||||
'dbsize' => $dbsize,
|
||||
'totaladdon' => $totaladdon,
|
||||
'totalworkingaddon' => $totalworkingaddon,
|
||||
'attachmentnums' => $attachmentnums,
|
||||
'attachmentsize' => $attachmentsize,
|
||||
'picturenums' => $picturenums,
|
||||
'picturesize' => $picturesize,
|
||||
'serverInfo' => $serverInfo,
|
||||
]);
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户