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);
}
File diff suppressed because it is too large Load Diff
@@ -277,6 +277,7 @@ class AuthController extends Controller
// claim بدون کد حسابداری — صف export مثل create
app(\App\Services\PargarSyncService::class)->registerOnCreate($customer);
app(\App\Services\TahesabSyncService::class)->registerOnCreate($customer);
app(\App\Services\ZarinSyncService::class)->registerOnCreate($customer);
}
return response()->json($customer);
@@ -384,6 +384,26 @@ class CartController extends Controller
}
}
if ($config->isZarinAccounting()) {
try {
app(\App\Http\Controllers\Admin\ZarinController::class)->storeTrade([
'customer_id' => $order->customer_id,
'amount' => $order->amount,
'direction' => (int) ($order->direction ?? 1),
'price' => $order->price,
'total_price' => $order->total_price,
'pay_at' => $order->pay_at ?? $order->created_at,
'product' => [
'metal_id' => $metalId,
'id' => $primaryProduct?->id,
],
'order' => ['id' => $order->id],
]);
} catch (\Throwable $e) {
report($e);
}
}
if ($config->isPargarAccounting()) {
try {
app(PargarSyncService::class)->recordTrade($order, true, [
@@ -411,6 +411,19 @@ class WalletController extends Controller
report($e);
}
}
if (app(ConfigService::class)->isZarinAccounting()) {
try {
app(\App\Http\Controllers\Admin\ZarinController::class)->wallet([
"customer_id" => auth('customer')->id(),
"value" => $data['value'],
"direction" => 1,
]);
} catch (\Exception $e) {
report($e);
}
}
$companyName = $this->Config('name_fa'); // Company name from configuration
$message = "کاربر $userName با شماره موبایل $userMobile درخواست برداشت مبلغ " . number_format($withdrawAmount) . " ریال را دارد. با تشکر، $companyName";
if (isset($request->otp)) {
@@ -218,6 +218,14 @@ class SingleOrderController extends Controller
}
}
if ($config->isZarinAccounting()) {
try {
$data['zarin'] = app(\App\Http\Controllers\Admin\ZarinController::class)->storeTrade($data);
} catch (\Exception $e) {
report($e);
}
}
if ($config->isPargarAccounting()) {
try {
$paymentProductId = (int) ($data['payment_product_id'] ?? 0);