feat: 新增发票抬头、晒单、钱包日志等模型及后台管理功能
- 新增 invoice_title、showcase、wallet_log 模型及对应语言包 - 新增后台控制器、视图及搜索字段配置 - 修复服务类目删除保护逻辑 - 优化后台登录页面文案及样式 - 新增前端角色切换逻辑及页面拦截 - 新增 SVG 图标及样式变量 - 修复接口权限及下拉框默认值问题
这个提交包含在:
@@ -34,20 +34,34 @@ class Home extends Backend
|
||||
$todayEnd = strtotime(date('Y-m-d 23:59:59'));
|
||||
$monthStart = strtotime(date('Y-m-01 00:00:00'));
|
||||
|
||||
// 2. 核心经营 KPI (真实数据聚合)
|
||||
// 2. 核心经营 KPI (真实数据聚合:仅统计已支付且未取消的有效订单流水)
|
||||
$totalOrder = Order::count();
|
||||
$totalGmv = (float)(Order::sum('pay_amount') ?: 0);
|
||||
$avgTicket = $totalOrder > 0 ? round($totalGmv / $totalOrder, 2) : 0;
|
||||
$paidOrderCount = Order::where('pay_status', 1)->where('status', '<>', 9)->count();
|
||||
$totalGmv = (float)(Order::where('pay_status', 1)->where('status', '<>', 9)->sum('pay_amount') ?: 0);
|
||||
$avgTicket = $paidOrderCount > 0 ? round($totalGmv / $paidOrderCount, 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);
|
||||
$todayGmv = (float)(Db::name('order')
|
||||
->where('pay_status', 1)
|
||||
->where('status', '<>', 9)
|
||||
->whereRaw('IF(pay_time > 0, pay_time, createtime) BETWEEN ' . (int)$todayStart . ' AND ' . (int)$todayEnd)
|
||||
->sum('pay_amount') ?: 0);
|
||||
$monthGmv = (float)(Db::name('order')
|
||||
->where('pay_status', 1)
|
||||
->where('status', '<>', 9)
|
||||
->whereRaw('IF(pay_time > 0, pay_time, createtime) BETWEEN ' . (int)$monthStart . ' AND ' . (int)$todayEnd)
|
||||
->sum('pay_amount') ?: 0);
|
||||
|
||||
// 运力与商户统计
|
||||
$totalMaster = Master::where('verify_status', 'pass')->count();
|
||||
$onlineMaster = Master::where('work_status', 'on')->count();
|
||||
$onlineMaster = Master::where('verify_status', 'pass')->where('work_status', 'on')->count();
|
||||
$totalMerchant = Merchant::where('verify_status', 'pass')->count();
|
||||
$totalUser = User::count();
|
||||
$totalUser = Db::name('user')->alias('u')
|
||||
->join('master ma', 'ma.user_id = u.id', 'LEFT')
|
||||
->join('merchant me', 'me.user_id = u.id', 'LEFT')
|
||||
->whereNull('ma.id')
|
||||
->whereNull('me.id')
|
||||
->count();
|
||||
|
||||
// 3. 订单状态分布与履约漏斗
|
||||
$statusCounts = Order::field('status, count(*) as cnt')
|
||||
@@ -60,17 +74,19 @@ class Home extends Backend
|
||||
|
||||
$unpaidCount = $statusCountMap[0] ?? 0;
|
||||
$waitDispatchCount = $statusCountMap[1] ?? 0;
|
||||
$inServiceCount = ($statusCountMap[3] ?? 0) + ($statusCountMap[6] ?? 0);
|
||||
$inServiceCount = ($statusCountMap[3] ?? 0) + ($statusCountMap[4] ?? 0) + ($statusCountMap[5] ?? 0) + ($statusCountMap[6] ?? 0) + ($statusCountMap[7] ?? 0);
|
||||
$doneCount = $statusCountMap[8] ?? 0;
|
||||
$afterSaleCount = $statusCountMap[10] ?? 0;
|
||||
|
||||
// 4. 实时待办预警与风控中心
|
||||
// 4. 实时待办预警与风控中心(6大核心运营待办)
|
||||
$pendingMaster = Master::where('verify_status', 'pending')->count();
|
||||
$pendingMerchant = Merchant::where('verify_status', 'pending')->count();
|
||||
$waitingAppeal = Appeal::where('status', 'wait')->count();
|
||||
$waitingWithdraw = Withdraw::where('status', 'wait')->count();
|
||||
$waitingInvoice = Db::name('invoice')->where('status', 'wait')->count();
|
||||
$pendingDispatch = $waitDispatchCount;
|
||||
|
||||
// 5. 近 7 天订单趋势与 GMV 流水 (双轴图表数据)
|
||||
// 5. 近 7 天订单趋势与已付 GMV 流水 (双轴图表数据)
|
||||
$dateColumns = [];
|
||||
$orderCounts = [];
|
||||
$orderAmounts = [];
|
||||
@@ -81,7 +97,11 @@ class Home extends Backend
|
||||
$dayEnd = strtotime($date . ' 23:59:59');
|
||||
|
||||
$cnt = Order::whereBetween('createtime', [$dayStart, $dayEnd])->count();
|
||||
$amt = Order::whereBetween('createtime', [$dayStart, $dayEnd])->sum('pay_amount') ?: 0;
|
||||
$amt = Db::name('order')
|
||||
->where('pay_status', 1)
|
||||
->where('status', '<>', 9)
|
||||
->whereRaw('IF(pay_time > 0, pay_time, createtime) BETWEEN ' . (int)$dayStart . ' AND ' . (int)$dayEnd)
|
||||
->sum('pay_amount') ?: 0;
|
||||
|
||||
$orderCounts[] = (int)$cnt;
|
||||
$orderAmounts[] = round((float)$amt, 2);
|
||||
@@ -147,8 +167,10 @@ class Home extends Backend
|
||||
'afterSaleCount' => $afterSaleCount,
|
||||
|
||||
'pendingMaster' => $pendingMaster,
|
||||
'pendingMerchant' => $pendingMerchant,
|
||||
'waitingAppeal' => $waitingAppeal,
|
||||
'waitingWithdraw' => $waitingWithdraw,
|
||||
'waitingInvoice' => $waitingInvoice,
|
||||
'pendingDispatch' => $pendingDispatch,
|
||||
|
||||
'masterAvgScore' => $masterAvg['avg_score'] ?: '5.0',
|
||||
|
||||
在新工单中引用
屏蔽一个用户