feat(payment): separate creator income settlement
This commit is contained in:
@@ -237,31 +237,31 @@ class PaymentRuntime {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>
|
||||
* Creator-income policy. Cash and points intentionally use separate ratio sets.
|
||||
*
|
||||
* @return array{enabled:bool,cycle_days:int,ratios:array<string,array<string,int>>,note:string}
|
||||
*/
|
||||
public static function get_payment_revenue_settings(): array {
|
||||
$settings = Settings::get_all();
|
||||
$note = trim((string) ($settings['payment_revenue_note'] ?? ''));
|
||||
$mode = sanitize_key((string) ($settings['payment_revenue_settlement_mode'] ?? 'automatic'));
|
||||
if (!in_array($mode, ['automatic', 'manual'], true)) {
|
||||
$mode = 'automatic';
|
||||
}
|
||||
$clamp_ratio = static fn ($value): int => max(0, min(100, (int) $value));
|
||||
|
||||
return [
|
||||
'enabled' => !empty($settings['pay_income_s']),
|
||||
'share_ratio' => max(0, min(100, (int) ($settings['payment_revenue_share_ratio'] ?? 60))),
|
||||
'ratio_vip1' => max(0, min(100, (int) ($settings['ratio_vip_1'] ?? 70))),
|
||||
'ratio_vip2' => max(0, min(100, (int) ($settings['ratio_vip_2'] ?? 80))),
|
||||
'settlement_threshold' => max(0, (int) ($settings['payment_revenue_settlement_threshold'] ?? 100)),
|
||||
'cycle_days' => max(1, min(365, (int) ($settings['payment_revenue_cycle_days'] ?? 30))),
|
||||
'settlement_mode' => $mode,
|
||||
'settlement_delay_hours' => max(0, min(8760, (int) ($settings['payment_revenue_settlement_delay_hours'] ?? 24))),
|
||||
'points_rule' => sanitize_textarea_field((string) ($settings['payment_revenue_points_rule'] ?? '')),
|
||||
'note' => $note !== '' ? $note : __('分成策略和台账结构已就绪,订单入账后自动按比例结算。', 'aksrt'),
|
||||
'display' => [
|
||||
'desc_details' => sanitize_textarea_field((string) ($settings['pay_income_desc_details'] ?? '')),
|
||||
'desc_page' => esc_url_raw((string) ($settings['pay_income_desc_page'] ?? '')),
|
||||
'enabled' => !empty($settings['pay_income_s']),
|
||||
'cycle_days' => max(1, min(365, (int) ($settings['payment_revenue_cycle_days'] ?? 30))),
|
||||
'ratios' => [
|
||||
'cash' => [
|
||||
'ordinary' => $clamp_ratio($settings['payment_revenue_cash_ratio_user'] ?? 60),
|
||||
'vip1' => $clamp_ratio($settings['payment_revenue_cash_ratio_vip_1'] ?? 70),
|
||||
'vip2' => $clamp_ratio($settings['payment_revenue_cash_ratio_vip_2'] ?? 80),
|
||||
],
|
||||
'points' => [
|
||||
'ordinary' => $clamp_ratio($settings['payment_revenue_points_ratio_user'] ?? 0),
|
||||
'vip1' => $clamp_ratio($settings['payment_revenue_points_ratio_vip_1'] ?? 0),
|
||||
'vip2' => $clamp_ratio($settings['payment_revenue_points_ratio_vip_2'] ?? 0),
|
||||
],
|
||||
],
|
||||
'note' => $note !== '' ? wp_kses_post($note) : __('<p>订单完成并经过结算周期后,作者分成会自动转入对应的钱包。</p>', 'aksrt'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user