Merge pull request 'feat(admin): deeper order/income filters, post pay-type, topic sales meta' (#159) from worktree-zibll-native-admin-menus into main
Reviewed-on: CYL/wordpress-theme-aksrt#159
This commit is contained in:
@@ -99,8 +99,8 @@ Note: zibll「商品管理」`zibpay_product_page` is **paid article sales**, no
|
||||
| 2b Shipping/after-sale/coupons/income/rebate | done |
|
||||
| 3 users.php submenus | done |
|
||||
| 4 SPA strip | done (ops routes redirect to native) |
|
||||
| 5+ behavior parity | done — native ops shell modularized + plate follow-pay MVP + topic pay/points + sales report + post sales column + order type tabs + download logs page + hidecontent alias + topic VIP1/2 matrix + users commerce column + topic partial hide |
|
||||
| 5 remaining | optional: multi-gateway for forum/topics; full zibll download modal UX; topic virtual_sales/coupon fields |
|
||||
| 5+ behavior parity | done — native ops shell + plate follow-pay + topic pay/points/VIP1-2/partial-hide + sales report + download logs + hidecontent + users commerce + order user/method filters + post pay_type filter + income/rebate user filter + topic virtual_sales/coupon meta |
|
||||
| 5 remaining | optional: multi-gateway cashier for forum topics; full bulk-edit of content pay fields |
|
||||
|
||||
## Dual-UI rule
|
||||
|
||||
|
||||
@@ -41,10 +41,11 @@ class AKSRT_Admin_Pay_Income {
|
||||
}
|
||||
|
||||
$status = isset($_GET['status']) ? sanitize_key((string) wp_unslash($_GET['status'])) : '';
|
||||
$user_id = isset($_GET['user_id']) ? max(0, (int) $_GET['user_id']) : 0;
|
||||
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
|
||||
$per_page = 20;
|
||||
$svc = AKSRT_Revenue::get_instance();
|
||||
$stats = $svc->get_stats();
|
||||
$stats = $user_id > 0 ? $svc->get_stats($user_id) : $svc->get_stats();
|
||||
|
||||
echo '<p>' . esc_html(sprintf(
|
||||
/* translators: 1: total 2: pending 3: settled */
|
||||
@@ -61,14 +62,22 @@ class AKSRT_Admin_Pay_Income {
|
||||
printf('<option value="%s"%s>%s</option>', esc_attr($key), selected($status, $key, false), esc_html($label));
|
||||
}
|
||||
echo '</select> ';
|
||||
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" /> ';
|
||||
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
|
||||
if ($user_id > 0) {
|
||||
echo ' <a class="button button-small" href="' . esc_url($this->page_url('aksrt_income')) . '">' . esc_html__('清除用户过滤', 'aksrt') . '</a>';
|
||||
}
|
||||
echo '</form>';
|
||||
|
||||
$result = $svc->get_list([
|
||||
$list_args = [
|
||||
'status' => $status,
|
||||
'limit' => $per_page,
|
||||
'offset' => ($page_num - 1) * $per_page,
|
||||
]);
|
||||
];
|
||||
if ($user_id > 0) {
|
||||
$list_args['user_id'] = $user_id;
|
||||
}
|
||||
$result = $svc->get_list($list_args);
|
||||
$items = $result['items'] ?? [];
|
||||
$total = (int) ($result['total'] ?? 0);
|
||||
$pages = max(1, (int) ($result['max_pages'] ?? 1));
|
||||
|
||||
@@ -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>';
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ class AKSRT_Admin_Pay_Rebate {
|
||||
}
|
||||
|
||||
$status = isset($_GET['status']) ? sanitize_key((string) wp_unslash($_GET['status'])) : '';
|
||||
$user_id = isset($_GET['user_id']) ? max(0, (int) $_GET['user_id']) : (isset($_GET['referrer_id']) ? max(0, (int) $_GET['referrer_id']) : 0);
|
||||
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
|
||||
$per_page = 20;
|
||||
$svc = AKSRT_Rebate::get_instance();
|
||||
@@ -62,14 +63,22 @@ class AKSRT_Admin_Pay_Rebate {
|
||||
printf('<option value="%s"%s>%s</option>', esc_attr($key), selected($status, $key, false), esc_html($label));
|
||||
}
|
||||
echo '</select> ';
|
||||
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" /> ';
|
||||
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
|
||||
if ($user_id > 0) {
|
||||
echo ' <a class="button button-small" href="' . esc_url($this->page_url('aksrt_rebate')) . '">' . esc_html__('清除用户过滤', 'aksrt') . '</a>';
|
||||
}
|
||||
echo '</form>';
|
||||
|
||||
$result = $svc->get_list([
|
||||
$list_args = [
|
||||
'status' => $status,
|
||||
'limit' => $per_page,
|
||||
'offset' => ($page_num - 1) * $per_page,
|
||||
]);
|
||||
];
|
||||
if ($user_id > 0) {
|
||||
$list_args['user_id'] = $user_id;
|
||||
}
|
||||
$result = $svc->get_list($list_args);
|
||||
$items = $result['items'] ?? [];
|
||||
$total = (int) ($result['total'] ?? 0);
|
||||
$pages = max(1, (int) ceil(max(1, $total) / $per_page));
|
||||
|
||||
@@ -595,6 +595,18 @@ class AKSRT_Forum {
|
||||
return $this->topic_service()->unlock_topic_with_credits($user_id, $topic_id);
|
||||
}
|
||||
|
||||
public function has_user_unlocked_topic(int $user_id, int $topic_id): bool {
|
||||
return $this->topic_service()->has_user_unlocked_topic($user_id, $topic_id);
|
||||
}
|
||||
|
||||
public function has_user_paid_topic(int $user_id, int $topic_id): bool {
|
||||
return $this->topic_service()->has_user_paid_topic($user_id, $topic_id);
|
||||
}
|
||||
|
||||
public function resolve_topic_pay_price(int $topic_id, int $user_id = 0): array {
|
||||
return $this->topic_service()->resolve_topic_pay_price($topic_id, $user_id);
|
||||
}
|
||||
|
||||
public function prepare_vote_meta(array $data): array {
|
||||
return $this->topic_service()->prepare_vote_meta($data);
|
||||
}
|
||||
|
||||
@@ -615,11 +615,34 @@ class AKSRT_Order_Repository {
|
||||
$params[] = $product_id;
|
||||
}
|
||||
|
||||
$user_id = (int) ($args['user_id'] ?? 0);
|
||||
if ($user_id > 0) {
|
||||
$where[] = 'user_id = %d';
|
||||
$params[] = $user_id;
|
||||
}
|
||||
|
||||
$payment_method = sanitize_key((string) ($args['payment_method'] ?? ''));
|
||||
if ($payment_method !== '') {
|
||||
$where[] = 'payment_method = %s';
|
||||
$params[] = $payment_method;
|
||||
}
|
||||
|
||||
if ($search !== '') {
|
||||
$where[] = '(order_number LIKE %s OR product_type LIKE %s)';
|
||||
$like = '%' . $wpdb->esc_like($search) . '%';
|
||||
$params[] = $like;
|
||||
$params[] = $like;
|
||||
// Numeric search may mean user_id or product_id; also match order number / type.
|
||||
if (ctype_digit($search)) {
|
||||
$where[] = '(order_number LIKE %s OR product_type LIKE %s OR user_id = %d OR product_id = %d)';
|
||||
$like = '%' . $wpdb->esc_like($search) . '%';
|
||||
$params[] = $like;
|
||||
$params[] = $like;
|
||||
$params[] = (int) $search;
|
||||
$params[] = (int) $search;
|
||||
} else {
|
||||
$where[] = '(order_number LIKE %s OR product_type LIKE %s OR payment_method LIKE %s)';
|
||||
$like = '%' . $wpdb->esc_like($search) . '%';
|
||||
$params[] = $like;
|
||||
$params[] = $like;
|
||||
$params[] = $like;
|
||||
}
|
||||
}
|
||||
|
||||
return [$where, $params];
|
||||
|
||||
@@ -35,6 +35,9 @@ class AKSRT_Post_Meta_Box {
|
||||
add_action('quick_edit_custom_box', [$this, 'render_quick_edit'], 10, 2);
|
||||
add_action('bulk_edit_custom_box', [$this, 'render_quick_edit'], 10, 2);
|
||||
add_action('admin_footer-edit.php', [$this, 'admin_quick_edit_script']);
|
||||
// Pay-type dropdown on posts list (zibll zibpay_type filter).
|
||||
add_action('restrict_manage_posts', [$this, 'render_pay_type_filter']);
|
||||
add_action('pre_get_posts', [$this, 'filter_posts_by_pay_type']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -539,6 +542,71 @@ class AKSRT_Post_Meta_Box {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Dropdown filter for content pay_type on edit.php?post_type=post.
|
||||
*/
|
||||
public function render_pay_type_filter(string $post_type): void {
|
||||
if ($post_type !== 'post' || !class_exists('AKSRT_Domain_Model')) {
|
||||
return;
|
||||
}
|
||||
$current = isset($_GET['aksrt_pay_type']) ? sanitize_key((string) wp_unslash($_GET['aksrt_pay_type'])) : '';
|
||||
$labels = AKSRT_Domain_Model::pay_type_labels();
|
||||
echo '<select name="aksrt_pay_type">';
|
||||
echo '<option value="">' . esc_html__('全部付费类型', 'aksrt') . '</option>';
|
||||
foreach ($labels as $key => $label) {
|
||||
printf(
|
||||
'<option value="%s"%s>%s</option>',
|
||||
esc_attr($key),
|
||||
selected($current, $key, false),
|
||||
esc_html($label)
|
||||
);
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply aksrt_pay_type filter via denormalized _aksrt_pay_type meta.
|
||||
*/
|
||||
public function filter_posts_by_pay_type(\WP_Query $query): void {
|
||||
if (!is_admin() || !$query->is_main_query()) {
|
||||
return;
|
||||
}
|
||||
$screen_post_type = $query->get('post_type');
|
||||
if ($screen_post_type !== 'post') {
|
||||
return;
|
||||
}
|
||||
if (empty($_GET['aksrt_pay_type'])) {
|
||||
return;
|
||||
}
|
||||
$pay_type = sanitize_key((string) wp_unslash($_GET['aksrt_pay_type']));
|
||||
if ($pay_type === '' || !class_exists('AKSRT_Domain_Model')) {
|
||||
return;
|
||||
}
|
||||
$pay_type = AKSRT_Domain_Model::normalize_pay_type($pay_type);
|
||||
$meta_query = (array) $query->get('meta_query');
|
||||
if ($pay_type === AKSRT_Domain_Model::PAY_TYPE_NO) {
|
||||
$meta_query[] = [
|
||||
'relation' => 'OR',
|
||||
[
|
||||
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
|
||||
'value' => AKSRT_Domain_Model::PAY_TYPE_NO,
|
||||
'compare' => '=',
|
||||
],
|
||||
[
|
||||
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
|
||||
'compare' => 'NOT EXISTS',
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$meta_query[] = [
|
||||
'key' => AKSRT_Domain_Model::PAY_TYPE_KEY,
|
||||
'value' => $pay_type,
|
||||
'compare' => '=',
|
||||
];
|
||||
}
|
||||
$query->set('meta_query', $meta_query);
|
||||
}
|
||||
|
||||
/**
|
||||
* §3.8 Render quick edit and bulk edit fields.
|
||||
*/
|
||||
|
||||
@@ -83,9 +83,9 @@ class AKSRT_Revenue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin list (all users) with optional status filter.
|
||||
* Admin list (all users) with optional status / user filter.
|
||||
*
|
||||
* @param array{status?:string,limit?:int,offset?:int} $args
|
||||
* @param array{status?:string,user_id?:int,limit?:int,offset?:int} $args
|
||||
* @return array{items:array<int,array>,total:int,page:int,max_pages:int}
|
||||
*/
|
||||
public function get_list(array $args = []): array {
|
||||
@@ -94,6 +94,7 @@ class AKSRT_Revenue {
|
||||
$limit = max(1, min(100, (int) ($args['limit'] ?? 20)));
|
||||
$offset = max(0, (int) ($args['offset'] ?? 0));
|
||||
$status = sanitize_key((string) ($args['status'] ?? ''));
|
||||
$user_id = (int) ($args['user_id'] ?? 0);
|
||||
|
||||
$where = [];
|
||||
$params = [];
|
||||
@@ -101,6 +102,10 @@ class AKSRT_Revenue {
|
||||
$where[] = 'status = %s';
|
||||
$params[] = $status;
|
||||
}
|
||||
if ($user_id > 0) {
|
||||
$where[] = 'user_id = %d';
|
||||
$params[] = $user_id;
|
||||
}
|
||||
$where_sql = $where ? 'WHERE ' . implode(' AND ', $where) : '';
|
||||
|
||||
$count_sql = "SELECT COUNT(*) FROM {$this->table()} {$where_sql}";
|
||||
|
||||
@@ -85,26 +85,19 @@ class AKSRT_User_Credits_Admin {
|
||||
number_format($total, 2),
|
||||
number_format($pending, 2)
|
||||
);
|
||||
$bits[] = '<a href="' . esc_url(admin_url('admin.php?page=aksrt_income')) . '">' . esc_html__('明细', 'aksrt') . '</a>';
|
||||
$bits[] = '<a href="' . esc_url(admin_url('admin.php?page=aksrt_income&user_id=' . $user_id)) . '">' . esc_html__('分成明细', 'aksrt') . '</a>';
|
||||
}
|
||||
}
|
||||
if (class_exists('AKSRT_Rebate')) {
|
||||
$list = AKSRT_Rebate::get_instance()->get_list(['user_id' => $user_id, 'limit' => 1]);
|
||||
$total_r = (int) ($list['total'] ?? 0);
|
||||
if ($total_r > 0) {
|
||||
$sum = 0.0;
|
||||
// Lightweight sum via stats if available; else show count.
|
||||
if (method_exists(AKSRT_Rebate::get_instance(), 'get_stats')) {
|
||||
// global stats only — show link with count
|
||||
$bits[] = sprintf(esc_html__('返佣 %d 笔', 'aksrt'), $total_r);
|
||||
} else {
|
||||
$bits[] = sprintf(esc_html__('返佣 %d 笔', 'aksrt'), $total_r);
|
||||
}
|
||||
$bits[] = '<a href="' . esc_url(admin_url('admin.php?page=aksrt_rebate')) . '">' . esc_html__('返佣', 'aksrt') . '</a>';
|
||||
$bits[] = sprintf(esc_html__('返佣 %d 笔', 'aksrt'), $total_r);
|
||||
$bits[] = '<a href="' . esc_url(admin_url('admin.php?page=aksrt_rebate&user_id=' . $user_id)) . '">' . esc_html__('返佣', 'aksrt') . '</a>';
|
||||
}
|
||||
}
|
||||
$bits[] = '<a href="' . esc_url(admin_url('admin.php?page=aksrt_download_logs&user_id=' . $user_id)) . '">' . esc_html__('下载记录', 'aksrt') . '</a>';
|
||||
$bits[] = '<a href="' . esc_url(admin_url('admin.php?page=aksrt_orders&s=' . $user_id)) . '">' . esc_html__('订单', 'aksrt') . '</a>';
|
||||
$bits[] = '<a href="' . esc_url(admin_url('admin.php?page=aksrt_orders&user_id=' . $user_id)) . '">' . esc_html__('订单', 'aksrt') . '</a>';
|
||||
|
||||
if (!$bits) {
|
||||
return '—';
|
||||
|
||||
@@ -96,6 +96,8 @@ class AKSRT_Topic_Meta_Box {
|
||||
$credits_vip2 = get_post_meta($post->ID, '_aksrt_credits_vip2', true);
|
||||
$credits_vip1_set = ($credits_vip1 !== '' && $credits_vip1 !== null && $credits_vip1 !== false);
|
||||
$credits_vip2_set = ($credits_vip2 !== '' && $credits_vip2 !== null && $credits_vip2 !== false);
|
||||
$virtual_sales = max(0, (int) get_post_meta($post->ID, '_aksrt_virtual_sales', true));
|
||||
$coupon_s = (int) get_post_meta($post->ID, '_aksrt_topic_coupon_s', true) === 1;
|
||||
$pay_hide_part = (int) get_post_meta($post->ID, '_aksrt_pay_hide_part', true) === 1;
|
||||
$view_roles = get_post_meta($post->ID, '_aksrt_visibility_roles', true);
|
||||
if (!is_array($view_roles)) {
|
||||
@@ -213,6 +215,18 @@ class AKSRT_Topic_Meta_Box {
|
||||
</label>
|
||||
<span class="description" style="display:block;"><?php esc_html_e('开启后正文仍输出,付费块用 [payshow] 或 [hidecontent type="payshow"] 包裹。未开启则全文门控。', 'aksrt'); ?></span>
|
||||
</p>
|
||||
<p class="aksrt-topic-meta-pay-fields aksrt-topic-meta-credits-fields">
|
||||
<label for="aksrt_virtual_sales"><strong><?php esc_html_e('虚拟销量', 'aksrt'); ?></strong></label>
|
||||
<input type="number" step="1" min="0" class="widefat" name="aksrt_virtual_sales" id="aksrt_virtual_sales" value="<?php echo esc_attr((string) $virtual_sales); ?>">
|
||||
<span class="description"><?php esc_html_e('展示用浮动销量,不计入真实订单统计。', 'aksrt'); ?></span>
|
||||
</p>
|
||||
<p class="aksrt-topic-meta-pay-fields">
|
||||
<label>
|
||||
<input type="checkbox" name="aksrt_topic_coupon_s" value="1" <?php checked($coupon_s); ?>>
|
||||
<?php esc_html_e('允许优惠码(预留)', 'aksrt'); ?>
|
||||
</label>
|
||||
<span class="description" style="display:block;"><?php esc_html_e('标记本帖允许优惠码;收银台多网关接入前仅存 meta。', 'aksrt'); ?></span>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -362,8 +376,21 @@ class AKSRT_Topic_Meta_Box {
|
||||
// Partial hide only meaningful for pay/credits; otherwise clear.
|
||||
if (in_array($visibility, ['pay', 'credits'], true)) {
|
||||
update_post_meta($post_id, '_aksrt_pay_hide_part', !empty($_POST['aksrt_pay_hide_part']) ? 1 : 0);
|
||||
$virtual = isset($_POST['aksrt_virtual_sales']) ? max(0, (int) wp_unslash($_POST['aksrt_virtual_sales'])) : 0;
|
||||
if ($virtual > 0) {
|
||||
update_post_meta($post_id, '_aksrt_virtual_sales', $virtual);
|
||||
} else {
|
||||
delete_post_meta($post_id, '_aksrt_virtual_sales');
|
||||
}
|
||||
if ($visibility === 'pay') {
|
||||
update_post_meta($post_id, '_aksrt_topic_coupon_s', !empty($_POST['aksrt_topic_coupon_s']) ? 1 : 0);
|
||||
} else {
|
||||
delete_post_meta($post_id, '_aksrt_topic_coupon_s');
|
||||
}
|
||||
} else {
|
||||
delete_post_meta($post_id, '_aksrt_pay_hide_part');
|
||||
delete_post_meta($post_id, '_aksrt_virtual_sales');
|
||||
delete_post_meta($post_id, '_aksrt_topic_coupon_s');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,6 +334,8 @@ function aksrt_register_forum_topic_meta() {
|
||||
'_aksrt_credits_vip1' => ['type' => 'integer', 'default' => 0],
|
||||
'_aksrt_credits_vip2' => ['type' => 'integer', 'default' => 0],
|
||||
'_aksrt_pay_hide_part' => ['type' => 'integer', 'default' => 0],
|
||||
'_aksrt_virtual_sales' => ['type' => 'integer', 'default' => 0],
|
||||
'_aksrt_topic_coupon_s' => ['type' => 'integer', 'default' => 0],
|
||||
'_aksrt_visibility_roles' => ['type' => 'array', 'default' => []],
|
||||
|
||||
// 状态工作流扩展位 (Wave4)
|
||||
|
||||
Reference in New Issue
Block a user