]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Исправления
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 16 Oct 2025 16:35:08 +0000 (19:35 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 16 Oct 2025 16:35:08 +0000 (19:35 +0300)
erp24/api2/controllers/DataController.php
erp24/services/UploadService.php

index d9be5164763f61adb987891d7836e8cbdaea07ec..58eab383917b81b2ad40db1d8e0d12bca5a423a5 100644 (file)
@@ -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)) {
index 32fc916c07be3dd2a2581c621f014ef5ebd553c3..b11e416078f12e6de96922fce8cc59d4dea38ef6 100644 (file)
@@ -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);