From: Vladimir Fomichev Date: Thu, 16 Oct 2025 16:35:08 +0000 (+0300) Subject: Исправления X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=cde5c48146cd5364b8ff6a449138be921c386fb8;p=erp24_rep%2Fyii-erp24%2F.git Исправления --- diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index d9be5164..58eab383 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -245,11 +245,22 @@ class DataController extends BaseController $payload = $mess; if ($apiCron) { + // Определяем итоговый request_id из api_cron (приоритет: json_post -> поле таблицы -> генерируем новый) + $cronDecoded = json_decode($apiCron->json_post, true) ?: []; + + if (!empty($cronDecoded['request_id'])) { + $finalRequestId = $cronDecoded['request_id']; + } elseif (!empty($apiCron->request_id)) { + $finalRequestId = $apiCron->request_id; + } else { + $finalRequestId = $mess['request_id'] ?? $requestId; + } + $claimed = ApiCron::updateAll( [ 'status' => 1, 'date_up' => date('Y-m-d H:i:s'), - 'request_id' => $mess['request_id'] ?? $requestId, + // НЕ перезаписываем request_id, если он уже есть ], [ 'and', @@ -259,15 +270,11 @@ class DataController extends BaseController ); if ($claimed) { - $cronDecoded = json_decode($apiCron->json_post, true) ?: []; - - if (!empty($cronDecoded['request_id'])) { - $jsonId = $cronDecoded['request_id']; - } else { - $jsonId = $apiCron->request_id ?: ($mess['request_id'] ?? $requestId); - } - + $jsonId = $finalRequestId; $payload = $this->mergePayloads($payload, $cronDecoded); + + // Устанавливаем правильный request_id в payload для передачи в очередь + $payload['request_id'] = $finalRequestId; $createEmployeeArray = $this->getCreateEmployee(); if (!empty($createEmployeeArray)) { diff --git a/erp24/services/UploadService.php b/erp24/services/UploadService.php index 32fc916c..b11e4160 100644 --- a/erp24/services/UploadService.php +++ b/erp24/services/UploadService.php @@ -81,16 +81,18 @@ class UploadService { file_put_contents(self::OUT_DIR . '/error_upload.txt', PHP_EOL . json_encode($result["error"], JSON_UNESCAPED_UNICODE), FILE_APPEND); } - $mess["result"] = true; - $checks_dell = ""; + $mess["result"] = true; + $checks_dell = ""; + // ВАЖНО: сначала берем request_id из входящих данных, если его нет - генерируем новый + if (array_key_exists("request_id", $result) && !empty($result["request_id"])) { + $requestId = $result["request_id"]; + } else { $requestId = DataHelper::getRequestId(); - if (array_key_exists("request_id", $result) && !empty($result["request_id"])) { - $requestId = $result["request_id"]; - } - $type_price = "Розничная цена"; - LogService::apiErrorLog(json_encode(["error_id" => 145, "error" => $requestId], JSON_UNESCAPED_UNICODE)); - if (!empty($requestId)) { - $apiCron = ApiCron::find()->select(['json_post'])->where(['request_id' => $requestId])->one(); + } + $type_price = "Розничная цена"; + LogService::apiErrorLog(json_encode(["error_id" => 145, "error" => $requestId], JSON_UNESCAPED_UNICODE)); + if (!empty($requestId)) { + $apiCron = ApiCron::find()->select(['json_post'])->where(['request_id' => $requestId])->one(); if ($apiCron) { $jsn = json_decode($apiCron->json_post, true, 512, JSON_UNESCAPED_UNICODE); $start_time = $jsn["checks"]["start_time"] ?? date('Y-m-d 00:00:00', time() - 3 * 86400);