feat(payment): 支付&付费菜单按参考主题重构并新增提现策略页

- 子菜单重组为知识付费/余额充值/VIP会员/创作分成/推广返佣/收款接口/提现策略
- 收款接口页 1:1 复刻 Zibll 双下拉结构,仅保留支付宝/微信/PayPal/Stripe/易支付
- 订单前缀/流水号前缀/提现单号前缀配置保留并移入收款接口页
- 知识付费/推广返佣按参考主题全字段复刻,余额充值并入充值卡配置
- 新增 tabbed/between_number/page_select 表单控件及后端 pages 搜索源
- 清理旧 SPA 组件、无消费者 REST 端点与废弃配置键(不写双路兼容)
- 更新存量契约测试至新 schema 文件
This commit is contained in:
2026-09-16 19:18:28 +08:00
parent fb5cdf247d
commit a48007a44d
36 changed files with 2042 additions and 2273 deletions
+2 -2
View File
@@ -37,9 +37,9 @@ class PageDisplayController extends ControllerBase {
$query = sanitize_text_field((string) $request->get_param('query'));
$include = array_values(array_filter(array_map('absint', (array) $request->get_param('include'))));
if ($source === 'posts') {
if ($source === 'posts' || $source === 'pages') {
$posts = get_posts([
'post_type' => 'post',
'post_type' => $source === 'pages' ? 'page' : 'post',
'post_status' => 'publish',
'posts_per_page' => 20,
's' => $query,
-224
View File
@@ -19,49 +19,6 @@ class PaymentController extends ControllerBase {
public function register_routes(): void {
$this->register_section_routes('payment', 'payment');
register_rest_route(self::API_NAMESPACE, '/payment/overview', [
'methods' => 'GET',
'callback' => [$this, 'rest_payment_overview'],
'permission_callback' => [$this, 'check_permission'],
]);
// Revenue stats (with optional time-series)
register_rest_route(self::API_NAMESPACE, '/payment/revenue', [
'methods' => 'GET',
'callback' => [$this, 'get_revenue'],
'permission_callback' => [$this, 'check_permission'],
'args' => [
'date_from' => ['default' => '', 'sanitize_callback' => 'sanitize_text_field'],
'date_to' => ['default' => '', 'sanitize_callback' => 'sanitize_text_field'],
'granularity' => ['default' => 'day', 'sanitize_callback' => 'sanitize_text_field'],
'time_series' => ['default' => false, 'sanitize_callback' => 'rest_sanitize_boolean'],
],
]);
register_rest_route(self::API_NAMESPACE, '/payment/creator-income', [
'methods' => 'GET',
'callback' => [$this, 'get_creator_income'],
'permission_callback' => [$this, 'check_permission'],
'args' => [
'page' => ['type' => 'integer', 'minimum' => 1, 'default' => 1],
'per_page' => ['type' => 'integer', 'minimum' => 1, 'maximum' => 100, 'default' => 20],
'status' => ['type' => 'string', 'enum' => ['', 'pending', 'settled']],
'user_id' => ['type' => 'integer', 'minimum' => 0, 'default' => 0],
'post_id' => ['type' => 'integer', 'minimum' => 0, 'default' => 0],
'currency' => ['type' => 'string', 'enum' => ['', 'CNY', 'cny', 'points']],
'order_status' => ['type' => 'string', 'sanitize_callback' => 'sanitize_key'],
'order_number' => ['type' => 'string', 'maxLength' => 64, 'sanitize_callback' => 'sanitize_text_field'],
'date_from' => ['type' => 'string', 'format' => 'date'],
'date_to' => ['type' => 'string', 'format' => 'date'],
],
]);
register_rest_route(self::API_NAMESPACE, '/payment/creator-income/(?P<id>\d+)/settle', [
'methods' => 'POST',
'callback' => [$this, 'settle_creator_income'],
'permission_callback' => [$this, 'check_permission'],
'args' => ['id' => ['type' => 'integer', 'minimum' => 1, 'required' => true]],
]);
register_rest_route(self::API_NAMESPACE, '/payment/withdrawals', [
'methods' => 'GET',
'callback' => [$this, 'get_withdrawals'],
@@ -154,187 +111,6 @@ class PaymentController extends ControllerBase {
}
public function rest_payment_overview(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Settings\Settings')) {
return $this->error('设置模块未初始化', 500);
}
$paid = \AKSRT\Settings\Settings::get_paid_content_settings();
$recharge = \AKSRT\Settings\Settings::get_payment_recharge_settings();
$vip = \AKSRT\Settings\Settings::get_payment_vip_settings();
$revenue = \AKSRT\Settings\Settings::get_payment_revenue_settings();
$affiliate = \AKSRT\Settings\Settings::get_payment_affiliate_settings();
$gateway = \AKSRT\Settings\Settings::get_payment_gateway_settings();
return $this->success([
'data' => [
'paid' => $paid,
'recharge' => $recharge,
'vip' => $vip,
'revenue' => $revenue,
'affiliate' => $affiliate,
'gateway' => $gateway,
'currency_name' => \AKSRT\Settings\Settings::get_currency_name(),
],
]);
}
/**
* GET /payment/revenue — revenue stats with optional time-series
*/
public function get_revenue(\WP_REST_Request $request): \WP_REST_Response {
$revenue_stats = [
'cash' => ['total' => '0.00', 'pending' => '0.00', 'settled' => '0.00', 'count' => 0],
'points' => ['total' => 0, 'pending' => 0, 'settled' => 0, 'count' => 0],
];
if (class_exists('\AKSRT\Payment\Revenue')) {
$revenue_stats = \AKSRT\Payment\Revenue::get_instance()->get_stats();
}
$withdrawal_stats = ['total' => 0, 'pending' => 0, 'processing' => 0, 'completed' => 0, 'rejected' => 0, 'total_paid' => '0.00'];
if (class_exists('\AKSRT\Payment\Withdrawal')) {
$withdrawal_stats = \AKSRT\Payment\Withdrawal::get_instance()->get_stats();
}
$response = [
'revenue' => $revenue_stats,
'withdrawal' => $withdrawal_stats,
];
// Time-series data
if ($request->get_param('time_series')) {
$response['time_series'] = $this->get_revenue_time_series($request);
}
return $this->success(['data' => $response]);
}
/**
* Build revenue time-series data.
*/
private function get_revenue_time_series(\WP_REST_Request $request): array {
global $wpdb;
$prefix = $wpdb->prefix;
$date_from = sanitize_text_field((string) $request->get_param('date_from'));
$date_to = sanitize_text_field((string) $request->get_param('date_to'));
$granularity = sanitize_text_field((string) $request->get_param('granularity'));
// Default: last 30 days in the WordPress site timezone.
$timezone = function_exists('wp_timezone') ? wp_timezone() : new \DateTimeZone('UTC');
$now = new \DateTimeImmutable('now', $timezone);
if (!$date_from) {
$date_from = $now->modify('-30 days')->format('Y-m-d');
}
if (!$date_to) {
$date_to = $now->format('Y-m-d');
}
// Granularity: day, week, month
$date_format = '%Y-%m-%d';
if ($granularity === 'week') {
$date_format = '%x-W%v';
} elseif ($granularity === 'month') {
$date_format = '%Y-%m';
}
$table = $prefix . 'aksrt_revenue';
$results = $wpdb->get_results($wpdb->prepare(
"SELECT currency, DATE_FORMAT(created_at, %s) AS period,
SUM(amount) AS total_amount,
COUNT(*) AS order_count
FROM {$table}
WHERE status IN ('pending', 'settled')
AND created_at >= %s AND created_at < DATE_ADD(%s, INTERVAL 1 DAY)
GROUP BY currency, period
ORDER BY period ASC",
$date_format,
$date_from,
$date_to
));
$series = ['cash' => [], 'points' => []];
foreach ((array) $results as $row) {
$key = (string) ($row->currency ?? '') === 'points' ? 'points' : 'cash';
$amount = (string) ($row->total_amount ?? '0');
if ($key === 'points') {
$amount = preg_match('/^(0|[1-9]\d*)(?:\.0+)?$/', $amount, $matches) ? (int) $matches[1] : 0;
} else {
try {
$amount = \AKSRT\Ledger\AssetAmount::balance($amount)->decimal();
} catch (\InvalidArgumentException $e) {
$amount = '0.00';
}
}
$series[$key][] = [
'date' => (string) $row->period,
'amount' => $amount,
'count' => (int) $row->order_count,
];
}
return $series;
}
/**
* GET /payment/creator-income — creator income operations list.
*/
public function get_creator_income(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\Revenue')) {
return $this->error(__('创作分成模块未启用', 'aksrt'), 500);
}
$page = max(1, (int) $request->get_param('page'));
$per_page = max(1, min(100, (int) ($request->get_param('per_page') ?: 20)));
$result = \AKSRT\Payment\Revenue::get_instance()->get_list([
'limit' => $per_page,
'offset' => ($page - 1) * $per_page,
'status' => sanitize_key((string) $request->get_param('status')),
'user_id' => max(0, (int) $request->get_param('user_id')),
'post_id' => max(0, (int) $request->get_param('post_id')),
'currency' => sanitize_key((string) $request->get_param('currency')),
'order_status' => sanitize_key((string) $request->get_param('order_status')),
'order_number' => sanitize_text_field((string) $request->get_param('order_number')),
'date_from' => sanitize_text_field((string) $request->get_param('date_from')),
'date_to' => sanitize_text_field((string) $request->get_param('date_to')),
]);
$result['page'] = $page;
$result['per_page'] = $per_page;
return $this->success(['data' => $result]);
}
/**
* POST /payment/creator-income/{id}/settle — settle one income record.
*/
public function settle_creator_income(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\Revenue')) {
return $this->error(__('创作分成模块未启用', 'aksrt'), 500);
}
$id = (int) $request->get_param('id');
$operation_key = \AKSRT\Ledger\OperationKey::from_request($request, 'admin-revenue-settle', get_current_user_id());
if (is_wp_error($operation_key)) {
return $this->error($operation_key->get_error_message(), (int) ($operation_key->get_error_data()['status'] ?? 400));
}
$result = \AKSRT\Payment\Revenue::get_instance()->settle_result($id, get_current_user_id(), $operation_key);
if (is_wp_error($result)) {
$data = $result->get_error_data();
return $this->error($result->get_error_message(), is_array($data) ? (int) ($data['status'] ?? 400) : 400);
}
$entry = (array) ($result->entries[0] ?? []);
$asset = (string) ($entry['asset'] ?? \AKSRT\Ledger\AssetType::BALANCE->value);
$author_id = (int) ($entry['user_id'] ?? 0);
$balance_minor = $result->balance($author_id, $asset);
$balance = $asset === \AKSRT\Ledger\AssetType::BALANCE->value
? \AKSRT\Ledger\AssetAmount::decimal_from_minor($balance_minor)
: $balance_minor;
return $this->success([
'message' => __('创作分成已结算', 'aksrt'),
'transaction_id' => $result->transaction_id,
'replayed' => $result->replayed,
'asset' => $asset,
'balance' => $balance,
]);
}
public function get_withdrawals(\WP_REST_Request $request): \WP_REST_Response {
if (!class_exists('\AKSRT\Payment\Withdrawal')) {
return $this->success(['data' => ['items' => [], 'total' => 0, 'page' => 1, 'total_pages' => 1, 'stats' => []]]);
+560 -316
View File
@@ -7,323 +7,567 @@ namespace AKSRT\Admin\Schema;
defined('ABSPATH') || exit;
/**
* 「支付&付费」设置 schema。
*
* 页面结构 1:1 复刻参考主题 Zibll 的「支付&付费」section(知识付费 / 余额充值 /
* VIP会员 / 创作分成 / 推广返佣 / 收款接口),并按产品需求新增「提现策略」子页。
* 收款接口仅保留支付宝、微信、PayPal、Stripe、易支付;订单前缀 / 流水号前缀 /
* 提现单号前缀配置保留并收口在收款接口页。
*/
class SchemaPayment {
public static function build(): array {
return [
'domain' => 'payment',
'title' => '支付&付费',
'sections' => [
'recharge' => [
'key' => 'recharge',
'title' => '余额充值',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '充值开关', 'fields' => [
['key' => 'pay_balance_s', 'label' => '启用余额功能', 'type' => 'switch', 'default' => true],
['key' => 'pay_balance_desc', 'label' => '充值说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
]],
['key' => 'packages', 'title' => '充值套餐', 'fields' => [
['key' => 'pay_balance_product', 'label' => '套餐列表', 'type' => 'textarea', 'default' => "30|30|入门包\n98|108|推荐包", 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
]],
['key' => 'product', 'title' => '充值产品', 'fields' => [
['key' => 'pay_balance_product_name', 'label' => '充值产品', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
['key' => 'pay_balance_price', 'label' => '充值价格', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 99999, 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
['key' => 'pay_balance_tag', 'label' => '价格标签', 'type' => 'input', 'default' => '元', 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
['key' => 'pay_balance_tag_class', 'label' => '标签样式', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
['key' => 'pay_balance_product_custom_s', 'label' => '自定义金额', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
['key' => 'pay_balance_product_custom_limit', 'label' => '自定义金额限制', 'type' => 'number', 'default' => 9999, 'min' => 1, 'max' => 99999, 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
]],
['key' => 'transfer', 'title' => '余额转账', 'fields' => [
['key' => 'pay_balance_transfer_s', 'label' => '启用余额转账', 'type' => 'switch', 'default' => false],
['key' => 'pay_balance_transfer_service_charge', 'label' => '转账手续费(%)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 50, 'dependsOn' => ['key' => 'pay_balance_transfer_s', 'value' => true]],
['key' => 'pay_balance_transfer_desc', 'label' => '转账说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'pay_balance_transfer_s', 'value' => true]],
]],
['key' => 'pass-charge', 'title' => '充值卡免扣', 'fields' => [
['key' => 'pay_balance_pass_charge_s', 'label' => '启用余额卡密兑换', 'type' => 'switch', 'default' => false],
['key' => 'pay_balance_pass_charge_desc', 'label' => '卡密兑换说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'pay_balance_pass_charge_s', 'value' => true]],
['key' => 'pay_balance_pass_charge_only_password', 'label' => '仅密码兑换', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'pay_balance_pass_charge_s', 'value' => true]],
]],
['key' => 'points-exchange', 'title' => '余额兑换积分', 'fields' => [
['key' => 'pay_balance_points_exchange_s', 'label' => '启用余额兑换积分', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
['key' => 'pay_balance_points_exchange_rate', 'label' => '兑换比例', 'type' => 'number', 'default' => 100, 'min' => 1, 'max' => 10000, 'help' => '1 余额 = N 积分', 'dependsOn' => ['key' => 'pay_balance_points_exchange_s', 'value' => true]],
['key' => 'pay_balance_points_exchange_min_points', 'label' => '单笔最低购买积分', 'type' => 'number', 'default' => 100, 'min' => 1, 'max' => 10000000, 'dependsOn' => ['key' => 'pay_balance_points_exchange_s', 'value' => true]],
['key' => 'pay_balance_points_exchange_daily_max_points', 'label' => '每日最高购买积分', 'type' => 'number', 'default' => 100000, 'min' => 1, 'max' => 10000000, 'dependsOn' => ['key' => 'pay_balance_points_exchange_s', 'value' => true]],
['key' => 'pay_balance_points_exchange_desc', 'label' => '兑换说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'pay_balance_points_exchange_s', 'value' => true]],
]],
],
],
'vip' => [
'key' => 'vip',
'title' => 'VIP会员',
'version' => '1.1.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '会员等级', 'fields' => [
['key' => 'nav_pay_vip', 'label' => '导航栏购买按钮', 'type' => 'switch', 'default' => true, 'help' => '在顶部导航栏显示开通会员按钮;请注意顶部导航的整体宽度。'],
['key' => 'nav_user_pay_vip', 'label' => '用户框购买按钮', 'type' => 'switch', 'default' => true, 'help' => '在导航栏用户框内显示开通会员按钮。'],
['key' => 'pay_user_vip_1_s', 'label' => '启用一级会员', 'type' => 'switch', 'default' => true],
['key' => 'pay_user_vip_1_name', 'label' => '一级会员名称', 'type' => 'input', 'default' => '一级会员', 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true]],
['key' => 'pay_user_vip_1_desc', 'label' => '一级会员一句话简介', 'type' => 'input', 'default' => '尊享一级会员特权', 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true]],
['key' => 'pay_user_vip_1_equity', 'label' => '一级会员权益 HTML', 'type' => 'textarea', 'default' => '<li>免费下载部分资源</li><li>会员专属身份标识</li><li>付费内容会员价</li>', 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true]],
['key' => 'vip_1_img_icon', 'label' => '一级会员图标 URL', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true], 'help' => '留空使用内置 vip-1.svg 图标'],
['key' => 'pay_user_vip_2_s', 'label' => '启用二级会员', 'type' => 'switch', 'default' => true],
['key' => 'pay_user_vip_2_name', 'label' => '二级会员名称', 'type' => 'input', 'default' => '二级会员', 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true]],
['key' => 'pay_user_vip_2_desc', 'label' => '二级会员一句话简介', 'type' => 'input', 'default' => '尊享二级会员特权', 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true]],
['key' => 'pay_user_vip_2_equity', 'label' => '二级会员权益 HTML', 'type' => 'textarea', 'default' => '<li>更高免费下载额度</li><li>更高等级身份标识</li><li>更多付费内容会员价</li>', 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true]],
['key' => 'vip_2_img_icon', 'label' => '二级会员图标 URL', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true], 'help' => '留空使用内置 vip-2.svg 图标'],
['key' => 'pay_user_vip_desc', 'label' => '弹窗顶部会员说明', 'type' => 'textarea', 'default' => ''],
['key' => 'pay_user_vip_more', 'label' => '弹窗底部补充说明 HTML', 'type' => 'textarea', 'default' => ''],
]],
['key' => 'packages', 'title' => '分档套餐', 'fields' => [
['key' => 'vip_1_product_s', 'label' => '允许购买一级会员', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true]],
['key' => 'payment_vip_1_products', 'label' => '一级会员套餐', 'type' => 'textarea', 'default' => "30|59|1|month|限时|月卡\n98|199|3|month|特惠|季卡\n365|599|12|month|超值|年卡\n999|1299|0|day|永久|永久卡", 'dependsOn' => ['key' => 'vip_1_product_s', 'value' => true], 'help' => '每行:执行价|原价|时长|单位(day|month)|标签|标题;时长 0=永久'],
['key' => 'vip_2_product_s', 'label' => '允许购买二级会员', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true]],
['key' => 'payment_vip_2_products', 'label' => '二级会员套餐', 'type' => 'textarea', 'default' => "58|99|1|month|限时|月卡\n168|299|3|month|特惠|季卡\n598|999|12|month|超值|年卡\n1299|1999|0|day|永久|永久卡", 'dependsOn' => ['key' => 'vip_2_product_s', 'value' => true], 'help' => '每行:执行价|原价|时长|单位(day|month)|标签|标题;时长 0=永久'],
]],
['key' => 'points_exchange', 'title' => '积分兑换会员', 'fields' => [
['key' => 'pay_vip_points_exchange_s', 'label' => '启用积分兑换', 'type' => 'switch', 'default' => false],
['key' => 'payment_vip_points_packages', 'label' => '兑换套餐', 'type' => 'textarea', 'default' => "1|500|30|积分月卡\n1|5000|0|积分永久", 'dependsOn' => ['key' => 'pay_vip_points_exchange_s', 'value' => true], 'help' => '每行:等级|积分|天数|标题(天数 0=永久;普通用户可开通,已有会员可续费同等级或升级更高等级)'],
['key' => 'pay_vip_points_exchange_desc', 'label' => '兑换说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'pay_vip_points_exchange_s', 'value' => true]],
]],
['key' => 'benefit', 'title' => '下载权益', 'fields' => [
['key' => 'pay_download_limit', 'label' => '普通用户下载限制', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 9999],
['key' => 'pay_download_limit_vip_1', 'label' => '一级会员下载限制', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 9999, 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true]],
['key' => 'pay_download_limit_vip_2', 'label' => '二级会员下载限制', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 9999, 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true]],
['key' => 'pay_vip_pass_charge_s', 'label' => '会员卡密兑换', 'type' => 'switch', 'default' => false],
['key' => 'pay_vip_pass_charge_desc', 'label' => '卡密兑换说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'pay_vip_pass_charge_s', 'value' => true]],
['key' => 'pay_vip_pass_charge_only_password', 'label' => '仅密码兑换', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_vip_pass_charge_s', 'value' => true]],
]],
['key' => 'renew', 'title' => '续费设置', 'fields' => [
['key' => 'vip_renew', 'label' => '允许续费', 'type' => 'switch', 'default' => true],
['key' => 'vip_renew_desc', 'label' => '续费说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'vip_renew', 'value' => true]],
['key' => 'vip_renew_price_type', 'label' => '续费价格类型', 'type' => 'radio', 'default' => 'discount', 'dependsOn' => ['key' => 'vip_renew', 'value' => true], 'options' => [
['label' => '相同价格', 'value' => 'same'],
['label' => '折扣价格', 'value' => 'discount'],
['label' => '优惠立减', 'value' => 'reduce'],
]],
['key' => 'vip_renew_discount', 'label' => '续费折扣(折,如 8=八折)', 'type' => 'number', 'default' => 8, 'min' => 1, 'max' => 100, 'dependsOn' => ['key' => 'vip_renew_price_type', 'value' => 'discount']],
['key' => 'vip_renew_reduce', 'label' => '续费减免金额', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '20.00', 'min' => 0, 'max' => 9999, 'dependsOn' => ['key' => 'vip_renew_price_type', 'value' => 'reduce']],
]],
['key' => 'upgrade', 'title' => '升级设置', 'fields' => [
['key' => 'vip_upgrade', 'label' => '允许升级', 'type' => 'switch', 'default' => true],
['key' => 'vip_upgrade_desc', 'label' => '升级说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'vip_upgrade', 'value' => true]],
['key' => 'vip_upgrade_product', 'label' => '升级产品', 'type' => 'textarea', 'default' => "unit|1|按剩余天数升级\njump|199|升级永久二级会员\npermanent|299|永久一级升永久二级", 'dependsOn' => ['key' => 'vip_upgrade', 'value' => true], 'help' => '每行一条。永久VIP1:permanent|价格|标题;剩余天:unit|每日单价|标题;跳转永久:jump|价格|标题'],
]],
],
],
'revenue' => [
'key' => 'revenue',
'title' => '创作中心',
'version' => '2.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '创作中心设置', 'fields' => [
['key' => 'pay_income_s', 'label' => '启用创作分成', 'type' => 'switch', 'default' => false],
['key' => 'payment_revenue_cycle_days', 'label' => '结算周期(天)', 'type' => 'number', 'default' => 30, 'min' => 1, 'max' => 365, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
['key' => 'payment_revenue_note', 'label' => '结算备注文案', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '<p>订单完成并经过结算周期后,作者分成会自动转入对应的钱包。</p>', 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
]],
['key' => 'cash', 'title' => '现金收益分成', 'fields' => [
['key' => 'payment_revenue_cash_ratio_user', 'label' => '普通用户分成比例(%)', 'type' => 'number', 'default' => 60, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
['key' => 'payment_revenue_cash_ratio_vip_1', 'label' => '一级会员分成比例(%)', 'type' => 'number', 'default' => 70, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
['key' => 'payment_revenue_cash_ratio_vip_2', 'label' => '二级会员分成比例(%)', 'type' => 'number', 'default' => 80, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
]],
['key' => 'points', 'title' => '积分收益分成', 'fields' => [
['key' => 'payment_revenue_points_ratio_user', 'label' => '普通用户分成比例(%)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
['key' => 'payment_revenue_points_ratio_vip_1', 'label' => '一级会员分成比例(%)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
['key' => 'payment_revenue_points_ratio_vip_2', 'label' => '二级会员分成比例(%)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
]],
],
],
'affiliate' => [
'key' => 'affiliate',
'title' => '推广返佣',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'policy', 'title' => '返佣策略', 'fields' => [
['key' => 'affiliate_enabled', 'label' => '启用推广返佣', 'type' => 'switch', 'default' => false],
['key' => 'affiliate_ratio_user', 'label' => '普通会员佣金比例(%)', 'type' => 'number', 'default' => 5, 'min' => 0, 'max' => 100],
['key' => 'affiliate_ratio_vip_1', 'label' => '一级会员佣金比例(%)', 'type' => 'number', 'default' => 5, 'min' => 0, 'max' => 100],
['key' => 'affiliate_ratio_vip_2', 'label' => '二级会员佣金比例(%)', 'type' => 'number', 'default' => 5, 'min' => 0, 'max' => 100],
['key' => 'affiliate_order_types', 'label' => '适用订单类型', 'type' => 'checkbox', 'options' => [['value' => 'membership', 'label' => '会员订单'], ['value' => 'content', 'label' => '付费内容'], ['value' => 'credits', 'label' => '购买积分']], 'default' => ['membership', 'content']],
['key' => 'affiliate_settlement_days', 'label' => '结算观察期(天)', 'type' => 'number', 'default' => 7, 'min' => 0, 'max' => 90],
]],
['key' => 'text', 'title' => '文案设置', 'fields' => [
['key' => 'affiliate_promotion_text', 'label' => '推广说明', 'type' => 'textarea', 'default' => ''],
]],
],
],
'gateway' => [
'key' => 'gateway',
'title' => '收款接口',
'version' => '1.2.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'notice', 'title' => '说明', 'fields' => [
['key' => 'payment_gateway_notice', 'label' => '通道说明', 'type' => 'notice', 'alertType' => 'info', 'alertContent' => '以渠道开关 + 凭据是否齐全为准。异步回调由各网关验签(支付宝/微信/Stripe/易支付等),无需额外口令。卡密为兑换入口,不出现在收银台支付方式列表。'],
]],
['key' => 'gateways', 'title' => '支付渠道开关', 'fields' => [
['key' => 'payment_balance_enabled', 'label' => '余额支付', 'type' => 'switch', 'default' => true, 'help' => '需同时在「余额充值」启用余额功能。关闭后用户中心仍可有钱包,但结账不可用余额支付。'],
['key' => 'payment_alipay_enabled', 'label' => '支付宝', 'type' => 'switch', 'default' => false],
['key' => 'payment_wechat_enabled', 'label' => '微信支付', 'type' => 'switch', 'default' => false],
['key' => 'payment_paypal_enabled', 'label' => 'PayPal', 'type' => 'switch', 'default' => false],
['key' => 'payment_stripe_enabled', 'label' => 'Stripe', 'type' => 'switch', 'default' => false],
['key' => 'payment_epay_enabled', 'label' => '易支付', 'type' => 'switch', 'default' => false, 'help' => '兼容彩虹易支付协议的聚合收银台,可同时开启支付宝/微信子通道。'],
['key' => 'payment_card_pass_enabled', 'label' => '卡密充值', 'type' => 'switch', 'default' => false, 'help' => '仅控制卡密兑换入口是否开放;卡密规则与批量发卡在「充值卡」页。不进入结账支付方式列表。'],
]],
// Channel credential groups: SPA uses collapsible + expandWhen + group dependsOn.
// Field-level dependsOn kept for contract audit / non-SPA consumers.
['key' => 'wechat', 'title' => '微信支付配置', 'collapsible' => true, 'expandWhen' => 'payment_wechat_enabled', 'dependsOn' => ['key' => 'payment_wechat_enabled', 'value' => true], 'fields' => [
['key' => 'wechat_merchantid', 'label' => '商户号', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_wechat_enabled', 'value' => true]],
['key' => 'wechat_appid', 'label' => 'AppID', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_wechat_enabled', 'value' => true]],
['key' => 'wechat_payment_type', 'label' => '支付方式', 'type' => 'select', 'default' => 'native', 'options' => [
['value' => 'native', 'label' => '扫码支付(Native)'],
['value' => 'h5', 'label' => 'H5支付'],
], 'dependsOn' => ['key' => 'payment_wechat_enabled', 'value' => true]],
['key' => 'wechat_api_v3_key', 'label' => 'APIv3密钥', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_wechat_enabled', 'value' => true]],
['key' => 'wechat_private_key_path', 'label' => '商户私钥路径', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_wechat_enabled', 'value' => true]],
['key' => 'wechat_cert_path', 'label' => '商户API证书路径', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_wechat_enabled', 'value' => true]],
]],
['key' => 'alipay', 'title' => '支付宝配置', 'collapsible' => true, 'expandWhen' => 'payment_alipay_enabled', 'dependsOn' => ['key' => 'payment_alipay_enabled', 'value' => true], 'fields' => [
['key' => 'alipay_appid', 'label' => 'AppID', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_alipay_enabled', 'value' => true]],
['key' => 'alipay_privatekey', 'label' => '应用私钥', 'type' => 'textarea', 'sanitize_type' => 'code', 'default' => '', 'dependsOn' => ['key' => 'payment_alipay_enabled', 'value' => true]],
['key' => 'alipay_payment_type', 'label' => '支付方式', 'type' => 'select', 'default' => 'page', 'options' => [
['value' => 'page', 'label' => '电脑网站支付(web)'],
['value' => 'wap', 'label' => '手机网站支付(wap)'],
], 'dependsOn' => ['key' => 'payment_alipay_enabled', 'value' => true]],
['key' => 'alipay_app_public_cert_path', 'label' => '应用公钥证书路径', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_alipay_enabled', 'value' => true]],
['key' => 'alipay_public_cert_path', 'label' => '支付宝公钥证书路径', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_alipay_enabled', 'value' => true]],
['key' => 'alipay_root_cert_path', 'label' => '支付宝根证书路径', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_alipay_enabled', 'value' => true]],
['key' => 'alipay_notify_help', 'label' => '回调地址说明', 'type' => 'notice', 'alertType' => 'info', 'alertContent' => '异步通知 / 同步返回已固定为 /wp-json/aksrt/v1/payment/alipay/{notify|return},无需在此填写。', 'dependsOn' => ['key' => 'payment_alipay_enabled', 'value' => true]],
]],
['key' => 'paypal', 'title' => 'PayPal配置', 'collapsible' => true, 'expandWhen' => 'payment_paypal_enabled', 'dependsOn' => ['key' => 'payment_paypal_enabled', 'value' => true], 'fields' => [
['key' => 'paypal_client_id', 'label' => 'Client ID', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_paypal_enabled', 'value' => true]],
['key' => 'paypal_client_secret', 'label' => 'Client Secret', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_paypal_enabled', 'value' => true]],
['key' => 'paypal_currency', 'label' => '货币', 'type' => 'input', 'default' => 'USD', 'dependsOn' => ['key' => 'payment_paypal_enabled', 'value' => true]],
['key' => 'paypal_sandbox', 'label' => '沙箱模式', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'payment_paypal_enabled', 'value' => true]],
]],
['key' => 'stripe', 'title' => 'Stripe配置', 'collapsible' => true, 'expandWhen' => 'payment_stripe_enabled', 'dependsOn' => ['key' => 'payment_stripe_enabled', 'value' => true], 'fields' => [
['key' => 'stripe_secret_key', 'label' => 'Secret Key', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_stripe_enabled', 'value' => true]],
['key' => 'stripe_publishable_key', 'label' => 'Publishable Key', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_stripe_enabled', 'value' => true]],
['key' => 'stripe_webhook_secret', 'label' => 'Webhook Secret', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_stripe_enabled', 'value' => true]],
['key' => 'stripe_currency', 'label' => '货币', 'type' => 'input', 'default' => 'usd', 'dependsOn' => ['key' => 'payment_stripe_enabled', 'value' => true]],
['key' => 'stripe_test_mode', 'label' => '测试模式', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'payment_stripe_enabled', 'value' => true]],
]],
['key' => 'epay', 'title' => '易支付配置', 'collapsible' => true, 'expandWhen' => 'payment_epay_enabled', 'dependsOn' => ['key' => 'payment_epay_enabled', 'value' => true], 'fields' => [
['key' => 'epay_apiurl', 'label' => '接口地址', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_epay_enabled', 'value' => true], 'help' => '易支付站点根地址,如 https://pay.example.com/(末尾斜杠可选)。'],
['key' => 'epay_pid', 'label' => '商户ID', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_epay_enabled', 'value' => true]],
['key' => 'epay_key', 'label' => '商户密钥', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'payment_epay_enabled', 'value' => true], 'help' => 'MD5 通信密钥。'],
['key' => 'epay_channel_alipay', 'label' => '启用支付宝通道', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'payment_epay_enabled', 'value' => true]],
['key' => 'epay_channel_wxpay', 'label' => '启用微信通道', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'payment_epay_enabled', 'value' => true]],
['key' => 'epay_device', 'label' => '下单终端', 'type' => 'select', 'default' => 'auto', 'options' => [
['value' => 'auto', 'label' => '自动(按 UA)'],
['value' => 'pc', 'label' => '电脑端 submit'],
['value' => 'mobile', 'label' => '移动端 mapi'],
], 'dependsOn' => ['key' => 'payment_epay_enabled', 'value' => true]],
['key' => 'epay_notify_help', 'label' => '回调地址说明', 'type' => 'notice', 'alertType' => 'info', 'alertContent' => '异步/同步回调固定为 /wp-json/aksrt/v1/payment/epay_alipay/{notify|return} 与 /payment/epay_wxpay/{notify|return},请在易支付后台放行对应 URL。', 'dependsOn' => ['key' => 'payment_epay_enabled', 'value' => true]],
]],
],
],
'order' => [
'key' => 'order',
'title' => '订单设置',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '订单基础', 'fields' => [
['key' => 'payment_order_prefix', 'label' => '订单前缀', 'type' => 'input', 'default' => 'AKSRT'],
['key' => 'payment_flow_prefix', 'label' => '流水号前缀', 'type' => 'input', 'sanitize_type' => 'business_prefix', 'default' => 'AK', 'maxlength' => 12, 'help' => '仅允许字母、数字、下划线和短横线,最多 12 位。'],
['key' => 'payment_withdrawal_prefix', 'label' => '提现单号前缀', 'type' => 'input', 'sanitize_type' => 'business_prefix', 'default' => 'TX', 'maxlength' => 12, 'help' => '仅允许字母、数字、下划线和短横线,最多 12 位。'],
['key' => 'payment_order_expiry', 'label' => '订单有效期(分钟)', 'type' => 'number', 'default' => 30, 'min' => 5, 'max' => 1440],
['key' => 'pay_show_user', 'label' => '显示用户信息', 'type' => 'switch', 'default' => true],
['key' => 'pay_show_paycount', 'label' => '显示购买次数', 'type' => 'switch', 'default' => true],
['key' => 'pay_no_logged_in', 'label' => '未登录提示', 'type' => 'switch', 'default' => true],
['key' => 'pay_cookie_day', 'label' => 'Cookie有效期(天)', 'type' => 'number', 'default' => 15, 'min' => 1, 'max' => 31],
['key' => 'pay_no_logged_remind', 'label' => '未登录提醒文案', 'type' => 'textarea', 'default' => '您当前未登录!建议登陆后购买,可保存购买订单'],
['key' => 'pay_wait_float_s', 'label' => '订单等待浮动', 'type' => 'switch', 'default' => true],
['key' => 'payment_order_max_minutes', 'label' => '订单最大支付时间(分钟)', 'type' => 'number', 'default' => 30, 'min' => 5, 'max' => 1440],
]],
['key' => 'display', 'title' => '展示设置', 'fields' => [
['key' => 'pay_mark', 'label' => '付费标记', 'type' => 'input', 'default' => '付费'],
['key' => 'pay_box_position', 'label' => '付费框位置', 'type' => 'radio', 'default' => 'top', 'options' => [
['label' => '文章框顶部', 'value' => 'box_top'],
['label' => '正文顶部', 'value' => 'top'],
['label' => '正文底部', 'value' => 'bottom'],
['label' => '文章框底部', 'value' => 'box_bottom'],
]],
['key' => 'payment_show_ip', 'label' => '显示用户IP', 'type' => 'switch', 'default' => false],
['key' => 'payment_show_device', 'label' => '显示设备信息', 'type' => 'switch', 'default' => false],
['key' => 'payment_show_order_no', 'label' => '显示订单号', 'type' => 'switch', 'default' => true],
['key' => 'payment_show_create_time', 'label' => '显示创建时间', 'type' => 'switch', 'default' => true],
['key' => 'payment_show_pay_time', 'label' => '显示支付时间', 'type' => 'switch', 'default' => true],
]],
['key' => 'status', 'title' => '状态设置', 'fields' => [
['key' => 'payment_order_status_pending', 'label' => '待支付状态文案', 'type' => 'input', 'default' => '待支付'],
['key' => 'payment_order_status_paid', 'label' => '已支付状态文案', 'type' => 'input', 'default' => '已支付'],
['key' => 'payment_order_status_refunding', 'label' => '退款中状态文案', 'type' => 'input', 'default' => '退款中'],
['key' => 'payment_order_status_refunded', 'label' => '已退款状态文案', 'type' => 'input', 'default' => '已退款'],
['key' => 'payment_order_status_closed', 'label' => '已关闭状态文案', 'type' => 'input', 'default' => '已关闭'],
]],
['key' => 'service', 'title' => '服务设置', 'fields' => [
['key' => 'pay_service', 'label' => '客服设置', 'type' => 'textarea', 'default' => ''],
['key' => 'pay_service_icon', 'label' => '客服图标', 'type' => 'icon', 'default' => ''],
['key' => 'pay_service_value', 'label' => '客服内容', 'type' => 'input', 'default' => ''],
['key' => 'pay_service_qq', 'label' => 'QQ客服', 'type' => 'input', 'default' => ''],
['key' => 'pay_service_wechat', 'label' => '微信客服', 'type' => 'media', 'default' => ''],
]],
],
],
'card-pass' => [
'key' => 'card-pass',
'title' => '充值卡',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'card-pass', 'title' => '充值卡', 'fields' => [
['key' => 'card_pass_enabled', 'label' => '启用充值卡', 'type' => 'switch', 'default' => false],
['key' => 'card_pass_desc', 'label' => '充值卡说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_type', 'label' => '充值卡类型', 'type' => 'select', 'default' => 'balance', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true], 'options' => [
['label' => '余额卡', 'value' => 'balance'],
['label' => 'VIP卡', 'value' => 'vip'],
['label' => '积分卡', 'value' => 'credits'],
]],
['key' => 'card_pass_prefix', 'label' => '卡号前缀', 'type' => 'input', 'default' => 'AK', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_length', 'label' => '卡号长度', 'type' => 'number', 'default' => 16, 'min' => 8, 'max' => 32, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_batch_size', 'label' => '批量生成数量', 'type' => 'number', 'default' => 50, 'min' => 1, 'max' => 500, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
]],
['key' => 'redeem', 'title' => '兑换设置', 'fields' => [
['key' => 'card_pass_max_redeem', 'label' => '单卡最大兑换次数', 'type' => 'number', 'default' => 1, 'min' => 1, 'max' => 100, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_expiry', 'label' => '有效期(天)', 'type' => 'number', 'default' => 0, 'min' => 0, 'help' => '0为永久有效', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
public static function build(): array {
return [
'domain' => 'payment',
'title' => '支付&付费',
'sections' => [
/* ------------------------------------------------------------------
* 知识付费
* ------------------------------------------------------------------ */
'knowledge' => [
'key' => 'knowledge',
'title' => '知识付费',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'notice', 'title' => '说明', 'fields' => [
['key' => 'knowledge_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<p><b>知识付费</b></p><ul style="margin:6px 0 0 18px;line-height:1.9"><li>知识付费功能主要分为文章付费、付费会员、余额系统、推广返佣、创作分成等功能组成,您可以根据您的需要开启对应功能</li><li>使用支付功能请先在「收款接口」页配置好收款通道</li></ul>'],
]],
['key' => 'guest-buy', 'title' => '免登陆购买', 'fields' => [
['key' => 'pay_no_logged_in', 'label' => '免登陆购买', 'type' => 'switch', 'default' => true, 'help' => '开启后如果用户未登录则使用浏览器缓存验证是否购买'],
['key' => 'pay_cookie_day', 'label' => 'Cookie时间(天)', 'type' => 'number', 'default' => 15, 'min' => 1, 'max' => 31, 'dependsOn' => ['key' => 'pay_no_logged_in', 'value' => true], 'help' => '免登陆购买的浏览器缓存有效时间'],
['key' => 'pay_no_logged_remind', 'label' => '未登录提醒', 'type' => 'textarea', 'default' => '您当前未登录!建议登陆后购买,可保存购买订单', 'rows' => 2, 'dependsOn' => ['key' => 'pay_no_logged_in', 'value' => true]],
]],
['key' => 'box-position', 'title' => '模块显示位置', 'fields' => [
['key' => 'pay_box_position', 'label' => '购买模块位置', 'type' => 'radio', 'default' => 'top', 'options' => [
['label' => '文章模块上方', 'value' => 'box_top'],
['label' => '文章内容顶部', 'value' => 'top'],
['label' => '文章内容底部', 'value' => 'bottom'],
['label' => '文章模块下方', 'value' => 'box_bottom'],
], 'help' => '在文章页面中购买模块的显示位置'],
]],
['key' => 'display-basic', 'title' => '基础显示', 'fields' => [
['key' => 'pay_free_logged_show', 'label' => '免费资源登录可见', 'type' => 'switch', 'default' => true, 'help' => '免费资源必须登录后才能查看'],
['key' => 'pay_show_user', 'label' => '订单数据', 'type' => 'switch', 'default' => true, 'help' => '在用户中心显示订单数据'],
['key' => 'pay_show_paycount', 'label' => '销量显示', 'type' => 'switch', 'default' => true, 'help' => '商品详情显示销售数量'],
]],
['key' => 'coupon', 'title' => '商品优惠码', 'fields' => [
['key' => 'coupon_post_s', 'label' => '为所有商品启用优惠券功能', 'type' => 'switch', 'default' => false, 'help' => '开启后将为所有商品显示输入优惠码的功能;也可以单独给任意一个商品开启'],
['key' => 'coupon_desc', 'label' => '优惠码默认说明', 'type' => 'textarea', 'default' => '', 'rows' => 1, 'dependsOn' => ['key' => 'coupon_post_s', 'value' => true], 'help' => '用户填写优惠码时展示的提醒内容,支持HTML代码'],
]],
['key' => 'display', 'title' => '展示设置', 'fields' => [
['key' => 'pay_mark', 'label' => '付费标记', 'type' => 'input', 'default' => '付费'],
['key' => 'payment_show_ip', 'label' => '显示用户IP', 'type' => 'switch', 'default' => false],
['key' => 'payment_show_device', 'label' => '显示设备信息', 'type' => 'switch', 'default' => false],
['key' => 'payment_show_order_no', 'label' => '显示订单号', 'type' => 'switch', 'default' => true],
['key' => 'payment_show_create_time', 'label' => '显示创建时间', 'type' => 'switch', 'default' => true],
['key' => 'payment_show_pay_time', 'label' => '显示支付时间', 'type' => 'switch', 'default' => true],
]],
['key' => 'status', 'title' => '状态设置', 'fields' => [
['key' => 'payment_order_status_pending', 'label' => '待支付状态文案', 'type' => 'input', 'default' => '待支付'],
['key' => 'payment_order_status_paid', 'label' => '已支付状态文案', 'type' => 'input', 'default' => '已支付'],
['key' => 'payment_order_status_refunding', 'label' => '退款中状态文案', 'type' => 'input', 'default' => '退款中'],
['key' => 'payment_order_status_refunded', 'label' => '已退款状态文案', 'type' => 'input', 'default' => '已退款'],
['key' => 'payment_order_status_closed', 'label' => '已关闭状态文案', 'type' => 'input', 'default' => '已关闭'],
]],
['key' => 'service', 'title' => '客户服务', 'fields' => [
['key' => 'pay_service', 'label' => '用户服务内容', 'type' => 'group', 'button_title' => '添加服务项', 'default' => [], 'fields' => [
['key' => 'value', 'label' => '服务内容', 'type' => 'input', 'default' => ''],
['key' => 'icon', 'label' => '自定义图标', 'type' => 'icon', 'default' => ''],
]],
]],
['key' => 'feature', 'title' => '商品功能配置', 'fields' => [
['key' => 'pay_type_option', 'label' => '商品功能配置', 'type' => 'tabbed', 'tabs' => [
['key' => 'download', 'title' => '付费下载', 'fields' => [
['key' => 'down_alone_page', 'label' => '独立下载页面', 'type' => 'switch', 'default' => false, 'help' => '开启后,付费资源的下载链接会跳转独立页面显示'],
['key' => 'down_user_log', 'label' => '保存用户下载记录(条)', 'type' => 'number', 'default' => 50, 'min' => 0, 'help' => '填0则不保存,注意记录量太大可能会影响网站性能'],
['key' => 'down_post_log', 'label' => '保存文章下载记录(条)', 'type' => 'number', 'default' => 50, 'min' => 0, 'help' => '填0则不保存,注意记录量太大可能会影响网站性能'],
['key' => 'down_remote_to_local_s', 'label' => '远程文件转本地文件下载', 'type' => 'switch', 'default' => true, 'help' => '当下载地址为外链文件时,先将远程文件下载到本地服务器,再提供给用户下载,可完全隐藏远程下载地址'],
['key' => 'down_remote_to_local_size', 'label' => '文件大小限制(Kb)', 'type' => 'number', 'default' => 2048, 'min' => 0],
['key' => 'down_remote_to_local_ext', 'label' => '文件格式限制', 'type' => 'input', 'default' => 'zip,rar,7z,text,png,jpg,jpeg,gif,mp3,mp4,avi,wmv,flv,swf,doc,docx,xls,xlsx,ppt,pptx,pdf', 'help' => '限制使用此功能的文件格式,多个用英文逗号隔开'],
['key' => 'down_verify_nonce', 'label' => '下载前检测用户环境', 'type' => 'switch', 'default' => true, 'help' => '防止机器批量扫描下载,有效防止跨站攻击'],
]],
]],
]],
['key' => 'presets', 'title' => '商品预置参数配置', 'fields' => [
['key' => 'presets_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '在下方配置的参数新建文章时候会自动填入,方便新建文章的设置。最终以文章配置为准'],
['key' => 'pay_modo_default', 'label' => '支付类型', 'type' => 'radio', 'default' => '0', 'options' => [
['label' => '普通商品(金钱购买)', 'value' => '0'],
['label' => '积分商品(积分购买,依赖于用户积分功能)', 'value' => 'points'],
]],
['key' => 'points_price_default', 'label' => '积分售价(积分)', 'type' => 'number', 'default' => 0, 'min' => 0],
['key' => 'vip_1_points_default', 'label' => '一级会员积分售价(积分)', 'type' => 'number', 'default' => 0, 'min' => 0],
['key' => 'vip_2_points_default', 'label' => '二级会员积分售价(积分)', 'type' => 'number', 'default' => 0, 'min' => 0],
['key' => 'pay_price_default', 'label' => '执行价', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '0.01', 'suffix' => '元'],
['key' => 'pay_original_price_default', 'label' => '原价', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '', 'suffix' => '元', 'help' => '显示在执行价格前面,并划掉'],
['key' => 'pay_promotion_tag_default', 'label' => '促销标签', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '<i class="fa fa-fw fa-bolt"></i> 限时特惠', 'rows' => 1],
['key' => 'vip_1_price_default', 'label' => '一级会员价格', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '0', 'suffix' => '元', 'help' => '填0则为一级会员免费'],
['key' => 'vip_2_price_default', 'label' => '二级会员价格', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '0', 'suffix' => '元', 'help' => '填0则为二级会员免费'],
['key' => 'pay_rebate_discount', 'label' => '推广折扣', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '0', 'suffix' => '元', 'help' => '通过推广链接购买,额外优惠的金额;需开启推广返佣功能,且不能超过实际购买价'],
['key' => 'pay_cuont_default', 'label' => '销量浮动', 'type' => 'between_number', 'default' => ['min' => 0, 'max' => 0], 'help' => '为真实销量增加或减少的数量,系统会根据此处设置的区间获取随机值作为预置参数'],
['key' => 'pay_details_default', 'label' => '更多详情', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '', 'rows' => 3, 'help' => '可插入任意的HTML代码'],
['key' => 'pay_extra_hide_default', 'label' => '额外隐藏内容', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '', 'rows' => 3, 'help' => '可插入任意的HTML代码'],
['key' => 'pay_attributes_default', 'label' => '资源属性', 'type' => 'group', 'button_title' => '添加属性', 'default' => [], 'fields' => [
['key' => 'key', 'label' => '属性名称', 'type' => 'input', 'default' => ''],
['key' => 'value', 'label' => '属性内容', 'type' => 'input', 'default' => ''],
]],
['key' => 'pay_gallery_show_default', 'label' => '付费图片免费查看数量(张)', 'type' => 'number', 'default' => 1, 'min' => 0, 'help' => '设置付费图片可免费查看前几张图片的数量的默认值'],
]],
],
],
/* ------------------------------------------------------------------
* 余额充值
* ------------------------------------------------------------------ */
'recharge' => [
'key' => 'recharge',
'title' => '余额充值',
'version' => '1.1.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'notice', 'title' => '说明', 'fields' => [
['key' => 'recharge_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<p><b>用户余额功能:</b></p><ul style="margin:6px 0 0 18px;line-height:1.9"><li>开启后用户可充值到余额,余额可用于全站消费</li><li>在下方设置默认的分成比例,同时支持单独为每一个用户设置独立的分成比例</li><li>可以在用户管理中,为某一个用户手动赠送余额</li></ul>'],
]],
['key' => 'basic', 'title' => '用户余额', 'fields' => [
['key' => 'pay_balance_s', 'label' => '启用余额充值/支付功能', 'type' => 'switch', 'default' => true, 'help' => '开启后用户中心显示现金钱包,并可作为收银台支付方式'],
['key' => 'pay_balance_withdraw_s', 'label' => '余额提现', 'type' => 'switch', 'default' => false, 'help' => '允许将余额提现', 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
['key' => 'pay_balance_desc', 'label' => '充值说明', 'type' => 'textarea', 'default' => '', 'rows' => 3, 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true], 'help' => '用户充值时显示的内容,建议为提醒事项、充值协议等,支持HTML代码'],
]],
['key' => 'transfer', 'title' => '余额转账', 'fields' => [
['key' => 'pay_balance_transfer_s', 'label' => '启用余额转账', 'type' => 'switch', 'default' => false, 'help' => '允许用户转账给其他用户'],
['key' => 'pay_balance_transfer_service_charge', 'label' => '转账手续费(%)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 50, 'dependsOn' => ['key' => 'pay_balance_transfer_s', 'value' => true]],
['key' => 'pay_balance_transfer_desc', 'label' => '转账说明', 'type' => 'textarea', 'default' => '', 'rows' => 2, 'dependsOn' => ['key' => 'pay_balance_transfer_s', 'value' => true], 'help' => '用户转账时候显示的内容,建议为提醒事项、转账协议等,支持HTML代码'],
]],
['key' => 'products', 'title' => '充值商品选项', 'fields' => [
['key' => 'pay_balance_product', 'label' => '充值金额选项', 'type' => 'group', 'button_title' => '添加充值金额选项', 'default' => [
['price' => 50, 'pay_price' => 0, 'tag' => '', 'tag_class' => ''],
['price' => 100, 'pay_price' => 98, 'tag' => '', 'tag_class' => ''],
['price' => 200, 'pay_price' => 188, 'tag' => '推荐', 'tag_class' => 'jb-cyan'],
['price' => 500, 'pay_price' => 468, 'tag' => '特惠', 'tag_class' => 'jb-pink'],
], 'help' => '用户充值时候,可快速选择的充值金额,同时支持设置折扣', 'fields' => [
['key' => 'price', 'label' => '充值金额', 'type' => 'number', 'default' => 100, 'min' => 0, 'suffix' => '元'],
['key' => 'pay_price', 'label' => '销售金额', 'type' => 'number', 'default' => 0, 'min' => 0, 'suffix' => '元', 'help' => '选填,设置不同的销售金额实现充值折扣的功能,设置为0则与充值金额一致'],
['key' => 'tag', 'label' => '小标签', 'type' => 'input', 'default' => '', 'help' => '支持HTML,请注意控制长度'],
['key' => 'tag_class', 'label' => '标签颜色类', 'type' => 'input', 'default' => '', 'help' => '主题标签颜色类,如 jb-cyan / jb-pink'],
]],
['key' => 'pay_balance_product_custom_s', 'label' => '自定义充值金额', 'type' => 'switch', 'default' => true, 'help' => '允许用户手动输入充值金额'],
['key' => 'pay_balance_product_custom_limit', 'label' => '自定义充值金额上限', 'type' => 'number', 'default' => 9999, 'min' => 1, 'max' => 99999, 'dependsOn' => ['key' => 'pay_balance_product_custom_s', 'value' => true]],
]],
['key' => 'pass-charge', 'title' => '卡密充值', 'fields' => [
['key' => 'pay_balance_pass_charge_s', 'label' => '启用卡密充值余额功能', 'type' => 'switch', 'default' => false],
['key' => 'pay_balance_pass_charge_desc', 'label' => '卡密充值说明', 'type' => 'textarea', 'default' => '', 'rows' => 2, 'dependsOn' => ['key' => 'pay_balance_pass_charge_s', 'value' => true], 'help' => '用户使用卡密充值时显示的内容,建议为提醒事项、充值协议等,支持HTML代码'],
['key' => 'pay_balance_pass_charge_only_password', 'label' => '单密码模式', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'pay_balance_pass_charge_s', 'value' => true], 'help' => '仅需输入密码,不需要卡号'],
]],
['key' => 'charge-card', 'title' => '充值卡', 'fields' => [
['key' => 'card_pass_enabled', 'label' => '启用充值卡', 'type' => 'switch', 'default' => false, 'help' => '充值卡规则与批量发卡配置;卡密兑换入口由上方「卡密充值」控制'],
['key' => 'card_pass_desc', 'label' => '充值卡说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_type', 'label' => '充值卡类型', 'type' => 'select', 'default' => 'balance', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true], 'options' => [
['label' => '余额卡', 'value' => 'balance'],
['label' => 'VIP卡', 'value' => 'vip'],
['label' => '积分卡', 'value' => 'credits'],
]],
['key' => 'card_pass_prefix', 'label' => '卡号前缀', 'type' => 'input', 'default' => 'AK', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_length', 'label' => '卡号长度', 'type' => 'number', 'default' => 16, 'min' => 8, 'max' => 32, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_batch_size', 'label' => '批量生成数量', 'type' => 'number', 'default' => 50, 'min' => 1, 'max' => 500, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_max_redeem', 'label' => '单卡最大兑换次数', 'type' => 'number', 'default' => 1, 'min' => 1, 'max' => 100, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_expiry', 'label' => '有效期(天)', 'type' => 'number', 'default' => 0, 'min' => 0, 'help' => '0为永久有效', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_amount', 'label' => '面额(元)', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '10.00', 'min' => 1, 'max' => 9999, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_vip_days', 'label' => 'VIP天数', 'type' => 'number', 'default' => 30, 'min' => 1, 'max' => 3650, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_credits', 'label' => '赠送积分', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 99999, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
]],
['key' => 'display', 'title' => '展示设置', 'fields' => [
['key' => 'card_pass_redeem_page', 'label' => '兑换页面', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_success_msg', 'label' => '兑换成功提示', 'type' => 'input', 'default' => '兑换成功!', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_fail_msg', 'label' => '兑换失败提示', 'type' => 'input', 'default' => '卡号无效或已过期', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
]],
],
],
'withdrawal' => [
'key' => 'withdrawal',
'title' => '提现策略',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '提现设置', 'fields' => [
['key' => 'affiliate_min_withdrawal', 'label' => '最低提现金额', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '50.00', 'desc' => '仅接受最多两位小数的十进制字符串。'],
['key' => 'affiliate_withdrawal_fee', 'label' => '提现手续费(%)', 'type' => 'number', 'default' => 5, 'min' => 0, 'max' => 100],
['key' => 'affiliate_daily_withdrawal_count', 'label' => '每日可提现次数', 'type' => 'number', 'default' => 3, 'min' => 0, 'max' => 99999],
['key' => 'affiliate_daily_withdrawal_limit', 'label' => '每日提现上限', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '500.00', 'desc' => '仅接受最多两位小数的十进制字符串。'],
['key' => 'affiliate_withdrawal_reset_time', 'label' => '重置时间', 'type' => 'input', 'default' => '00:00', 'help' => '按站点 WordPress 时区重置,格式 HH:MM。'],
['key' => 'affiliate_payout_channels', 'label' => '可用收款渠道', 'type' => 'checkbox', 'options' => [['value' => 'alipay', 'label' => '支付宝收款码'], ['value' => 'wechat', 'label' => '微信收款码']], 'default' => ['alipay', 'wechat']],
]],
],
],
],
];
}
['key' => 'card_pass_vip_days', 'label' => 'VIP天数', 'type' => 'number', 'default' => 30, 'min' => 1, 'max' => 3650, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_credits', 'label' => '赠送积分', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 99999, 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_redeem_page', 'label' => '兑换页面', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_success_msg', 'label' => '兑换成功提示', 'type' => 'input', 'default' => '兑换成功!', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
['key' => 'card_pass_fail_msg', 'label' => '兑换失败提示', 'type' => 'input', 'default' => '卡号无效或已过期', 'dependsOn' => ['key' => 'card_pass_enabled', 'value' => true]],
]],
['key' => 'points-exchange', 'title' => '余额兑换积分', 'fields' => [
['key' => 'pay_balance_points_exchange_s', 'label' => '启用余额兑换积分', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'pay_balance_s', 'value' => true]],
['key' => 'pay_balance_points_exchange_rate', 'label' => '兑换比例', 'type' => 'number', 'default' => 100, 'min' => 1, 'max' => 10000, 'help' => '1 余额 = N 积分', 'dependsOn' => ['key' => 'pay_balance_points_exchange_s', 'value' => true]],
['key' => 'pay_balance_points_exchange_min_points', 'label' => '单笔最低购买积分', 'type' => 'number', 'default' => 100, 'min' => 1, 'max' => 10000000, 'dependsOn' => ['key' => 'pay_balance_points_exchange_s', 'value' => true]],
['key' => 'pay_balance_points_exchange_daily_max_points', 'label' => '每日最高购买积分', 'type' => 'number', 'default' => 100000, 'min' => 1, 'max' => 10000000, 'dependsOn' => ['key' => 'pay_balance_points_exchange_s', 'value' => true]],
['key' => 'pay_balance_points_exchange_desc', 'label' => '兑换说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'pay_balance_points_exchange_s', 'value' => true]],
]],
],
],
/* ------------------------------------------------------------------
* VIP会员
* ------------------------------------------------------------------ */
'vip' => [
'key' => 'vip',
'title' => 'VIP会员',
'version' => '1.1.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'notice', 'title' => '说明', 'fields' => [
['key' => 'vip_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<ul style="margin:0 0 0 18px;line-height:1.9"><li>开启付费会员功能之前,请先配置好收款接口,确保网站收款正常</li><li>会员功能的设置项目较多,请仔细核对,避免出现价格、时间的问题</li><li>配合设置名称、有效期等可搭配出不同类型的会员</li><li>管理员可在后台为用户单独开启会员</li></ul>'],
]],
['key' => 'basic', 'title' => '会员等级', 'fields' => [
['key' => 'nav_pay_vip', 'label' => '导航栏购买按钮', 'type' => 'switch', 'default' => true, 'help' => '在顶部导航栏显示开通会员按钮;请注意顶部导航的整体宽度。'],
['key' => 'nav_user_pay_vip', 'label' => '用户框购买按钮', 'type' => 'switch', 'default' => true, 'help' => '在导航栏用户框内显示开通会员按钮。'],
['key' => 'pay_user_vip_1_s', 'label' => '启用一级会员', 'type' => 'switch', 'default' => true],
['key' => 'pay_user_vip_1_name', 'label' => '一级会员显示名称', 'type' => 'input', 'default' => '一级会员', 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true]],
['key' => 'pay_user_vip_1_desc', 'label' => '一级会员一句话简介', 'type' => 'input', 'default' => '尊享一级会员特权', 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true]],
['key' => 'pay_user_vip_1_equity', 'label' => '一级会员权益 HTML', 'type' => 'textarea', 'default' => '<li>免费下载部分资源</li><li>会员专属身份标识</li><li>付费内容会员价</li>', 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true]],
['key' => 'vip_1_img_icon', 'label' => '一级会员图标 URL', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true], 'help' => '留空使用内置 vip-1.svg 图标'],
['key' => 'pay_user_vip_2_s', 'label' => '启用二级会员', 'type' => 'switch', 'default' => true],
['key' => 'pay_user_vip_2_name', 'label' => '二级会员显示名称', 'type' => 'input', 'default' => '二级会员', 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true]],
['key' => 'pay_user_vip_2_desc', 'label' => '二级会员一句话简介', 'type' => 'input', 'default' => '尊享二级会员特权', 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true]],
['key' => 'pay_user_vip_2_equity', 'label' => '二级会员权益 HTML', 'type' => 'textarea', 'default' => '<li>更高免费下载额度</li><li>更高等级身份标识</li><li>更多付费内容会员价</li>', 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true]],
['key' => 'vip_2_img_icon', 'label' => '二级会员图标 URL', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true], 'help' => '留空使用内置 vip-2.svg 图标'],
['key' => 'pay_user_vip_desc', 'label' => '弹窗顶部会员说明', 'type' => 'textarea', 'default' => ''],
['key' => 'pay_user_vip_more', 'label' => '弹窗底部补充说明 HTML', 'type' => 'textarea', 'default' => ''],
]],
['key' => 'benefit', 'title' => '会员权益', 'fields' => [
['key' => 'vip_benefit', 'label' => '会员权益', 'type' => 'tabbed', 'tabs' => [
['key' => 'ordinary', 'title' => '普通用户', 'fields' => [
['key' => 'pay_download_limit', 'label' => '付费资源:免费资源每日可下载(个)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 9999, 'help' => '普通用户每日最多可下载几个免费资源(为0则不限制)'],
['key' => 'pay_download_speed', 'label' => '付费资源:下载限速(KB/s)', 'type' => 'number', 'default' => 0, 'min' => 0, 'help' => '付费下载限制最大下载速度(为0则不限制);只对本地服务器文件有效'],
]],
['key' => 'vip1', 'title' => '一级会员', 'fields' => [
['key' => 'pay_download_limit_vip_1', 'label' => '付费资源:免费资源每日可下载(个)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 9999, 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true], 'help' => '一级会员每日最多可下载几个免费资源(为0则不限制)'],
['key' => 'pay_download_speed_vip_1', 'label' => '付费资源:下载限速(KB/s)', 'type' => 'number', 'default' => 0, 'min' => 0, 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true], 'help' => '付费下载限制最大下载速度(为0则不限制);只对本地服务器文件有效'],
]],
['key' => 'vip2', 'title' => '二级会员', 'fields' => [
['key' => 'pay_download_limit_vip_2', 'label' => '付费资源:免费资源每日可下载(个)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 9999, 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true], 'help' => '二级会员每日最多可下载几个免费资源(为0则不限制)'],
['key' => 'pay_download_speed_vip_2', 'label' => '付费资源:下载限速(KB/s)', 'type' => 'number', 'default' => 0, 'min' => 0, 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true], 'help' => '付费下载限制最大下载速度(为0则不限制);只对本地服务器文件有效'],
]],
]],
]],
['key' => 'opt', 'title' => '会员购买选项', 'fields' => [
['key' => 'vip_opt', 'label' => '会员购买选项', 'type' => 'tabbed', 'tabs' => [
['key' => 'vip1', 'title' => '一级会员', 'fields' => [
['key' => 'vip_1_product_s', 'label' => '允许购买一级会员', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_user_vip_1_s', 'value' => true]],
['key' => 'payment_vip_1_products', 'label' => '一级会员套餐', 'type' => 'textarea', 'default' => "30|59|1|month|限时|月卡\n98|199|3|month|特惠|季卡\n365|599|12|month|超值|年卡\n999|1299|0|day|永久|永久卡", 'dependsOn' => ['key' => 'vip_1_product_s', 'value' => true], 'help' => '每行:执行价|原价|时长|单位(day|month)|标签|标题;时长 0=永久'],
]],
['key' => 'vip2', 'title' => '二级会员', 'fields' => [
['key' => 'vip_2_product_s', 'label' => '允许购买二级会员', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_user_vip_2_s', 'value' => true]],
['key' => 'payment_vip_2_products', 'label' => '二级会员套餐', 'type' => 'textarea', 'default' => "58|99|1|month|限时|月卡\n168|299|3|month|特惠|季卡\n598|999|12|month|超值|年卡\n1299|1999|0|day|永久|永久卡", 'dependsOn' => ['key' => 'vip_2_product_s', 'value' => true], 'help' => '每行:执行价|原价|时长|单位(day|month)|标签|标题;时长 0=永久'],
]],
['key' => 'renew', 'title' => '会员续费', 'fields' => [
['key' => 'vip_renew', 'label' => '允许续费', 'type' => 'switch', 'default' => true, 'help' => '关闭后则不能续费,只能会员到期之后再购买。永久会员不需要续费'],
['key' => 'vip_renew_desc', 'label' => '续费说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'vip_renew', 'value' => true]],
['key' => 'vip_renew_price_type', 'label' => '续费价格类型', 'type' => 'radio', 'default' => 'discount', 'dependsOn' => ['key' => 'vip_renew', 'value' => true], 'options' => [
['label' => '相同价格', 'value' => 'same'],
['label' => '折扣价格', 'value' => 'discount'],
['label' => '优惠立减', 'value' => 'reduce'],
]],
['key' => 'vip_renew_discount', 'label' => '续费折扣(折,如 8=八折)', 'type' => 'number', 'default' => 8, 'min' => 1, 'max' => 100, 'dependsOn' => ['key' => 'vip_renew_price_type', 'value' => 'discount']],
['key' => 'vip_renew_reduce', 'label' => '续费减免金额', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '20.00', 'min' => 0, 'max' => 9999, 'dependsOn' => ['key' => 'vip_renew_price_type', 'value' => 'reduce']],
]],
['key' => 'upgrade', 'title' => '会员升级', 'fields' => [
['key' => 'vip_upgrade', 'label' => '允许升级', 'type' => 'switch', 'default' => true],
['key' => 'vip_upgrade_desc', 'label' => '升级说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'vip_upgrade', 'value' => true]],
['key' => 'vip_upgrade_product', 'label' => '升级产品', 'type' => 'textarea', 'default' => "unit|1|按剩余天数升级\njump|199|升级永久二级会员\npermanent|299|永久一级升永久二级", 'dependsOn' => ['key' => 'vip_upgrade', 'value' => true], 'help' => '每行一条。永久VIP1:permanent|价格|标题;剩余天:unit|每日单价|标题;跳转永久:jump|价格|标题'],
]],
]],
]],
['key' => 'pass-charge', 'title' => '卡密兑换会员', 'fields' => [
['key' => 'pay_vip_pass_charge_s', 'label' => '启用卡密兑换会员功能', 'type' => 'switch', 'default' => false],
['key' => 'pay_vip_pass_charge_desc', 'label' => '卡密兑换说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'pay_vip_pass_charge_s', 'value' => true], 'help' => '用户使用卡密兑换时显示的内容,建议为提醒事项、充值协议等,支持HTML代码'],
['key' => 'pay_vip_pass_charge_only_password', 'label' => '单密码模式', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_vip_pass_charge_s', 'value' => true], 'help' => '仅需输入密码,不需要卡号'],
]],
['key' => 'points-exchange', 'title' => '积分兑换会员', 'fields' => [
['key' => 'pay_vip_points_exchange_s', 'label' => '启用积分兑换', 'type' => 'switch', 'default' => false],
['key' => 'payment_vip_points_packages', 'label' => '兑换套餐', 'type' => 'textarea', 'default' => "1|500|30|积分月卡\n1|5000|0|积分永久", 'dependsOn' => ['key' => 'pay_vip_points_exchange_s', 'value' => true], 'help' => '每行:等级|积分|天数|标题(天数 0=永久;普通用户可开通,已有会员可续费同等级或升级更高等级)'],
['key' => 'pay_vip_points_exchange_desc', 'label' => '兑换说明', 'type' => 'textarea', 'default' => '', 'dependsOn' => ['key' => 'pay_vip_points_exchange_s', 'value' => true]],
]],
],
],
/* ------------------------------------------------------------------
* 创作分成
* ------------------------------------------------------------------ */
'revenue' => [
'key' => 'revenue',
'title' => '创作分成',
'version' => '2.1.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'notice', 'title' => '说明', 'fields' => [
['key' => 'revenue_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<ul style="margin:0 0 0 18px;line-height:1.9"><li>开启创作分成后,用户发布的付费内容则按设置的比例收入与用户分成</li><li>在下方设置默认的分成比例,同时支持单独为每一个用户设置独立的分成比例</li><li>用户分成比例是按照订单实收现金并扣除推广佣金后,再按设置的比例分成</li><li>禁用此功能后,所有收款将不会与作者分成</li></ul>'],
]],
['key' => 'basic', 'title' => '创作中心设置', 'fields' => [
['key' => 'pay_income_s', 'label' => '启用创作分成', 'type' => 'switch', 'default' => false],
['key' => 'payment_revenue_cycle_days', 'label' => '结算周期(天)', 'type' => 'number', 'default' => 30, 'min' => 1, 'max' => 365, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
['key' => 'payment_revenue_note', 'label' => '结算备注文案', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '<p>订单完成并经过结算周期后,作者分成会自动转入对应的钱包。</p>', 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
]],
['key' => 'cash', 'title' => '现金收益分成', 'fields' => [
['key' => 'payment_revenue_cash_ratio_user', 'label' => '普通用户分成比例(%)', 'type' => 'number', 'default' => 60, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true], 'help' => '为0则不参与分成'],
['key' => 'payment_revenue_cash_ratio_vip_1', 'label' => '一级会员分成比例(%)', 'type' => 'number', 'default' => 70, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
['key' => 'payment_revenue_cash_ratio_vip_2', 'label' => '二级会员分成比例(%)', 'type' => 'number', 'default' => 80, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
]],
['key' => 'points', 'title' => '积分收益分成', 'fields' => [
['key' => 'payment_revenue_points_ratio_user', 'label' => '普通用户分成比例(%)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true], 'help' => '为0则不参与分成(用户采用积分支付的订单给与作者的分成比例)'],
['key' => 'payment_revenue_points_ratio_vip_1', 'label' => '一级会员分成比例(%)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
['key' => 'payment_revenue_points_ratio_vip_2', 'label' => '二级会员分成比例(%)', 'type' => 'number', 'default' => 0, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true]],
]],
['key' => 'detail', 'title' => '分成说明', 'fields' => [
['key' => 'pay_income_desc_details', 'label' => '创作分成说明', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '<p>在本站发布付费内容,获得的收益将参与收入分成</p><p>普通用户分成比例为:60%</p><p>一级会员分成比例为:70%</p><p>二级会员分成比例为:80%</p><p>分成比例的计算方式为:(实收现金-推广佣金)x 分成比例</p><p>申请提现后,需后台人工处理,一般2-3小时,请耐心等待</p>', 'rows' => 8, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true], 'help' => '显示在用户中心的说明,建议为发布协议或者其他说明(必填项,内容不易太少),支持HTML代码'],
['key' => 'pay_income_desc_page_s', 'label' => '创作分成详情页面', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'pay_income_s', 'value' => true], 'help' => '您可以新建一个页面写入更加详细的创作分成说明及协议内容,再开启此项并选择对应的页面'],
['key' => 'pay_income_desc_page', 'label' => '选择页面', 'type' => 'page_select', 'default' => 0, 'dependsOn' => ['key' => 'pay_income_desc_page_s', 'value' => true]],
]],
],
],
/* ------------------------------------------------------------------
* 推广返佣
* ------------------------------------------------------------------ */
'affiliate' => [
'key' => 'affiliate',
'title' => '推广返佣',
'version' => '1.1.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'notice', 'title' => '说明', 'fields' => [
['key' => 'affiliate_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<ul style="margin:0 0 0 18px;line-height:1.9"><li>识别模式「绑定注册」:用户只要是通过任意推广链接注册的,今后此用户消费均会给推荐人返佣</li><li>识别模式「仅推广链接」:只有通过推广链接购买的才会给推荐人返佣,不会考虑是否是推荐注册的</li><li>开启的订单类型如果一个都不勾选,则代表该用户类型不参与此功能</li><li>您可以根据网站的VIP设置相互配合设置相应的规则</li><li>下面的设置为全局设置,还可以单独为每一个用户设置规则和比例</li></ul>'],
]],
['key' => 'switch', 'title' => '推广返佣', 'fields' => [
['key' => 'pay_rebate_s', 'label' => '启用推广返佣', 'type' => 'switch', 'default' => false],
]],
['key' => 'mode', 'title' => '推广识别模式', 'fields' => [
['key' => 'pay_rebate_judgment', 'label' => '推广识别模式', 'type' => 'radio', 'default' => 'all', 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true], 'options' => [
['label' => '绑定注册', 'value' => 'all'],
['label' => '仅推广链接', 'value' => 'link'],
]],
['key' => 'pay_rebate_show_users', 'label' => '用户中心显示我推荐的用户', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_rebate_judgment', 'value' => 'all']],
['key' => 'pay_rebate_self_s', 'label' => '自己推广自己', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true], 'help' => '允许使用自己的推广链接购买商品并获得佣金'],
]],
['key' => 'rules', 'title' => '返佣规则', 'fields' => [
['key' => 'rebate_rule', 'label' => '为不同用户类型设置返佣规则', 'type' => 'tabbed', 'tabs' => [
['key' => 'ordinary', 'title' => '普通用户', 'fields' => [
['key' => 'pay_rebate_user_s', 'label' => '返佣订单', 'type' => 'checkbox', 'default' => [], 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true], 'options' => [
['label' => '全部订单', 'value' => 'all'],
['label' => '购买会员', 'value' => 'membership'],
['label' => '付费内容', 'value' => 'content'],
['label' => '购买积分', 'value' => 'credits'],
], 'help' => '普通用户返利的订单类型,全部关闭,则代表普通用户不参与推广返佣'],
['key' => 'pay_rebate_ratio', 'label' => '普通用户返佣比例(%)', 'type' => 'number', 'default' => 5, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true]],
]],
['key' => 'vip1', 'title' => '一级会员', 'fields' => [
['key' => 'pay_rebate_user_s_1', 'label' => '返佣订单', 'type' => 'checkbox', 'default' => ['all'], 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true], 'options' => [
['label' => '全部订单', 'value' => 'all'],
['label' => '购买会员', 'value' => 'membership'],
['label' => '付费内容', 'value' => 'content'],
['label' => '购买积分', 'value' => 'credits'],
], 'help' => '一级会员返利的订单类型,全部关闭,则代表一级会员用户不参与推广返佣'],
['key' => 'pay_rebate_ratio_vip_1', 'label' => '一级会员返佣比例(%)', 'type' => 'number', 'default' => 10, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true]],
]],
['key' => 'vip2', 'title' => '二级会员', 'fields' => [
['key' => 'pay_rebate_user_s_2', 'label' => '返佣订单', 'type' => 'checkbox', 'default' => ['all'], 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true], 'options' => [
['label' => '全部订单', 'value' => 'all'],
['label' => '购买会员', 'value' => 'membership'],
['label' => '付费内容', 'value' => 'content'],
['label' => '购买积分', 'value' => 'credits'],
], 'help' => '二级会员返利的订单类型,全部关闭,则代表二级会员用户不参与推广返佣'],
['key' => 'pay_rebate_ratio_vip_2', 'label' => '二级会员返佣比例(%)', 'type' => 'number', 'default' => 20, 'min' => 0, 'max' => 100, 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true]],
]],
]],
['key' => 'affiliate_settlement_days', 'label' => '结算观察期(天)', 'type' => 'number', 'default' => 7, 'min' => 0, 'max' => 90, 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true], 'help' => '订单完成后经过观察期,佣金才会结算到可提现余额'],
]],
['key' => 'text', 'title' => '返佣文案', 'fields' => [
['key' => 'pay_rebate_text_desc', 'label' => '返佣文案(一句话简介)', 'type' => 'input', 'default' => '加入分享计划,获得高额奖励', 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true]],
['key' => 'pay_rebate_text_details_title', 'label' => '返佣详情标题', 'type' => 'input', 'default' => '返佣详解', 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true]],
['key' => 'pay_rebate_text_details', 'label' => '返佣详情内容', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '<p>通过您的推广链接打开本站后,在本站购买商品即可获得佣金</p><p>通过您的推广链接注册后的用户今后购买的商品均可获得佣金</p><p>申请提现后,需后台人工处理,一般2-3小时,请耐心等待</p>', 'rows' => 6, 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true], 'help' => '返佣详情介绍,建议为规则介绍或者其他说明,支持HTML代码'],
]],
['key' => 'poster', 'title' => '推广海报', 'fields' => [
['key' => 'pay_rebate_poster_s', 'label' => '推广海报', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true], 'help' => '在用户中心显示包含二维码的推广海报'],
['key' => 'pay_rebate_poster_img', 'label' => '推广海报顶部图片', 'type' => 'media', 'default' => '', 'dependsOn' => ['key' => 'pay_rebate_poster_s', 'value' => true]],
['key' => 'pay_rebate_poster_title', 'label' => '推广海报标题(20-30个字)', 'type' => 'input', 'default' => '发现一个精品网站,快来看一看', 'dependsOn' => ['key' => 'pay_rebate_poster_s', 'value' => true]],
['key' => 'pay_rebate_poster_desc', 'label' => '推广海报简介(40-60个字)', 'type' => 'input', 'default' => '网站有超多精品资源和优惠福利,扫码进入网站还可享受诸多优惠哦', 'dependsOn' => ['key' => 'pay_rebate_poster_s', 'value' => true]],
]],
['key' => 'discount', 'title' => '推广让利标签', 'fields' => [
['key' => 'discount_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<p><b>推广让利标签配置详解:</b></p><ul style="margin:6px 0 0 18px;line-height:1.9"><li>可使用的变量:折扣 <code>%discount%</code>、推荐人姓名 <code>%referrer_name%</code></li><li>使用变量示例:<code>%referrer_name%推荐购买 下单再减%discount%元</code></li></ul>', 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true]],
['key' => 'pay_rebate_text_discount', 'label' => '推广让利标签', 'type' => 'input', 'default' => '推荐购买 下单再减%discount%', 'dependsOn' => ['key' => 'pay_rebate_s', 'value' => true], 'help' => '显示在购买模块,推广让利的标签文案'],
]],
],
],
/* ------------------------------------------------------------------
* 收款接口(支付宝 / 微信 / PayPal / Stripe / 易支付)
* ------------------------------------------------------------------ */
'gateway' => [
'key' => 'gateway',
'title' => '收款接口',
'version' => '2.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'notice', 'title' => '说明', 'fields' => [
['key' => 'gateway_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<ul style="margin:0 0 0 18px;line-height:1.9"><li>以下收款接口,主题仅提供API接入服务,收款平台的可靠性请自行斟酌!</li><li>涉及到资金及信息安全,有相关执照的商家推荐使用官方接口</li><li>微信 / 支付宝接口可在「官方」与「易支付」之间选择;PayPal 与 Stripe 独立开关</li><li>异步回调由各网关验签,无需额外口令;回调地址固定为 /wp-json/aksrt/v1/payment/{gateway}/{notify|return}</li></ul>'],
]],
['key' => 'channels', 'title' => '收款接口选择', 'fields' => [
['key' => 'pay_wechat_sdk_options', 'label' => '微信收款接口', 'type' => 'select', 'default' => 'null', 'options' => [
['label' => '微信官方', 'value' => 'official_wechat'],
['label' => '易支付-微信', 'value' => 'epay'],
['label' => '关闭微信收款', 'value' => 'null'],
]],
['key' => 'pay_alipay_sdk_options', 'label' => '支付宝收款接口', 'type' => 'select', 'default' => 'null', 'options' => [
['label' => '支付宝企业支付/当面付', 'value' => 'official_alipay'],
['label' => '易支付-支付宝', 'value' => 'epay'],
['label' => '关闭支付宝收款', 'value' => 'null'],
]],
['key' => 'pay_paypal_sdk_s', 'label' => 'PayPal支付(贝宝)', 'type' => 'switch', 'default' => false, 'help' => '启用后请在下方配置参数'],
['key' => 'pay_stripe_sdk_s', 'label' => 'Stripe支付', 'type' => 'switch', 'default' => false, 'help' => '启用后请在下方配置参数'],
]],
['key' => 'currency', 'title' => '货币与结算', 'fields' => [
['key' => 'pay_currency_mark', 'label' => '本地货币符号', 'type' => 'input', 'default' => '¥', 'help' => '显示在金额前面(例如 $ 或 ¥)'],
['key' => 'pay_currency_unit', 'label' => '本地货币单位名称', 'type' => 'input', 'default' => '元', 'help' => '金额后缀,例如:人民币填「元」、美元填「dollars」'],
['key' => 'pay_wechat_settle', 'label' => '微信结算配置', 'type' => 'fieldset', 'default' => ['settle_rate' => '1', 'settle_mark' => '¥', 'settle_unit' => '元'], 'fields' => [
['key' => 'settle_rate', 'label' => '结算汇率', 'type' => 'input', 'default' => '1'],
['key' => 'settle_mark', 'label' => '结算货币符号', 'type' => 'input', 'default' => '¥'],
['key' => 'settle_unit', 'label' => '结算货币单位', 'type' => 'input', 'default' => '元'],
]],
['key' => 'pay_alipay_settle', 'label' => '支付宝结算配置', 'type' => 'fieldset', 'default' => ['settle_rate' => '1', 'settle_mark' => '¥', 'settle_unit' => '元'], 'fields' => [
['key' => 'settle_rate', 'label' => '结算汇率', 'type' => 'input', 'default' => '1'],
['key' => 'settle_mark', 'label' => '结算货币符号', 'type' => 'input', 'default' => '¥'],
['key' => 'settle_unit', 'label' => '结算货币单位', 'type' => 'input', 'default' => '元', 'help' => '如果接入的收款方式与本地的货币类型不同,则在此配置结算汇率及单位'],
]],
['key' => 'pay_sdk_custom_title_s', 'label' => '自定义收款标题', 'type' => 'switch', 'default' => false, 'help' => '默认为付款类型加网站名,如需自定义请开启'],
['key' => 'pay_sdk_custom_title', 'label' => '自定义收款标题', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'pay_sdk_custom_title_s', 'value' => true], 'help' => '可使用变量:订单类型 %order_type%,例如:%order_type%-AKSRT;注意控制总长度,太长会导致部分接口报错'],
]],
['key' => 'order', 'title' => '订单与编号', 'fields' => [
['key' => 'payment_order_prefix', 'label' => '订单前缀', 'type' => 'input', 'default' => 'AKSRT', 'help' => '订单号生成前缀'],
['key' => 'payment_flow_prefix', 'label' => '流水号前缀', 'type' => 'input', 'sanitize_type' => 'business_prefix', 'default' => 'AK', 'maxlength' => 12, 'help' => '仅允许字母、数字、下划线和短横线,最多 12 位。'],
['key' => 'payment_withdrawal_prefix', 'label' => '提现单号前缀', 'type' => 'input', 'sanitize_type' => 'business_prefix', 'default' => 'TX', 'maxlength' => 12, 'help' => '仅允许字母、数字、下划线和短横线,最多 12 位。'],
['key' => 'payment_order_expiry', 'label' => '订单支付时效(分钟)', 'type' => 'number', 'default' => 30, 'min' => 5, 'max' => 1440, 'help' => '用户下单后,最大支付时间,超过后订单将自动关闭(不能低于5分钟)'],
['key' => 'pay_wait_float_s', 'label' => '浮窗显示待支付订单', 'type' => 'switch', 'default' => true, 'help' => '将用户待支付订单一直显示在右上角,提醒用户付款'],
]],
['key' => 'sdk-order', 'title' => '收款接口显示顺序', 'fields' => [
['key' => 'pay_sdk_order', 'label' => '显示顺序', 'type' => 'sortable', 'default' => [], 'items' => [
['key' => 'wechat', 'title' => '微信', 'fields' => []],
['key' => 'alipay', 'title' => '支付宝', 'fields' => []],
['key' => 'paypal', 'title' => 'PayPal(贝宝)', 'fields' => []],
['key' => 'stripe', 'title' => 'Stripe', 'fields' => []],
['key' => 'balance', 'title' => '余额', 'fields' => []],
['key' => 'card_pass', 'title' => '卡密', 'fields' => []],
], 'help' => '收银台支付方式显示顺序;仅显示已开启的接口'],
]],
['key' => 'alipay', 'title' => '支付宝官方', 'collapsible' => true, 'expandWhen' => 'pay_alipay_sdk_options', 'dependsOn' => ['key' => 'pay_alipay_sdk_options', 'value' => 'official_alipay'], 'fields' => [
['key' => 'alipay_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<ul style="margin:0 0 0 18px;line-height:1.9"><li>支付宝公钥为必填项目(公钥错误可以成功付款,但会回调失败)</li><li>回调地址固定为 /wp-json/aksrt/v1/payment/alipay/{notify|return}</li><li>同时填写了企业支付以及当面付参数,则优先使用当面付</li></ul>'],
['key' => 'alipay_appid', 'label' => '当面付:APPID', 'type' => 'input', 'default' => ''],
['key' => 'alipay_privatekey', 'label' => '当面付:应用私钥', 'type' => 'textarea', 'sanitize_type' => 'code', 'default' => '', 'rows' => 4],
['key' => 'alipay_payment_type', 'label' => '支付方式', 'type' => 'select', 'default' => 'page', 'options' => [
['label' => '电脑网站支付(web)', 'value' => 'page'],
['label' => '手机网站支付(wap)', 'value' => 'wap'],
]],
['key' => 'alipay_app_public_cert_path', 'label' => '应用公钥证书路径', 'type' => 'input', 'default' => '', 'help' => 'appCertPublicKey.crt 绝对路径。'],
['key' => 'alipay_public_cert_path', 'label' => '支付宝公钥证书路径', 'type' => 'input', 'default' => '', 'help' => 'alipayCertPublicKey_RSA2.crt 绝对路径。'],
['key' => 'alipay_root_cert_path', 'label' => '支付宝根证书路径', 'type' => 'input', 'default' => '', 'help' => 'alipayRootCert.crt 绝对路径。'],
]],
['key' => 'wechat', 'title' => '微信官方', 'collapsible' => true, 'expandWhen' => 'pay_wechat_sdk_options', 'dependsOn' => ['key' => 'pay_wechat_sdk_options', 'value' => 'official_wechat'], 'fields' => [
['key' => 'wechat_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<ul style="margin:0 0 0 18px;line-height:1.9"><li>微信企业支付:官方接口,商家可申请,有年费,申请较为复杂</li><li>回调地址固定为 /wp-json/aksrt/v1/payment/wechatpay/{notify|return},请配置 Native 支付回调链接</li></ul>'],
['key' => 'wechat_merchantid', 'label' => '商户号 PartnerID', 'type' => 'input', 'default' => ''],
['key' => 'wechat_appid', 'label' => '授权绑定的AppID', 'type' => 'input', 'default' => ''],
['key' => 'wechat_payment_type', 'label' => '支付方式', 'type' => 'select', 'default' => 'native', 'options' => [
['label' => '扫码支付(Native)', 'value' => 'native'],
['label' => 'H5支付', 'value' => 'h5'],
]],
['key' => 'wechat_api_v3_key', 'label' => '支付APIv3密钥', 'type' => 'input', 'default' => '', 'help' => '微信商户平台设置的 APIv3 密钥(32位)。'],
['key' => 'wechat_private_key_path', 'label' => '商户私钥路径', 'type' => 'input', 'default' => '', 'help' => 'apiclient_key.pem 绝对路径,用于签名。'],
['key' => 'wechat_cert_path', 'label' => '商户API证书路径', 'type' => 'input', 'default' => '', 'help' => 'apiclient_cert.pem 绝对路径。'],
]],
['key' => 'paypal', 'title' => 'PayPal(贝宝)', 'collapsible' => true, 'expandWhen' => 'pay_paypal_sdk_s', 'dependsOn' => ['key' => 'pay_paypal_sdk_s', 'value' => true], 'fields' => [
['key' => 'paypal_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<ul style="margin:0 0 0 18px;line-height:1.9"><li>PayPal(贝宝)是常见的海外支付接口</li><li>如果您的收款账户为中国大陆地区,则账户类型必须是企业,且只能收取非中国大陆区的PayPal付款</li><li>REST 应用申请:https://developer.paypal.com/dashboard/applications</li></ul>'],
['key' => 'paypal_client_id', 'label' => 'Client ID', 'type' => 'input', 'default' => ''],
['key' => 'paypal_client_secret', 'label' => 'Client Secret', 'type' => 'input', 'default' => ''],
['key' => 'paypal_currency', 'label' => '结算货币', 'type' => 'select', 'default' => 'USD', 'options' => self::currency_options()],
['key' => 'paypal_rates', 'label' => '货币汇率', 'type' => 'input', 'default' => '0.14', 'help' => '根据你选择的货币类型与您定价货币的汇率进行填写,例如1元人民币兑换0.137美元(USD),则此处填0.137'],
['key' => 'paypal_sandbox', 'label' => '沙盒调试模式', 'type' => 'switch', 'default' => false, 'help' => '沙箱模式(Sandbox)是PayPal支付的测试环境。开启后请使用沙箱环境生成的收款账户和付款账户进行测试。'],
]],
['key' => 'stripe', 'title' => 'Stripe', 'collapsible' => true, 'expandWhen' => 'pay_stripe_sdk_s', 'dependsOn' => ['key' => 'pay_stripe_sdk_s', 'value' => true], 'fields' => [
['key' => 'stripe_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<ul style="margin:0 0 0 18px;line-height:1.9"><li>Stripe 是常见的海外信用卡收款接口</li><li>API 密钥申请:https://dashboard.stripe.com/apikeys</li><li>Webhook 事件:checkout.session.completed</li><li>测试环境请使用 sk_test_ 开头的 Secret Key</li></ul>'],
['key' => 'stripe_secret_key', 'label' => '私钥Secret Key', 'type' => 'input', 'default' => '', 'help' => 'Stripe Dashboard → Developers → API keys → Secret key'],
['key' => 'stripe_publishable_key', 'label' => 'Publishable Key', 'type' => 'input', 'default' => ''],
['key' => 'stripe_webhook_secret', 'label' => '签名密钥Webhook Secret', 'type' => 'input', 'default' => '', 'help' => 'Developers → Webhooks → 端点 → Signing secret(whsec_ 开头)'],
['key' => 'stripe_currency', 'label' => '结算货币', 'type' => 'select', 'default' => 'USD', 'options' => self::currency_options()],
['key' => 'stripe_rates', 'label' => '货币汇率', 'type' => 'input', 'default' => '0.14', 'help' => '根据你选择的货币类型与您定价货币的汇率进行填写,例如1元人民币兑换0.137美元(USD),则此处填0.137'],
['key' => 'stripe_test_mode', 'label' => '测试模式', 'type' => 'switch', 'default' => false, 'help' => '如果使用的测试开放模式,则请使用 sk_test_ 测试密钥与 Stripe 测试卡进行配置'],
]],
['key' => 'epay', 'title' => '易支付', 'collapsible' => true, 'expandWhen' => 'pay_wechat_sdk_options', 'dependsOn' => ['any' => [
['key' => 'pay_wechat_sdk_options', 'value' => 'epay'],
['key' => 'pay_alipay_sdk_options', 'value' => 'epay'],
]], 'fields' => [
['key' => 'epay_notice', 'label' => '', 'type' => 'content', 'ui_only' => true, 'content' => '<ul style="margin:0 0 0 18px;line-height:1.9"><li>易支付是一个常见的支付系统源码,任何人都可以下载并搭建</li><li>同时市面上多数的小规模支付平台都是由易支付修改而来,例如部分码支付、源支付等等</li><li>由于此接口服务商众多,主题只负责技术接入,平台可靠性请自行斟酌</li></ul>'],
['key' => 'epay_apiurl', 'label' => 'API接口网址', 'type' => 'input', 'default' => '', 'help' => '请填写接口地址,例如:https://pay.xxxxxxx.cn/'],
['key' => 'epay_pid', 'label' => '商户号', 'type' => 'input', 'default' => ''],
['key' => 'epay_key', 'label' => '商户秘钥', 'type' => 'input', 'default' => '', 'help' => 'MD5 通信密钥。'],
['key' => 'epay_device', 'label' => '下单终端', 'type' => 'select', 'default' => 'auto', 'options' => [
['label' => '自动(按 UA)', 'value' => 'auto'],
['label' => '电脑端 submit', 'value' => 'pc'],
['label' => '移动端 mapi', 'value' => 'mobile'],
]],
]],
],
],
/* ------------------------------------------------------------------
* 提现策略
* ------------------------------------------------------------------ */
'withdrawal' => [
'key' => 'withdrawal',
'title' => '提现策略',
'version' => '1.1.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'basic', 'title' => '提现门槛', 'fields' => [
['key' => 'affiliate_min_withdrawal', 'label' => '提现最低金额限制', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '50.00', 'help' => '当用户可提现总金额(推广佣金、余额、创作分成)高于多少时候,才能发起提现'],
['key' => 'affiliate_withdrawal_fee', 'label' => '提现手续费(%)', 'type' => 'number', 'default' => 5, 'min' => 0, 'max' => 100],
]],
['key' => 'limits', 'title' => '每日限制', 'fields' => [
['key' => 'affiliate_daily_withdrawal_count', 'label' => '每日可提现次数', 'type' => 'number', 'default' => 3, 'min' => 0, 'max' => 99999],
['key' => 'affiliate_daily_withdrawal_limit', 'label' => '每日提现上限', 'type' => 'input', 'sanitize_type' => 'money_decimal', 'default' => '500.00'],
['key' => 'affiliate_withdrawal_reset_time', 'label' => '重置时间', 'type' => 'input', 'default' => '00:00', 'help' => '按站点 WordPress 时区重置,格式 HH:MM。'],
]],
['key' => 'channels', 'title' => '收款渠道', 'fields' => [
['key' => 'affiliate_payout_channels', 'label' => '可用收款渠道', 'type' => 'checkbox', 'options' => [['value' => 'alipay', 'label' => '支付宝收款码'], ['value' => 'wechat', 'label' => '微信收款码']], 'default' => ['alipay', 'wechat']],
]],
['key' => 'agreement', 'title' => '提现协议', 'fields' => [
['key' => 'pay_rebate_withdraw_text_details', 'label' => '提现协议', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '<div>可提现金额达到50元后即可发起提现</div><div>申请提现需后台人工处理,一般2-3小时,请耐心等待</div><div>如有其它疑问,请与客服联系</div>', 'rows' => 4, 'help' => '用户申请提现时展示的内容,建议为提现须知等,支持HTML代码'],
]],
],
],
],
];
}
/**
* PayPal / Stripe 结算货币选项(参考主题同款 26 种)。
*
* @return array<int,array{label:string,value:string}>
*/
private static function currency_options(): array {
$currencies = [
'AUD' => '澳元 (AUD)',
'BRL' => '巴西雷亚尔 (BRL)',
'CAD' => '加拿大元 (CAD)',
'CNY' => '人民币 (CNY)',
'CZK' => '克朗 (CZK)',
'DKK' => '丹麦克朗 (DKK)',
'EUR' => '欧元 (EUR)',
'HKD' => '港币 (HKD)',
'HUF' => '匈牙利福林 (HUF)',
'INR' => '印度卢比 (INR)',
'ILS' => '以色列新谢克尔 (ILS)',
'JPY' => '日元 (JPY)',
'MYR' => '马来西亚林吉特 (MYR)',
'MXN' => '墨西哥比索 (MXN)',
'TWD' => '新台币 (TWD)',
'NZD' => '新西兰元 (NZD)',
'NOK' => '挪威克朗 (NOK)',
'PHP' => '菲律宾比索 (PHP)',
'PLN' => '波兰兹罗提 (PLN)',
'GBP' => '英镑 (GBP)',
'RUB' => '俄罗斯卢布 (RUB)',
'SGD' => '新加坡元 (SGD)',
'SEK' => '瑞典克朗 (SEK)',
'CHF' => '瑞士法郎 (CHF)',
'THB' => '泰铢 (THB)',
'USD' => '美元 (USD)',
];
$options = [];
foreach ($currencies as $code => $label) {
$options[] = ['label' => $label, 'value' => $code];
}
return $options;
}
}
+49 -13
View File
@@ -192,7 +192,7 @@ class SchemaProvider {
continue;
}
if (in_array($type, ['fieldset', 'accordion', 'sortable', 'link'], true) && !is_array($value)) {
if (in_array($type, ['fieldset', 'accordion', 'sortable', 'link', 'between_number'], true) && !is_array($value)) {
$errors[] = sprintf('%s must be an object', $field['label'] ?? $key);
continue;
}
@@ -732,23 +732,46 @@ class SchemaProvider {
continue;
}
foreach ($group['fields'] ?? [] as $field) {
if (!is_array($field) || empty($field['key'])) {
continue;
}
// UI-only controls never become persisted settings keys.
if (!empty($field['ui_only'])) {
continue;
}
// Notice/help-only rows are UI chrome, not stored settings keys.
if (($field['type'] ?? '') === 'notice') {
continue;
}
$fields[] = $field;
$fields = array_merge($fields, $this->collect_persisted_fields(is_array($field) ? $field : []));
}
}
return $fields;
}
/**
* Flatten one field definition into persisted keys. Tabbed is a UI-only
* container: its sub-fields are flat top-level option keys, so they are
* expanded into the persisted field list (notice / ui_only rows skipped).
*
* @return array<int,array<string,mixed>>
*/
private function collect_persisted_fields(array $field): array {
if (($field['type'] ?? '') === 'tabbed') {
$fields = [];
foreach ((array) ($field['tabs'] ?? []) as $tab) {
if (!is_array($tab)) {
continue;
}
foreach ((array) ($tab['fields'] ?? []) as $sub) {
$fields = array_merge($fields, $this->collect_persisted_fields(is_array($sub) ? $sub : []));
}
}
return $fields;
}
if (empty($field['key'])) {
return [];
}
// UI-only controls never become persisted settings keys.
if (!empty($field['ui_only'])) {
return [];
}
// Notice/help-only rows are UI chrome, not stored settings keys.
if (($field['type'] ?? '') === 'notice') {
return [];
}
return [$field];
}
/**
* Normalize legacy numeric money settings without accepting lossy precision.
*
@@ -848,6 +871,17 @@ class SchemaProvider {
return $this->sanitize_object_fields($value, (array) ($field['fields'] ?? []));
}
if ($type === 'between_number') {
$defaults = is_array($field['default'] ?? null) ? $field['default'] : ['min' => 0, 'max' => 0];
if (!is_array($value)) {
return ['min' => (int) ($defaults['min'] ?? 0), 'max' => (int) ($defaults['max'] ?? 0)];
}
return [
'min' => is_numeric($value['min'] ?? null) ? (int) $value['min'] : (int) ($defaults['min'] ?? 0),
'max' => is_numeric($value['max'] ?? null) ? (int) $value['max'] : (int) ($defaults['max'] ?? 0),
];
}
if (in_array($type, ['group', 'repeater'], true)) {
if (!is_array($value)) {
return [];
@@ -1006,6 +1040,8 @@ class SchemaProvider {
'accordion'=> 'array',
'sortable' => 'array',
'link' => 'array',
'between_number' => 'array',
'page_select' => 'int',
'async_select' => 'array',
'json' => 'array',
// 自定义面板(验证码服务商等)按对象存储
+7 -2
View File
@@ -179,8 +179,13 @@ trait ScriptsPart1c {
'www' => home_url('/'),
'uri' => $runtime_uri,
'ver' => $runtime_version,
'pay_mark' => '¥',
'pay_currency_unit' => __('元', 'aksrt'),
// 货币符号 / 单位来自「收款接口」页配置(pay_currency_mark / pay_currency_unit)。
'pay_mark' => class_exists('\AKSRT\Settings\Settings') && class_exists('\AKSRT\Settings\PaymentRuntime')
? \AKSRT\Settings\PaymentRuntime::get_paid_content_settings()['display']['currency_symbol']
: '¥',
'pay_currency_unit' => class_exists('\AKSRT\Settings\Settings') && class_exists('\AKSRT\Settings\PaymentRuntime')
? \AKSRT\Settings\PaymentRuntime::get_paid_content_settings()['display']['currency_unit']
: __('元', 'aksrt'),
'imgbox' => $lightbox_on,
'imgbox_type' => 'group',
'imgbox_thumbs' => $lightbox_on && (!isset($post_page_settings['lightbox_thumbs']) || !empty($post_page_settings['lightbox_thumbs'])),
+3 -1
View File
@@ -47,7 +47,6 @@ final class CommissionLedger {
$map = ['vip' => 'membership', 'resource' => 'content'];
$order_type = $map[$type] ?? $type;
$settings = \AKSRT\Settings\Settings::get_affiliate_settings();
if (!in_array($order_type, (array) $settings['order_types'], true)) return 0;
$order_no = sanitize_text_field((string) ($order['order_number'] ?? ''));
$buyer = (int) ($order['user_id'] ?? 0);
try {
@@ -58,6 +57,9 @@ final class CommissionLedger {
if ($order_no === '' || $buyer <= 0 || $amount->minor() <= 0) return 0;
$promoter = ReferralAttribution::get_instance()->resolve($buyer);
if ($promoter <= 0) return 0;
// 返佣订单类型按推广者会员等级分档(参考主题:每档独立勾选)。
$promoter_level = function_exists('aksrt_get_user_vip_level') ? (int) aksrt_get_user_vip_level($promoter) : 0;
if (!in_array($order_type, \AKSRT\Settings\PaymentRuntime::affiliate_order_types_for_level($promoter_level), true)) return 0;
$ratio = \AKSRT\Settings\PaymentRuntime::affiliate_ratio_for_user($promoter);
$commission_minor = (intdiv($amount->minor(), 100) * $ratio)
+ intdiv((($amount->minor() % 100) * $ratio) + 50, 100);
+44 -3
View File
@@ -45,7 +45,7 @@ class Gateway {
}
/**
* 获取可用网关列表(已配置的)
* 获取可用网关列表(已配置的),按「收款接口显示顺序」配置排序。
*/
public function get_available(): array {
$available = [];
@@ -54,7 +54,48 @@ class Gateway {
$available[$id] = $gateway;
}
}
return $available;
return $this->apply_sdk_order($available);
}
/**
* 按 pay_sdk_order(收款接口显示顺序)重排可用网关。
* 易支付子通道跟随对应渠道槽位(epay_wxpay 跟随 wechat、epay_alipay 跟随 alipay);
* 未配置顺序时保持注册顺序,未纳入槽位的扩展网关保持在末尾。
*
* @param array<string,GatewayInterface> $available
* @return array<string,GatewayInterface>
*/
private function apply_sdk_order(array $available): array {
$settings = \AKSRT\Settings\Settings::get_all();
$configured = (array) ($settings['pay_sdk_order'] ?? []);
$order = array_values(array_filter(array_map('sanitize_key', array_keys($configured))));
if (!$order) {
return $available;
}
$slot_map = [
'wechat' => ['wechatpay', 'epay_wxpay'],
'alipay' => ['alipay', 'epay_alipay'],
'paypal' => ['paypal'],
'stripe' => ['stripe'],
'balance' => ['balance'],
'card_pass' => ['card_pass'],
];
$sorted = [];
foreach ($order as $slot) {
foreach (($slot_map[$slot] ?? []) as $id) {
if (isset($available[$id]) && !isset($sorted[$id])) {
$sorted[$id] = $available[$id];
}
}
}
foreach ($available as $id => $gateway) {
if (!isset($sorted[$id])) {
$sorted[$id] = $gateway;
}
}
return $sorted;
}
/**
@@ -311,7 +352,7 @@ class Gateway {
}
$gateway_id = sanitize_key((string) ($order['payment_method'] ?? ''));
if ($gateway_id === '' || in_array($gateway_id, ['balance', 'points', 'manual_review'], true)) {
if ($gateway_id === '' || in_array($gateway_id, ['balance', 'points'], true)) {
return null;
}
$gateway = $this->get_gateway($gateway_id);
+1 -1
View File
@@ -186,7 +186,7 @@ class UserOrders {
$image = $this->resolve_image($meta, $product_id);
$group = $this->status_group($status);
$payment_method = sanitize_key((string) ($order['payment_method'] ?? ''));
$can_pay = $group === OrderCenterQuery::STATUS_PENDING && $payment_method !== 'manual_review';
$can_pay = $group === OrderCenterQuery::STATUS_PENDING;
$can_cancel = $group === OrderCenterQuery::STATUS_PENDING;
$order_number = (string) ($order['order_number'] ?? '');
$updated_at = $this->resolve_updated_at($order);
+2 -2
View File
@@ -160,7 +160,7 @@ trait CreditsPaymentGroups {
public static function get_settlement_settings(): array { return PaymentRuntime::get_settlement_settings(); }
/**
* @return array{mode:string,test_enabled:bool,manual_review:bool,callback_secret:string,help_text:string}
* @return array<string,mixed>
*/
public static function get_payment_gateway_settings(): array {
return PaymentRuntime::get_payment_gateway_settings();
@@ -169,7 +169,7 @@ trait CreditsPaymentGroups {
/**
* 获取订单设置
*
* @return array{prefix:string,flow_prefix:string,withdrawal_prefix:string,expiry:int,show_user:bool,show_paycount:bool,no_logged_in:bool,cookie_day:int,no_logged_remind:bool,wait_float:bool,order_max_minutes:int,mark:string,box_position:string,show_ip:bool,show_device:bool,show_order_no:bool,show_create_time:bool,show_pay_time:bool,status_texts:array,service:array}
* @return array{prefix:string,flow_prefix:string,withdrawal_prefix:string,expiry:int,show_user:bool,show_paycount:bool,no_logged_in:bool,cookie_day:int,no_logged_remind:bool,wait_float:bool,mark:string,box_position:string,show_ip:bool,show_device:bool,show_order_no:bool,show_create_time:bool,show_pay_time:bool,status_texts:array,service:array}
*/
public static function get_order_settings(): array {
return PaymentRuntime::get_order_settings();
+173 -82
View File
@@ -34,27 +34,29 @@ class PaymentRuntime {
'catalog_note' => '',
'manual_delivery_note' => __('付费或人工确认内容请在订单备注中记录交付方式。', 'aksrt'),
'no_logged_in' => !isset($settings['pay_no_logged_in']) || !empty($settings['pay_no_logged_in']),
'down_alone_page' => false,
'free_logged_show' => !isset($settings['pay_free_logged_show']) || !empty($settings['pay_free_logged_show']),
'down_alone_page' => !empty($settings['down_alone_page']),
'display' => [
'mark' => sanitize_text_field((string) ($settings['pay_mark'] ?? '付费')),
'currency_symbol' => '¥',
'currency_symbol' => sanitize_text_field((string) ($settings['pay_currency_mark'] ?? '¥')),
'currency_unit' => sanitize_text_field((string) ($settings['pay_currency_unit'] ?? '元')),
'show_user' => !isset($settings['pay_show_user']) || !empty($settings['pay_show_user']),
'show_paycount' => !isset($settings['pay_show_paycount']) || !empty($settings['pay_show_paycount']),
'box_position' => $box_position,
],
'download' => [
'enabled' => true,
'remote' => true,
'verify_nonce' => true,
'user_log' => 50,
'post_log' => 50,
'remote_size' => 2048,
'remote_ext' => 'zip,rar,7z',
'alone_page' => false,
'remote' => !isset($settings['down_remote_to_local_s']) || !empty($settings['down_remote_to_local_s']),
'verify_nonce' => !isset($settings['down_verify_nonce']) || !empty($settings['down_verify_nonce']),
'user_log' => max(0, (int) ($settings['down_user_log'] ?? 50)),
'post_log' => max(0, (int) ($settings['down_post_log'] ?? 50)),
'remote_size' => max(0, (int) ($settings['down_remote_to_local_size'] ?? 2048)),
'remote_ext' => sanitize_text_field((string) ($settings['down_remote_to_local_ext'] ?? 'zip,rar,7z')),
'alone_page' => !empty($settings['down_alone_page']),
],
// 内容收银台优惠码:不再提供全局开关,默认关闭。
'coupon_post_s' => false,
'coupon_desc' => '',
// 内容收银台优惠码:全局开关 + 默认说明。
'coupon_post_s' => !empty($settings['coupon_post_s']),
'coupon_desc' => sanitize_textarea_field((string) ($settings['coupon_desc'] ?? '')),
];
}
@@ -87,6 +89,7 @@ class PaymentRuntime {
return [
'enabled' => !empty($settings['pay_balance_s']),
'withdraw_enabled' => !empty($settings['pay_balance_withdraw_s']),
'desc' => $desc,
'packages_raw' => $packages,
'package_count' => self::count_structured_lines($packages),
@@ -279,28 +282,64 @@ class PaymentRuntime {
}
/**
* Affiliate policy. Layout follows the reference theme: one rebate rule
* set per user tier (pay_rebate_user_s / _1 / _2 + pay_rebate_ratio*).
*
* @return array<string,mixed>
*/
public static function get_payment_affiliate_settings(): array {
$settings = Settings::get_all();
$clamp_ratio = static fn($value): int => max(0, min(100, (int) $value));
$types = (array) ($settings['affiliate_order_types'] ?? ['membership', 'content']);
$types = array_values(array_intersect(['membership', 'content', 'credits'], array_map('sanitize_key', $types)));
if (!$types) { $types = ['membership', 'content']; }
$resolve_types = static function (array $types): array {
$types = array_values(array_intersect(['all', 'membership', 'content', 'credits'], array_map('sanitize_key', $types)));
// 「全部订单」展开为全部可返佣订单类型。
if (in_array('all', $types, true)) {
return ['membership', 'content', 'credits'];
}
return $types;
};
$types_by_level = [
0 => $resolve_types((array) ($settings['pay_rebate_user_s'] ?? [])),
1 => $resolve_types((array) ($settings['pay_rebate_user_s_1'] ?? ['all'])),
2 => $resolve_types((array) ($settings['pay_rebate_user_s_2'] ?? ['all'])),
];
$judgment = sanitize_key((string) ($settings['pay_rebate_judgment'] ?? 'all'));
if (!in_array($judgment, ['all', 'link'], true)) {
$judgment = 'all';
}
return [
'enabled' => !empty($settings['affiliate_enabled']),
'enabled' => !empty($settings['pay_rebate_s']),
'judgment' => $judgment,
'show_users' => !isset($settings['pay_rebate_show_users']) || !empty($settings['pay_rebate_show_users']),
'self_rebate' => !isset($settings['pay_rebate_self_s']) || !empty($settings['pay_rebate_self_s']),
'ratios' => [
'user' => $clamp_ratio($settings['affiliate_ratio_user'] ?? 5),
'vip_1' => $clamp_ratio($settings['affiliate_ratio_vip_1'] ?? 5),
'vip_2' => $clamp_ratio($settings['affiliate_ratio_vip_2'] ?? 5),
'user' => $clamp_ratio($settings['pay_rebate_ratio'] ?? 5),
'vip_1' => $clamp_ratio($settings['pay_rebate_ratio_vip_1'] ?? 10),
'vip_2' => $clamp_ratio($settings['pay_rebate_ratio_vip_2'] ?? 20),
],
'order_types' => $types,
'order_types' => $types_by_level[0],
'order_types_by_level' => $types_by_level,
'window_days' => (int) CreditsRuntime::get_referral_settings()['window_days'],
'settlement_days' => max(0, min(90, (int) ($settings['affiliate_settlement_days'] ?? 7))),
'promotion_text' => sanitize_textarea_field((string) ($settings['affiliate_promotion_text'] ?? '')),
'promotion_text' => sanitize_textarea_field((string) ($settings['pay_rebate_text_details'] ?? '')),
];
}
/**
* 某等级推广者可获返佣的订单类型;空数组代表该等级用户不参与推广返佣。
*
* @return array<int,string>
*/
public static function affiliate_order_types_for_level(int $level): array {
$settings = self::get_payment_affiliate_settings();
$key = $level >= 2 ? 2 : ($level >= 1 ? 1 : 0);
return (array) ($settings['order_types_by_level'][$key] ?? []);
}
public static function affiliate_enabled(): bool { return !empty(self::get_payment_affiliate_settings()['enabled']); }
public static function affiliate_ratio_for_user(int $user_id): int {
$level = function_exists('aksrt_get_user_vip_level') ? (int) aksrt_get_user_vip_level($user_id) : 0;
@@ -318,26 +357,55 @@ class PaymentRuntime {
}
/**
* Gateway channel selection. WeChat / Alipay each pick between the
* official SDK and 易支付; PayPal / Stripe are standalone toggles.
*
* @return array<string,mixed>
*/
public static function get_payment_gateway_settings(): array {
$settings = Settings::get_all();
$gateway_keys = ['wechat', 'alipay', 'paypal', 'stripe', 'balance', 'card_pass', 'epay'];
$gateways = [];
foreach ($gateway_keys as $gw) {
$gateways[$gw] = !empty($settings["payment_{$gw}_enabled"]);
$wechat = sanitize_key((string) ($settings['pay_wechat_sdk_options'] ?? 'null'));
if (!in_array($wechat, ['official_wechat', 'epay', 'null'], true)) {
$wechat = 'null';
}
$alipay = sanitize_key((string) ($settings['pay_alipay_sdk_options'] ?? 'null'));
if (!in_array($alipay, ['official_alipay', 'epay', 'null'], true)) {
$alipay = 'null';
}
$paypal_enabled = !empty($settings['pay_paypal_sdk_s']);
$stripe_enabled = !empty($settings['pay_stripe_sdk_s']);
$balance_enabled = !empty($settings['pay_balance_s']);
$card_pass_enabled = !empty($settings['pay_balance_pass_charge_s']);
return [
'help_text' => __('以渠道开关与凭据是否齐全为准;异步回调由各网关验签。卡密为兑换入口,不进入收银台。', 'aksrt'),
'gateways' => $gateways,
'epay' => [
'apiurl' => esc_url_raw((string) ($settings['epay_apiurl'] ?? '')),
'pid' => sanitize_text_field((string) ($settings['epay_pid'] ?? '')),
'key' => sanitize_text_field((string) ($settings['epay_key'] ?? '')),
'channel_alipay' => !array_key_exists('epay_channel_alipay', $settings) || !empty($settings['epay_channel_alipay']),
'channel_wxpay' => !array_key_exists('epay_channel_wxpay', $settings) || !empty($settings['epay_channel_wxpay']),
'device' => sanitize_key((string) ($settings['epay_device'] ?? 'auto')),
'help_text' => __('微信 / 支付宝可在官方与易支付之间选择;PayPal、Stripe 独立开关。异步回调由各网关验签。', 'aksrt'),
'wechat_sdk_options' => $wechat,
'alipay_sdk_options' => $alipay,
'paypal_enabled' => $paypal_enabled,
'stripe_enabled' => $stripe_enabled,
'balance_enabled' => $balance_enabled,
'card_pass_enabled' => $card_pass_enabled,
'gateways' => [
'wechat' => $wechat === 'official_wechat',
'alipay' => $alipay === 'official_alipay',
'paypal' => $paypal_enabled,
'stripe' => $stripe_enabled,
'balance' => $balance_enabled,
'card_pass' => $card_pass_enabled,
'epay' => $wechat === 'epay' || $alipay === 'epay',
],
'currency' => [
'mark' => sanitize_text_field((string) ($settings['pay_currency_mark'] ?? '¥')),
'unit' => sanitize_text_field((string) ($settings['pay_currency_unit'] ?? '元')),
],
'custom_title_s' => !empty($settings['pay_sdk_custom_title_s']),
'custom_title' => sanitize_text_field((string) ($settings['pay_sdk_custom_title'] ?? '')),
'epay' => [
'apiurl' => esc_url_raw((string) ($settings['epay_apiurl'] ?? '')),
'pid' => sanitize_text_field((string) ($settings['epay_pid'] ?? '')),
'key' => sanitize_text_field((string) ($settings['epay_key'] ?? '')),
'device' => sanitize_key((string) ($settings['epay_device'] ?? 'auto')),
],
];
}
@@ -352,7 +420,6 @@ class PaymentRuntime {
$expiry = max(5, min(1440, (int) ($s['payment_order_expiry'] ?? 30)));
$cookie_day = max(1, min(31, (int) ($s['pay_cookie_day'] ?? 15)));
$max_minutes = max(5, min(1440, (int) ($s['payment_order_max_minutes'] ?? 30)));
$box_position = sanitize_key((string) ($s['pay_box_position'] ?? 'top'));
if (!in_array($box_position, ['box_top', 'top', 'bottom', 'box_bottom'], true)) {
@@ -378,7 +445,6 @@ class PaymentRuntime {
'cookie_day' => $cookie_day,
'no_logged_remind' => sanitize_textarea_field((string) ($s['pay_no_logged_remind'] ?? '')),
'wait_float' => !isset($s['pay_wait_float_s']) || !empty($s['pay_wait_float_s']),
'order_max_minutes' => $max_minutes,
'mark' => sanitize_text_field((string) ($s['pay_mark'] ?? '付费')),
'box_position' => $box_position,
'show_ip' => !empty($s['payment_show_ip']),
@@ -387,13 +453,39 @@ class PaymentRuntime {
'show_create_time' => !isset($s['payment_show_create_time']) || !empty($s['payment_show_create_time']),
'show_pay_time' => !isset($s['payment_show_pay_time']) || !empty($s['payment_show_pay_time']),
'status_texts' => $status_texts,
'service' => [
'text' => sanitize_textarea_field((string) ($s['pay_service'] ?? '')),
'icon' => sanitize_text_field((string) ($s['pay_service_icon'] ?? '')),
'value' => sanitize_text_field((string) ($s['pay_service_value'] ?? '')),
'qq' => sanitize_text_field((string) ($s['pay_service_qq'] ?? '')),
'wechat' => esc_url_raw((string) ($s['pay_service_wechat'] ?? '')),
],
'service' => self::format_service_items((array) ($s['pay_service'] ?? [])),
];
}
/**
* 客户服务:参考主题为 {value, icon} 数组;首项同时回填旧单值键,兼容既有消费方。
*
* @param array<int,mixed> $items
* @return array<string,mixed>
*/
private static function format_service_items(array $items): array {
$clean = [];
foreach ($items as $row) {
if (!is_array($row)) {
continue;
}
$value = sanitize_textarea_field((string) ($row['value'] ?? ''));
if ($value === '') {
continue;
}
$clean[] = [
'value' => $value,
'icon' => sanitize_text_field((string) ($row['icon'] ?? '')),
];
}
$first = $clean[0] ?? [];
return [
'items' => $clean,
'text' => (string) ($first['value'] ?? ''),
'icon' => (string) ($first['icon'] ?? ''),
'value' => (string) ($first['value'] ?? ''),
'qq' => '',
'wechat' => '',
];
}
@@ -462,48 +554,43 @@ class PaymentRuntime {
/**
* Whether a registered adapter is admin-enabled.
* Maps gateway ids (wechatpay) to schema toggles (payment_wechat_enabled).
* Gateway ids (wechatpay) map to the reference-theme channel selectors:
* pay_wechat_sdk_options / pay_alipay_sdk_options / pay_paypal_sdk_s / pay_stripe_sdk_s.
*/
public static function is_gateway_enabled(string $gateway_id): bool {
$settings = Settings::get_all();
$gateway_id = sanitize_key($gateway_id);
$map = [
'alipay' => 'payment_alipay_enabled',
'wechatpay' => 'payment_wechat_enabled',
'paypal' => 'payment_paypal_enabled',
'stripe' => 'payment_stripe_enabled',
'balance' => 'payment_balance_enabled',
'card_pass' => 'payment_card_pass_enabled',
'epay' => 'payment_epay_enabled',
'epay_alipay' => 'payment_epay_enabled',
'epay_wxpay' => 'payment_epay_enabled',
];
$key = $map[$gateway_id] ?? '';
if ($key === '') {
return false;
$wechat = sanitize_key((string) ($settings['pay_wechat_sdk_options'] ?? 'null'));
if (!in_array($wechat, ['official_wechat', 'epay', 'null'], true)) {
$wechat = 'null';
}
if ($gateway_id === 'balance') {
// Master: 余额充值 → 启用余额功能. Optional kill-switch: payment_balance_enabled=false.
// Missing key (legacy sites) follows pay_balance_s so "open wallet" alone enables pay.
if (empty($settings['pay_balance_s'])) {
return false;
}
if (array_key_exists('payment_balance_enabled', $settings) && empty($settings['payment_balance_enabled'])) {
return false;
}
return true;
$alipay = sanitize_key((string) ($settings['pay_alipay_sdk_options'] ?? 'null'));
if (!in_array($alipay, ['official_alipay', 'epay', 'null'], true)) {
$alipay = 'null';
}
if (empty($settings[$key])) {
return false;
switch ($gateway_id) {
case 'alipay':
return $alipay === 'official_alipay';
case 'wechatpay':
return $wechat === 'official_wechat';
case 'paypal':
return !empty($settings['pay_paypal_sdk_s']);
case 'stripe':
return !empty($settings['pay_stripe_sdk_s']);
case 'balance':
return !empty($settings['pay_balance_s']);
case 'card_pass':
return !empty($settings['pay_balance_pass_charge_s']);
case 'epay':
return $wechat === 'epay' || $alipay === 'epay';
case 'epay_alipay':
return $alipay === 'epay';
case 'epay_wxpay':
return $wechat === 'epay';
}
// Epay sub-channels require the matching channel switch (default on when key missing).
if ($gateway_id === 'epay_alipay') {
return !array_key_exists('epay_channel_alipay', $settings) || !empty($settings['epay_channel_alipay']);
}
if ($gateway_id === 'epay_wxpay') {
return !array_key_exists('epay_channel_wxpay', $settings) || !empty($settings['epay_channel_wxpay']);
}
return true;
return false;
}
private static function count_structured_lines(string $raw): int {
@@ -530,6 +617,9 @@ class PaymentRuntime {
}
/**
* Format recharge product rows (reference-theme group shape:
* price 充值金额 / pay_price 销售金额 / tag 小标签) into "支付|到账|标题" lines.
*
* @param array<int,mixed> $products
*/
private static function format_product_lines(array $products): string {
@@ -538,10 +628,11 @@ class PaymentRuntime {
if (!is_array($row)) {
continue;
}
$price = $row['pay_price'] ?? $row['price'] ?? '';
$value = $row['value'] ?? $row['balance'] ?? $price;
$title = $row['title'] ?? $row['name'] ?? '';
$lines[] = $price . '|' . $value . '|' . $title;
$price = max(0, (float) ($row['price'] ?? 0));
$pay_price = max(0, (float) ($row['pay_price'] ?? 0));
$pay = $pay_price > 0 ? $pay_price : $price;
$title = trim((string) ($row['tag'] ?? ''));
$lines[] = $pay . '|' . $price . '|' . $title;
}
return implode("\n", $lines);
}