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 <cursoragent@cursor.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user