From: fomichev Date: Fri, 25 Apr 2025 11:23:21 +0000 (+0300) Subject: Добавление полей в тест X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=a4775d36628deb457857c7d295dd613c24e995c8;p=erp24_rep%2Fyii-erp24%2F.git Добавление полей в тест --- diff --git a/erp24/controllers/MarketplaceOrdersController.php b/erp24/controllers/MarketplaceOrdersController.php index a42e8c0d..7451fc04 100644 --- a/erp24/controllers/MarketplaceOrdersController.php +++ b/erp24/controllers/MarketplaceOrdersController.php @@ -161,6 +161,8 @@ class MarketplaceOrdersController extends Controller $m->store_id = 4; $m->status_1c = MarketplaceOrders::STATUSES_1C_CREATED_IN_ERP; $m->guid = DataHelper::createGuidMy('08'); + $m->delivery_to = date('Y-m-d H:i:s', strtotime( '+1 hour')); + $m->readyto_1c = 1; if ($m->save()) { MarketplaceService::createOrUpdateStatusHistory($m->id, $status->id, $substatus->id, $orderDetails); @@ -306,6 +308,20 @@ class MarketplaceOrdersController extends Controller "vehicleNumber" => "Е507ХН152", "vehicleDescription" => "Chevrolet Aveo чёрный", ], + "shipments" => [ + [ + "id" => random_int(600000000, 699999999), + "shipmentDate" => date('Y-m-d '), + "shipmentTime" => date('H:i:s', strtotime("+1 hour")), + "tracks" => [], + "boxes" => [ + [ + "id" => random_int(600000000, 699999999), + "fulfilmentId" => $orderNumber . "-1", + ], + ], + ], + ], ], "buyer" => ["type" => "PERSON"], "notes" => "Звоните хотя бы за час", @@ -342,7 +358,9 @@ class MarketplaceOrdersController extends Controller $m->status_id = $status->id; $m->substatus_id = $substatus->id; $m->status_1c = MarketplaceOrders::STATUSES_1C_CREATED_IN_ERP; - + $deliveryTo = $raw['delivery']['shipments'][0]['shipmentDate'] . ' ' . $raw['delivery']['shipments'][0]['shipmentTime']; + $m->delivery_to = $deliveryTo; + $m->readyto_1c = 1; if (!$m->save()) { Yii::$app->session->setFlash('error', 'Ошибка создания Яндекс-заказа: ' . json_encode($m->getErrors(), JSON_UNESCAPED_UNICODE)); @@ -582,7 +600,7 @@ class MarketplaceOrdersController extends Controller if ($date && $time) { $order->delivery_to = "$date $time:00"; - + $order->readyto_1c = 1; if (!$order->save()) { Yii::error('Ошибка сохранения delivery_to: ' . json_encode($order->getErrors(), JSON_UNESCAPED_UNICODE), __METHOD__); } diff --git a/erp24/records/MarketplaceOrders.php b/erp24/records/MarketplaceOrders.php index 05bbf7ad..96d757d5 100644 --- a/erp24/records/MarketplaceOrders.php +++ b/erp24/records/MarketplaceOrders.php @@ -36,6 +36,7 @@ use Yii; * @property string|null $status_processing_1c Статус обработки заказа в 1С * @property string|null $order_link Ссылка на заказ в МП * @property string|null $delivery_to Сроки доставки заказа + * @property int $readyto_1c Готовность к отправке в 1С: 0 - не готов, 1 - готов. Зависит от наполения $delivery_to */ class MarketplaceOrders extends \yii\db\ActiveRecord { @@ -84,11 +85,11 @@ class MarketplaceOrders extends \yii\db\ActiveRecord { return [ [['store_id', 'warehouse_guid', 'returned_at', 'return_data', 'raw_data', 'guid'], 'default', 'value' => null], - [['cancel_requested', 'status_telegram'], 'default', 'value' => 0], + [['cancel_requested', 'status_telegram', 'readyto_1c'], 'default', 'value' => 0], [['marketplace_order_id', 'marketplace_id', 'marketplace_name', 'status_id', 'substatus_id', 'creation_date', 'updated_at', 'total', 'delivery_total', 'buyer_total_before_discount', 'tax_system', 'payment_type', 'payment_method'], 'required'], [['store_id', 'status_id', 'substatus_id', 'fake', 'cancel_requested', 'status_1c', 'status_processing_1c', 'order_link', 'delivery_to'], 'default', 'value' => null], [[ 'fake'], 'default', 'value' => 0], - [['store_id', 'status_id', 'substatus_id', 'fake', 'cancel_requested', 'status_1c', 'marketplace_id', 'status_telegram', 'status_processing_1c'], 'integer'], + [['store_id', 'status_id', 'substatus_id', 'fake', 'cancel_requested', 'status_1c', 'marketplace_id', 'status_telegram', 'status_processing_1c', 'readyto_1c'], 'integer'], [['creation_date', 'updated_at', 'returned_at'], 'safe'], [['return_data', 'raw_data', 'marketplace_name', 'telegram_error', 'order_link', 'delivery_to'], 'string'], [['total', 'delivery_total', 'buyer_total_before_discount'], 'number'], @@ -136,6 +137,7 @@ class MarketplaceOrders extends \yii\db\ActiveRecord 'status_processing_1c' => 'Статус обработки заказа в 1С', 'order_link' => 'Ссылка на заказ в МП', 'delivery_to' => 'Сроки доставки заказа', + 'readyto_1c' => 'Готовность к отправке в 1С', ]; } diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index e4580972..70cd3022 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -2235,9 +2235,10 @@ class MarketplaceService if ($model->delivery_start) { $order->delivery_to = $model->delivery_start; + $order->readyto_1c = 1; if (!$order->save()) { Yii::error( - 'Ошибка сохранения элеиента: ' . json_encode($order->getErrors(), JSON_UNESCAPED_UNICODE) + 'Ошибка сохранения срока заказа: ' . json_encode($order->getErrors(), JSON_UNESCAPED_UNICODE) ); } }