borsecu withdraw bug fixed

This commit is contained in:
2026-07-06 22:10:40 +03:30
parent c05a24d57b
commit 20a884a874
@@ -31,15 +31,56 @@ class WalletController extends Controller
{
public function withdrawTable(Request $request)
{
$records = Withdraw::with(['transaction'])->where('customer_id', auth('customer')->id())->whereIn('sts', [2,1])->orderBy('id','desc');
$customerId = (int) auth('customer')->id();
$records = Withdraw::query()
->with(['transaction'])
->where('customer_id', $customerId);
Withdraw::scopeDeposits($records);
$records->where(function ($q) {
$q->where('cash', '>', 0)
->orWhere('gold', '>', 0);
})->orderByDesc('id');
TableEngine::create($records, $request->all())
->initSearch(['customer.name'])
->initSearch(['customer.name', 'note'])
->select([
'*',Withdraw::$SELECT_STS_STR,Withdraw::$SELECT_DAJ
'*', Withdraw::$SELECT_STS_STR, Withdraw::$SELECT_DAJ,
])->export($records);
foreach ($records['rows'] as &$record) {
$this->applyWithdrawDepositRowPresentation($record);
}
unset($record);
return response()->json($records);
}
private function applyWithdrawDepositRowPresentation($record): void
{
$record->title = $this->resolveWithdrawDepositListTitle($record);
$record->expire_at = $record->date_at ?? $record->created_at;
$record->type = 3;
$record->unit = 'ریال';
$sts = (int) ($record->sts ?? 0);
$record->sts_str = Withdraw::GetSts($sts) ?? (string) $sts;
}
private function resolveWithdrawDepositListTitle($record): string
{
$note = trim((string) ($record->note ?? ''));
if ($note !== '') {
return $note;
}
return match ((int) ($record->sts ?? 0)) {
4 => self::rialDepositTitle(),
5 => 'پاداش معرفی',
9 => 'سود زیر مجموعه',
default => self::rialDepositTitle(),
};
}
public function walletMe(WalletBalanceService $balanceService)
{
$customer = auth('customer')->user();