all customer from pargar fixing 2
This commit is contained in:
@@ -391,4 +391,48 @@ class PargarInboundWalletService
|
||||
|
||||
return (float) str_replace('/', '.', (string) $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* پس از اتصال کد پرگار / claim ثبتنام — همگامسازی کیف در پسزمینه.
|
||||
*/
|
||||
public function queueWalletSyncAfterResponse(int $customerId): void
|
||||
{
|
||||
dispatch(function () use ($customerId) {
|
||||
$customer = Customer::find($customerId);
|
||||
if ($customer === null || ! $customer->hasValidPargarAccountId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->attachOrphanMandeLogs($customer);
|
||||
|
||||
try {
|
||||
$this->syncWalletFromPargar($customer, true);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('Pargar auto wallet sync failed', [
|
||||
'customer_id' => $customerId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
})->afterResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* لاگهای ماندهای که قبل از ساخت/لینک مشتری با pargar_ref آمدهاند را به مشتری وصل میکند.
|
||||
*/
|
||||
public function attachOrphanMandeLogs(Customer $customer): int
|
||||
{
|
||||
if (! $customer->hasValidPargarAccountId()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$accountId = trim((string) $customer->pargar_account_id);
|
||||
|
||||
return PargarSyncLog::query()
|
||||
->where('type', PargarSyncService::TYPE_MANDE)
|
||||
->where('pargar_ref', $accountId)
|
||||
->where(function ($q) {
|
||||
$q->whereNull('customer_id')->orWhere('customer_id', 0);
|
||||
})
|
||||
->update(['customer_id' => $customer->id]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user