Merge pull request 'fix(user-center): refresh revenue withdrawal state' (#391) from worktree-fix-revenue-center into main
Reviewed-on: CYL/wordpress-theme-aksrt#391
This commit is contained in:
commit
ae5beec7a6
3 files changed
+35
-4
No files matched your search
@@ -141,8 +141,9 @@
|
|||||||
|
|
||||||
.uc-reward-tabs {
|
.uc-reward-tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
overflow-x: auto;
|
overflow: hidden;
|
||||||
border-bottom: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
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 withdrawForm = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-form]');
|
||||||
var withdrawTip = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-tip]');
|
var withdrawTip = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-tip]');
|
||||||
var withdrawSubmit = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-submit]');
|
var withdrawSubmit = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-submit]');
|
||||||
@@ -224,6 +247,10 @@
|
|||||||
}
|
}
|
||||||
withdrawForm.reset();
|
withdrawForm.reset();
|
||||||
setWithdrawBusy(false);
|
setWithdrawBusy(false);
|
||||||
|
closeWithdrawModal();
|
||||||
|
reloadRevenuePanel().catch(function () {
|
||||||
|
if (typeof showToast === 'function') showToast('提现已提交,但收益数据刷新失败');
|
||||||
|
});
|
||||||
}).catch(function () { setWithdrawBusy(false); setWithdrawTip('网络错误,请稍后重试', true); });
|
}).catch(function () { setWithdrawBusy(false); setWithdrawTip('网络错误,请稍后重试', true); });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -277,9 +277,12 @@ class PaymentController extends ControllerBase {
|
|||||||
return $this->error('无效的提现 ID');
|
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->success(['message' => __('提现状态已更新', 'aksrt')]);
|
||||||
}
|
}
|
||||||
return $this->error(__('更新失败', 'aksrt'));
|
return $this->error(__('更新失败', 'aksrt'));
|
||||||
|
|||||||
Reference in new issue
Block a user