From 97865a98fc2031bc92185e4d0706cd342b21608e Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Mon, 2 Nov 2026 13:05:53 +0330 Subject: [PATCH] fix(shayegan): register customers as floating detail jobs Customer accounts are not sub-accounts of moin 12101. Send Job/Put with JobNumber moin plus customer id. Co-authored-by: Cursor --- .../abshode-domain-lookup/learned-notes.md | 4 ++-- app/Services/ShayeganSyncService.php | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.cursor/skills/abshode-domain-lookup/learned-notes.md b/.cursor/skills/abshode-domain-lookup/learned-notes.md index bb18037..dbcc7fc 100644 --- a/.cursor/skills/abshode-domain-lookup/learned-notes.md +++ b/.cursor/skills/abshode-domain-lookup/learned-notes.md @@ -3,8 +3,8 @@ فرمت هر خط: - YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی -- 2026-11-02 | جدول اسناد شایگان | `shayeganTable.vue` + `ShayeganController::table` | مثل پرگار با BaseTable و TableEngine؛ صفحه‌بندی «مورد یافت شد / ردیف» نه page انگلیسی -- 2026-11-02 | شماره تفصیلی شایگان | `ShayeganSyncService::registerCustomer` | `AccountNumber` = معین + کد کاربری. معین 12101 و مشتری 530 → `12101530` +- 2026-11-02 | جدول اسناد شایگان | `shayeganTable.vue` + `ShayeganController::table` | BaseTable؛ پاسخ بدون `query` را خود فرانت به `{rows,query}` برمی‌گرداند. ستون عملیات `ops` است تا در RTL هشدار fixed ندهد +- 2026-11-02 | مشتری تفصیلی شناور | `ShayeganSyncService::registerCustomer` → `Job/Put` | معین 12101 حساب جدا نمی‌سازد؛ `JobNumber` = معین+کد (`12101530`). گروه: setting `shayegan_job_group` - 2026-11-02 | دیباگ تبادل شایگان | `ShayeganClient::request` + `registerCustomer` / health / retry | پاسخ ادمین `client_request` و `server_response` دارد؛ رمز DB و Auth برابر `***` - 2026-11-02 | سه سطح شایگان | `ShayeganSyncService::registerCustomer` + migration `2026_11_02_000001` | کل 121، معین `12101`، تفصیلی = معین+کد کاربری (`12101530`). `1210101` غلط است - 2026-11-01 | پیامک تبدیل | `CopperConvertRequestService::notifyCustomer` | بعد از تأیید یا رد، پیامک جدا به موبایل مشتری؛ خطا پیامک سفارش را برنمی‌گرداند diff --git a/app/Services/ShayeganSyncService.php b/app/Services/ShayeganSyncService.php index 72122ff..be5e02b 100644 --- a/app/Services/ShayeganSyncService.php +++ b/app/Services/ShayeganSyncService.php @@ -115,28 +115,29 @@ class ShayeganSyncService } $moinRaw = trim($this->config->getString('shayegan_moin_customer', '')); - $moinNumber = is_numeric($moinRaw) ? (int) $moinRaw : $moinRaw; $name = trim((string) ($customer->name ?? '')); if ($name === '') { $name = 'مشتری ' . $customer->id; } - // تفصیلی = معین + کد کاربری. مثال: معین 12101 و مشتری 530 → 12101530 + // مشتری تفصیلی شناور است (Job/Put)، نه حساب زیر معین. شماره = معین + کد کاربری. $requestedAccountNumber = $moinRaw . ((string) (int) $customer->id); $guid = (string) Str::uuid(); $put = [[ - 'MoinNumber' => $moinNumber, - 'AccountNumber' => $requestedAccountNumber, - 'AccountTypeId' => 1, - 'AccountName' => mb_substr($name, 0, 200), + 'JobNumber' => $requestedAccountNumber, + 'JobName' => mb_substr($name, 0, 200), 'Mobile' => trim((string) ($customer->mobile ?? '')) ?: null, 'mellicode' => trim((string) ($customer->n_code ?? '')) ?: null, 'GuId' => $guid, 'UpdateKind' => 0, ]]; + $jobGroup = trim($this->config->getString('shayegan_job_group', '')); + if ($jobGroup !== '') { + $put[0]['JobGroupNumber'] = $jobGroup; + } - $result = $this->client->put('Account/Put', $put); + $result = $this->client->put('Job/Put', $put); $accountNumber = trim((string) ($result['number'] ?? '')); $exchange = $this->client->debugExchange($result); @@ -163,10 +164,10 @@ class ShayeganSyncService $row->withdraw_id = null; $row->product_id = null; $row->amount = null; - $row->desc = 'ثبت حساب مشتری'; + $row->desc = 'ثبت تفصیلی شناور مشتری'; $row->type = self::TYPE_CUSTOMER; $row->date = now(); - $row->endpoint = 'Account/Put'; + $row->endpoint = 'Job/Put'; $row->request_guid = $guid; $row->shayegan_number = $accountNumber; $row->shayegan_guid = $result['guid'] ?? null; @@ -180,7 +181,7 @@ class ShayeganSyncService return array_merge([ 'ok' => true, - 'message' => 'حساب تفصیلی مشتری در شایگان ایجاد شد', + 'message' => 'تفصیلی شناور مشتری در شایگان ایجاد شد', 'moshtari_code' => $accountNumber, ], $exchange); }