From: Vladimir Fomichev Date: Mon, 13 Oct 2025 14:07:31 +0000 (+0300) Subject: Тестовые статусы X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=14d5ccea10e6b3215e4bc8c9839e4c7cd0248aaa;p=erp24_rep%2Fyii-erp24%2F.git Тестовые статусы --- diff --git a/erp24/controllers/MarketplaceOrdersController.php b/erp24/controllers/MarketplaceOrdersController.php index de671206..c4917790 100644 --- a/erp24/controllers/MarketplaceOrdersController.php +++ b/erp24/controllers/MarketplaceOrdersController.php @@ -666,19 +666,26 @@ class MarketplaceOrdersController extends Controller try { if ($model->fake) { - $deliveredStatusId = MarketplaceOrderStatusTypes::find()->select('id')->where(['code' => 'DELIVERED'])->one(); - $deliveredSubstatusId = MarketplaceOrderStatusTypes::find()->select('id')->where(['code' => 'DELIVERY_SERVICE_DELIVERED'])->one(); + $deliveredStatus = MarketplaceOrderStatusTypes::find()->select('id')->where(['code' => 'DELIVERED'])->one(); + $deliveredSubstatus = MarketplaceOrderStatusTypes::find()->select('id')->where(['code' => 'DELIVERY_SERVICE_DELIVERED'])->one(); - if (!$deliveredStatusId || !$deliveredSubstatusId) { + if (!$deliveredStatus || !$deliveredSubstatus) { throw new \Exception('Не удалось найти статусы DELIVERED / DELIVERY_SERVICE_DELIVERED'); } - - $model->status_id = $deliveredStatusId->id; - $model->substatus_id = $deliveredSubstatusId->id; + $deliveredStatusId = $deliveredStatus->id ?? null; + $deliveredSubstatusId = $deliveredSubstatus->id ?? null; + $model->status_id = $deliveredStatusId; + $model->substatus_id = $deliveredSubstatusId; + $status1cWithDeliveredId = ArrayHelper::getColumn(MarketplaceOrder1cStatuses::find() + ->where(['order_status_id' => $deliveredStatusId]) + ->andWhere(['marketplace_id' => 2]) + ->asArray() + ->all(), 'id')[0] ?? null; + $model->status_processing_1c = $status1cWithDeliveredId; if ((int)$model->marketplace_id === MarketplaceStore::YANDEX_WAREHOUSE_ID) { $rawData = json_decode($model->raw_data, true, 512, JSON_THROW_ON_ERROR); - $rawData['status'] = $deliveredStatusId->code; - $rawData['substatus'] = $deliveredSubstatusId->code; + $rawData['status'] = $deliveredStatus->code; + $rawData['substatus'] = $deliveredSubstatus->code; $model->raw_data = json_encode($rawData, JSON_UNESCAPED_UNICODE); } diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index fb5c079d..97563ffd 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -1196,7 +1196,7 @@ class MarketplaceService $marketplaceOrder->raw_data = $newRawData; $marketplaceOrder->status_1c = MarketplaceOrders::STATUSES_1C_CREATED_IN_ERP; - // Логика отмены для Яндекс.Маркета: если заказ получен уже отмененным + // Логика отмены для ЯндексМаркета: если заказ получен уже отмененным if ($statusCode === 'CANCELLED') { $cancelledStatusId = $statuses[MarketplaceOrderStatusTypes::CANSELLED_CODE] ?? null; if ($cancelledStatusId) { @@ -2002,11 +2002,12 @@ class MarketplaceService ->all(); $statuses = ArrayHelper::map($statuses, 'code', 'id'); $cancelledStatusId = $statuses[MarketplaceOrderStatusTypes::CANSELLED_CODE]; + $deliveredStatusId = $statuses['DELIVERED']; $status1cWithCancelledId = ArrayHelper::getColumn(MarketplaceOrder1cStatuses::find() ->where(['order_status_id' => $cancelledStatusId]) ->andWhere(['marketplace_id' => 1]) ->asArray() - ->all(), 'id')[0] ?? null;; + ->all(), 'id')[0] ?? null; $order = self::getOrdersDataFromMessage($message); if ($message['subject_index'] == self::SUBJECT_INDEX[self::SUBJECT_NEW]) { @@ -2032,6 +2033,8 @@ class MarketplaceService if ($statusCode == 'DELIVERED' && $substatusCode == 'DELIVERY_SERVICE_DELIVERED' && $marketplaceOrder) { Yii::error('Заказ доставлен ' . $marketplaceOrder->marketplace_order_id); /* @var $marketplaceOrder MarketplaceOrders */ + $marketplaceOrder->status_processing_1c = 'delivered'; + $marketplaceOrder->save(); $isCheckCreated = self::createCheckForMarketplaceOrder($marketplaceOrder); } if ($statusCode == MarketplaceOrderStatusTypes::CANSELLED_CODE && $substatusCode == 'USER_CHANGED_MIND' && $marketplaceOrder) {