]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Тестовые статусы
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 13 Oct 2025 14:07:31 +0000 (17:07 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 13 Oct 2025 14:07:31 +0000 (17:07 +0300)
erp24/controllers/MarketplaceOrdersController.php
erp24/services/MarketplaceService.php

index de671206318b44daac4b49a5367f1ad037b09b80..c4917790f0ced2a5429b44dac9b1b9da4baa7b89 100644 (file)
@@ -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);
                 }
 
index fb5c079d08b0b6e75ee45de287257f728310dacc..97563ffd7e551006bc3b26ff7880cbeacd04dbf1 100644 (file)
@@ -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) {