better-staridc-MNBT
1<?php
2/**
3 * 管理员端 - 订单管理
4 */
5if (!defined('IN_CRONLITE')) {
6 exit;
7}
8mnbt_admin_include('head');
9
10$page = max(1, (int)($_GET['page_num'] ?? 1));
11$filters = [
12 'status' => $_GET['status'] ?? '',
13 'order_no' => $_GET['order_no'] ?? '',
14 'user_id' => $_GET['user_id'] ?? '',
15 'supplier_id' => $_GET['supplier_id'] ?? '',
16];
17$orders = zjmf_order_list_all($page, 30, $filters);
18$suppliers = zjmf_supplier_list_all();
19
20$action_labels = [
21 'buy' => '购买',
22 'upgrade_config' => '配置升级',
23 'upgrade_product' => '产品升级',
24];
25$status_labels = [
26 'pending' => '待处理',
27 'paid' => '已支付',
28 'opened' => '已完成',
29 'failed' => '失败',
30 'cancelled' => '已取消',
31];
32$status_classes = [
33 'pending' => 'badge-secondary',
34 'paid' => 'badge-info',
35 'opened' => 'badge-success',
36 'failed' => 'badge-danger',
37 'cancelled' => 'badge-warning',
38];
39$title = $title ?? '订单管理';
40?>
41<div class="container-fluid p-t-15">
42 <div class="card">
43 <div class="card-header"><h4 style="display:inline-block">订单管理</h4></div>
44 <div class="card-body">
45 <form method="get" class="form-inline mb-3">
46 <input type="hidden" name="p" value="zjmfmanager_reserve">
47 <input type="hidden" name="page" value="orders">
48 <select name="status" class="form-control form-control-sm mr-2">
49 <option value="">全部状态</option>
50 <?php foreach ($status_labels as $k => $v): ?>
51 <option value="<?= htmlspecialchars($k, ENT_QUOTES) ?>"
52 <?= $filters['status'] === $k ? 'selected' : '' ?>>
53 <?= htmlspecialchars($v) ?>
54 </option>
55 <?php endforeach; ?>
56 </select>
57 <select name="supplier_id" class="form-control form-control-sm mr-2">
58 <option value="">全部供应商</option>
59 <?php foreach ($suppliers as $s): ?>
60 <option value="<?= (int)$s['id'] ?>"
61 <?= $filters['supplier_id'] == $s['id'] ? 'selected' : '' ?>>
62 <?= htmlspecialchars($s['name'], ENT_QUOTES) ?>
63 </option>
64 <?php endforeach; ?>
65 </select>
66 <input type="text" name="order_no" class="form-control form-control-sm mr-2"
67 placeholder="订单号" value="<?= htmlspecialchars($filters['order_no'], ENT_QUOTES) ?>">
68 <input type="number" name="user_id" class="form-control form-control-sm mr-2"
69 placeholder="用户 ID" value="<?= htmlspecialchars($filters['user_id'], ENT_QUOTES) ?>">
70 <button type="submit" class="btn btn-sm btn-primary">筛选</button>
71 </form>
72
73 <div class="table-responsive">
74 <table class="table table-bordered table-hover">
75 <thead>
76 <tr>
77 <th>ID</th>
78 <th>订单号</th>
79 <th>动作</th>
80 <th>供应商</th>
81 <th>用户ID</th>
82 <th>商品</th>
83 <th>周期</th>
84 <th>金额</th>
85 <th>上游订单</th>
86 <th>上游主机</th>
87 <th>状态</th>
88 <th>下单时间</th>
89 <th>完成时间</th>
90 <th>备注/失败原因</th>
91 </tr>
92 </thead>
93 <tbody>
94 <?php if (empty($orders['list'])): ?>
95 <tr><td colspan="14" class="text-center text-muted">暂无订单</td></tr>
96 <?php else: ?>
97 <?php foreach ($orders['list'] as $o): ?>
98 <tr>
99 <td><?= (int)$o['id'] ?></td>
100 <td class="small text-muted"><?= htmlspecialchars($o['order_no'], ENT_QUOTES) ?></td>
101 <td><?= htmlspecialchars($action_labels[$o['action']] ?? $o['action']) ?></td>
102 <td><?= htmlspecialchars($o['supplier_name'] ?: '-') ?></td>
103 <td><?= (int)$o['user_id'] ?></td>
104 <td><?= htmlspecialchars($o['product_name'], ENT_QUOTES) ?></td>
105 <td><?= htmlspecialchars($o['cycle_name'] ?: '-') ?></td>
106 <td>¥<?= zjmf_format_cents($o['amount_cents']) ?></td>
107 <td><?= (int)$o['up_order_id'] > 0 ? (int)$o['up_order_id'] : '-' ?></td>
108 <td><?= (int)$o['up_host_id'] > 0 ? (int)$o['up_host_id'] : '-' ?></td>
109 <td>
110 <span class="badge <?= htmlspecialchars($status_classes[$o['status']] ?? 'badge-secondary') ?>">
111 <?= htmlspecialchars($status_labels[$o['status']] ?? $o['status']) ?>
112 </span>
113 </td>
114 <td class="small"><?= htmlspecialchars($o['created_at']) ?></td>
115 <td class="small"><?= htmlspecialchars($o['opened_at'] ?: '-') ?></td>
116 <td class="small text-danger"><?= htmlspecialchars($o['remark'] ?: '-') ?></td>
117 </tr>
118 <?php endforeach; ?>
119 <?php endif; ?>
120 </tbody>
121 </table>
122 </div>
123
124 <?php
125 $total_pages = max(1, (int)ceil($orders['total'] / $orders['per_page']));
126 $current_page = (int)$orders['page'];
127 if ($total_pages > 1):
128 $qs = http_build_query([
129 'p' => 'zjmfmanager_reserve', 'page' => 'orders',
130 'status' => $filters['status'], 'order_no' => $filters['order_no'],
131 'user_id' => $filters['user_id'], 'supplier_id' => $filters['supplier_id'],
132 ]);
133 ?>
134 <nav>
135 <ul class="pagination pagination-sm">
136 <?php if ($current_page > 1): ?>
137 <li class="page-item"><a class="page-link"
138 href="plugin.php?<?= htmlspecialchars(
139 $qs . '&page_num=' . ($current_page - 1), ENT_QUOTES
140 ) ?>">上一页</a></li>
141 <?php endif; ?>
142 <li class="page-item disabled"><span class="page-link">
143 第 <?= $current_page ?> / <?= $total_pages ?> 页(共 <?= (int)$orders['total'] ?> 条)
144 </span></li>
145 <?php if ($current_page < $total_pages): ?>
146 <li class="page-item"><a class="page-link"
147 href="plugin.php?<?= htmlspecialchars(
148 $qs . '&page_num=' . ($current_page + 1), ENT_QUOTES
149 ) ?>">下一页</a></li>
150 <?php endif; ?>
151 </ul>
152 </nav>
153 <?php endif; ?>
154 </div>
155 </div>
156</div>