all customer from pargar fixing 2
This commit is contained in:
@@ -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++;
|
||||
|
||||
Reference in New Issue
Block a user