diff --git a/assets/admin/src/schema/sections/payment/affiliate.js b/assets/admin/src/schema/sections/payment/affiliate.js index d117e385..0bd2368b 100644 --- a/assets/admin/src/schema/sections/payment/affiliate.js +++ b/assets/admin/src/schema/sections/payment/affiliate.js @@ -12,8 +12,6 @@ export const affiliateSchema = { affiliate_allow_self_purchase: false, affiliate_show_stats: true, affiliate_promotion_text: '', - affiliate_earnings_text: '', - affiliate_withdrawal_agreement: '', affiliate_payout_channels: ['alipay', 'wechat'], affiliate_min_withdrawal: 50, affiliate_withdrawal_fee: 5, @@ -55,8 +53,6 @@ export const affiliateSchema = { icon: 'fas fa-pen-fancy', fields: [ { key: 'affiliate_promotion_text', label: '推广说明', type: 'textarea', default: '', dependsOn: { key: 'affiliate_enabled', value: true } }, - { key: 'affiliate_earnings_text', label: '收益说明', type: 'textarea', default: '', dependsOn: { key: 'affiliate_enabled', value: true } }, - { key: 'affiliate_withdrawal_agreement', label: '提现协议', type: 'textarea', default: '', dependsOn: { key: 'affiliate_enabled', value: true } }, ], }, ], diff --git a/assets/css/routes/user-center/promotion.css b/assets/css/routes/user-center/promotion.css index 7af47243..1deff321 100644 --- a/assets/css/routes/user-center/promotion.css +++ b/assets/css/routes/user-center/promotion.css @@ -87,9 +87,238 @@ .uc-content .uc-affiliate-stats article strong { color:var(--primary,#2563eb); font-size:24px; font-variant-numeric:tabular-nums; } .uc-content .uc-affiliate-link-card [data-affiliate-feedback] { grid-column:1/-1; margin:0; min-height:18px; color:var(--success,#16a34a); font-size:12px; } .uc-content .uc-affiliate-link-card [data-affiliate-feedback].is-error { color:var(--danger,#dc2626); } -.uc-content .uc-affiliate-accounts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; padding-top:4px; } -.uc-content .uc-affiliate-accounts label { display:grid; gap:5px; color:var(--muted,#6b7280); font-size:12px; } -.uc-content .uc-affiliate-accounts input { height:38px; padding:0 10px; border:1px solid var(--border,#e5e7eb); border-radius:8px; background:var(--surface,#fff); color:var(--text,#111827); } -.uc-content .uc-affiliate-accounts button { justify-self:start; } -.uc-content .uc-affiliate-accounts p { grid-column:1/-1; margin:0; color:var(--success,#16a34a); font-size:12px; } -@media (max-width:640px) { .uc-content .aksrt-affiliate-panel { padding:16px; } .uc-content .uc-affiliate-link-card { align-items:stretch; flex-direction:column; } .uc-content .uc-affiliate-link-card button { width:100%; } .uc-content .uc-affiliate-stats,.uc-content .uc-affiliate-accounts { grid-template-columns:1fr; } } +@media (max-width:640px) { .uc-content .aksrt-affiliate-panel { padding:16px; } .uc-content .uc-affiliate-link-card { align-items:stretch; flex-direction:column; } .uc-content .uc-affiliate-link-card button { width:100%; } .uc-content .uc-affiliate-stats { grid-template-columns:1fr; } } + +/* 推广收益新版布局:顶部概览卡 + 单一推荐奖励白卡。 */ +.uc-content .uc-revenue-panel { + gap: 22px; +} + +.uc-content .uc-commission-summary { + gap: 18px; +} + +.uc-content .uc-commission-card { + min-height: 174px; + padding: 24px 26px; + border: 0; + border-radius: 18px; + box-shadow: 0 12px 28px rgba(15, 23, 42, .08); +} + +.uc-content .uc-commission-card--ratio { + color: #fff; + background: + radial-gradient(circle at 86% 4%, rgba(255, 255, 255, .16) 0 22%, transparent 22.5%), + radial-gradient(circle at 32% 110%, rgba(213, 37, 43, .28) 0 42%, transparent 42.5%), + linear-gradient(135deg, #ff6d61 0%, #ff3e3e 100%); +} + +.uc-content .uc-commission-card--balance { + color: #fff; + background: + radial-gradient(circle at 14% 96%, rgba(11, 103, 204, .2) 0 44%, transparent 44.5%), + radial-gradient(circle at 100% 100%, rgba(255, 255, 255, .12) 0 28%, transparent 28.5%), + linear-gradient(135deg, #48b7ee 0%, #2b8fe8 100%); +} + +.uc-content .uc-commission-card__body { + display: grid; + align-content: space-between; + min-height: 126px; +} + +.uc-content .uc-commission-card__body > span, +.uc-content .uc-commission-card__body > p, +.uc-content .uc-commission-card__body strong, +.uc-content .uc-commission-card__body strong small { + color: inherit; +} + +.uc-content .uc-commission-card__body > span:first-child { + margin: 0; + font-size: 18px; + font-weight: 700; +} + +.uc-content .uc-commission-card__body strong { + font-size: 42px; + line-height: 1; +} + +.uc-content .uc-commission-card__body strong small { + margin-left: 4px; + font-size: 18px; +} + +.uc-content .uc-commission-card__body > span:last-child, +.uc-content .uc-commission-card__body > p { + margin: 0; + font-size: 14px; + opacity: .92; +} + +.uc-content .uc-commission-card--ratio .uc-commission-card__body strong { + color: inherit; +} + +.uc-content .uc-commission-card__action { + align-self: center; + margin-left: auto; + padding: 10px 16px; + border: 0; + border-radius: 999px; + color: #fff; + background: rgba(255, 255, 255, .14); + font-size: 14px; + backdrop-filter: blur(4px); +} + +.uc-content .uc-commission-card__action:hover { + background: rgba(255, 255, 255, .24); +} + +.uc-content .aksrt-affiliate-panel { + gap: 24px; + padding: 34px 44px 38px; + border: 0; + border-radius: 18px; + background: var(--surface-1, #fff); + box-shadow: 0 8px 26px rgba(15, 23, 42, .06); +} + +.uc-content .uc-panel-heading { + padding-bottom: 20px; + border-bottom: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08)); +} + +.uc-content .uc-panel-heading h2 { + display: inline-block; + position: relative; + margin: 0 0 10px; + font-size: 20px; +} + +.uc-content .uc-panel-heading h2::after { + position: absolute; + right: 0; + bottom: -11px; + left: 0; + height: 3px; + border-radius: 999px; + background: #f1498c; + content: ""; +} + +.uc-content .uc-panel-heading p { + font-size: 16px; +} + +.uc-content .uc-affiliate-link-card { + display: grid; + grid-template-columns: auto minmax(0, 1fr) auto; + align-items: center; + gap: 12px; + padding: 0; + background: transparent; +} + +.uc-content .uc-affiliate-link-card > div { + display: contents; +} + +.uc-content .uc-affiliate-link-card > div > span { + color: var(--color-ink-4); + font-size: 15px; +} + +.uc-content .uc-affiliate-link-card input { + height: 42px; + border: 0; + border-radius: 7px; + color: #ef5370; + background: #fff0f2; + font-size: 15px; +} + +.uc-content .uc-affiliate-link-card button { + min-height: 42px; + border-radius: 7px; + white-space: nowrap; +} + +.uc-content .uc-affiliate-link-card [data-affiliate-feedback] { + grid-column: 2 / -1; +} + +.uc-content .uc-affiliate-stats { + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 12px; +} + +.uc-content .uc-affiliate-stats article { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 48px; + padding: 0 14px; + border: 0; + border-radius: 8px; + background: var(--surface-2, #f7f8fa); +} + +.uc-content .uc-affiliate-stats article strong { + color: var(--color-primary); + font-size: 16px; +} + +.uc-content .uc-affiliate-stats article:first-child strong { + color: #e94568; +} + +.uc-content .uc-affiliate-note { + margin-top: -8px; + font-size: 13px; +} + +@media (max-width: 720px) { + .uc-content .uc-commission-summary { + grid-template-columns: 1fr; + } + + .uc-content .aksrt-affiliate-panel { + padding: 24px 20px 28px; + } +} + +@media (max-width: 560px) { + .uc-content .uc-commission-card { + min-height: 150px; + padding: 20px; + } + + .uc-content .uc-commission-card__body { + min-height: 108px; + } + + .uc-content .uc-commission-card__body strong { + font-size: 36px; + } + + .uc-content .uc-affiliate-link-card { + grid-template-columns: 1fr; + } + + .uc-content .uc-affiliate-link-card > div { + display: grid; + gap: 6px; + } + + .uc-content .uc-affiliate-link-card [data-affiliate-feedback] { + grid-column: 1; + } + + .uc-content .uc-affiliate-stats { + grid-template-columns: 1fr; + } +} diff --git a/assets/js/credits.js b/assets/js/credits.js index 0ef6c28b..ecb6a019 100644 --- a/assets/js/credits.js +++ b/assets/js/credits.js @@ -407,13 +407,6 @@ if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(input.value).then(done).catch(function () { input.focus(); input.select(); setFeedback('复制失败,请手动复制。', true); }); else { input.focus(); input.select(); try { document.execCommand('copy'); done(); } catch (e) { setFeedback('复制失败,请手动复制。', true); } } }); - var accountForm = root.querySelector('[data-affiliate-accounts]'); - if (accountForm) accountForm.addEventListener('submit', function (event) { - event.preventDefault(); - var feedback = accountForm.querySelector('[data-affiliate-account-feedback]'); - var accounts = {}; new FormData(accountForm).forEach(function (value, key) { if (String(value).trim()) accounts[key] = String(value).trim(); }); - api('/promotion/payout-accounts', { method: 'PUT', body: JSON.stringify({ accounts: accounts }) }).then(function (r) { if (feedback) feedback.textContent = r.ok ? '收款方式已保存。' : ((r.json && r.json.message) || '保存失败。'); }).catch(function () { if (feedback) feedback.textContent = '网络错误,请稍后重试。'; }); - }); } window.AKSRTAffiliatePromotionInit = initAffiliatePromotion; diff --git a/inc/helpers/user-center-renderers/profile-revenue.php b/inc/helpers/user-center-renderers/profile-revenue.php index 3a614945..0c31f62e 100644 --- a/inc/helpers/user-center-renderers/profile-revenue.php +++ b/inc/helpers/user-center-renderers/profile-revenue.php @@ -39,7 +39,7 @@ $available_commission = class_exists('\AKSRT\Credits\Balance') : (float) ($commission_stats['settled'] ?? 0); $vip_ratios = []; $commission_ratio = (float) ($affiliate['ratio'] ?? 0); -$details_text = trim((string) ($affiliate['earnings_text'] ?? '')); +$details_text = trim((string) ($affiliate['promotion_text'] ?? '')); if ($details_text === '') { $details_text = __('好友通过推广链接完成符合条件的订单后,系统会按当前佣金比例记录返佣,结算后进入可提现余额。', 'aksrt'); } @@ -85,9 +85,28 @@ $status_labels = [ ]; ?>
+
+
+
+ + % +

0 ? esc_html__('普通用户推广订单返佣比例', 'aksrt') : esc_html__('暂未参与', 'aksrt'); ?>

+
+
+
+
+ + ¥ + +
+ + + +
+
-

+

-
- - - -

-

-
-
-
-
-
- - % -

-
-
-
-
-
- - - -
- - - -
-
-

- +

+
@@ -171,6 +163,7 @@ $status_labels = [

+
'text', 'title' => '文案设置', 'fields' => [ ['key' => 'affiliate_promotion_text', 'label' => '推广说明', 'type' => 'textarea', 'default' => ''], - ['key' => 'affiliate_earnings_text', 'label' => '收益说明', 'type' => 'textarea', 'default' => ''], - ['key' => 'affiliate_withdrawal_agreement', 'label' => '提现协议', 'type' => 'textarea', 'default' => ''], ['key' => 'affiliate_payout_channels', 'label' => '可用收款渠道', 'type' => 'checkbox', 'options' => [['value' => 'alipay', 'label' => '支付宝收款码'], ['value' => 'wechat', 'label' => '微信收款码']], 'default' => ['alipay', 'wechat']], ]], ], diff --git a/src/Payment/ReferralAttribution.php b/src/Payment/ReferralAttribution.php index dc5139f6..bd5a4ab7 100644 --- a/src/Payment/ReferralAttribution.php +++ b/src/Payment/ReferralAttribution.php @@ -146,12 +146,6 @@ final class ReferralAttribution { 'callback' => [$this, 'rest_me'], 'permission_callback' => static fn() => is_user_logged_in(), ]); - register_rest_route('aksrt/v1', '/promotion/payout-accounts', [ - 'methods' => \WP_REST_Server::EDITABLE, - 'callback' => [$this, 'rest_save_payout_accounts'], - 'permission_callback' => static fn() => is_user_logged_in(), - 'args' => ['accounts' => ['required' => true, 'type' => 'array']], - ]); } public function rest_me(): \WP_REST_Response { @@ -169,29 +163,6 @@ final class ReferralAttribution { ], 200); } - public function rest_save_payout_accounts(\WP_REST_Request $request): \WP_REST_Response|\WP_Error { - $accounts = $request->get_param('accounts'); - if (!is_array($accounts)) { - return new \WP_Error('aksrt_payout_accounts', __('收款账户格式无效。', 'aksrt'), ['status' => 400]); - } - global $wpdb; - $table = \AKSRT\Core\DBMigrator::table('payout_account'); - if ($table === '') { - return new \WP_Error('aksrt_payout_unavailable', __('收款账户服务不可用。', 'aksrt'), ['status' => 500]); - } - $uid = get_current_user_id(); - $now = current_time('mysql', true); - foreach (['alipay', 'wechat'] as $channel) { - $value = isset($accounts[$channel]) ? sanitize_text_field((string) $accounts[$channel]) : ''; - if ($value === '') { - $wpdb->update($table, ['status' => 'inactive', 'updated_at' => $now], ['user_id' => $uid, 'channel' => $channel], ['%s', '%s'], ['%d', '%s']); - continue; - } - $wpdb->replace($table, ['user_id' => $uid, 'channel' => $channel, 'attachment_id' => 0, 'account_hash' => hash('sha256', $value), 'status' => 'active', 'created_at' => $now, 'updated_at' => $now], ['%d', '%s', '%d', '%s', '%s', '%s', '%s']); - } - return new \WP_REST_Response(['success' => true], 200); - } - private function resolve_promoter(string $code): int { $code = sanitize_key($code); if ($code === '') { diff --git a/src/Settings/PaymentRuntime.php b/src/Settings/PaymentRuntime.php index daf62497..ab394260 100644 --- a/src/Settings/PaymentRuntime.php +++ b/src/Settings/PaymentRuntime.php @@ -301,8 +301,6 @@ class PaymentRuntime { 'allow_self_purchase' => !empty($settings['affiliate_allow_self_purchase']), 'show_stats' => !isset($settings['affiliate_show_stats']) || !empty($settings['affiliate_show_stats']), 'promotion_text' => sanitize_textarea_field((string) ($settings['affiliate_promotion_text'] ?? '')), - 'earnings_text' => sanitize_textarea_field((string) ($settings['affiliate_earnings_text'] ?? '')), - 'withdrawal_agreement' => sanitize_textarea_field((string) ($settings['affiliate_withdrawal_agreement'] ?? '')), ]; }