Files
wordpress-theme-aksrt/templates/parts/resource-download-box.php
T
kate522 aad83072a8 refactor(pay): 统一流水号,移除订单/流水/提现三类号码前缀
订单号、资金流水号、提现单号此前各自带前缀配置,同一笔业务在不同界面会
呈现多个号码口径,对账与客诉排查都要先做一次前缀换算。现收敛为单一流水号
分配器,不再按业务类型区分号码形态。

- 删除 payment_order_prefix / payment_flow_prefix /
  payment_withdrawal_prefix 三项配置项及其生成、校验链路
- BusinessNumber::allocate() 成为唯一入口,输出 {YmdHis}{6 位随机},
  共 20 位无前缀,满足 VARCHAR(32) 与网关 out_trade_no ≤ 32 的限制
- 订单、资金流水、提现、卡密渠道交易号四处生成点全部改走该分配器
- 后台支付中心表头「订单号 / 提现单号」统一为「流水号」
- 前台用户中心与订单卡片文案同步统一;前台订单详情合并为单行流水号,
  账本流水号不再下发到前台,避免同一单据出现两个对外号码
- 同步更新 financial-flow / pay-card / card-pass-order-numbers 契约测试
  与 BusinessNumberTest 断言

按用户要求不做双路逻辑与数据迁移,直接替换为统一方案,历史行不做转换。

验证:node --test tests/**/*.test.cjs 362/364 通过,新增 37 项契约;失败的
2 项在改动前的干净 HEAD 基线上同样失败(基线 327 项 / 失败 2 项),分别命中
遗留的 fa fa- 标记与 FA 版本号断言,与本次改动无关。phpunit 44 项 / 103
断言全部通过;php -l 全部改动的 PHP 文件通过。
2026-09-18 22:14:27 +08:00

511 lines
24 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Unified paid-content download box.
*
* Downloadable content now follows the unified single.php mainline; resource-
* specific visuals are treated as content variants rather than a separate page
* system.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$post_id = get_the_ID();
$meta = get_query_var('aksrt_resource_meta', null);
if (!is_array($meta)) {
$meta = function_exists('aksrt_get_download_box_meta') ? aksrt_get_download_box_meta($post_id) : null;
}
if (!is_array($meta)) return;
$downloads = is_array($meta['downloads']) ? $meta['downloads'] : [];
$pay_type = $meta['pay_type'] ?? 'download';
if ($pay_type !== 'download' || empty($downloads)) {
return;
}
$is_resource_context = function_exists('aksrt_is_resource_post') && aksrt_is_resource_post($post_id);
$context_variant = $is_resource_context ? 'resource' : 'content';
// 下载总开关关闭 = 直连模式:下载按钮直接输出原始地址,不走本站中转链接。
$direct_download = class_exists('\AKSRT\Content\Download')
&& !\AKSRT\Content\Download::get_instance()->is_enabled();
$subject_label = trim((string) ($meta['subject_label'] ?? ''));
if ($subject_label === '') {
$subject_label = $is_resource_context ? __('资源', 'aksrt') : __('内容', 'aksrt');
}
$price_label = function_exists('aksrt_get_pay_price_label')
? aksrt_get_pay_price_label($post_id)
: ['text' => '', 'free' => true];
// 下载策略检查
$gate = function_exists('aksrt_can_download') ? aksrt_can_download($post_id) : true;
$gate_blocked = is_wp_error($gate);
$gate_code = $gate_blocked ? $gate->get_error_code() : '';
$gate_data = $gate_blocked ? (array) $gate->get_error_data() : [];
$paid_settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_paid_content_settings()
: ['download_credit' => true];
$access = class_exists('\AKSRT\Content\Visibility')
? \AKSRT\Content\Visibility::get_post_access_state($post_id)
: [];
$has_paid_access = !empty($access['has_paid_access']);
$priced = function_exists('aksrt_get_user_pay_price') ? aksrt_get_user_pay_price($post_id) : null;
$pay_modo = is_array($priced)
? ((($priced['modo'] ?? '0') === 'points') ? 'points' : '0')
: ((($meta['pay_modo'] ?? '0') === 'points') ? 'points' : '0');
$user_amount = is_array($priced) ? (float) ($priced['amount'] ?? 0) : (float) ($meta['price'] ?? 0);
$cost = function_exists('aksrt_resource_download_cost') ? (int) aksrt_resource_download_cost($post_id) : 0;
// 直连模式下没有“获取链接”请求,验证码容器不会被打开,属死 UI 不渲染。
$captcha_active = !$direct_download
&& function_exists('aksrt_is_captcha_enabled_for')
&& aksrt_is_captcha_enabled_for('download');
$balance = (int) ($gate_data['balance'] ?? (is_user_logged_in() ? \AKSRT\Ledger\LedgerService::get_instance()->balance(get_current_user_id(), \AKSRT\Ledger\AssetType::POINTS) : 0));
$login_url = (string) ($gate_data['login_url'] ?? wp_login_url(get_permalink($post_id)));
$vip_url = function_exists('aksrt_get_user_center_tab_url')
? aksrt_get_user_center_tab_url('credits')
: (function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : home_url('/'));
$is_need_login = $gate_blocked && $gate_code === 'aksrt_need_login';
$is_need_vip = $gate_blocked && $gate_code === 'aksrt_need_vip';
$is_need_purchase = $gate_blocked && $gate_code === 'aksrt_need_purchase';
// Points unpaid may also surface as need_purchase; treat low balance only after cashier.
$is_low_credit = false;
$allow_guest_buy = !is_user_logged_in()
&& function_exists('aksrt_allow_guest_content_pay')
&& aksrt_allow_guest_content_pay($post_id)
&& $pay_modo !== 'points'
&& $user_amount > 0
&& empty($access['need_vip']);
// If gate only says login but guest buy allowed for cash posts, convert to purchase CTA.
if ($is_need_login && $allow_guest_buy) {
$is_need_login = false;
$is_need_purchase = true;
$gate_blocked = true;
}
$price_amount = (float) ($price_label['amount'] ?? $user_amount);
// legacy down_alone_page: single entry to independent download page.
$alone_page = !empty($paid_settings['down_alone_page']) || !empty($paid_settings['download']['alone_page']);
$alone_url = '';
if ($alone_page && function_exists('aksrt_get_single_download_page_url')) {
$alone_url = aksrt_get_single_download_page_url($post_id);
}
$use_alone_entry = $alone_page && $alone_url !== '' && !$is_need_login && !$is_need_vip && !$is_need_purchase && !$gate_blocked;
if (!empty($GLOBALS['aksrt_on_download_file_page'])) {
$use_alone_entry = false;
}
// 缩略图
$thumbnail = get_the_post_thumbnail_url($post_id, 'medium') ?: '';
$has_thumbnail = $thumbnail !== '';
// 原价 & VIP 价(按 pay_modo 切换现金/积分档)
$original_price = (float) ($meta['original_price'] ?? 0);
if ($pay_modo === 'points') {
$vip1_price = (float) ($meta['vip1_points'] ?? 0);
$vip2_price = (float) ($meta['vip2_points'] ?? 0);
$base_price = (float) ($meta['points_price'] ?? $meta['price'] ?? 0);
} else {
$vip1_price = (float) ($meta['vip1_price'] ?? 0);
$vip2_price = (float) ($meta['vip2_price'] ?? 0);
$base_price = (float) ($meta['price'] ?? 0);
}
$has_original = $original_price > 0 && $original_price > $base_price;
$has_vip = ($vip1_price > 0 && $vip1_price < $base_price) || ($vip2_price > 0 && $vip2_price < $base_price);
$pay_limit = (int) ($meta['pay_limit'] ?? 0);
$user_vip_level = is_array($priced) ? (int) ($priced['vip_level'] ?? 0) : 0;
$member_blocked = $pay_limit > 0 && $user_vip_level < $pay_limit;
// 销量
$download_count = (int) ($meta['download_count'] ?? 0);
$sales_count = (int) ($meta['sales_count'] ?? 0);
$display_count = max($download_count, $sales_count);
$show_sales = !isset($meta['show_sales']) || !empty($meta['show_sales']);
// 付费类型徽章
$pay_type_badge = function_exists('aksrt_get_pay_type_badge') ? aksrt_get_pay_type_badge($pay_type) : '';
// 货币名称
$currency = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_currency_name() : __('积分', 'aksrt');
$cash_symbol = '¥';
if (class_exists('\AKSRT\Settings\Settings')) {
$paid_display = \AKSRT\Settings\Settings::get_paid_content_settings();
$cash_symbol = (string) ($paid_display['display']['currency_symbol'] ?? '¥');
}
$format_vip = static function (float $amount) use ($pay_modo, $currency, $cash_symbol): string {
if ($amount <= 0) {
return (string) __('免费', 'aksrt');
}
$n = function_exists('aksrt_format_price') ? aksrt_format_price($amount) : (string) $amount;
return $pay_modo === 'points' ? ($n . ' ' . $currency) : ($cash_symbol . $n);
};
$purchase_label = '';
if ($is_need_purchase && $user_amount > 0) {
$purchase_label = $pay_modo === 'points'
? sprintf(__('立即购买(%s %s)', 'aksrt'), aksrt_format_price($user_amount), $currency)
: sprintf(__('立即购买(%s%s)', 'aksrt'), $cash_symbol, aksrt_format_price($user_amount));
} elseif ($is_need_purchase) {
$purchase_label = __('购买后下载', 'aksrt');
}
?>
<section class="widget resource-download-box resource-download-box--v2<?php echo $gate_blocked ? ' is-blocked' : ''; ?><?php echo $has_paid_access ? ' is-purchased' : ''; ?> resource-download-box--<?php echo esc_attr($context_variant); ?>"
data-aksrt-download-box
data-post-id="<?php echo esc_attr((string) $post_id); ?>"
data-price="<?php echo esc_attr((string) $base_price); ?>"
data-amount="<?php echo esc_attr((string) $user_amount); ?>"
data-pay-modo="<?php echo esc_attr($pay_modo); ?>"
data-pay-limit="<?php echo esc_attr((string) $pay_limit); ?>"
data-has-paid="<?php echo $has_paid_access ? '1' : '0'; ?>"
data-credit="0"
data-captcha="<?php echo $captcha_active ? '1' : '0'; ?>"
aria-label="<?php esc_attr_e('下载区', 'aksrt'); ?>">
<?php if ($has_paid_access && $user_amount > 0) : ?>
<span class="resource-download-box__sales-badge resource-download-box__paid-badge">
<i class="fa fas fa-check-circle" aria-hidden="true"></i>
<?php esc_html_e('已购买', 'aksrt'); ?>
</span>
<?php elseif ($show_sales && $display_count > 0) : ?>
<span class="resource-download-box__sales-badge">
<i class="fa fas fa-fire" aria-hidden="true"></i>
<?php
/* translators: %s: 下载/销量数 */
printf(esc_html__('已售 %s', 'aksrt'), number_format_i18n($display_count));
?>
</span>
<?php endif; ?>
<?php
$paid_order = null;
if ($has_paid_access && is_user_logged_in() && function_exists('aksrt_get_user_content_paid_order')) {
$paid_order = aksrt_get_user_content_paid_order((int) $post_id);
}
?>
<div class="resource-download-box__body">
<?php if ($has_thumbnail) : ?>
<div class="resource-download-box__thumb-col">
<img<?php echo aksrt_get_lazy_attr('lazy_other', (string) $thumbnail, 'resource-download-box__thumb'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt="<?php echo esc_attr(get_the_title()); ?>">
<?php if ($pay_type_badge) : ?>
<div class="resource-download-box__pay-tag"><?php echo $pay_type_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="resource-download-box__content-col">
<header class="resource-download-box__header">
<div>
<p class="resource-download-box__eyebrow"><?php echo esc_html(sprintf(__('%s付费 / 下载能力', 'aksrt'), $subject_label)); ?></p>
<h2 class="resource-download-box__title">
<i class="fa fas fa-cloud-download-alt" aria-hidden="true"></i>
<?php echo $has_paid_access ? esc_html__('资源下载', 'aksrt') : esc_html__('解锁下载', 'aksrt'); ?>
</h2>
</div>
<span class="resource-download-box__count">
<?php echo esc_html(sprintf(_n('%s 个下载源', '%s 个下载源', count($downloads), 'aksrt'), number_format_i18n(count($downloads)))); ?>
</span>
</header>
<?php if ($has_paid_access && $user_amount > 0) : ?>
<div class="resource-download-box__pricing">
<span class="resource-download-box__price is-free"><?php esc_html_e('已解锁', 'aksrt'); ?></span>
<?php echo $pay_type_badge && !$has_thumbnail ? $pay_type_badge : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php if (is_array($paid_order) && !empty($paid_order['order_number'])) : ?>
<div class="resource-download-box__paid-meta">
<span><?php printf(esc_html__('流水号:%s', 'aksrt'), esc_html((string) $paid_order['order_number'])); ?></span>
<?php if (!empty($paid_order['paid_at'])) : ?>
<span><?php printf(esc_html__('支付时间:%s', 'aksrt'), esc_html((string) $paid_order['paid_at'])); ?></span>
<?php endif; ?>
<span>
<?php
$paid_amt = (float) ($paid_order['amount'] ?? 0);
$paid_cur = (string) ($paid_order['currency'] ?? '');
if ($paid_cur === 'points') {
printf(esc_html__('实付:%s %s', 'aksrt'), esc_html(function_exists('aksrt_format_price') ? aksrt_format_price($paid_amt) : (string) $paid_amt), esc_html($currency));
} else {
printf(esc_html__('实付:%s%s', 'aksrt'), esc_html($cash_symbol), esc_html(function_exists('aksrt_format_price') ? aksrt_format_price($paid_amt) : (string) $paid_amt));
}
?>
</span>
</div>
<?php endif; ?>
<?php else : ?>
<div class="resource-download-box__pricing">
<span class="resource-download-box__price<?php echo !empty($price_label['free']) || $has_paid_access ? ' is-free' : ''; ?>">
<?php
if ($has_paid_access && $user_amount > 0) {
esc_html_e('已解锁', 'aksrt');
} else {
echo esc_html((string) ($price_label['text'] ?? ''));
}
?>
</span>
<?php if ($has_original && !$member_blocked && !$has_paid_access) : ?>
<span class="resource-download-box__original-price">
<?php
echo esc_html(
$pay_modo === 'points'
? (aksrt_format_price($original_price) . ' ' . $currency)
: ($cash_symbol . aksrt_format_price($original_price))
);
?>
</span>
<?php endif; ?>
<?php echo $pay_type_badge && !$has_thumbnail ? $pay_type_badge : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php endif; ?>
<?php if ($has_vip && !$member_blocked && !$has_paid_access) : ?>
<div class="resource-download-box__vip-pricing">
<?php if ($vip1_price > 0 && $vip1_price < $base_price) : ?>
<span class="resource-download-box__vip-badge resource-download-box__vip-badge--1">
<i class="fa fas fa-certificate" aria-hidden="true"></i>
<?php
/* translators: %s: VIP1 价格 */
printf(esc_html__('VIP1 %s', 'aksrt'), $format_vip($vip1_price));
?>
</span>
<?php endif; ?>
<?php if ($vip2_price > 0 && $vip2_price < $base_price) : ?>
<span class="resource-download-box__vip-badge resource-download-box__vip-badge--2">
<i class="fa fas fa-gem" aria-hidden="true"></i>
<?php
/* translators: %s: VIP2 价格 */
printf(esc_html__('VIP2 %s', 'aksrt'), $format_vip($vip2_price));
?>
</span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
if (function_exists('aksrt_get_pay_attributes_html')) {
echo aksrt_get_pay_attributes_html($post_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
<?php if (!empty($paid_settings['catalog_note'])) : ?>
<p class="resource-download-box__catalog-note"><?php echo esc_html((string) $paid_settings['catalog_note']); ?></p>
<?php endif; ?>
<?php if ($is_need_vip || $member_blocked) : ?>
<div class="mt10 resource-download-box__vip-gate">
<a href="<?php echo esc_url($vip_url); ?>" class="resource-download-box__btn btn-primary resource-download-box__btn--vip">
<i class="fa fas fa-certificate" aria-hidden="true"></i>
<span><?php echo esc_html($gate instanceof WP_Error ? $gate->get_error_message() : __('开通会员后下载', 'aksrt')); ?></span>
</a>
<?php
if (function_exists('aksrt_get_demo_link_html')) {
echo aksrt_get_demo_link_html($post_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
<?php elseif ($is_need_purchase) : ?>
<div class="mt10 resource-download-box__purchase-gate">
<button
type="button"
class="resource-download-box__btn btn-primary resource-download-box__btn--purchase cashier-link <?php echo $pay_modo === 'points' ? 'is-points' : 'is-cash'; ?>"
data-action="aksrt-need-purchase"
data-aksrt-pay-content="<?php echo esc_attr((string) $post_id); ?>"
data-post-id="<?php echo esc_attr((string) $post_id); ?>"
data-pay-modo="<?php echo esc_attr($pay_modo); ?>"
data-amount="<?php echo esc_attr((string) $user_amount); ?>"
>
<i class="fa fas fa-shopping-cart" aria-hidden="true"></i>
<span><?php echo esc_html($purchase_label); ?></span>
</button>
<?php
if (function_exists('aksrt_get_demo_link_html')) {
echo aksrt_get_demo_link_html($post_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
<?php elseif (!empty($use_alone_entry)) : ?>
<div class="mt10 resource-download-box__alone">
<a target="_blank" rel="nofollow" href="<?php echo esc_url($alone_url); ?>" class="resource-download-box__btn btn-primary resource-download-box__btn--alone">
<i class="fa fas fa-download" aria-hidden="true"></i>
<span><?php esc_html_e('资源下载', 'aksrt'); ?></span>
</a>
<?php
if (function_exists('aksrt_get_demo_link_html')) {
echo aksrt_get_demo_link_html($post_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
<?php else : ?>
<ul class="resource-download-box__list">
<?php foreach ($downloads as $idx => $row) :
$label = isset($row['label']) ? (string) $row['label'] : '';
if ($label === '') {
$label = sprintf(__('下载源 %d', 'aksrt'), $idx + 1);
}
$type = isset($row['type']) ? (string) $row['type'] : 'direct';
$url = isset($row['url']) ? (string) $row['url'] : '';
if ($direct_download && $url === '') {
// 直连模式没有可用的原始地址,空源不渲染。
continue;
}
$extract_code = isset($row['extract_code']) ? trim((string) $row['extract_code']) : '';
$has_extract = $extract_code !== '';
$service = function_exists('aksrt_detect_cloud_service') ? aksrt_detect_cloud_service($url) : ['key' => 'other', 'name' => $label, 'color' => '#6b7280'];
if (strpos($label, '下载源') === 0 && $service['key'] !== 'other') {
$label = $service['name'];
}
if ($is_need_login) {
$btn_tag = 'a';
$btn_href = $login_url;
$btn_text = __('登录后下载', 'aksrt');
$btn_icon = 'fa-sign-in-alt';
$btn_modifier = ' resource-download-box__btn--login';
$btn_action = '';
$btn_target = '';
$btn_rel = '';
} elseif ($direct_download) {
$btn_tag = 'a';
$btn_href = $url;
$btn_text = __('立即下载', 'aksrt');
$btn_icon = 'fa-download';
$btn_modifier = $has_paid_access ? ' resource-download-box__btn--owned' : '';
$btn_action = '';
$btn_target = ' target="_blank"';
$btn_rel = ' rel="nofollow noopener"';
} else {
$btn_tag = 'button';
$btn_href = '';
$btn_text = __('立即下载', 'aksrt');
$btn_icon = 'fa-download';
$btn_modifier = $has_paid_access ? ' resource-download-box__btn--owned' : '';
$btn_action = 'aksrt-download';
$btn_target = '';
$btn_rel = '';
}
?>
<li class="resource-download-box__item">
<?php if ($btn_tag === 'a') : ?>
<a
class="resource-download-box__btn btn-primary resource-download-box__btn--service-<?php echo esc_attr($service['key']); ?><?php echo esc_attr($btn_modifier); ?>"
href="<?php echo esc_url($btn_href); ?>"<?php echo $btn_target; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><?php echo $btn_rel; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
data-source-index="<?php echo esc_attr((string) $idx); ?>"
data-source-type="<?php echo esc_attr($type); ?>"
style="--service-color: <?php echo esc_attr($service['color']); ?>"
>
<i class="fa <?php echo esc_attr($btn_icon); ?>" aria-hidden="true"></i>
<span><?php echo esc_html($btn_text); ?></span>
<span class="resource-download-box__service-badge" style="background: <?php echo esc_attr($service['color']); ?>">
<?php echo esc_html($service['name']); ?>
</span>
</a>
<?php if ($direct_download && $has_extract) : ?>
<button type="button" class="resource-download-box__btn resource-download-box__btn--extract"
data-clipboard-tag="<?php esc_attr_e('提取码', 'aksrt'); ?>"
data-clipboard-text="<?php echo esc_attr($extract_code); ?>"
><?php echo esc_html($extract_code); ?></button>
<?php endif; ?>
<?php else : ?>
<button
type="button"
class="resource-download-box__btn btn-primary resource-download-box__btn--service-<?php echo esc_attr($service['key']); ?><?php echo esc_attr($btn_modifier); ?>"
data-action="<?php echo esc_attr($btn_action); ?>"
data-source-index="<?php echo esc_attr((string) $idx); ?>"
data-source-type="<?php echo esc_attr($type); ?>"
data-has-extract="<?php echo $has_extract ? '1' : '0'; ?>"
data-balance="<?php echo esc_attr((string) $balance); ?>"
data-cost="<?php echo esc_attr((string) $cost); ?>"
style="--service-color: <?php echo esc_attr($service['color']); ?>"
>
<i class="fa <?php echo esc_attr($btn_icon); ?>" aria-hidden="true"></i>
<span><?php echo esc_html($btn_text); ?></span>
<span class="resource-download-box__service-badge" style="background: <?php echo esc_attr($service['color']); ?>">
<?php echo esc_html($service['name']); ?>
</span>
</button>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php
if (function_exists('aksrt_get_demo_link_html')) {
$demo = aksrt_get_demo_link_html($post_id);
if ($demo !== '') {
echo '<div class="mt10 resource-download-box__demo-row">' . $demo . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
?>
<?php endif; ?>
<?php
if (is_user_logged_in() && $user_amount <= 0 && function_exists('aksrt_get_user_free_download_limit')) {
$dl_limit = aksrt_get_user_free_download_limit();
if ($dl_limit > 0) {
$dl_used = function_exists('aksrt_get_user_free_downloaded_number') ? aksrt_get_user_free_downloaded_number() : 0;
$dl_surplus = max(0, $dl_limit - $dl_used);
$vip_lv = function_exists('aksrt_get_user_vip_level') ? aksrt_get_user_vip_level() : 0;
$over_price = max(0.0, (float) ($meta['download_limit_over_price'] ?? 0));
if ($dl_surplus <= 0) {
echo '<div class="resource-download-box__quota-notice"><span class="badg c-red btn-block">' . esc_html__('您今日下载免费资源个数已超限,请明日再下载。', 'aksrt') . '</span></div>';
if ($over_price > 0 && !$has_paid_access) {
$over_label = $pay_modo === 'points'
? sprintf(__('立即购买(%s %s)', 'aksrt'), function_exists('aksrt_format_price') ? aksrt_format_price($over_price) : (string) $over_price, $currency)
: sprintf(__('立即购买(%s%s)', 'aksrt'), $cash_symbol, function_exists('aksrt_format_price') ? aksrt_format_price($over_price) : (string) $over_price);
echo '<div class="mt10 resource-download-box__purchase-gate">';
echo '<button type="button" class="resource-download-box__btn btn-primary resource-download-box__btn--purchase cashier-link" data-action="aksrt-need-purchase" data-aksrt-pay-content="' . esc_attr((string) $post_id) . '" data-post-id="' . esc_attr((string) $post_id) . '" data-price-type="download_limit_over" data-pay-modo="' . esc_attr($pay_modo) . '" data-amount="' . esc_attr((string) $over_price) . '">';
echo '<i class="fa fas fa-shopping-cart" aria-hidden="true"></i><span>' . esc_html($over_label) . '</span></button></div>';
}
} else {
$who = $vip_lv > 0 ? esc_html__('您是尊贵的会员,', 'aksrt') : esc_html__('您', 'aksrt');
echo '<div class="resource-download-box__quota-notice"><span class="badg c-red btn-block">' . $who . esc_html(sprintf(__('今日还可下载 %s 个免费资源', 'aksrt'), number_format_i18n($dl_surplus))) . '</span></div>';
}
}
}
?>
<?php $service_html = aksrt_get_pay_service_html(); ?>
<?php if ($service_html !== '') : ?>
<div class="resource-download-box__guarantees">
<?php echo $service_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php endif; ?>
</div>
</div>
<?php if ($is_need_login) : ?>
<p class="resource-download-box__hint resource-download-box__hint--login">
<i class="fa fas fa-info-circle" aria-hidden="true"></i>
<?php echo ($price_amount <= 0) ? esc_html__('免费资源,请登录后下载。', 'aksrt') : esc_html__('登录后可解锁并下载该内容。', 'aksrt'); ?>
</p>
<?php elseif ($is_need_vip || $member_blocked) : ?>
<p class="resource-download-box__hint resource-download-box__hint--vip">
<i class="fa fas fa-info-circle" aria-hidden="true"></i>
<?php echo esc_html($gate instanceof WP_Error ? $gate->get_error_message() : __('该资源仅限会员购买/下载。', 'aksrt')); ?>
</p>
<?php elseif ($is_need_purchase) : ?>
<p class="resource-download-box__hint resource-download-box__hint--purchase">
<i class="fa fas fa-info-circle" aria-hidden="true"></i>
<?php esc_html_e('请先完成购买后再下载该资源。', 'aksrt'); ?>
</p>
<?php endif; ?>
<?php if ($captcha_active && function_exists('aksrt_render_captcha')) : ?>
<div class="resource-download-box__captcha resource-download-box__captcha--hidden" data-aksrt-download-captcha>
<?php aksrt_render_captcha('download'); ?>
</div>
<?php endif; ?>
<footer class="resource-download-box__footer">
<p class="resource-download-box__notice-text">
<i class="fa fas fa-info-circle" aria-hidden="true"></i>
<?php esc_html_e('下载能力是统一付费内容的一部分,请确认内容适用性后再使用。', 'aksrt'); ?>
</p>
</footer>
</section>