better-staridc-MNBT
1<?php
2/**
3 * 管理员端 - 订单管理
4 */
5if (!defined('IN_CRONLITE')) {
6 exit;
7}
8
9$page = max(1, (int)($_GET['page_num'] ?? 1));
10$filters = [
11 'status' => $_GET['status'] ?? '',
12 'user_id' => $_GET['user_id'] ?? '',
13 'order_no' => $_GET['order_no'] ?? '',
14];
15$orders = hosting_order_list_all($page, 30, $filters);
16
17$status_labels = [
18 'pending' => '待支付',
19 'paid' => '已支付',
20 'opened' => '已开通',
21 'failed' => '失败',
22 'cancelled' => '已取消',
23];
24$status_classes = [
25 'pending' => 'badge-secondary',
26 'paid' => 'badge-info',
27 'opened' => 'badge-success',
28 'failed' => 'badge-danger',
29 'cancelled' => 'badge-warning',
30];
31
32$title = $title ?? '订单管理';
33mnbt_admin_include('head');
34?>
35<div class="container-fluid p-t-15">
36 <div class="card">
37 <div class="card-header">
38 <h4 style="display:inline-block">订单管理</h4>
39 </div>
40 <div class="card-body">
41 <form method="get" class="form-inline mb-3">
42 <input type="hidden" name="p" value="hosting_shop">
43 <input type="hidden" name="page" value="orders">
44 <select name="status" class="form-control form-control-sm mr-2">
45 <option value="">全部状态</option>
46 <?php foreach ($status_labels as $k => $v): ?>
47 <option value="<?= htmlspecialchars($k, ENT_QUOTES) ?>" <?= $filters['status'] === $k ? 'selected' : '' ?>><?= htmlspecialchars($v) ?></option>
48 <?php endforeach; ?>
49 </select>
50 <input type="text" name="order_no" class="form-control form-control-sm mr-2" placeholder="订单号" value="<?= htmlspecialchars($filters['order_no'], ENT_QUOTES) ?>">
51 <input type="number" name="user_id" class="form-control form-control-sm mr-2" placeholder="用户 ID" value="<?= htmlspecialchars($filters['user_id'], ENT_QUOTES) ?>">
52 <button type="submit" class="btn btn-sm btn-primary">筛选</button>
53 </form>
54
55 <div class="table-responsive">
56 <table class="table table-bordered table-hover">
57 <thead>
58 <tr>
59 <th>ID</th>
60 <th>订单号</th>
61 <th>用户ID</th>
62 <th>套餐</th>
63 <th>周期</th>
64 <th>金额</th>
65 <th>节点</th>
66 <th>主机ID</th>
67 <th>状态</th>
68 <th>下单时间</th>
69 <th>开通时间</th>
70 <th>备注</th>
71 </tr>
72 </thead>
73 <tbody>
74 <?php if (empty($orders['list'])): ?>
75 <tr><td colspan="12" class="text-center text-muted">暂无订单</td></tr>
76 <?php else: ?>
77 <?php foreach ($orders['list'] as $o): ?>
78 <tr>
79 <td><?= (int)$o['id'] ?></td>
80 <td class="small text-muted"><?= htmlspecialchars($o['order_no'], ENT_QUOTES) ?></td>
81 <td><?= (int)$o['user_id'] ?></td>
82 <td><?= htmlspecialchars($o['plan_name'], ENT_QUOTES) ?></td>
83 <td><?= $o['period'] === 'year' ? '年付' : '月付' ?></td>
84 <td>¥<?= htmlspecialchars(hosting_format_cents($o['amount_cents'])) ?></td>
85 <td><?= htmlspecialchars($o['node'], ENT_QUOTES) ?></td>
86 <td><?= (int)$o['host_id'] > 0 ? (int)$o['host_id'] : '-' ?></td>
87 <td>
88 <span class="badge <?= htmlspecialchars($status_classes[$o['status']] ?? 'badge-secondary', ENT_QUOTES) ?>">
89 <?= htmlspecialchars($status_labels[$o['status']] ?? $o['status']) ?>
90 </span>
91 </td>
92 <td class="small"><?= htmlspecialchars($o['created_at']) ?></td>
93 <td class="small"><?= htmlspecialchars($o['opened_at']) ?></td>
94 <td class="small"><?= htmlspecialchars($o['remark'] ?: '-', ENT_QUOTES) ?></td>
95 </tr>
96 <?php endforeach; ?>
97 <?php endif; ?>
98 </tbody>
99 </table>
100 </div>
101
102 <?php
103 $total_pages = max(1, (int)ceil($orders['total'] / $orders['per_page']));
104 $current_page = (int)$orders['page'];
105 if ($total_pages > 1):
106 $qs = http_build_query(['p' => 'hosting_shop', 'page' => 'orders', 'status' => $filters['status'], 'order_no' => $filters['order_no'], 'user_id' => $filters['user_id']]);
107 ?>
108 <nav>
109 <ul class="pagination pagination-sm">
110 <?php if ($current_page > 1): ?>
111 <li class="page-item"><a class="page-link" href="plugin.php?<?= htmlspecialchars($qs . '&page_num=' . ($current_page - 1), ENT_QUOTES) ?>">上一页</a></li>
112 <?php endif; ?>
113 <li class="page-item disabled"><span class="page-link">第 <?= $current_page ?> / <?= $total_pages ?> 页(共 <?= (int)$orders['total'] ?> 条)</span></li>
114 <?php if ($current_page < $total_pages): ?>
115 <li class="page-item"><a class="page-link" href="plugin.php?<?= htmlspecialchars($qs . '&page_num=' . ($current_page + 1), ENT_QUOTES) ?>">下一页</a></li>
116 <?php endif; ?>
117 </ul>
118 </nav>
119 <?php endif; ?>
120 </div>
121 </div>
122</div>