feat(admin): manual deposit recording, transaction export, ticket filters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
40bf6b54f9
commit
0cdf224309
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Enums\TransactionStatus;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
final class TransactionsExport implements BrandedReport
|
||||
{
|
||||
public function __construct(private readonly Builder $query) {}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return 'Danh sách giao dịch nạp tiền';
|
||||
}
|
||||
|
||||
public function query(): Builder
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
public function moneyColumns(): array
|
||||
{
|
||||
return ['E', 'F', 'G'];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Mã giao dịch', 'Khách hàng', 'Email', 'Số điện thoại', 'Khách khai', 'Thực nhận', 'Chênh lệch',
|
||||
'Trạng thái', 'Chứng từ', 'Người nạp', 'Ghi chú', 'Ngày tạo',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
*/
|
||||
public function map($transaction): array
|
||||
{
|
||||
$received = $transaction->received_amount === null ? null : (int) $transaction->received_amount;
|
||||
|
||||
return [
|
||||
$transaction->public_code ?? $transaction->trans,
|
||||
$transaction->customer?->fullname,
|
||||
$transaction->customer?->email,
|
||||
$transaction->customer?->phone,
|
||||
(int) $transaction->amount,
|
||||
$received,
|
||||
$received === null ? null : $received - (int) $transaction->amount,
|
||||
$this->statusLabel($transaction),
|
||||
$transaction->proof_image ? 'Có' : 'Không',
|
||||
$transaction->user?->name ?: $transaction->user?->username,
|
||||
$transaction->note,
|
||||
$transaction->created_at?->format('d/m/Y H:i'),
|
||||
];
|
||||
}
|
||||
|
||||
private function statusLabel(Transaction $transaction): string
|
||||
{
|
||||
if ((int) $transaction->status === TransactionStatus::PENDING->value && ! $transaction->proof_image) {
|
||||
return 'Chưa gửi chứng từ';
|
||||
}
|
||||
|
||||
return TransactionStatus::tryFrom((int) $transaction->status)?->label() ?? (string) $transaction->status;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user