added zarin

This commit is contained in:
2026-07-23 20:24:58 +03:30
parent d8b685524b
commit 8a4a406e66
17 changed files with 2007 additions and 10 deletions
@@ -155,6 +155,16 @@ class WalletController extends Controller
}
}
if (app(ConfigService::class)->isZarinAccounting()) {
try {
$data['direction'] = $deposit ? 0 : 1;
$data['withdraw_id'] = $Withdraw->id;
app(\App\Http\Controllers\Admin\ZarinController::class)->wallet($data);
} catch (\Exception $e) {
report($e);
}
}
try {
app(PargarSyncService::class)->queueWalletDocument(
$customer,
@@ -243,6 +253,16 @@ class WalletController extends Controller
}
}
if (app(ConfigService::class)->isZarinAccounting()) {
try {
$data['direction'] = $deposit ? 1 : 0;
$data['withdraw_id'] = $Withdraw->id;
app(\App\Http\Controllers\Admin\ZarinController::class)->walletGold($data);
} catch (\Exception $e) {
report($e);
}
}
try {
app(PargarSyncService::class)->queueWalletDocument(
$customer,
@@ -408,6 +428,16 @@ class WalletController extends Controller
}
}
if (app(ConfigService::class)->isZarinAccounting()) {
try {
$data['direction'] = $deposit ? 1 : 0;
$data['withdraw_id'] = $Withdraw->id;
app(\App\Http\Controllers\Admin\ZarinController::class)->walletGold($data);
} catch (\Exception $e) {
report($e);
}
}
try {
// فقط محصول متصل به کیف اصلی → سند طلای پرگار
app(PargarSyncService::class)->queueWalletDocument(
@@ -651,6 +681,32 @@ class WalletController extends Controller
}
}
if (app(ConfigService::class)->isZarinAccounting() && isset($records['rows']) && is_array($records['rows'])) {
$withdrawIds = collect($records['rows'])->pluck('id')->filter()->values()->all();
if ($withdrawIds !== []) {
$failedByWithdraw = \App\Models\Zarin::query()
->whereIn('withdraw_id', $withdrawIds)
->where(function ($query) {
$query->whereNull('zarin_id');
if (\Illuminate\Support\Facades\Schema::hasColumn('zarin', 'sync_status')) {
$query->orWhere('sync_status', \App\Services\ZarinSyncService::STATUS_FAILED);
}
})
->orderByDesc('id')
->get()
->unique('withdraw_id')
->keyBy('withdraw_id');
foreach ($records['rows'] as &$row) {
$zarin = $failedByWithdraw->get($row['id'] ?? null);
if ($zarin) {
$row['zarin_failed_id'] = $zarin->id;
}
}
unset($row);
}
}
return response()->json($records);
}