all customer from pargar fixing 2

This commit is contained in:
2026-07-22 00:31:38 +03:30
parent 1476f6efb1
commit 01031e9e01
7 changed files with 273 additions and 22 deletions
@@ -133,11 +133,43 @@ class PargarController extends Controller
$fullName = trim($item['name']);
$accountId = (string) $item['code'];
// بدون موبایل ردیف placeholder نساز — باعث ثبت‌نام تکراری و کیف جدا می‌شود
if ($mobile === '') {
$failed++;
$errors[] = [
'name' => $item['name'],
'code' => $item['code'],
'error' => 'شماره موبایل خالی است — وارد نشد',
];
continue;
}
$existing = Customer::whereNull('deleted_at')
->where('pargar_account_id', $accountId)
->first();
if ($existing) {
$changed = false;
if (($existing->mobile === null || trim((string) $existing->mobile) === '')) {
if (Customer::isMobileTaken($mobile, (int) $existing->id)) {
$failed++;
$errors[] = [
'name' => $item['name'],
'code' => $item['code'],
'error' => 'شماره موبایل تکراری است',
];
continue;
}
$existing->mobile = $mobile;
if (empty($existing->password)) {
$existing->password = $mobile;
}
$changed = true;
}
if ($changed) {
$existing->save();
app(PargarInboundWalletService::class)->queueWalletSyncAfterResponse((int) $existing->id);
}
$success++;
continue;
}
@@ -162,6 +194,7 @@ class PargarController extends Controller
$byMobile->name = $fullName;
}
$byMobile->save();
app(PargarInboundWalletService::class)->queueWalletSyncAfterResponse((int) $byMobile->id);
$success++;
continue;
}
@@ -190,10 +223,9 @@ class PargarController extends Controller
$customer->pargar_account_id = $accountId;
$customer->referral_id = $this->uniqueReferralId();
$customer->type = 2;
if ($mobile !== '') {
$customer->password = $mobile;
}
$customer->password = $mobile;
$customer->save();
app(PargarInboundWalletService::class)->queueWalletSyncAfterResponse((int) $customer->id);
$success++;
} catch (\Throwable $e) {
$failed++;
@@ -230,6 +230,17 @@ class TahesabController extends Controller
$fullName = trim($item['name']);
$code = (int) $item['code'];
// بدون موبایل ردیف placeholder نساز
if ($mobile === '') {
$failed++;
$errors[] = [
'name' => $item['name'],
'code' => $item['code'],
'error' => 'شماره موبایل خالی است — وارد نشد',
];
continue;
}
$existing = Customer::whereNull('deleted_at')->where('moshtari_code', $code)->first();
if ($existing) {
$changed = false;