fix(user-center): refresh revenue withdrawal state
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -141,8 +141,9 @@
|
||||
|
||||
.uc-reward-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
overflow-x: auto;
|
||||
overflow: hidden;
|
||||
border-bottom: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,30 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
var withdrawModal = document.querySelector('[data-aksrt-commission-withdraw-modal]');
|
||||
function reloadRevenuePanel() {
|
||||
var current = document.querySelector('[data-aksrt-revenue-page]');
|
||||
if (!current) return Promise.resolve();
|
||||
var panelUrl = rest + '/user-center/panel/revenue';
|
||||
var query = new URL(window.location.href).searchParams;
|
||||
query.delete('tab');
|
||||
panelUrl += '?' + query.toString();
|
||||
return fetch(panelUrl, {
|
||||
credentials: 'same-origin',
|
||||
headers: { 'X-WP-Nonce': data.restNonce || data.nonce || '' }
|
||||
}).then(function (response) {
|
||||
return response.json().then(function (payload) {
|
||||
if (!response.ok || !payload.success || !payload.data || !payload.data.html) throw new Error('revenue-refresh-failed');
|
||||
var wrapper = document.createElement('div');
|
||||
wrapper.innerHTML = payload.data.html;
|
||||
var next = wrapper.firstElementChild;
|
||||
if (!next) throw new Error('revenue-html-empty');
|
||||
current.replaceWith(next);
|
||||
window.AKSRTRevenueCenterInit(next);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var withdrawModal = root.querySelector('[data-aksrt-commission-withdraw-modal]') || document.querySelector('[data-aksrt-commission-withdraw-modal]');
|
||||
var withdrawForm = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-form]');
|
||||
var withdrawTip = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-tip]');
|
||||
var withdrawSubmit = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-submit]');
|
||||
@@ -224,6 +247,10 @@
|
||||
}
|
||||
withdrawForm.reset();
|
||||
setWithdrawBusy(false);
|
||||
closeWithdrawModal();
|
||||
reloadRevenuePanel().catch(function () {
|
||||
if (typeof showToast === 'function') showToast('提现已提交,但收益数据刷新失败');
|
||||
});
|
||||
}).catch(function () { setWithdrawBusy(false); setWithdrawTip('网络错误,请稍后重试', true); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -277,9 +277,12 @@ class PaymentController extends ControllerBase {
|
||||
return $this->error('无效的提现 ID');
|
||||
}
|
||||
|
||||
$success = \AKSRT\Payment\Withdrawal::get_instance()->update_status($id, $new_status, $note);
|
||||
$result = \AKSRT\Payment\Withdrawal::get_instance()->process_status_change($id, $new_status, $note);
|
||||
|
||||
if ($success) {
|
||||
if (is_wp_error($result)) {
|
||||
return $this->error($result->get_error_message());
|
||||
}
|
||||
if ($result) {
|
||||
return $this->success(['message' => __('提现状态已更新', 'aksrt')]);
|
||||
}
|
||||
return $this->error(__('更新失败', 'aksrt'));
|
||||
|
||||
Reference in New Issue
Block a user