zarbox added 9

This commit is contained in:
2026-06-04 19:09:58 +03:30
parent 5864be8855
commit 7a3d8ab661
@@ -85,21 +85,6 @@ class WalletController extends Controller
}
foreach ($records['rows'] as &$record) {
// اولویت اول: واریز توسط ادمین
// حتی اگر title قبلاً برداشت ریالی ذخیره شده باشد، باید اصلاح شود
if (
isset($record->withdraw) &&
(int) $record->withdraw->sts === 4
) {
$record->title = "واریز ریالی";
// اگر می‌خوای تو دیتابیس هم اصلاح بشه
$record->save();
continue;
}
// بقیه رکوردها فقط اگر title ندارند یا تعریف نشده هستند اصلاح شوند
if (empty($record->title) || $record->title == "تعریف نشده") {
@@ -463,16 +448,60 @@ class WalletController extends Controller
}
/**
* برداشت API فروشگاه (RequestsController) withdraw_id ندارد — برای UI همان withdraw.sts_str.
* متن وضعیت آبی UI — کلاینت: order.sts_str ?? withdraw.sts_str (بدون تغییر اپ).
*/
private function applyTransactionDisplayStatus($record): void
{
if (!empty($record->withdraw) || !empty($record->order)) {
if ((int) $record->type === 4 && empty($record->withdraw_id)) {
$this->setWithdrawStsStr($record, 'برداشت ریالی توسط فروشگاه');
return;
}
if ((int) $record->type === 4 && empty($record->withdraw_id)) {
$record->setRelation('withdraw', (object) ['sts_str' => 'درخواست از فروشگاه']);
if ($this->isShopGoldTransaction($record)) {
$this->setOrderStsStr($record, 'برداشت طلایی توسط فروشگاه');
return;
}
}
/** برداشت طلا از API خارجی (RequestsController::processGoldTransaction) */
private function isShopGoldTransaction($record): bool
{
if ((int) $record->type !== 10 || empty($record->order_id) || empty($record->order)) {
return false;
}
$order = $record->order;
if ((int) ($order->direction ?? 0) !== 2) {
return false;
}
$montify = trim((string) $this->Config('montify_name'));
if ($montify !== '' && str_contains((string) ($order->description ?? ''), $montify)) {
return true;
}
return (int) ($order->sts ?? 0) === 2
&& (int) ($order->payment_sts ?? 0) === 4
&& empty($record->withdraw_id);
}
private function setWithdrawStsStr($record, string $label): void
{
if ($record->withdraw instanceof Withdraw) {
$record->withdraw->setAttribute('sts_str', $label);
return;
}
$record->setRelation('withdraw', (object) ['sts_str' => $label]);
}
private function setOrderStsStr($record, string $label): void
{
if (!empty($record->order)) {
$record->order->setAttribute('sts_str', $label);
}
}