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);
}
$marketplaceOrder->raw_data = $newRawData;
$marketplaceOrder->status_1c = MarketplaceOrders::STATUSES_1C_CREATED_IN_ERP;
- // Логика отмены для Яндекс.Маркета: если заказ получен уже отмененным
+ // Логика отмены для ЯндексМаркета: если заказ получен уже отмененным
if ($statusCode === 'CANCELLED') {
$cancelledStatusId = $statuses[MarketplaceOrderStatusTypes::CANSELLED_CODE] ?? null;
if ($cancelledStatusId) {
->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]) {
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) {