From: Vladimir Fomichev Date: Mon, 25 Aug 2025 08:37:04 +0000 (+0300) Subject: Merge branch 'refs/heads/develop' into feature_fomichev_erp-443_add_canceled_orders_t... X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ad22aa70335ac7dd78441ae512bc1ab883d30671;p=erp24_rep%2Fyii-erp24%2F.git Merge branch 'refs/heads/develop' into feature_fomichev_erp-443_add_canceled_orders_to_1c_exchange_request # Conflicts: # erp24/api2/controllers/DataController.php # erp24/services/MarketplaceService.php --- ad22aa70335ac7dd78441ae512bc1ab883d30671 diff --cc erp24/api2/controllers/DataController.php index 800ec6d4,94eae6f6..5ae91dda --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@@ -2482,76 -2554,15 +2556,83 @@@ class DataController extends BaseContro } } + if (!empty($result['cancelled_orders'])) { + foreach ($result['cancelled_orders'] as $arr) { + $marketplaceOrders = null; + $marketplaceOrdersGuidArr = []; + + $marketplaceOrders = MarketplaceOrders::find()->where(['guid' => $arr])->one(); + $marketplaceOrdersGuidArr[] = $marketplaceOrders->guid; + + if (!empty($marketplaceOrders)) { + /** @var MarketplaceOrders $marketplaceOrders */ + + if (!empty($arr["errors"]) || !empty($arr["error"]) || !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($arr["error"])) { + //"error": "Ошибка преобразования ИД документа", + //"error_description": "ИД документа 01202307-2705-1039-09bc-100015809667 уже записан в системе", + $errorText .= $arr["error"]; + $errorText .= ' ,' . $arr['error_description']; + } + + $marketplaceOrders->status_1c = MarketplaceOrders::STATUSES_1C_ERROR_1C; + $marketplaceOrders->error_text = $errorText; + $marketplaceOrders->save(); + if ($marketplaceOrders->getErrors()) { + LogService::apiErrorLog( + json_encode( + ["error_id" => 41, "error" => $marketplaceOrders->getErrors()], + JSON_UNESCAPED_UNICODE + ) + ); + } + } else { + $marketplaceOrder->cancelled_order_sent = MarketplaceOrders::STATUSES_1C_CANCELLED_ORDER_SENT_IN_1C; + $marketplaceOrders->save(); + if ($marketplaceOrders->getErrors()) { + LogService::apiErrorLog( + json_encode( + ["error_id" => 41, "error" => $marketplaceOrders->getErrors()], + JSON_UNESCAPED_UNICODE + ) + ); + } + } + } + } + - ++ + + } + + $mess['line'][] = __LINE__; } catch (Exception $e) { + LogService::apiDataLogs(1, json_encode($mess, JSON_UNESCAPED_UNICODE), $requestIdText); file_put_contents(self::OUT_DIR . '/log_error.txt', PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage() . " " . $e->getLine(), FILE_APPEND); + Yii::error('Ошибка upload - блок catch '. json_encode($e->getMessage() . " " . $e->getLine(), JSON_UNESCAPED_UNICODE)); + LogService::apiErrorLog(json_encode([ + "error_id" => 44, + "error" => "Ошибка загрузки " . $e->getMessage() . " " . $e->getLine(), + ], JSON_UNESCAPED_UNICODE)); } finally { LogService::apiDataLogs(1, json_encode($mess, JSON_UNESCAPED_UNICODE), $requestIdText); } @@@ -3039,10 -3042,10 +3126,10 @@@ /** @var $status MarketplaceOrderStatusTypes */ /** @var $substatus MarketplaceOrderStatusTypes */ $status = $statusId1C->orderStatus; - $substatus = $statusId1C->orderStatus; + $substatus = $statusId1C->orderSubstatus; if ( - in_array($statusId1C->status_id, ['1013', '1010']) && + in_array($statusId1C->status_id, $statuses1cToChangeYandexMarketFakeOrderId) && $marketplaceOrder->marketplace_id == 2 ) { if (!$debug) { diff --cc erp24/api2/controllers/OrdersController.php index 8a23af07,20976f09..026e1a29 --- a/erp24/api2/controllers/OrdersController.php +++ b/erp24/api2/controllers/OrdersController.php @@@ -134,10 -118,10 +134,10 @@@ class OrdersController extends BaseCont /** @var $status MarketplaceOrderStatusTypes */ /** @var $substatus MarketplaceOrderStatusTypes */ $status = $statusId1C->orderStatus; - $substatus = $statusId1C->orderStatus; + $substatus = $statusId1C->orderSubstatus; if ( - in_array($statusId1C->status_id, ['1013', '1010']) && + in_array($statusId1C->status_id, $statuses1cToChangeYandexMarketFakeOrderId) && $order->marketplace_id == 2 ) { if (!$debug) {