fix(tahesab): sync gateway and admin cash deposits as VKHBank charge
Route online wallet deposits to Tahesab/Zarin wallet() instead of leaving staff to post gold buy docs; keep «شارژ حساب» in accounting notes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -262,6 +262,9 @@ class WalletController extends Controller
|
|||||||
try {
|
try {
|
||||||
$data['direction'] = $deposit ? 0 : 1;
|
$data['direction'] = $deposit ? 0 : 1;
|
||||||
$data['withdraw_id'] = $Withdraw->id;
|
$data['withdraw_id'] = $Withdraw->id;
|
||||||
|
if ($deposit && trim((string) ($data['note'] ?? '')) === '') {
|
||||||
|
$data['note'] = 'شارژ حساب';
|
||||||
|
}
|
||||||
app(TahesabController::class)->wallet($data);
|
app(TahesabController::class)->wallet($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
report($e);
|
report($e);
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ class Controller extends BaseController
|
|||||||
'واریز طلایی', 'برداشت طلایی',
|
'واریز طلایی', 'برداشت طلایی',
|
||||||
'واریز درگاه', 'واریز آنلاین',
|
'واریز درگاه', 'واریز آنلاین',
|
||||||
'واریز به کیف پول', 'برداشت از کیف پول',
|
'واریز به کیف پول', 'برداشت از کیف پول',
|
||||||
'شارژ حساب', 'برداشت از حساب',
|
'برداشت از حساب',
|
||||||
'شارژ', 'دشارژ',
|
'شارژ', 'دشارژ',
|
||||||
'شارژ طلای کیف اصلی', 'برداشت طلای کیف اصلی',
|
'شارژ طلای کیف اصلی', 'برداشت طلای کیف اصلی',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ class WalletDepositCreditor
|
|||||||
report($e);
|
report($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->syncGatewayDepositToAccounting($user, $locked, $note);
|
||||||
|
|
||||||
$locked->loadMissing('customer');
|
$locked->loadMissing('customer');
|
||||||
$message = 'کاربر ' . ($locked->customer->name ?? '') . ' با شماره موبایل ' . ($locked->customer->mobile ?? '')
|
$message = 'کاربر ' . ($locked->customer->name ?? '') . ' با شماره موبایل ' . ($locked->customer->mobile ?? '')
|
||||||
. ' حساب خود را به مقدار ' . number_format((int) $locked->cash) . ' ریال شارژ کرد. با تشکر، '
|
. ' حساب خود را به مقدار ' . number_format((int) $locked->cash) . ' ریال شارژ کرد. با تشکر، '
|
||||||
@@ -90,4 +92,38 @@ class WalletDepositCreditor
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** سند بانکی تهحساب/زرین — قبلاً فقط پرگار میرفت و در تهحساب «خرید» دستی ثبت میشد */
|
||||||
|
private function syncGatewayDepositToAccounting(Customer $customer, Withdraw $withdraw, string $note): void
|
||||||
|
{
|
||||||
|
$cash = (int) round(abs((float) $withdraw->cash));
|
||||||
|
if ($cash <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$accountingNote = trim($note) !== '' ? $note : 'دریافت وجه بابت شارژ';
|
||||||
|
$payload = [
|
||||||
|
'customer_id' => (int) $customer->id,
|
||||||
|
'value' => $cash,
|
||||||
|
'direction' => 0,
|
||||||
|
'withdraw_id' => (int) $withdraw->id,
|
||||||
|
'note' => $accountingNote,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($this->config->isTahesabAccounting()) {
|
||||||
|
try {
|
||||||
|
app(\App\Http\Controllers\Admin\TahesabController::class)->wallet($payload);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
report($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->isZarinAccounting()) {
|
||||||
|
try {
|
||||||
|
app(\App\Http\Controllers\Admin\ZarinController::class)->wallet($payload);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
report($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user