fix some bugs
This commit is contained in:
@@ -272,9 +272,9 @@ class PargarInboundController extends Controller
|
||||
'tx_count' => is_array($data['transactions'] ?? null) ? count($data['transactions']) : 0,
|
||||
]);
|
||||
|
||||
// بهمحض ورود اسناد → ack + اعمال آخرین مانده
|
||||
// بهمحض ورود اسناد → ack + اعمال آخرین مانده (با تأخیر کوتاه تا webhook مانده قفل را بگیرد)
|
||||
if ($customer) {
|
||||
$this->inboundWallet()->queueWalletSyncAfterResponse((int) $customer->id);
|
||||
$this->inboundWallet()->queueWalletSyncAfterResponse((int) $customer->id, delaySeconds: 2);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
@@ -356,19 +356,21 @@ class PargarInboundController extends Controller
|
||||
]), JSON_UNESCAPED_UNICODE),
|
||||
]);
|
||||
|
||||
// سند pending نباشد → مانده را همینجا اعمال کن تا تغییر دستی حسابدار فوری روی اپ بنشیند
|
||||
// (صف afterResponse برای وقتی است که هنوز باید منتظر ثبت سند پنل بمانیم)
|
||||
// بدون سند pending → همینجا اعمال؛ اگر قفل/خطا بود صف با تأخیر تکرار میکند
|
||||
// (اسناد و مانده اغلب پشتسرهم میآیند و قفل همزمان شایع است)
|
||||
$appliedNow = false;
|
||||
if ($pendingOutbound) {
|
||||
$this->inboundWallet()->queueWalletSyncAfterResponse((int) $customer->id);
|
||||
$appliedNow = false;
|
||||
$this->inboundWallet()->queueWalletSyncAfterResponse((int) $customer->id, delaySeconds: 2);
|
||||
} else {
|
||||
$appliedNow = false;
|
||||
try {
|
||||
$syncResult = $this->inboundWallet()->syncWalletFromPargar($customer, forceMande: false, auto: true);
|
||||
$appliedNow = (bool) ($syncResult['mande']['applied'] ?? false);
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
$this->inboundWallet()->queueWalletSyncAfterResponse((int) $customer->id);
|
||||
}
|
||||
|
||||
if (! $appliedNow) {
|
||||
$this->inboundWallet()->queueWalletSyncAfterResponse((int) $customer->id, delaySeconds: 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,11 +380,11 @@ class PargarInboundController extends Controller
|
||||
? 'مانده ذخیره شد؛ بعد از ثبت سند در پرگار خودکار سینک میشود'
|
||||
: ($appliedNow
|
||||
? 'مانده دریافت و روی کیف اپ اعمال شد'
|
||||
: 'مانده دریافت شد؛ همگامسازی انجام شد'),
|
||||
: 'مانده دریافت شد؛ همگامسازی خودکار در صف است'),
|
||||
'data' => [
|
||||
'awaiting_outbound_confirm' => $pendingOutbound,
|
||||
'wallet_applied' => $appliedNow,
|
||||
'auto_sync_queued' => $pendingOutbound,
|
||||
'auto_sync_queued' => ! $appliedNow,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user