feat: redesign promotion earnings cards

This commit is contained in:
kate522 committed 2026-08-16 20:15:56 +08:00
1 parent 6dbb556d60
commit 8799063c6c
7 files changed
+260 -82

No files matched your search

-29
View File
@@ -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 === '') {