银行存取补充 user_currency_logs 流水记录

- CurrencySource 新增 BANK_DEPOSIT / BANK_WITHDRAW 两个来源枚举
- BankController deposit/withdraw 改用 UserCurrencyService::change() 记录 jjb 变动
- AiFinanceService bankExcessGold/raiseWalletTo 补充 UserCurrencyService::change() 调用
- 银行存取双轨记录:bank_logs(银行流水)+ user_currency_logs(金币流水)
This commit is contained in:
pllx
2026-05-28 13:13:34 +08:00
parent ce6d71a4f2
commit dce0a52750
4 changed files with 31 additions and 10 deletions
+10 -2
View File
@@ -13,9 +13,12 @@
namespace App\Http\Controllers;
use App\Enums\CurrencySource;
use App\Models\BankLog;
use App\Models\Sysparam;
use App\Models\User;
use App\Models\UserCurrencyLog;
use App\Services\UserCurrencyService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
@@ -26,6 +29,9 @@ use Illuminate\Support\Facades\DB;
*/
class BankController extends Controller
{
public function __construct(
private readonly UserCurrencyService $currencyService,
) {}
/**
* 查询银行余额及最近20条流水记录
*/
@@ -107,7 +113,8 @@ class BankController extends Controller
}
DB::transaction(function () use ($user, $amount): void {
$user->decrement('jjb', $amount);
$this->currencyService->change($user, 'gold', -$amount, CurrencySource::BANK_DEPOSIT, "存入银行 {$amount} 金币");
$user->increment('bank_jjb', $amount);
BankLog::create([
@@ -151,7 +158,8 @@ class BankController extends Controller
DB::transaction(function () use ($user, $amount): void {
$user->decrement('bank_jjb', $amount);
$user->increment('jjb', $amount);
$this->currencyService->change($user, 'gold', $amount, CurrencySource::BANK_WITHDRAW, "取出银行存款 {$amount} 金币");
BankLog::create([
'user_id' => $user->id,