feat(admin): deeper order/income filters, post pay-type, topic sales meta

Add order user/payment filters, income/rebate user_id filter, posts list
pay_type dropdown, topic virtual_sales/coupon meta, and forum unlock
facade methods used by hidecontent/payshow.
This commit is contained in:
2026-07-15 11:35:35 +08:00
parent 8d31e65ccd
commit f197745830
11 changed files with 222 additions and 30 deletions
@@ -52,6 +52,8 @@ class AKSRT_Admin_Pay_Orders {
$search = isset($_GET['s']) ? sanitize_text_field((string) wp_unslash($_GET['s'])) : '';
$product_type = isset($_GET['product_type']) ? sanitize_key((string) wp_unslash($_GET['product_type'])) : '';
$product_id = isset($_GET['product_id']) ? max(0, (int) $_GET['product_id']) : 0;
$user_id = isset($_GET['user_id']) ? max(0, (int) $_GET['user_id']) : 0;
$pay_method = isset($_GET['payment_method']) ? sanitize_key((string) wp_unslash($_GET['payment_method'])) : '';
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
@@ -69,6 +71,12 @@ class AKSRT_Admin_Pay_Orders {
if ($product_id > 0) {
$args['product_id'] = $product_id;
}
if ($user_id > 0) {
$args['user_id'] = $user_id;
}
if ($pay_method !== '') {
$args['payment_method'] = $pay_method;
}
$items = $repo->get_orders_admin($args, $search);
$total = $repo->get_orders_count($args, $search);
@@ -90,9 +98,11 @@ class AKSRT_Admin_Pay_Orders {
$tab_bits = [];
foreach ($type_tabs as $tkey => $tlabel) {
$url = $this->page_url('aksrt_orders', array_filter([
'product_type' => $tkey !== '' ? $tkey : null,
'product_id' => $product_id > 0 ? $product_id : null,
'status' => ($status !== '' && $status !== 'all') ? $status : null,
'product_type' => $tkey !== '' ? $tkey : null,
'product_id' => $product_id > 0 ? $product_id : null,
'user_id' => $user_id > 0 ? $user_id : null,
'payment_method' => $pay_method !== '' ? $pay_method : null,
'status' => ($status !== '' && $status !== 'all') ? $status : null,
]));
$cls = ($product_type === $tkey) ? 'current' : '';
$tab_bits[] = '<li><a class="' . esc_attr($cls) . '" href="' . esc_url($url) . '">' . esc_html($tlabel) . '</a></li>';
@@ -100,6 +110,30 @@ class AKSRT_Admin_Pay_Orders {
echo implode(' | ', $tab_bits);
echo '</ul><div style="clear:both;"></div>';
// Payment method quick tabs.
$method_tabs = [
'' => __('全部支付', 'aksrt'),
'balance' => __('余额', 'aksrt'),
'points' => __('积分', 'aksrt'),
'alipay' => __('支付宝', 'aksrt'),
'wechat' => __('微信', 'aksrt'),
];
echo '<ul class="subsubsub" style="float:none;margin:0 0 12px;">';
$m_bits = [];
foreach ($method_tabs as $mkey => $mlabel) {
$url = $this->page_url('aksrt_orders', array_filter([
'product_type' => $product_type !== '' ? $product_type : null,
'product_id' => $product_id > 0 ? $product_id : null,
'user_id' => $user_id > 0 ? $user_id : null,
'payment_method' => $mkey !== '' ? $mkey : null,
'status' => ($status !== '' && $status !== 'all') ? $status : null,
]));
$cls = ($pay_method === $mkey) ? 'current' : '';
$m_bits[] = '<li><a class="' . esc_attr($cls) . '" href="' . esc_url($url) . '">' . esc_html($mlabel) . '</a></li>';
}
echo implode(' | ', $m_bits);
echo '</ul><div style="clear:both;"></div>';
echo '<form method="get" style="margin:12px 0;">';
echo '<input type="hidden" name="page" value="aksrt_orders" />';
if ($product_type !== '') {
@@ -108,6 +142,9 @@ class AKSRT_Admin_Pay_Orders {
if ($product_id > 0) {
echo '<input type="hidden" name="product_id" value="' . esc_attr((string) $product_id) . '" />';
}
if ($pay_method !== '') {
echo '<input type="hidden" name="payment_method" value="' . esc_attr($pay_method) . '" />';
}
echo '<select name="status">';
echo '<option value="">' . esc_html__('全部状态', 'aksrt') . '</option>';
foreach ($labels as $key => $label) {
@@ -119,9 +156,10 @@ class AKSRT_Admin_Pay_Orders {
);
}
echo '</select> ';
echo '<input type="search" name="s" value="' . esc_attr($search) . '" placeholder="' . esc_attr__('订单号 / 类型', 'aksrt') . '" /> ';
echo '<input type="number" min="0" name="user_id" value="' . esc_attr($user_id > 0 ? (string) $user_id : '') . '" placeholder="' . esc_attr__('用户 ID', 'aksrt') . '" class="small-text" /> ';
echo '<input type="search" name="s" value="' . esc_attr($search) . '" placeholder="' . esc_attr__('订单号 / 类型 / 用户', 'aksrt') . '" /> ';
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
if ($product_id > 0 || $product_type !== '') {
if ($product_id > 0 || $product_type !== '' || $user_id > 0 || $pay_method !== '') {
$filter_bits = [];
if ($product_type !== '') {
$filter_bits[] = sprintf(__('类型=%s', 'aksrt'), $product_type);
@@ -129,8 +167,14 @@ class AKSRT_Admin_Pay_Orders {
if ($product_id > 0) {
$filter_bits[] = sprintf(__('商品ID=%d', 'aksrt'), $product_id);
}
if ($user_id > 0) {
$filter_bits[] = sprintf(__('用户=%d', 'aksrt'), $user_id);
}
if ($pay_method !== '') {
$filter_bits[] = sprintf(__('支付=%s', 'aksrt'), $pay_method);
}
echo ' <span class="description">' . esc_html(implode(' · ', $filter_bits)) . '</span>';
echo ' <a class="button button-small" href="' . esc_url($this->page_url('aksrt_orders')) . '">' . esc_html__('清除商品过滤', 'aksrt') . '</a>';
echo ' <a class="button button-small" href="' . esc_url($this->page_url('aksrt_orders')) . '">' . esc_html__('清除过滤', 'aksrt') . '</a>';
}
echo '</form>';