fix pargar bugs 6

This commit is contained in:
2026-07-21 14:23:26 +03:30
parent 38ae7ae627
commit 64a4a4ca95
3 changed files with 185 additions and 278 deletions
@@ -240,13 +240,14 @@ class PargarInboundController extends Controller
? Customer::where('pargar_account_id', $accountId)->first()
: null;
// فقط لاگ — اعمال خودکار روی کیف خاموش است (جلوگیری از شارژ چندباره وقتی پرگار مکرر می‌فرستد)
// فقط لاگ — اعمال خودکار روی کیف کاملاً خاموش است
// اگر هنوز موجودی بالا می‌رود = worker/php قدیمی هنوز زنده است → ری‌استارت الزامی
PargarSyncLog::create([
'customer_id' => $customer?->id,
'amount' => $summary['amount'],
'desc' => $customer
? ($summary['desc'] !== '' ? $summary['desc'] : 'دریافت اسناد از پرگار')
: 'دریافت اسناد از پرگار — مشتری یافت نشد',
? ('[no-apply] '.($summary['desc'] !== '' ? $summary['desc'] : 'دریافت اسناد از پرگار'))
: '[no-apply] دریافت اسناد از پرگار — مشتری یافت نشد',
'type' => PargarSyncService::TYPE_DOCUMENT,
'sync_status' => PargarSyncService::STATUS_SUCCESS,
'pargar_ref' => $accountId !== '' ? $accountId : null,
@@ -254,15 +255,23 @@ class PargarInboundController extends Controller
'_summary' => $summary,
'wallet_applied' => false,
'auto_apply_disabled' => true,
'code_build' => 'no-apply-v2',
]), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
]);
\Illuminate\Support\Facades\Log::info('Pargar documents stored without wallet apply', [
'account_id' => $accountId,
'customer_id' => $customer?->id,
'tx_count' => is_array($data['transactions'] ?? null) ? count($data['transactions']) : 0,
]);
return response()->json([
'success' => true,
'message' => $customer
? 'اسناد مشتری دریافت و ثبت شد (بدون تغییر کیف)'
: 'اسناد دریافت شد ولی مشتری با این کد حساب یافت نشد',
'data' => null,
'message' => 'اسناد ثبت شد بدون تغییر کیف (no-apply-v2)',
'data' => [
'wallet_applied' => false,
'build' => 'no-apply-v2',
],
]);
}
@@ -284,6 +293,7 @@ class PargarInboundController extends Controller
$rialInv = isset($data['RialInv']) ? (float) str_replace('/', '.', (string) $data['RialInv']) : 0;
// فقط مقایسه برای لاگ — اپ source of truth است؛ کیف را از مانده پرگار عوض نکن
// اضطراری: هیچ‌وقت از mande کیف را تغییر نده (حتی اگر کد قدیمی جایی مانده باشد)
$ownerType = (int) ($customer->type ?? 2);
$walletInterface = new WalletInterface($customer->id, $ownerType);
$wallet = $walletInterface->wallet;