feat(admin): topic governance list columns and native charge-card batching
Add native aksrt_forum_topic list filters/columns/bulk/quick-edit for sticky/lock/review/plate. Replace SPA charge-card batch link with an inline batch generator on the 支付中心卡密 page. No build artifacts.
This commit is contained in:
@@ -33,6 +33,7 @@ class AKSRT_Admin_Pay_Menus {
|
||||
add_action('admin_post_aksrt_pay_update_order_status', [$this, 'handle_update_order_status']);
|
||||
add_action('admin_post_aksrt_pay_update_withdrawal', [$this, 'handle_update_withdrawal']);
|
||||
add_action('admin_post_aksrt_pay_disable_charge_card', [$this, 'handle_disable_charge_card']);
|
||||
add_action('admin_post_aksrt_pay_batch_charge_cards', [$this, 'handle_batch_charge_cards']);
|
||||
add_action('admin_post_aksrt_pay_update_shipping', [$this, 'handle_update_shipping']);
|
||||
add_action('admin_post_aksrt_pay_update_after_sale', [$this, 'handle_update_after_sale']);
|
||||
add_action('admin_post_aksrt_pay_create_coupon', [$this, 'handle_create_coupon']);
|
||||
@@ -197,6 +198,8 @@ class AKSRT_Admin_Pay_Menus {
|
||||
'withdraw_failed' => __('提现状态更新失败。', 'aksrt'),
|
||||
'card_disabled' => __('充值卡已禁用。', 'aksrt'),
|
||||
'card_failed' => __('充值卡禁用失败。', 'aksrt'),
|
||||
'card_batch_ok' => __('卡密批量生成完成。', 'aksrt'),
|
||||
'card_batch_failed' => __('卡密批量生成失败。', 'aksrt'),
|
||||
'shipping_updated' => __('物流状态已更新。', 'aksrt'),
|
||||
'shipping_failed' => __('物流状态更新失败。', 'aksrt'),
|
||||
'after_sale_updated' => __('售后状态已更新。', 'aksrt'),
|
||||
@@ -592,6 +595,34 @@ class AKSRT_Admin_Pay_Menus {
|
||||
(int) ($stats['used'] ?? 0)
|
||||
)) . '</p>';
|
||||
|
||||
echo '<h2>' . esc_html__('批量生成卡密', 'aksrt') . '</h2>';
|
||||
echo '<form method="post" action="' . esc_url(admin_url('admin-post.php')) . '" style="margin:12px 0 20px;display:flex;flex-wrap:wrap;gap:8px;align-items:end;">';
|
||||
echo '<input type="hidden" name="action" value="aksrt_pay_batch_charge_cards" />';
|
||||
wp_nonce_field('aksrt_pay_batch_charge_cards');
|
||||
echo '<p><label>' . esc_html__('类型', 'aksrt') . '<br><select name="type">';
|
||||
echo '<option value="balance">' . esc_html__('余额', 'aksrt') . '</option>';
|
||||
echo '<option value="vip">' . esc_html__('VIP', 'aksrt') . '</option>';
|
||||
echo '<option value="credits">' . esc_html__('积分', 'aksrt') . '</option>';
|
||||
echo '</select></label></p>';
|
||||
echo '<p><label>' . esc_html__('数量', 'aksrt') . '<br><input type="number" name="count" min="1" max="500" value="10" /></label></p>';
|
||||
echo '<p><label>' . esc_html__('长度', 'aksrt') . '<br><input type="number" name="length" min="8" max="32" value="16" /></label></p>';
|
||||
echo '<p><label>' . esc_html__('前缀', 'aksrt') . '<br><input type="text" name="prefix" value="" /></label></p>';
|
||||
echo '<p><label>' . esc_html__('面额/积分', 'aksrt') . '<br><input type="number" step="0.01" name="amount" value="10" /></label></p>';
|
||||
echo '<p><label>' . esc_html__('VIP等级', 'aksrt') . '<br><input type="number" name="vip_level" min="1" max="2" value="1" /></label></p>';
|
||||
echo '<p><label>' . esc_html__('VIP天数', 'aksrt') . '<br><input type="number" name="vip_days" min="1" value="30" /></label></p>';
|
||||
echo '<p><label>' . esc_html__('备注', 'aksrt') . '<br><input type="text" name="note" value="" /></label></p>';
|
||||
submit_button(__('生成', 'aksrt'), 'primary', '', false);
|
||||
echo '</form>';
|
||||
|
||||
if (!empty($_GET['aksrt_generated'])) {
|
||||
$generated = (int) $_GET['aksrt_generated'];
|
||||
echo '<div class="notice notice-success"><p>' . esc_html(sprintf(
|
||||
/* translators: %d count */
|
||||
__('成功生成 %d 张卡密。', 'aksrt'),
|
||||
$generated
|
||||
)) . '</p></div>';
|
||||
}
|
||||
|
||||
echo '<form method="get" style="margin:12px 0;">';
|
||||
echo '<input type="hidden" name="page" value="aksrt_charge_cards" />';
|
||||
echo '<select name="status">';
|
||||
@@ -615,6 +646,7 @@ class AKSRT_Admin_Pay_Menus {
|
||||
'balance' => __('余额', 'aksrt'),
|
||||
'vip' => __('VIP', 'aksrt'),
|
||||
'points' => __('积分', 'aksrt'),
|
||||
'credits' => __('积分(credits)', 'aksrt'),
|
||||
] as $key => $label) {
|
||||
printf(
|
||||
'<option value="%s"%s>%s</option>',
|
||||
@@ -625,7 +657,6 @@ class AKSRT_Admin_Pay_Menus {
|
||||
}
|
||||
echo '</select> ';
|
||||
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
|
||||
echo ' <a class="button" href="' . esc_url(admin_url('admin.php?page=aksrt-settings#/payment/charge-card')) . '">' . esc_html__('SPA 批量生成(过渡)', 'aksrt') . '</a>';
|
||||
echo '</form>';
|
||||
|
||||
$result = $svc->get_list([
|
||||
@@ -720,6 +751,50 @@ class AKSRT_Admin_Pay_Menus {
|
||||
exit;
|
||||
}
|
||||
|
||||
public function handle_batch_charge_cards(): void {
|
||||
if (!current_user_can(self::CAPABILITY)) {
|
||||
wp_die(esc_html__('权限不足', 'aksrt'));
|
||||
}
|
||||
check_admin_referer('aksrt_pay_batch_charge_cards');
|
||||
|
||||
if (!class_exists('AKSRT_Charge_Card')) {
|
||||
wp_safe_redirect($this->page_url('aksrt_charge_cards', ['aksrt_pay_msg' => 'card_batch_failed']));
|
||||
exit;
|
||||
}
|
||||
|
||||
$type = isset($_POST['type']) ? sanitize_key((string) wp_unslash($_POST['type'])) : 'balance';
|
||||
$count = isset($_POST['count']) ? (int) $_POST['count'] : 10;
|
||||
$length = isset($_POST['length']) ? (int) $_POST['length'] : 16;
|
||||
$prefix = isset($_POST['prefix']) ? sanitize_text_field((string) wp_unslash($_POST['prefix'])) : '';
|
||||
$amount = isset($_POST['amount']) ? (float) wp_unslash($_POST['amount']) : 0;
|
||||
$note = isset($_POST['note']) ? sanitize_textarea_field((string) wp_unslash($_POST['note'])) : '';
|
||||
$level = isset($_POST['vip_level']) ? max(1, min(2, (int) $_POST['vip_level'])) : 1;
|
||||
$days = isset($_POST['vip_days']) ? max(1, (int) $_POST['vip_days']) : 30;
|
||||
|
||||
if ($type === 'points') {
|
||||
$type = 'credits';
|
||||
}
|
||||
|
||||
$meta = [];
|
||||
if ($type === 'balance') {
|
||||
$meta['amount'] = max(0, $amount);
|
||||
} elseif ($type === 'credits') {
|
||||
$meta['points'] = max(0, (int) $amount);
|
||||
} elseif ($type === 'vip') {
|
||||
$meta['level'] = $level;
|
||||
$meta['days'] = $days;
|
||||
}
|
||||
|
||||
$codes = AKSRT_Charge_Card::get_instance()->batch_create($type, $meta, $count, $length, $prefix, '', $note);
|
||||
$ok = !empty($codes);
|
||||
|
||||
wp_safe_redirect($this->page_url('aksrt_charge_cards', [
|
||||
'aksrt_pay_msg' => $ok ? 'card_batch_ok' : 'card_batch_failed',
|
||||
'aksrt_generated' => count($codes),
|
||||
]));
|
||||
exit;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
* Shipping
|
||||
* ----------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user