From 1cd6c61e0f245484aa7321a8042723f2310923b3 Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Mon, 2 Nov 2026 10:57:57 +0330 Subject: [PATCH] fix(shayegan): send the customer detail code on account create Hesabgar fails when it must invent the account number. Send the subsidiary code plus the customer id as AccountNumber. Co-authored-by: Cursor --- .../abshode-domain-lookup/learned-notes.md | 2 + app/Services/ShayeganSyncService.php | 4 ++ ...2_000001_shayegan_customer_tafsil_code.php | 39 +++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 database/migrations/2026_11_02_000001_shayegan_customer_tafsil_code.php diff --git a/.cursor/skills/abshode-domain-lookup/learned-notes.md b/.cursor/skills/abshode-domain-lookup/learned-notes.md index 88b1510..c77ab52 100644 --- a/.cursor/skills/abshode-domain-lookup/learned-notes.md +++ b/.cursor/skills/abshode-domain-lookup/learned-notes.md @@ -3,6 +3,8 @@ فرمت هر خط: - YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی +- 2026-11-02 | PDF وب‌سرویس شایگان | `docs/shayegan/shayegan.pdf` صفحه ارسال حساب | نمونهٔ رسمی `AccountNumber` نمی‌فرستد؛ `MoinNumber` + `UpdateKind=0` + `AccountTypeId=1`. فرمول `12101530` در PDF نیست +- 2026-11-02 | سه سطح شایگان | `ShayeganSyncService::registerCustomer` + migration `2026_11_02_000001` | کل 121، معین `12101`، تفصیلی = معین+کد کاربری (`12101530`). `1210101` غلط است - 2026-11-01 | پیامک تبدیل | `CopperConvertRequestService::notifyCustomer` | بعد از تأیید یا رد، پیامک جدا به موبایل مشتری؛ خطا پیامک سفارش را برنمی‌گرداند - 2026-11-01 | درخواست تبدیل مس | `CopperConvertRequestService` + `copper_convert_requests` + `POST customer/copper-convert-request` + `admin/copper-convert-request/{id}/approve` | تأیید = فروش دارایی و خرید حلقه با quote_unit_price؛ مهاجرت `2026_11_01_000001` - 2026-10-28 | شایگان کالا/مشتری | `products.shayegan_item_number` + `ShayeganSyncService::registerCustomer` Account/Put + `ensureCustomerAccountNumber` | بانک 10001 و معین 12101 در settings؛ ItemNumber per-product diff --git a/app/Services/ShayeganSyncService.php b/app/Services/ShayeganSyncService.php index 45c1852..7cab2e2 100644 --- a/app/Services/ShayeganSyncService.php +++ b/app/Services/ShayeganSyncService.php @@ -121,9 +121,13 @@ class ShayeganSyncService $name = 'مشتری ' . $customer->id; } + // کل ۱۲۱ داخل معین است. تفصیلی = معین + کد کاربری. مثال: 12101 و مشتری 530 → 12101530 + $requestedAccountNumber = $moinRaw . ((string) (int) $customer->id); + $guid = (string) Str::uuid(); $put = [[ 'MoinNumber' => $moinNumber, + 'AccountNumber' => $requestedAccountNumber, 'AccountTypeId' => null, 'AccountName' => mb_substr($name, 0, 200), 'Mobile' => trim((string) ($customer->mobile ?? '')) ?: null, diff --git a/database/migrations/2026_11_02_000001_shayegan_customer_tafsil_code.php b/database/migrations/2026_11_02_000001_shayegan_customer_tafsil_code.php new file mode 100644 index 0000000..e91e34d --- /dev/null +++ b/database/migrations/2026_11_02_000001_shayegan_customer_tafsil_code.php @@ -0,0 +1,39 @@ +where('key', 'shayegan_moin_customer')->first(); + if (! $row) { + return; + } + + $current = trim((string) ($row->value ?? '')); + $update = [ + 'description' => 'معین Account/Put. کل ۱۲۱ داخل همین کد است. شماره تفصیلی = این مقدار + کد کاربری. مثال: 12101 و مشتری 530 → 12101530.', + 'updated_at' => now(), + ]; + if ($current === '' || $current === '1210101') { + $update['value'] = '12101'; + } + + DB::table('settings')->where('key', 'shayegan_moin_customer')->update($update); + } + + public function down(): void + { + } +};