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

This commit is contained in:
2026-08-24 15:59:11 +08:00
parent ca12226b39
commit 5cae5b5c93
159 changed files with 7275 additions and 4718 deletions
+19 -9
View File
@@ -609,9 +609,25 @@ class Badges {
if ($type === '' || $type === 'manually_add') {
continue;
}
$need = max(0, (float) ($item['get_val'] ?? 0));
$have = (float) self::metric_value($user_id, $type);
if ($have >= $need) {
if (in_array($type, ['creator_income', 'affiliate_commission'], true)) {
try {
$need_minor = \AKSRT\Ledger\AssetAmount::balance((string) ($item['get_val'] ?? '0'))->minor();
} catch (\InvalidArgumentException $e) {
continue;
}
$reason = $type;
$have_minor = \AKSRT\Ledger\LedgerQuery::get_instance()->sum_positive(
$user_id,
\AKSRT\Ledger\AssetType::BALANCE,
$reason
);
$qualified = $have_minor >= $need_minor;
} else {
$need = max(0, (float) ($item['get_val'] ?? 0));
$have = (float) self::metric_value($user_id, $type);
$qualified = $have >= $need;
}
if ($qualified) {
self::grant($user_id, $slug, 0);
$owned_map[$slug] = true;
}
@@ -678,12 +694,6 @@ class Badges {
}
return $sum;
case 'pay_income':
return (float) get_user_meta($user_id, 'aksrt_pay_income_sum', true);
case 'pay_rebate':
return (float) get_user_meta($user_id, 'aksrt_pay_rebate_sum', true);
default:
return 0.0;
}