zarbox added 9
This commit is contained in:
@@ -85,21 +85,6 @@ class WalletController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($records['rows'] as &$record) {
|
foreach ($records['rows'] as &$record) {
|
||||||
|
|
||||||
// اولویت اول: واریز توسط ادمین
|
|
||||||
// حتی اگر title قبلاً برداشت ریالی ذخیره شده باشد، باید اصلاح شود
|
|
||||||
if (
|
|
||||||
isset($record->withdraw) &&
|
|
||||||
(int) $record->withdraw->sts === 4
|
|
||||||
) {
|
|
||||||
$record->title = "واریز ریالی";
|
|
||||||
|
|
||||||
// اگر میخوای تو دیتابیس هم اصلاح بشه
|
|
||||||
$record->save();
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// بقیه رکوردها فقط اگر title ندارند یا تعریف نشده هستند اصلاح شوند
|
// بقیه رکوردها فقط اگر title ندارند یا تعریف نشده هستند اصلاح شوند
|
||||||
if (empty($record->title) || $record->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
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int) $record->type === 4 && empty($record->withdraw_id)) {
|
if ($this->isShopGoldTransaction($record)) {
|
||||||
$record->setRelation('withdraw', (object) ['sts_str' => 'درخواست از فروشگاه']);
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user