better-staridc-MNBT
1<?php
2/**
3 * 管理员端 - 余额流水查询
4 */
5if (!defined('IN_CRONLITE')) {
6 exit;
7}
8
9$page_num = max(1, (int)($_GET['page_num'] ?? 1));
10$filters = [
11 'user_id' => trim((string)($_GET['user_id'] ?? '')),
12 'type' => trim((string)($_GET['type'] ?? '')),
13 'order_no' => trim((string)($_GET['order_no'] ?? '')),
14];
15$result = balance_admin_logs($page_num, 30, $filters);
16$list = $result['list'];
17$total = $result['total'];
18$total_pages = $result['per_page'] > 0 ? (int)ceil($total / $result['per_page']) : 1;
19
20$type_labels = [
21 'recharge' => '充值',
22 'consume' => '消费',
23 'refund' => '退款',
24 'adjust' => '调整',
25];
26$type_classes = [
27 'recharge' => 'badge-success',
28 'consume' => 'badge-danger',
29 'refund' => 'badge-info',
30 'adjust' => 'badge-warning',
31];
32
33$title = $title ?? '余额流水';
34mnbt_admin_include('head');
35?>
36
37<div class="container-fluid p-t-15">
38 <div class="card">
39 <div class="card-header">
40 <h4 style="display:inline-block">余额流水记录</h4>
41 <small class="text-muted ml-2">共 <?= $total ?> 条记录</small>
42 </div>
43 <div class="card-body">
44 <form method="get" class="form-inline mb-3">
45 <input type="hidden" name="p" value="balance">
46 <input type="hidden" name="page" value="balance_logs">
47 <input type="number" name="user_id" class="form-control form-control-sm mr-2" placeholder="用户 ID" value="<?= htmlspecialchars($filters['user_id'], ENT_QUOTES) ?>">
48 <select name="type" class="form-control form-control-sm mr-2">
49 <option value="">全部类型</option>
50 <?php foreach ($type_labels as $k => $v): ?>
51 <option value="<?= htmlspecialchars($k, ENT_QUOTES) ?>" <?= $filters['type'] === $k ? 'selected' : '' ?>><?= htmlspecialchars($v) ?></option>
52 <?php endforeach; ?>
53 </select>
54 <input type="text" name="order_no" class="form-control form-control-sm mr-2" placeholder="订单号" value="<?= htmlspecialchars($filters['order_no'], ENT_QUOTES) ?>">
55 <button type="submit" class="btn btn-sm btn-primary">筛选</button>
56 <a href="plugin.php?p=balance&page=balance_logs" class="btn btn-sm btn-outline-secondary ml-2">重置</a>
57 </form>
58
59 <div class="table-responsive">
60 <table class="table table-bordered table-hover">
61 <thead>
62 <tr>
63 <th style="width:60px">ID</th>
64 <th>用户ID</th>
65 <th>用户名</th>
66 <th>金额(元)</th>
67 <th>变动后余额(元)</th>
68 <th>类型</th>
69 <th>订单号</th>
70 <th>备注</th>
71 <th>时间</th>
72 </tr>
73 </thead>
74 <tbody>
75 <?php if (empty($list)): ?>
76 <tr><td colspan="9" class="text-center text-muted">暂无记录</td></tr>
77 <?php else: ?>
78 <?php foreach ($list as $log):
79 $amt = (int)$log['amount'];
80 $is_income = $amt >= 0;
81 ?>
82 <tr>
83 <td><?= (int)$log['id'] ?></td>
84 <td><?= (int)$log['user_id'] ?></td>
85 <td><code><?= htmlspecialchars($log['username'] ?: ('#' . $log['user_id']), ENT_QUOTES) ?></code></td>
86 <td>
87 <b class="<?= $is_income ? 'text-success' : 'text-danger' ?>">
88 <?= $is_income ? '+' : '' ?>¥<?= htmlspecialchars(balance_format(abs($amt)), ENT_QUOTES) ?>
89 </b>
90 </td>
91 <td>¥<?= htmlspecialchars(balance_format((int)$log['balance_after']), ENT_QUOTES) ?></td>
92 <td>
93 <span class="badge <?= htmlspecialchars($type_classes[$log['type']] ?? 'badge-secondary', ENT_QUOTES) ?>">
94 <?= htmlspecialchars($type_labels[$log['type']] ?? $log['type']) ?>
95 </span>
96 </td>
97 <td class="small text-muted"><?= htmlspecialchars($log['order_no'] ?: '-', ENT_QUOTES) ?></td>
98 <td class="small"><?= htmlspecialchars($log['remark'] ?: '-', ENT_QUOTES) ?></td>
99 <td class="small text-muted"><?= htmlspecialchars($log['created_at'], ENT_QUOTES) ?></td>
100 </tr>
101 <?php endforeach; ?>
102 <?php endif; ?>
103 </tbody>
104 </table>
105 </div>
106
107 <?php if ($total_pages > 1):
108 $qs = http_build_query([
109 'p' => 'balance',
110 'page' => 'balance_logs',
111 'user_id' => $filters['user_id'],
112 'type' => $filters['type'],
113 'order_no' => $filters['order_no'],
114 ]);
115 ?>
116 <nav>
117 <ul class="pagination justify-content-center">
118 <?php for ($i = 1; $i <= $total_pages; $i++): ?>
119 <li class="page-item <?= $i === $page_num ? 'active' : '' ?>">
120 <a class="page-link" href="plugin.php?<?= htmlspecialchars($qs . '&page_num=' . $i, ENT_QUOTES) ?>"><?= $i ?></a>
121 </li>
122 <?php endfor; ?>
123 </ul>
124 </nav>
125 <?php endif; ?>
126 </div>
127 </div>
128</div>