积分与余额账务系统硬切重构

This commit is contained in:
kate522 committed 2026-08-24 15:59:11 +08:00
1 parent ca12226b39
commit 5cae5b5c93
159 files changed
+7275 -4718

No files matched your search

-51
View File
@@ -48,54 +48,3 @@ function aksrt_get_orders_page_view(int $user_id, int $paged = 1, int $per_page
return $empty;
}
function aksrt_get_revenue_page_view(int $user_id): array {
$balance = 0.0;
$total_earned = 0.0;
$total_withdrawn = 0.0;
$records = [];
if (class_exists('\AKSRT\Credits\Balance')) {
$balance = (float) \AKSRT\Credits\Balance::balance($user_id);
}
if (class_exists('\AKSRT\Payment\Revenue')) {
$revenues = \AKSRT\Payment\Revenue::get_instance()->get_user_revenues($user_id, ['limit' => 200]);
foreach ($revenues as $rev) {
$row = is_array($rev) ? $rev : (array) $rev;
$total_earned += (float) ($row['amount'] ?? 0);
$records[] = [
'type' => 'earning',
'title' => (string) ($row['description'] ?? $row['type'] ?? __('创作分成', 'aksrt')),
'amount' => (float) ($row['amount'] ?? 0),
'created_at' => (string) ($row['created_at'] ?? ''),
];
}
}
if (class_exists('\AKSRT\Payment\Withdrawal')) {
$withdrawals = \AKSRT\Payment\Withdrawal::get_instance()->get_user_withdrawals($user_id, ['limit' => 200]);
foreach ($withdrawals as $w) {
$wrow = is_array($w) ? $w : (array) $w;
$total_withdrawn += (float) ($wrow['amount'] ?? 0);
$records[] = [
'type' => 'withdrawal',
'title' => __('提现', 'aksrt'),
'amount' => (float) ($wrow['amount'] ?? 0),
'created_at' => (string) ($wrow['created_at'] ?? ''),
'status' => (string) ($wrow['status'] ?? ''),
];
}
}
usort($records, static function ($a, $b) {
return strcmp($b['created_at'] ?? '', $a['created_at'] ?? '');
});
return [
'balance' => $balance,
'total_earned' => $total_earned,
'total_withdrawn' => $total_withdrawn,
'records' => $records,
];
}