';
echo '| ' . esc_html((string) $id) . ' | ';
- echo '' . esc_html((string) ($row['type'] ?? '')) . ' | ';
+ echo '' . esc_html($type_labels[$row_type] ?? $row_type) . ' | ';
echo '' . esc_html((string) ($row['password'] ?? $row['code'] ?? '')) . ' | ';
echo '' . esc_html((string) ($row['amount'] ?? '')) . ' | ';
- echo '' . esc_html($st) . ' | ';
+ echo '' . esc_html($status_labels[$st] ?? $st) . ' | ';
+ echo '' . esc_html((string) ($row['expires_at'] ?? '—')) . ' | ';
echo '' . ($user ? esc_html($user->display_name) : '—') . ' | ';
echo '' . esc_html((string) ($row['created_at'] ?? '')) . ' | ';
echo '';
@@ -974,6 +1006,13 @@ class AKSRT_Admin_Pay_Menus {
$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;
+ $expires = isset($_POST['expires_at']) ? sanitize_text_field((string) wp_unslash($_POST['expires_at'])) : '';
+ if ($expires !== '') {
+ $expires = str_replace('T', ' ', $expires);
+ if (strlen($expires) === 16) {
+ $expires .= ':00';
+ }
+ }
if ($type === 'points') {
$type = 'credits';
@@ -989,8 +1028,11 @@ class AKSRT_Admin_Pay_Menus {
$meta['days'] = $days;
}
- $codes = AKSRT_Charge_Card::get_instance()->batch_create($type, $meta, $count, $length, $prefix, '', $note);
+ $codes = AKSRT_Charge_Card::get_instance()->batch_create($type, $meta, $count, $length, $prefix, $expires, $note);
$ok = !empty($codes);
+ if ($ok) {
+ set_transient('aksrt_pay_card_codes_' . get_current_user_id(), $codes, 10 * MINUTE_IN_SECONDS);
+ }
wp_safe_redirect($this->page_url('aksrt_charge_cards', [
'aksrt_pay_msg' => $ok ? 'card_batch_ok' : 'card_batch_failed',
@@ -1415,6 +1457,14 @@ class AKSRT_Admin_Pay_Menus {
$page_num = max(1, (int) ($_GET['paged'] ?? 1));
$per_page = 20;
$svc = AKSRT_Coupon::get_instance();
+ $type_labels = [
+ 'fixed' => __('固定金额', 'aksrt'),
+ 'percent' => __('折扣百分比', 'aksrt'),
+ ];
+ $status_labels = [
+ 'active' => __('可用', 'aksrt'),
+ 'disabled' => __('已禁用', 'aksrt'),
+ ];
echo '' . esc_html__('新建优惠码', 'aksrt') . '';
echo '';
+ echo '' . esc_html__('批量生成优惠码', 'aksrt') . '';
+ echo '';
+
+ if (!empty($_GET['aksrt_coupon_generated'])) {
+ $generated = (int) $_GET['aksrt_coupon_generated'];
+ echo '' . esc_html(sprintf(
+ /* translators: %d count */
+ __('成功生成 %d 个优惠码。', 'aksrt'),
+ $generated
+ )) . ' ';
+ }
+ $generated_codes = get_transient('aksrt_pay_coupon_codes_' . get_current_user_id());
+ if (is_array($generated_codes) && $generated_codes) {
+ delete_transient('aksrt_pay_coupon_codes_' . get_current_user_id());
+ echo '' . esc_html__('本次生成优惠码(请及时复制保存):', 'aksrt') . ' ';
+ echo ' ';
+ echo ' ';
+ }
+
echo ' |