feat: 添加货币格式化功能,更新多个控制器以支持金额和余额的格式化显示,增强 API 响应的可读性
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Admin\Risk;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Models\Draw;
|
||||
use App\Models\RiskPool;
|
||||
use App\Models\RiskPoolLockLog;
|
||||
use App\Support\AdminApiList;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Support\AdminApiList;
|
||||
use App\Models\RiskPoolLockLog;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* GET /api/v1/admin/draws/{draw}/risk-pools/{number_4d} — 单号码风险池详情 + 占用流水。
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Support\ApiResponse;
|
||||
use App\Models\TransferOrder;
|
||||
use App\Support\PaginationTrait;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Support\CurrencyFormatter;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Admin\TransferOrderListRequest;
|
||||
|
||||
@@ -96,6 +97,7 @@ final class TransferOrderListController extends Controller
|
||||
private function formatRow(TransferOrder $o): array
|
||||
{
|
||||
$p = $o->player;
|
||||
$amount = (int) $o->amount;
|
||||
|
||||
return [
|
||||
'id' => $o->id,
|
||||
@@ -107,7 +109,8 @@ final class TransferOrderListController extends Controller
|
||||
'nickname' => $p?->nickname,
|
||||
'direction' => $o->direction,
|
||||
'currency_code' => $o->currency_code,
|
||||
'amount' => (int) $o->amount,
|
||||
'amount' => $amount,
|
||||
'amount_formatted' => CurrencyFormatter::fromMinor($amount),
|
||||
'idempotent_key' => $o->idempotent_key,
|
||||
'status' => $o->status,
|
||||
'external_ref_no' => $o->external_ref_no,
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\WalletTxn;
|
||||
use App\Support\ApiResponse;
|
||||
use App\Support\PaginationTrait;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Support\CurrencyFormatter;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Admin\WalletTransactionListRequest;
|
||||
|
||||
@@ -100,6 +101,9 @@ final class WalletTransactionListController extends Controller
|
||||
private function formatRow(WalletTxn $t): array
|
||||
{
|
||||
$p = $t->player;
|
||||
$amount = (int) $t->amount;
|
||||
$balanceBefore = (int) $t->balance_before;
|
||||
$balanceAfter = (int) $t->balance_after;
|
||||
|
||||
return [
|
||||
'id' => $t->id,
|
||||
@@ -112,15 +116,17 @@ final class WalletTransactionListController extends Controller
|
||||
'biz_type' => $t->biz_type,
|
||||
'biz_no' => $t->biz_no,
|
||||
'direction' => (int) $t->direction,
|
||||
'amount' => (int) $t->amount,
|
||||
'balance_before' => (int) $t->balance_before,
|
||||
'balance_after' => (int) $t->balance_after,
|
||||
'amount' => $amount,
|
||||
'amount_formatted' => CurrencyFormatter::fromMinor($amount),
|
||||
'balance_before' => $balanceBefore,
|
||||
'balance_before_formatted' => CurrencyFormatter::fromMinor($balanceBefore),
|
||||
'balance_after' => $balanceAfter,
|
||||
'balance_after_formatted' => CurrencyFormatter::fromMinor($balanceAfter),
|
||||
'status' => $t->status,
|
||||
'external_ref_no' => $t->external_ref_no,
|
||||
'idempotent_key' => $t->idempotent_key,
|
||||
'remark' => $t->remark,
|
||||
'created_at' => $t->created_at?->toIso8601String(),
|
||||
/** 展示用「完成时间」;无业务终态时可与 created_at 相同 */
|
||||
'updated_at' => $t->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user