From e2263ea7ba1a853a5d69c97691171afcde4e6777 Mon Sep 17 00:00:00 2001 From: marina Date: Thu, 19 Dec 2024 13:38:15 +0300 Subject: [PATCH] =?utf8?q?ERP-256=20=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D1=82?= =?utf8?q?=D1=8C=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D1=83=20?= =?utf8?q?=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20?= =?utf8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=86?= =?utf8?q?=D0=B0=20=D0=B2=201=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/DataController.php | 80 +++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index 8d0c6889..2244b928 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -1234,6 +1234,86 @@ class DataController extends BaseController } } + if (!empty($result['create_resortings'])) { + file_put_contents( + self::OUT_DIR . '/create_resortings_upload_' + . date("Y_m_d") . '.json', + PHP_EOL + . json_encode($result["create_resortings"], JSON_UNESCAPED_UNICODE), + FILE_APPEND + ); + foreach ($result["create_resortings"] as $arr) { + if (!empty($arr["id"])) { + $replacementInvoice = ReplacementInvoice::findOne(['guid' => $arr["arr"]]); + } + + if (!empty($replacementInvoice)) { + if (!empty($arr["errors"]) || !empty($arr["errors_items"])) { + $errorText = ''; + if (!empty($arr["errors"])) { + foreach ($arr["errors"] as $errorRow) { + if (!empty($errorRow['error'])) { + $errorText .= $errorRow['error']; + + $errorText .= ' ,' . $errorRow['error_description']; + if (!empty($errorRow['error_json'])) { + foreach ($errorRow['error_json'] as $errorJsonRow) { + $errorText .= ' , поле: ' . $errorJsonRow['field']; + $errorText .= ' , ошибка: ' . $errorJsonRow['error']; + } + } + } + + if (!empty($errorRow["errors_items"])) { + foreach ($errorRow["errors_items"] as $errorDopRow) { + $productName = $errorDopRow['product_id']; + + if (array_key_exists($errorDopRow['product_id'], $productsNames)) { + $productName = $productsNames[$errorDopRow['product_id']]; + } + + $errorText .= ' ' . $errorDopRow['error_dop']; + $errorText .= ' , поле: ' . $errorDopRow['field']; + $errorText .= ' , товар: ' . $productName; + $errorText .= ' , ошибка: ' . $errorDopRow['error']; + } + } + } + } + + /** @var ReplacementInvoice $replacementInvoice */ + $replacementInvoice->status = WriteOffsErp::STATUS_ERROR_1С; + $replacementInvoice->error_text = $errorText; + $replacementInvoice->save(); + if ($replacementInvoice->getErrors()) { + LogService::apiErrorLog( + json_encode( + ["error_id" => 4.55, "error" => $replacementInvoice->getErrors()], + JSON_UNESCAPED_UNICODE + ) + ); + } + + } else { + if (isset($arr["held"]) && $arr["held"] == 'true') { + /** @var ReplacementInvoice $replacementInvoice */ + $replacementInvoice->status = WriteOffsErp::STATUS_CREATED_1С; + $replacementInvoice->number_1c = $arr["name"] ?? ''; + $replacementInvoice->save(); + if ($replacementInvoice->getErrors()) { + LogService::apiErrorLog( + json_encode( + ["error_id" => 4.55, "error" => $replacementInvoice->getErrors()], + JSON_UNESCAPED_UNICODE + ) + ); + } + } + } + } + } + } + $update = false; if (!empty($start_time) && !empty($end_time)) { $start_time_unix = strtotime($start_time); -- 2.39.5