feat(pay): 卡密兑换入口收敛到三个购买弹窗并对齐参考主题
- 移除余额卡片独立「卡密兑换」通用弹窗,兑换入口分布到充值/积分/会员三个弹窗的支付方式中 - 充值弹窗补齐卡密 logo 与仅卡密时的金额选择隐藏逻辑 - 积分购买弹窗 1:1 复刻参考主题 points-pay modal(商品档位/自定义/支付方式/立即支付),REST 改为 product+custom 契约 - 会员弹窗注入卡密渠道:视图模型透传 card_pass,前端渲染卡密盒并直兑 /pay/card-pass/redeem type=vip - 后台卡密兑换拆分为余额/积分/会员三个独立开关,VIP 段旧会员卡密组清理 - REST type 改为必填(balance/vip/credits),三类型独立闸门 - 测试重写为 card-pass-modal-redeem 契约,321 项全部通过
This commit is contained in:
1 parent
74e43aaa76
commit
b88eab0bfe
18 files changed
+746
-472
No files matched your search
@@ -45,12 +45,12 @@ if ($withdraw_on && class_exists('\AKSRT\Payment\Withdrawal')) {
|
||||
$withdraw_pending_hold = $wd_svc->sum_pending_hold((int) ($user_id ?? 0));
|
||||
$withdraw_usage = $wd_svc->daily_usage((int) ($user_id ?? 0), $withdraw_settings);
|
||||
}
|
||||
// 卡密兑换总开关(后台 余额充值 → 卡密兑换 → 启用卡密兑换功能),
|
||||
// 通用弹窗支持余额 / 会员 / 积分三类卡密,类型由后端按卡密自动识别。
|
||||
$card_pass_redeem = ['enabled' => false, 'desc' => ''];
|
||||
// 卡密支付渠道(后台 余额充值 → 卡密兑换 → 启用卡密兑换余额功能):
|
||||
// 兑换入口收敛到充值弹窗的支付方式,不再有独立入口。
|
||||
$card_pass_redeem = ['enabled' => false, 'desc' => '', 'only_password' => false];
|
||||
if (class_exists('\AKSRT\Payment\ChargeCard')) {
|
||||
$opts = \AKSRT\Payment\ChargeCard::get_instance()->get_public_options();
|
||||
$card_pass_redeem = is_array($opts['balance'] ?? null) ? $opts['balance'] : $card_pass_redeem;
|
||||
$card_opts = \AKSRT\Payment\ChargeCard::get_instance()->get_public_options();
|
||||
$card_pass_redeem = is_array($card_opts['balance'] ?? null) ? $card_opts['balance'] : $card_pass_redeem;
|
||||
}
|
||||
|
||||
$charge_view = [];
|
||||
@@ -92,43 +92,14 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
|
||||
<button type="button" class="but b-blue-2" data-aksrt-charge-open><?php esc_html_e('充值', 'aksrt'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($withdraw_on || !empty($card_pass_redeem['enabled'])) : ?>
|
||||
<?php if ($withdraw_on) : ?>
|
||||
<div class="uc-asset-card__foot muted-2-color em09 mt6 flex jsb ac">
|
||||
<?php if ($withdraw_on) : ?>
|
||||
<span><?php printf(esc_html__('冻结中 %s', 'aksrt'), esc_html($normalize_balance($withdraw_pending_hold)->formatted())); ?></span>
|
||||
<?php else : ?>
|
||||
<span></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($card_pass_redeem['enabled'])) : ?>
|
||||
<button type="button" class="uc-asset-card__head-action muted-color px12" data-aksrt-card-pass-open>
|
||||
<?php esc_html_e('卡密兑换', 'aksrt'); ?>
|
||||
<i class="fa fas fa-angle-right em12 ml3" aria-hidden="true"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<span><?php printf(esc_html__('冻结中 %s', 'aksrt'), esc_html($normalize_balance($withdraw_pending_hold)->formatted())); ?></span>
|
||||
<span></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($card_pass_redeem['enabled'])) : ?>
|
||||
<div class="uc-modal" id="aksrt-card-pass-modal" hidden data-aksrt-card-pass-modal data-aksrt-card-pass="">
|
||||
<div class="uc-modal__overlay" data-aksrt-card-pass-close></div>
|
||||
<div class="uc-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="aksrt-card-pass-title">
|
||||
<button type="button" class="uc-modal__close" data-aksrt-card-pass-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
|
||||
<h3 id="aksrt-card-pass-title" class="uc-modal__title"><i class="fa fas fa-ticket-alt mr6" aria-hidden="true"></i><?php esc_html_e('卡密兑换', 'aksrt'); ?></h3>
|
||||
<?php if (!empty($card_pass_redeem['desc'])) : ?>
|
||||
<div class="uc-modal__desc muted-box em09"><?php echo esc_html((string) $card_pass_redeem['desc']); ?></div>
|
||||
<?php endif; ?>
|
||||
<input type="text" class="uc-card-pass__input" name="aksrt_card_no" data-aksrt-card-no autocomplete="off" placeholder="<?php esc_attr_e('请输入卡号(选填)', 'aksrt'); ?>">
|
||||
<input type="text" class="uc-card-pass__input" name="aksrt_card_password" data-aksrt-card-password autocomplete="off" placeholder="<?php esc_attr_e('请输入卡密', 'aksrt'); ?>">
|
||||
<div class="uc-card-pass-actions">
|
||||
<button type="button" class="uc-card-pass__btn" data-aksrt-card-redeem>
|
||||
<?php esc_html_e('立即兑换', 'aksrt'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Charge modal — Zibll balance-charge modal 1:1 (refresh_modal shell + zibpay_get_balance_charge_modal) -->
|
||||
<?php
|
||||
$charge_method_logos = [
|
||||
@@ -139,9 +110,13 @@ $charge_method_logos = [
|
||||
'epay_wxpay' => 'pay-wechat-logo.svg',
|
||||
'paypal' => 'pay-paypal-logo.svg',
|
||||
'stripe' => 'pay-stripe-logo.svg',
|
||||
'card_pass' => 'pay-card-pass-logo.svg',
|
||||
];
|
||||
$charge_img_uri = get_template_directory_uri() . '/assets/img/';
|
||||
$charge_default_product = $packages ? (string) $packages[0]['key'] : 'custom';
|
||||
// 仅卡密可用时隐藏金额选择(参考主题:卡密决定充值金额)。
|
||||
$charge_card_only = count($methods) === 1 && (string) ($methods[0]['id'] ?? '') === 'card_pass';
|
||||
$charge_card_in_methods = count($methods) > 0 && $methods[count($methods) - 1]['id'] === 'card_pass';
|
||||
$charge_mark_symbol = !in_array($mark, ['', '元'], true);
|
||||
$charge_mark_html = $charge_mark_symbol
|
||||
? '<span class="px12">' . esc_html($mark) . '</span>'
|
||||
@@ -170,32 +145,34 @@ $charge_custom_block = static function () use ($mark, $charge_mark_html, $charge
|
||||
<div class="modal-body">
|
||||
<div class="mb10 touch"><button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><svg class="ic-close" aria-hidden="true"><use xlink:href="#icon-close"></use></svg></button><b class="modal-title flex ac"><span class="mr6 em14"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-money-color-2"></use></svg></span><?php esc_html_e('余额充值', 'aksrt'); ?></b></div>
|
||||
<form class="balance-charge-form mini-scrollbar scroll-y max-vh7" data-aksrt-charge-form>
|
||||
<?php if ($packages) : ?>
|
||||
<div class="charge-box mb20">
|
||||
<div class="muted-color mb6"><?php esc_html_e('请选择充值金额', 'aksrt'); ?></div>
|
||||
<?php foreach ($packages as $idx => $pkg) :
|
||||
$package_credit = $normalize_balance($pkg['price'] ?? '');
|
||||
$package_pay = $normalize_balance($pkg['pay_price'] ?? '');
|
||||
$package_saving_minor = max(0, $package_credit->minor() - $package_pay->minor());
|
||||
?>
|
||||
<div class="zib-widget vip-product relative product-box<?php echo $idx === 0 ? ' active' : ''; ?>" data-for="balance_product" data-value="<?php echo esc_attr((string) $pkg['key']); ?>">
|
||||
<?php if (!empty($pkg['tag'])) : ?>
|
||||
<div class="abs-right vip-tag badg jb-yellow"><?php echo esc_html((string) $pkg['tag']); ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="em14"><?php echo $charge_mark_html; // phpcs:ignore WordPress.Security.EscapeOutput -- escaped span + esc_html mark above ?><?php echo esc_html((string) $pkg['price']); ?></div>
|
||||
<div class="c-red"><?php echo $charge_mark_html; // phpcs:ignore WordPress.Security.EscapeOutput ?><span><?php echo esc_html((string) $pkg['pay_price']); ?></span><?php if ($package_saving_minor > 0) : ?><span class="ml6 c-yellow smail"><?php printf(esc_html__('省%s', 'aksrt'), esc_html(\AKSRT\Ledger\AssetAmount::decimal_from_minor($package_saving_minor) . $charge_unit)); ?></span><?php endif; ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($custom_s) : ?>
|
||||
<div class="muted-color mt20 mb6"><?php esc_html_e('自定义充值金额', 'aksrt'); ?></div>
|
||||
<?php if (!$charge_card_only) : ?>
|
||||
<?php if ($packages) : ?>
|
||||
<div class="charge-box mb20">
|
||||
<div class="muted-color mb6"><?php esc_html_e('请选择充值金额', 'aksrt'); ?></div>
|
||||
<?php foreach ($packages as $idx => $pkg) :
|
||||
$package_credit = $normalize_balance($pkg['price'] ?? '');
|
||||
$package_pay = $normalize_balance($pkg['pay_price'] ?? '');
|
||||
$package_saving_minor = max(0, $package_credit->minor() - $package_pay->minor());
|
||||
?>
|
||||
<div class="zib-widget vip-product relative product-box<?php echo $idx === 0 ? ' active' : ''; ?>" data-for="balance_product" data-value="<?php echo esc_attr((string) $pkg['key']); ?>">
|
||||
<?php if (!empty($pkg['tag'])) : ?>
|
||||
<div class="abs-right vip-tag badg jb-yellow"><?php echo esc_html((string) $pkg['tag']); ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="em14"><?php echo $charge_mark_html; // phpcs:ignore WordPress.Security.EscapeOutput -- escaped span + esc_html mark above ?><?php echo esc_html((string) $pkg['price']); ?></div>
|
||||
<div class="c-red"><?php echo $charge_mark_html; // phpcs:ignore WordPress.Security.EscapeOutput ?><span><?php echo esc_html((string) $pkg['pay_price']); ?></span><?php if ($package_saving_minor > 0) : ?><span class="ml6 c-yellow smail"><?php printf(esc_html__('省%s', 'aksrt'), esc_html(\AKSRT\Ledger\AssetAmount::decimal_from_minor($package_saving_minor) . $charge_unit)); ?></span><?php endif; ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($custom_s) : ?>
|
||||
<div class="muted-color mt20 mb6"><?php esc_html_e('自定义充值金额', 'aksrt'); ?></div>
|
||||
<?php $charge_custom_block(); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php elseif ($custom_s) : ?>
|
||||
<div class="charge-box mb20">
|
||||
<div class="muted-color mb6"><?php esc_html_e('请输入充值金额', 'aksrt'); ?></div>
|
||||
<?php $charge_custom_block(); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php elseif ($custom_s) : ?>
|
||||
<div class="charge-box mb20">
|
||||
<div class="muted-color mb6"><?php esc_html_e('请输入充值金额', 'aksrt'); ?></div>
|
||||
<?php $charge_custom_block(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($charge_view['desc'])) : ?>
|
||||
<div class="muted-box muted-2-color padding-10 mb10 em09"><?php echo esc_html((string) $charge_view['desc']); ?></div>
|
||||
@@ -217,6 +194,20 @@ $charge_custom_block = static function () use ($mark, $charge_mark_html, $charge
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($charge_card_in_methods) : ?>
|
||||
<div class="mb10 padding-h10 padding-w6" data-controller="payment_method" data-condition="==" data-value="card_pass"<?php echo !$charge_card_only ? ' style="display: none;"' : ''; ?>>
|
||||
<?php if (!empty($card_pass_redeem['desc'])) : ?>
|
||||
<div class="muted-box muted-2-color padding-10 mb10 em09"><?php echo esc_html((string) $card_pass_redeem['desc']); ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="muted-2-color em09 mb6"><?php echo !empty($card_pass_redeem['only_password']) ? esc_html__('请输入卡密', 'aksrt') : esc_html__('请输入卡号和密码', 'aksrt'); ?></div>
|
||||
<?php if (empty($card_pass_redeem['only_password'])) : ?>
|
||||
<div class="mb6"><input type="input" class="form-control" name="card_pass[card]" placeholder="<?php esc_attr_e('卡号', 'aksrt'); ?>" value=""></div>
|
||||
<?php endif; ?>
|
||||
<div class="">
|
||||
<input type="input" class="form-control" name="card_pass[password]" placeholder="<?php esc_attr_e('卡密', 'aksrt'); ?>" value="">
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="balance_product" value="<?php echo esc_attr($charge_default_product); ?>">
|
||||
<input type="hidden" name="payment_method" value="<?php echo esc_attr((string) ($methods[0]['id'] ?? '')); ?>">
|
||||
<?php if ($methods) : ?>
|
||||
|
||||
Reference in new issue
Block a user