From 6fe8a97c492e853fc08d35dd1c2b649b21e71c7c Mon Sep 17 00:00:00 2001 From: fomichev Date: Thu, 20 Feb 2025 12:49:52 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D0=B5=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=20=D0=B8=20=D0=B4?= =?utf8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=8D?= =?utf8?q?=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B8=20?= =?utf8?q?=D0=B4=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../controllers/YandexMarketController.php | 338 ++++++++++++++---- .../MarketplaceOrderItemsController.php | 134 +++++++ ...062708_create_marketplace_orders_table.php | 10 +- ...e_marketplace_order_status_types_table.php | 2 +- ...marketplace_order_status_history_table.php | 30 -- ...reate_marketplace_order_delivery_table.php | 12 +- ...2_create_marketplace_order_items_table.php | 50 +++ erp24/records/MarketplaceOrderDelivery.php | 19 +- erp24/records/MarketplaceOrderItems.php | 82 +++++ erp24/records/MarketplaceOrderItemsSearch.php | 84 +++++ .../records/MarketplaceOrderStatusHistory.php | 37 -- erp24/records/MarketplaceOrderStatusTypes.php | 24 +- erp24/records/MarketplaceOrders.php | 53 +-- erp24/records/MarketplaceOrdersSearch.php | 12 +- .../views/marketplace-order-items/_search.php | 57 +++ erp24/views/marketplace-order-items/index.php | 58 +++ erp24/views/marketplace-order-items/view.php | 51 +++ erp24/views/marketplace-orders/_search.php | 10 +- erp24/views/marketplace-orders/index.php | 8 +- erp24/views/marketplace-orders/view.php | 6 +- 20 files changed, 845 insertions(+), 232 deletions(-) create mode 100644 erp24/controllers/MarketplaceOrderItemsController.php create mode 100644 erp24/migrations/m250220_084832_create_marketplace_order_items_table.php create mode 100644 erp24/records/MarketplaceOrderItems.php create mode 100644 erp24/records/MarketplaceOrderItemsSearch.php create mode 100644 erp24/views/marketplace-order-items/_search.php create mode 100644 erp24/views/marketplace-order-items/index.php create mode 100644 erp24/views/marketplace-order-items/view.php diff --git a/erp24/api2/controllers/YandexMarketController.php b/erp24/api2/controllers/YandexMarketController.php index a065e0f4..760c0796 100644 --- a/erp24/api2/controllers/YandexMarketController.php +++ b/erp24/api2/controllers/YandexMarketController.php @@ -10,6 +10,8 @@ use OpenAPI\Client\Api; use OpenAPI\Client\Model; use GuzzleHttp; use yii\web\Response; +use yii_app\records\MarketplaceOrderDelivery; +use yii_app\records\MarketplaceOrderItems; use yii_app\records\MarketplaceOrders; use yii_app\records\MarketplaceOrderStatusHistory; use yii_app\records\MarketplaceOrderStatusTypes; @@ -183,7 +185,7 @@ class YandexMarketController extends Controller ->select(['warehouse_guid']) ->where(['warehouse_id' => 2]) ->column(); - + $statuses = MarketplaceOrderStatusTypes::find() ->select(['id', 'code']) ->indexBy('code') @@ -191,7 +193,7 @@ class YandexMarketController extends Controller $statuses = ArrayHelper::map($statuses, 'code', 'id'); $statusCodes = array_unique(array_keys($statuses)); - // var_dump($statusCodes);die(); + // var_dump($statusCodes);die(); $apiInstance = new Api\OrdersApi(new GuzzleHttp\Client(), $config); @@ -206,10 +208,9 @@ class YandexMarketController extends Controller $orders = $result[0]->getOrders(); foreach ($orders as $order) { - // var_dump($statusCodes);die(); - // Установка и сохранение статусов $status = $statuses[$order->getStatus()] ?? null; $substatus = $statuses[$order->getSubstatus()] ?? null; + if (!in_array($order->getStatus(), $statusCodes)) { $newStatus = new MarketplaceOrderStatusTypes(); $newStatus->code = $order->getStatus(); @@ -218,61 +219,39 @@ class YandexMarketController extends Controller $statusCodes[] = $order->getStatus(); $statuses[$order->getStatus()] = $newStatus->id; } else { - Yii::error('Ошибка сохранения' . json_encode($newStatus->getErrors(), JSON_UNESCAPED_UNICODE)); + Yii::error( + 'Ошибка сохранения статуса: ' . json_encode($newStatus->getErrors(), JSON_UNESCAPED_UNICODE) + ); } } + if (!in_array($order->getSubstatus(), $statusCodes)) { $newSubstatus = new MarketplaceOrderStatusTypes(); $newSubstatus->code = $order->getSubstatus(); if ($newSubstatus->save()) { $substatus = $newSubstatus->id; $statusCodes[] = $order->getSubstatus(); - $statuses[$order->getSubstatus()] = $newStatus->id; + $statuses[$order->getSubstatus()] = $newSubstatus->id; } else { - Yii::error('Ошибка сохранения' . json_encode($newSubstatus->getErrors(), JSON_UNESCAPED_UNICODE)); + Yii::error( + 'Ошибка сохранения подстатуса: ' . json_encode( + $newSubstatus->getErrors(), + JSON_UNESCAPED_UNICODE + ) + ); } } - $marketplaceOrder = MarketplaceOrders::find()->where(['marketplace_id' => (string)$order->getId()])->one(); - - if (!empty($marketplaceOrder)) { - $statusHistoryRecord = MarketplaceOrderStatusHistory::find() - ->where(['id' => $marketplaceOrder->status_history_id]) - ->one(); - if(!empty($statusHistoryRecord) && ($statusHistoryRecord->status_id !== $status || $statusHistoryRecord->substatus_id !== $substatus)) { - $statusHistoryRecord->active = 0; - $statusHistoryRecord->date_to = date(); - $statusHistoryRecord->save(); - $newStatusHistoryRecord = new MarketplaceOrderStatusHistory(); - $newStatusHistoryRecord->order_id = $marketplaceOrder->id; - $newStatusHistoryRecord->status_id = (int)$status; - $newStatusHistoryRecord->substatus_id = (int)$substatus; - $newStatusHistoryRecord->active = 1; - $newStatusHistoryRecord->initiator = "ERP"; - $newStatusHistoryRecord->date_from = date(); - $newStatusHistoryRecord->date_end = date('Y-m-d H:i:s',strtotime("2100-01-01")); - if (!$newStatusHistoryRecord->save()) { - Yii::error('Ошибка сохранения' . json_encode($newStatusHistoryRecord->getErrors(), JSON_UNESCAPED_UNICODE)); - } else { - $marketplaceOrder->status_history_id = $newStatusHistoryRecord->id; - } - } - } else { + $newRawData = json_encode($order); + $marketplaceOrder = MarketplaceOrders::find() + ->where(['marketplace_order_id' => (string)$order->getId()]) + ->one(); + + if (!$marketplaceOrder) { $marketplaceOrder = new MarketplaceOrders(); - $marketplaceOrder->marketplace_id = (string)$order->getId(); - //var_dump((int)$order->getCancelRequested()); die(); - $creationDate = strtotime($order->getCreationDate()); - if ($creationDate !== false) { - $marketplaceOrder->creation_date = date('Y-m-d H:i:s', $creationDate); - } else { - Yii::error("Неверный формат даты: " . $order->getCreationDate()); - } - $updatedAt = strtotime($order->getUpdatedAt()); - if ($updatedAt !== false) { - $marketplaceOrder->updated_at = date('Y-m-d H:i:s', $updatedAt); - } else { - Yii::error("Неверный формат даты: " . $order->getUpdatedAt()); - } + $marketplaceOrder->marketplace_order_id = (string)$order->getId(); + $marketplaceOrder->creation_date = date('Y-m-d H:i:s', strtotime($order->getCreationDate())); + $marketplaceOrder->updated_at = date('Y-m-d H:i:s', strtotime($order->getUpdatedAt())); $marketplaceOrder->total = $order->getBuyerTotal(); $marketplaceOrder->delivery_total = $order->getDeliveryTotal(); $marketplaceOrder->buyer_total_before_discount = $order->getBuyerTotalBeforeDiscount(); @@ -280,16 +259,17 @@ class YandexMarketController extends Controller $marketplaceOrder->payment_type = $order->getPaymentType(); $marketplaceOrder->payment_method = $order->getPaymentMethod(); $marketplaceOrder->cancel_requested = (int)$order->getCancelRequested(); - $marketplaceOrder->store_id = (string)$campaignId; - $marketplaceOrder->raw_data = json_encode($order); - if (!$marketplaceOrder->save()) { - Yii::error( - "Ошибка сохранения заказа с marketplace_id: " . $order->getId() . ". Ошибки: " . json_encode( - $marketplaceOrder->getErrors(), JSON_UNESCAPED_UNICODE - ) - ); - } else { + $warehouseGuid = (string)$campaignId; + $store = MarketplaceStore::findOne(['warehouse_guid' => $warehouseGuid]); + $marketplaceOrder->store_id = $store ? $store->store_id : null; + $marketplaceOrder->warehouse_guid = $warehouseGuid; + + $marketplaceOrder->status_id = (int)$status; + $marketplaceOrder->substatus_id = (int)$substatus; + $marketplaceOrder->raw_data = $newRawData; + + if ($marketplaceOrder->save()) { $newStatusHistoryRecord = new MarketplaceOrderStatusHistory(); $newStatusHistoryRecord->order_id = $marketplaceOrder->id; $newStatusHistoryRecord->status_id = (int)$status; @@ -297,19 +277,253 @@ class YandexMarketController extends Controller $newStatusHistoryRecord->active = 1; $newStatusHistoryRecord->initiator = "ERP"; $newStatusHistoryRecord->date_from = date('Y-m-d H:i:s'); - $newStatusHistoryRecord->date_end = date('Y-m-d H:i:s',strtotime("2100-01-01")); + $newStatusHistoryRecord->date_end = '2100-01-01 00:00:00'; + if (!$newStatusHistoryRecord->save()) { - Yii::error('Ошибка сохранения' . json_encode($newStatusHistoryRecord->getErrors(), JSON_UNESCAPED_UNICODE)); - } else { - $marketplaceOrder->status_history_id = $newStatusHistoryRecord->id; - if (!$marketplaceOrder->save()) { + Yii::error( + 'Ошибка сохранения истории: ' . json_encode( + $newStatusHistoryRecord->getErrors(), + JSON_UNESCAPED_UNICODE + ) + ); + } + + + $delivery = $order->getDelivery(); + if ($delivery) { + $deliveryModel = new MarketplaceOrderDelivery(); + $deliveryModel->order_id = $marketplaceOrder->id; + $deliveryModel->type = $delivery->getType(); + $deliveryModel->service_name = $delivery->getServiceName(); + $deliveryModel->partner_type = $delivery->getDeliveryPartnerType(); + + $address = $delivery->getAddress(); + if ($address) { + $deliveryModel->country = $address->getCountry(); + $deliveryModel->postcode = $address->getPostcode(); + $deliveryModel->city = $address->getCity(); + $deliveryModel->street = $address->getStreet(); + $deliveryModel->house = $address->getHouse(); + $deliveryModel->apartment = $address->getApartment(); + $deliveryModel->latitude = $address->getGps()->getLatitude(); + $deliveryModel->longitude = $address->getGps()->getLongitude(); + } + + $dates = $delivery->getDates(); + if ($dates) { + $deliveryModel->delivery_start = date( + 'Y-m-d H:i:s', + strtotime($dates->getFromDate() . ' ' . $dates->getFromTime()) + ); + $deliveryModel->delivery_end = date( + 'Y-m-d H:i:s', + strtotime($dates->getToDate() . ' ' . $dates->getToTime()) + ); + } + + $courier = $delivery->getCourier(); + if ($courier) { + $deliveryModel->courier_full_name = $courier->getFullName(); + $deliveryModel->courier_phone = $courier->getPhone(); + $deliveryModel->courier_extension = $courier->getPhoneExtension(); + $deliveryModel->courier_vehicle_number = $courier->getVehicleNumber(); + $deliveryModel->courier_vehicle_description = $courier->getVehicleDescription(); + } + + if (!$deliveryModel->save()) { Yii::error( - "Ошибка сохранения заказа с marketplace_id: " . $order->getId() . ". Ошибки: " . json_encode( - $marketplaceOrder->getErrors(), JSON_UNESCAPED_UNICODE + 'Ошибка сохранения доставки: ' . json_encode( + $deliveryModel->getErrors(), + JSON_UNESCAPED_UNICODE ) ); } } + + $items = $order->getItems(); + if (!empty($items)) { + foreach ($items as $item) { + $orderItem = new MarketplaceOrderItems(); + $orderItem->order_id = $marketplaceOrder->id; + $orderItem->external_item_id = $item->getId(); + $orderItem->offer_id = $item->getOfferId(); + $orderItem->offer_name = $item->getOfferName(); + $orderItem->price = $item->getPrice(); + $orderItem->buyer_price = $item->getBuyerPrice(); + $orderItem->buyer_price_before_discount = $item->getBuyerPriceBeforeDiscount(); + $orderItem->price_before_discount = $item->getPriceBeforeDiscount(); + $orderItem->count = $item->getCount(); + $orderItem->vat = $item->getVat(); + $orderItem->shop_sku = $item->getShopSku(); + $orderItem->subsidy = $item->getSubsidy(); + $orderItem->partner_warehouse_id = $item->getPartnerWarehouseId(); + $orderItem->promos = json_encode($item->getPromos()); + $orderItem->subsidies = json_encode($item->getSubsidies()); + + if (!$orderItem->save()) { + Yii::error( + 'Ошибка сохранения элемента заказа: ' . json_encode( + $orderItem->getErrors(), + JSON_UNESCAPED_UNICODE + ) + ); + } + } + } + } else { + Yii::error( + 'Ошибка сохранения заказа: ' . json_encode( + $marketplaceOrder->getErrors(), + JSON_UNESCAPED_UNICODE + ) + ); + } + } else { + if ($newRawData !== $marketplaceOrder->raw_data) { + $marketplaceOrder->updated_at = date('Y-m-d H:i:s', strtotime($order->getUpdatedAt())); + $marketplaceOrder->total = $order->getBuyerTotal(); + $marketplaceOrder->delivery_total = $order->getDeliveryTotal(); + $marketplaceOrder->buyer_total_before_discount = $order->getBuyerTotalBeforeDiscount(); + $marketplaceOrder->tax_system = $order->getTaxSystem(); + $marketplaceOrder->payment_type = $order->getPaymentType(); + $marketplaceOrder->payment_method = $order->getPaymentMethod(); + $marketplaceOrder->cancel_requested = (int)$order->getCancelRequested(); + $marketplaceOrder->raw_data = $newRawData; + + $statusHistoryRecord = MarketplaceOrderStatusHistory::find() + ->where(['order_id' => $marketplaceOrder->id]) + ->one(); + if ( + (!empty($statusHistoryRecord)) && + ($statusHistoryRecord->status_id !== $status + || $statusHistoryRecord->substatus_id !== $substatus) + ) { + $statusHistoryRecord->active = 0; + $statusHistoryRecord->date_to = date(); + $statusHistoryRecord->save(); + + $newStatusHistoryRecord = new MarketplaceOrderStatusHistory(); + $newStatusHistoryRecord->order_id = $marketplaceOrder->id; + $newStatusHistoryRecord->status_id = (int)$status; + $newStatusHistoryRecord->substatus_id = (int)$substatus; + $newStatusHistoryRecord->active = 1; + $newStatusHistoryRecord->initiator = "ERP"; + $newStatusHistoryRecord->date_from = date('Y-m-d H:i:s'); + $newStatusHistoryRecord->date_end = date('Y-m-d H:i:s', strtotime("2100-01-01")); + if (!$newStatusHistoryRecord->save()) { + Yii::error( + 'Ошибка сохранения' . json_encode( + $newStatusHistoryRecord->getErrors(), + JSON_UNESCAPED_UNICODE + ) + ); + } + } + $marketplaceOrder->status_id = (int)$status; + $marketplaceOrder->substatus_id = (int)$substatus; + $marketplaceOrder->updated_at = date('Y-m-d H:i:s', strtotime($order->getUpdatedAt())); + $marketplaceOrder->save(); + + $newItems = $order->getItems(); + $existingItems = MarketplaceOrderItems::find()->where(['order_id' => $marketplaceOrder->id]) + ->all(); + + if (count($existingItems) !== count($newItems)) { + MarketplaceOrderItems::deleteAll(['order_id' => $marketplaceOrder->id]); + foreach ($newItems as $item) { + $orderItem = new MarketplaceOrderItems(); + $orderItem->order_id = $marketplaceOrder->id; + $orderItem->external_item_id = $item->getId(); + $orderItem->offer_id = $item->getOfferId(); + $orderItem->offer_name = $item->getOfferName(); + $orderItem->price = $item->getPrice(); + $orderItem->buyer_price = $item->getBuyerPrice(); + $orderItem->buyer_price_before_discount = $item->getBuyerPriceBeforeDiscount(); + $orderItem->price_before_discount = $item->getPriceBeforeDiscount(); + $orderItem->count = $item->getCount(); + $orderItem->vat = $item->getVat(); + $orderItem->shop_sku = $item->getShopSku(); + $orderItem->subsidy = $item->getSubsidy(); + $orderItem->partner_warehouse_id = $item->getPartnerWarehouseId(); + $orderItem->promos = json_encode($item->getPromos()); + $orderItem->subsidies = json_encode($item->getSubsidies()); + + if (!$orderItem->save()) { + Yii::error( + 'Ошибка сохранения элемента заказа: ' . json_encode( + $orderItem->getErrors(), + JSON_UNESCAPED_UNICODE + ) + ); + } + } + } else { + foreach ($newItems as $item) { + $orderItem = MarketplaceOrderItems::findOne([ + 'order_id' => $marketplaceOrder->id, + 'external_item_id' => $item->getId() + ]); + if ($orderItem) { + $updateNeeded = false; + $fields = [ + 'offer_id' => $item->getOfferId(), + 'offer_name' => $item->getOfferName(), + 'price' => $item->getPrice(), + 'buyer_price' => $item->getBuyerPrice(), + 'buyer_price_before_discount' => $item->getBuyerPriceBeforeDiscount(), + 'price_before_discount' => $item->getPriceBeforeDiscount(), + 'count' => $item->getCount(), + 'vat' => $item->getVat(), + 'shop_sku' => $item->getShopSku(), + 'subsidy' => $item->getSubsidy(), + 'partner_warehouse_id' => $item->getPartnerWarehouseId(), + 'promos' => json_encode($item->getPromos()), + 'subsidies' => json_encode($item->getSubsidies()), + ]; + + foreach ($fields as $attr => $value) { + if ($orderItem->$attr != $value) { + $orderItem->$attr = $value; + $updateNeeded = true; + } + } + if ($updateNeeded && !$orderItem->save()) { + Yii::error( + 'Ошибка обновления элемента заказа: ' . json_encode( + $orderItem->getErrors(), + JSON_UNESCAPED_UNICODE + ) + ); + } + } else { + $orderItem = new MarketplaceOrderItems(); + $orderItem->order_id = $marketplaceOrder->id; + $orderItem->external_item_id = $item->getId(); + $orderItem->offer_id = $item->getOfferId(); + $orderItem->offer_name = $item->getOfferName(); + $orderItem->price = $item->getPrice(); + $orderItem->buyer_price = $item->getBuyerPrice(); + $orderItem->buyer_price_before_discount = $item->getBuyerPriceBeforeDiscount(); + $orderItem->price_before_discount = $item->getPriceBeforeDiscount(); + $orderItem->count = $item->getCount(); + $orderItem->vat = $item->getVat(); + $orderItem->shop_sku = $item->getShopSku(); + $orderItem->subsidy = $item->getSubsidy(); + $orderItem->partner_warehouse_id = $item->getPartnerWarehouseId(); + $orderItem->promos = json_encode($item->getPromos()); + $orderItem->subsidies = json_encode($item->getSubsidies()); + + if (!$orderItem->save()) { + Yii::error( + 'Ошибка сохранения нового элемента заказа: ' . json_encode( + $orderItem->getErrors(), + JSON_UNESCAPED_UNICODE + ) + ); + } + } + } + } } } } diff --git a/erp24/controllers/MarketplaceOrderItemsController.php b/erp24/controllers/MarketplaceOrderItemsController.php new file mode 100644 index 00000000..d9ff24f5 --- /dev/null +++ b/erp24/controllers/MarketplaceOrderItemsController.php @@ -0,0 +1,134 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ] + ); + } + + /** + * Lists all MarketplaceOrderItems models. + * + * @return string + */ + public function actionIndex() + { + $searchModel = new MarketplaceOrderItemsSearch(); + $dataProvider = $searchModel->search($this->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single MarketplaceOrderItems model. + * @param int $id ID + * @return string + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new MarketplaceOrderItems model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return string|\yii\web\Response + */ + public function actionCreate() + { + $model = new MarketplaceOrderItems(); + + if ($this->request->isPost) { + if ($model->load($this->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + } else { + $model->loadDefaultValues(); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing MarketplaceOrderItems model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param int $id ID + * @return string|\yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing MarketplaceOrderItems model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param int $id ID + * @return \yii\web\Response + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the MarketplaceOrderItems model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param int $id ID + * @return MarketplaceOrderItems the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = MarketplaceOrderItems::findOne(['id' => $id])) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/erp24/migrations/m250219_062708_create_marketplace_orders_table.php b/erp24/migrations/m250219_062708_create_marketplace_orders_table.php index a54bd4f4..f99e9307 100644 --- a/erp24/migrations/m250219_062708_create_marketplace_orders_table.php +++ b/erp24/migrations/m250219_062708_create_marketplace_orders_table.php @@ -17,9 +17,13 @@ class m250219_062708_create_marketplace_orders_table extends Migration if (!isset($tableSchema)) { $this->createTable(self::TABLE_NAME, [ 'id' => $this->bigPrimaryKey()->comment('ID заказа'), - 'marketplace_id' => $this->string(64)->notNull()->unique()->comment('ID заказа в системе маркетплейса'), - 'store_id' => $this->string(36)->comment('Идентификатор склада/магазина'), - 'status_history_id' => $this->bigInteger()->comment('Ссылка на текущий активный статус'), + 'marketplace_order_id' => $this->string(64)->notNull() + ->unique() + ->comment('ID заказа в системе маркетплейса'), + 'store_id' => $this->integer()->comment('Идентификатор магазина'), + 'status_id' => $this->integer()->notNull()->comment('Ссылка на тип статуса'), + 'substatus_id' => $this->integer()->notNull()->comment('Ссылка на подстатус'), + 'warehouse_guid' => $this->string(36)->comment('Идентификатор магазина'), 'creation_date' => $this->dateTime()->notNull()->comment('Дата создания заказа'), 'updated_at' => $this->dateTime()->notNull()->comment('Время последнего обновления'), 'total' => $this->decimal(15, 2)->notNull()->comment('Итоговая сумма к оплате'), diff --git a/erp24/migrations/m250219_081610_create_marketplace_order_status_types_table.php b/erp24/migrations/m250219_081610_create_marketplace_order_status_types_table.php index 7ed87fb1..f62aff55 100644 --- a/erp24/migrations/m250219_081610_create_marketplace_order_status_types_table.php +++ b/erp24/migrations/m250219_081610_create_marketplace_order_status_types_table.php @@ -15,7 +15,7 @@ class m250219_081610_create_marketplace_order_status_types_table extends Migrati if (!isset($tableSchema)) { $this->createTable(self::TABLE_NAME, [ 'id' => $this->primaryKey()->comment('ID статуса'), - 'code' => $this->string(64)->notNull()->comment('Код статуса'), + 'code' => $this->string(64)->notNull()->unique()->comment('Код статуса'), 'name' => $this->string(255)->null()->comment('Название статуса'), 'description' => $this->string()->null()->comment('Описание статуса'), ]); diff --git a/erp24/migrations/m250219_081716_create_marketplace_order_status_history_table.php b/erp24/migrations/m250219_081716_create_marketplace_order_status_history_table.php index 664e9d39..96b495f0 100644 --- a/erp24/migrations/m250219_081716_create_marketplace_order_status_history_table.php +++ b/erp24/migrations/m250219_081716_create_marketplace_order_status_history_table.php @@ -23,36 +23,6 @@ class m250219_081716_create_marketplace_order_status_history_table extends Migra 'date_end' => $this->dateTime()->null()->comment('Дата и время окончания активности'), 'initiator' => $this->text()->comment('Инициатор изменения'), ]); - - $this->addForeignKey( - 'fk_order_status_history_order', - self::TABLE_NAME, - 'order_id', - 'marketplace_orders', - 'id', - 'SET NULL', - 'CASCADE' - ); - - $this->addForeignKey( - 'fk_order_status_history_status', - self::TABLE_NAME, - 'status_id', - 'marketplace_order_status_types', - 'id', - 'RESTRICT', - 'CASCADE' - ); - - $this->addForeignKey( - 'fk_order_status_history_substatus', - self::TABLE_NAME, - 'substatus_id', - 'marketplace_order_status_types', - 'id', - 'SET NULL', - 'CASCADE' - ); } } diff --git a/erp24/migrations/m250219_082141_create_marketplace_order_delivery_table.php b/erp24/migrations/m250219_082141_create_marketplace_order_delivery_table.php index 6c1e0f18..cd4547f8 100644 --- a/erp24/migrations/m250219_082141_create_marketplace_order_delivery_table.php +++ b/erp24/migrations/m250219_082141_create_marketplace_order_delivery_table.php @@ -20,7 +20,7 @@ class m250219_082141_create_marketplace_order_delivery_table extends Migration 'service_name' => $this->string(64)->notNull()->comment('Название службы доставки'), 'partner_type' => $this->string(32)->notNull()->comment('Тип партнера доставки'), 'country' => $this->string(64)->notNull()->comment('Страна'), - 'postcode' => $this->string(16)->notNull()->comment('Индекс'), + 'postcode' => $this->string(16)->null()->comment('Индекс'), 'city' => $this->string(128)->notNull()->comment('Город'), 'street' => $this->string(255)->notNull()->comment('Улица'), 'house' => $this->string(16)->notNull()->comment('Дом'), @@ -35,16 +35,6 @@ class m250219_082141_create_marketplace_order_delivery_table extends Migration 'courier_vehicle_number' => $this->string(32)->null()->comment('Номер автомобиля курьера'), 'courier_vehicle_description' => $this->string(255)->null()->comment('Описание автомобиля курьера'), ]); - - $this->addForeignKey( - 'fk_order_delivery_order', - self::TABLE_NAME, - 'order_id', - 'marketplace_orders', - 'id', - 'SET NULL', - 'CASCADE' - ); } } diff --git a/erp24/migrations/m250220_084832_create_marketplace_order_items_table.php b/erp24/migrations/m250220_084832_create_marketplace_order_items_table.php new file mode 100644 index 00000000..f8c38272 --- /dev/null +++ b/erp24/migrations/m250220_084832_create_marketplace_order_items_table.php @@ -0,0 +1,50 @@ +db->getTableSchema(self::TABLE_NAME); + if (!isset($tableSchema)) { + $this->createTable(self::TABLE_NAME, [ + 'id' => $this->primaryKey(), + 'order_id' => $this->integer()->notNull()->comment('Ссылка на заказ'), + 'external_item_id' => $this->bigInteger()->notNull()->comment('ID элемента заказа из API'), + 'offer_id' => $this->string(64)->notNull()->comment('ID предложения'), + 'offer_name' => $this->string()->notNull()->comment('Название предложения'), + 'price' => $this->decimal(10, 2)->notNull()->comment('Цена'), + 'buyer_price' => $this->decimal(10, 2)->notNull()->comment('Цена для покупателя'), + 'buyer_price_before_discount' => $this->decimal(10, 2)->notNull()->comment('Цена для покупателя до скидки'), + 'price_before_discount' => $this->decimal(10, 2)->notNull()->comment('Цена до скидки'), + 'count' => $this->integer()->notNull()->comment('Количество'), + 'vat' => $this->string(32)->notNull()->comment('НДС'), + 'shop_sku' => $this->string(64)->notNull()->comment('SKU магазина'), + 'subsidy' => $this->decimal(10, 2)->notNull()->comment('Субсидия'), + 'partner_warehouse_id' => $this->string(64)->notNull()->comment('ID склада партнёра'), + 'promos' => $this->text()->comment('Промо скидки в формате JSON'), + 'subsidies' => $this->text()->comment('Субсидии в формате JSON'), + ]); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $tableSchema = $this->db->getTableSchema(self::TABLE_NAME); + + if (isset($tableSchema)) { + $this->dropTable(self::TABLE_NAME); + } + } +} diff --git a/erp24/records/MarketplaceOrderDelivery.php b/erp24/records/MarketplaceOrderDelivery.php index 2562101c..06061e12 100644 --- a/erp24/records/MarketplaceOrderDelivery.php +++ b/erp24/records/MarketplaceOrderDelivery.php @@ -13,7 +13,7 @@ use Yii; * @property string $service_name Название службы доставки * @property string $partner_type Тип партнера доставки * @property string $country Страна - * @property string $postcode Индекс + * @property string|null $postcode Индекс * @property string $city Город * @property string $street Улица * @property string $house Дом @@ -27,8 +27,6 @@ use Yii; * @property string|null $courier_extension Дополнительный номер курьера * @property string|null $courier_vehicle_number Номер автомобиля курьера * @property string|null $courier_vehicle_description Описание автомобиля курьера - * - * @property MarketplaceOrders $order */ class MarketplaceOrderDelivery extends \yii\db\ActiveRecord { @@ -48,8 +46,8 @@ class MarketplaceOrderDelivery extends \yii\db\ActiveRecord public function rules() { return [ - [['apartment', 'delivery_start', 'delivery_end', 'courier_full_name', 'courier_phone', 'courier_extension', 'courier_vehicle_number', 'courier_vehicle_description'], 'default', 'value' => null], - [['order_id', 'type', 'service_name', 'partner_type', 'country', 'postcode', 'city', 'street', 'house', 'latitude', 'longitude'], 'required'], + [['postcode', 'apartment', 'delivery_start', 'delivery_end', 'courier_full_name', 'courier_phone', 'courier_extension', 'courier_vehicle_number', 'courier_vehicle_description'], 'default', 'value' => null], + [['order_id', 'type', 'service_name', 'partner_type', 'country', 'city', 'street', 'house', 'latitude', 'longitude'], 'required'], [['order_id'], 'default', 'value' => null], [['order_id'], 'integer'], [['latitude', 'longitude'], 'number'], @@ -59,7 +57,6 @@ class MarketplaceOrderDelivery extends \yii\db\ActiveRecord [['postcode', 'house', 'apartment', 'courier_extension'], 'string', 'max' => 16], [['city'], 'string', 'max' => 128], [['street', 'courier_full_name', 'courier_vehicle_description'], 'string', 'max' => 255], - [['order_id'], 'exist', 'skipOnError' => true, 'targetClass' => MarketplaceOrders::class, 'targetAttribute' => ['order_id' => 'id']], ]; } @@ -92,14 +89,4 @@ class MarketplaceOrderDelivery extends \yii\db\ActiveRecord ]; } - /** - * Gets query for [[Order]]. - * - * @return \yii\db\ActiveQuery - */ - public function getOrder() - { - return $this->hasOne(MarketplaceOrders::class, ['id' => 'order_id']); - } - } diff --git a/erp24/records/MarketplaceOrderItems.php b/erp24/records/MarketplaceOrderItems.php new file mode 100644 index 00000000..26b56b80 --- /dev/null +++ b/erp24/records/MarketplaceOrderItems.php @@ -0,0 +1,82 @@ + null], + [['order_id', 'external_item_id', 'offer_id', 'offer_name', 'price', 'buyer_price', 'buyer_price_before_discount', 'price_before_discount', 'count', 'vat', 'shop_sku', 'subsidy', 'partner_warehouse_id'], 'required'], + [['order_id', 'external_item_id', 'count'], 'default', 'value' => null], + [['order_id', 'external_item_id', 'count'], 'integer'], + [['price', 'buyer_price', 'buyer_price_before_discount', 'price_before_discount', 'subsidy'], 'number'], + [['promos', 'subsidies'], 'string'], + [['offer_id', 'shop_sku', 'partner_warehouse_id'], 'string', 'max' => 64], + [['offer_name'], 'string', 'max' => 255], + [['vat'], 'string', 'max' => 32], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'order_id' => 'Ссылка на заказ', + 'external_item_id' => 'ID элемента заказа из API', + 'offer_id' => 'ID предложения', + 'offer_name' => 'Название предложения', + 'price' => 'Цена', + 'buyer_price' => 'Цена для покупателя', + 'buyer_price_before_discount' => 'Цена для покупателя до скидки', + 'price_before_discount' => 'Цена до скидки', + 'count' => 'Количество', + 'vat' => 'НДС', + 'shop_sku' => 'SKU магазина', + 'subsidy' => 'Субсидия', + 'partner_warehouse_id' => 'ID склада партнёра', + 'promos' => 'Промо скидки в формате JSON', + 'subsidies' => 'Субсидии в формате JSON', + ]; + } + +} diff --git a/erp24/records/MarketplaceOrderItemsSearch.php b/erp24/records/MarketplaceOrderItemsSearch.php new file mode 100644 index 00000000..4f2617ac --- /dev/null +++ b/erp24/records/MarketplaceOrderItemsSearch.php @@ -0,0 +1,84 @@ +load()` method. + * + * @return ActiveDataProvider + */ + public function search($params, $formName = null) + { + $query = MarketplaceOrderItems::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params, $formName); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'order_id' => $this->order_id, + 'external_item_id' => $this->external_item_id, + 'price' => $this->price, + 'buyer_price' => $this->buyer_price, + 'buyer_price_before_discount' => $this->buyer_price_before_discount, + 'price_before_discount' => $this->price_before_discount, + 'count' => $this->count, + 'subsidy' => $this->subsidy, + ]); + + $query->andFilterWhere(['ilike', 'offer_id', $this->offer_id]) + ->andFilterWhere(['ilike', 'offer_name', $this->offer_name]) + ->andFilterWhere(['ilike', 'vat', $this->vat]) + ->andFilterWhere(['ilike', 'shop_sku', $this->shop_sku]) + ->andFilterWhere(['ilike', 'partner_warehouse_id', $this->partner_warehouse_id]) + ->andFilterWhere(['ilike', 'promos', $this->promos]) + ->andFilterWhere(['ilike', 'subsidies', $this->subsidies]); + + return $dataProvider; + } +} diff --git a/erp24/records/MarketplaceOrderStatusHistory.php b/erp24/records/MarketplaceOrderStatusHistory.php index 91230b82..25212740 100644 --- a/erp24/records/MarketplaceOrderStatusHistory.php +++ b/erp24/records/MarketplaceOrderStatusHistory.php @@ -15,10 +15,6 @@ use Yii; * @property string $date_from Дата и время начала активности * @property string|null $date_end Дата и время окончания активности * @property string|null $initiator Инициатор изменения - * - * @property MarketplaceOrders $order - * @property MarketplaceOrderStatusTypes $status - * @property MarketplaceOrderStatusTypes $substatus */ class MarketplaceOrderStatusHistory extends \yii\db\ActiveRecord { @@ -45,9 +41,6 @@ class MarketplaceOrderStatusHistory extends \yii\db\ActiveRecord [['order_id', 'status_id', 'substatus_id', 'active'], 'integer'], [['date_from', 'date_end'], 'safe'], [['initiator'], 'string'], - [['status_id'], 'exist', 'skipOnError' => true, 'targetClass' => MarketplaceOrderStatusTypes::class, 'targetAttribute' => ['status_id' => 'id']], - [['substatus_id'], 'exist', 'skipOnError' => true, 'targetClass' => MarketplaceOrderStatusTypes::class, 'targetAttribute' => ['substatus_id' => 'id']], - [['order_id'], 'exist', 'skipOnError' => true, 'targetClass' => MarketplaceOrders::class, 'targetAttribute' => ['order_id' => 'id']], ]; } @@ -68,34 +61,4 @@ class MarketplaceOrderStatusHistory extends \yii\db\ActiveRecord ]; } - /** - * Gets query for [[Order]]. - * - * @return \yii\db\ActiveQuery - */ - public function getOrder() - { - return $this->hasOne(MarketplaceOrders::class, ['id' => 'order_id']); - } - - /** - * Gets query for [[Status]]. - * - * @return \yii\db\ActiveQuery - */ - public function getStatus() - { - return $this->hasOne(MarketplaceOrderStatusTypes::class, ['id' => 'status_id']); - } - - /** - * Gets query for [[Substatus]]. - * - * @return \yii\db\ActiveQuery - */ - public function getSubstatus() - { - return $this->hasOne(MarketplaceOrderStatusTypes::class, ['id' => 'substatus_id']); - } - } diff --git a/erp24/records/MarketplaceOrderStatusTypes.php b/erp24/records/MarketplaceOrderStatusTypes.php index 94076309..ceb8bb22 100644 --- a/erp24/records/MarketplaceOrderStatusTypes.php +++ b/erp24/records/MarketplaceOrderStatusTypes.php @@ -11,9 +11,6 @@ use Yii; * @property string $code Код статуса * @property string|null $name Название статуса * @property string|null $description Описание статуса - * - * @property MarketplaceOrderStatusHistory[] $marketplaceOrderStatusHistories - * @property MarketplaceOrderStatusHistory[] $marketplaceOrderStatusHistories0 */ class MarketplaceOrderStatusTypes extends \yii\db\ActiveRecord { @@ -37,6 +34,7 @@ class MarketplaceOrderStatusTypes extends \yii\db\ActiveRecord [['code'], 'required'], [['code'], 'string', 'max' => 64], [['name', 'description'], 'string', 'max' => 255], + [['code'], 'unique'], ]; } @@ -53,24 +51,4 @@ class MarketplaceOrderStatusTypes extends \yii\db\ActiveRecord ]; } - /** - * Gets query for [[MarketplaceOrderStatusHistories]]. - * - * @return \yii\db\ActiveQuery - */ - public function getMarketplaceOrderStatusHistories() - { - return $this->hasMany(MarketplaceOrderStatusHistory::class, ['status_id' => 'id']); - } - - /** - * Gets query for [[MarketplaceOrderStatusHistories0]]. - * - * @return \yii\db\ActiveQuery - */ - public function getMarketplaceOrderStatusHistories0() - { - return $this->hasMany(MarketplaceOrderStatusHistory::class, ['substatus_id' => 'id']); - } - } diff --git a/erp24/records/MarketplaceOrders.php b/erp24/records/MarketplaceOrders.php index 626c5e60..eda6edf3 100644 --- a/erp24/records/MarketplaceOrders.php +++ b/erp24/records/MarketplaceOrders.php @@ -8,9 +8,11 @@ use Yii; * This is the model class for table "marketplace_orders". * * @property int $id ID заказа - * @property string $marketplace_id ID заказа в системе маркетплейса - * @property string|null $store_id Идентификатор склада/магазина - * @property int|null $status_history_id Ссылка на текущий активный статус + * @property string $marketplace_order_id ID заказа в системе маркетплейса + * @property int|null $store_id Идентификатор магазина + * @property int $status_id Ссылка на тип статуса + * @property int $substatus_id Ссылка на подстатус + * @property string|null $warehouse_guid Идентификатор магазина * @property string $creation_date Дата создания заказа * @property string $updated_at Время последнего обновления * @property float $total Итоговая сумма к оплате @@ -23,9 +25,6 @@ use Yii; * @property string|null $raw_data Полный сырой ответ API * @property string|null $guid GUID заказа в 1С * @property int|null $status_1c Статус заказа в 1С - * - * @property MarketplaceOrderDelivery[] $marketplaceOrderDeliveries - * @property MarketplaceOrderStatusHistory[] $marketplaceOrderStatusHistories */ class MarketplaceOrders extends \yii\db\ActiveRecord { @@ -45,19 +44,19 @@ class MarketplaceOrders extends \yii\db\ActiveRecord public function rules() { return [ - [['store_id', 'status_history_id', 'raw_data', 'guid'], 'default', 'value' => null], + [['store_id', 'warehouse_guid', 'raw_data', 'guid'], 'default', 'value' => null], [['cancel_requested'], 'default', 'value' => 0], [['status_1c'], 'default', 'value' => 1], - [['marketplace_id', 'creation_date', 'updated_at', 'total', 'delivery_total', 'buyer_total_before_discount', 'tax_system', 'payment_type', 'payment_method'], 'required'], - [['status_history_id', 'cancel_requested', 'status_1c'], 'default', 'value' => null], - [['status_history_id', 'cancel_requested', 'status_1c'], 'integer'], + [['marketplace_order_id', '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', 'cancel_requested', 'status_1c'], 'default', 'value' => null], + [['store_id', 'status_id', 'substatus_id', 'cancel_requested', 'status_1c'], 'integer'], [['creation_date', 'updated_at'], 'safe'], [['total', 'delivery_total', 'buyer_total_before_discount'], 'number'], [['raw_data'], 'string'], - [['marketplace_id'], 'string', 'max' => 64], - [['store_id', 'guid'], 'string', 'max' => 36], + [['marketplace_order_id'], 'string', 'max' => 64], + [['warehouse_guid', 'guid'], 'string', 'max' => 36], [['tax_system', 'payment_type', 'payment_method'], 'string', 'max' => 32], - [['marketplace_id'], 'unique'], + [['marketplace_order_id'], 'unique'], ]; } @@ -68,9 +67,11 @@ class MarketplaceOrders extends \yii\db\ActiveRecord { return [ 'id' => 'ID заказа', - 'marketplace_id' => 'ID заказа в системе маркетплейса', - 'store_id' => 'Идентификатор склада/магазина', - 'status_history_id' => 'Ссылка на текущий активный статус', + 'marketplace_order_id' => 'ID заказа в системе маркетплейса', + 'store_id' => 'Идентификатор магазина', + 'status_id' => 'Ссылка на тип статуса', + 'substatus_id' => 'Ссылка на подстатус', + 'warehouse_guid' => 'Идентификатор магазина', 'creation_date' => 'Дата создания заказа', 'updated_at' => 'Время последнего обновления', 'total' => 'Итоговая сумма к оплате', @@ -86,24 +87,4 @@ class MarketplaceOrders extends \yii\db\ActiveRecord ]; } - /** - * Gets query for [[MarketplaceOrderDeliveries]]. - * - * @return \yii\db\ActiveQuery - */ - public function getMarketplaceOrderDeliveries() - { - return $this->hasMany(MarketplaceOrderDelivery::class, ['order_id' => 'id']); - } - - /** - * Gets query for [[MarketplaceOrderStatusHistories]]. - * - * @return \yii\db\ActiveQuery - */ - public function getMarketplaceOrderStatusHistories() - { - return $this->hasMany(MarketplaceOrderStatusHistory::class, ['order_id' => 'id']); - } - } diff --git a/erp24/records/MarketplaceOrdersSearch.php b/erp24/records/MarketplaceOrdersSearch.php index 2f0a0f85..c1fa088d 100644 --- a/erp24/records/MarketplaceOrdersSearch.php +++ b/erp24/records/MarketplaceOrdersSearch.php @@ -17,8 +17,8 @@ class MarketplaceOrdersSearch extends MarketplaceOrders public function rules() { return [ - [['id', 'status_history_id', 'cancel_requested', 'status_1c'], 'integer'], - [['marketplace_id', 'store_id', 'creation_date', 'updated_at', 'tax_system', 'payment_type', 'payment_method', 'raw_data', 'guid'], 'safe'], + [['id', 'store_id', 'status_id', 'substatus_id', 'cancel_requested', 'status_1c'], 'integer'], + [['marketplace_order_id', 'warehouse_guid', 'creation_date', 'updated_at', 'tax_system', 'payment_type', 'payment_method', 'raw_data', 'guid'], 'safe'], [['total', 'delivery_total', 'buyer_total_before_discount'], 'number'], ]; } @@ -61,7 +61,9 @@ class MarketplaceOrdersSearch extends MarketplaceOrders // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, - 'status_history_id' => $this->status_history_id, + 'store_id' => $this->store_id, + 'status_id' => $this->status_id, + 'substatus_id' => $this->substatus_id, 'creation_date' => $this->creation_date, 'updated_at' => $this->updated_at, 'total' => $this->total, @@ -71,8 +73,8 @@ class MarketplaceOrdersSearch extends MarketplaceOrders 'status_1c' => $this->status_1c, ]); - $query->andFilterWhere(['ilike', 'marketplace_id', $this->marketplace_id]) - ->andFilterWhere(['ilike', 'store_id', $this->store_id]) + $query->andFilterWhere(['ilike', 'marketplace_order_id', $this->marketplace_order_id]) + ->andFilterWhere(['ilike', 'warehouse_guid', $this->warehouse_guid]) ->andFilterWhere(['ilike', 'tax_system', $this->tax_system]) ->andFilterWhere(['ilike', 'payment_type', $this->payment_type]) ->andFilterWhere(['ilike', 'payment_method', $this->payment_method]) diff --git a/erp24/views/marketplace-order-items/_search.php b/erp24/views/marketplace-order-items/_search.php new file mode 100644 index 00000000..1491d224 --- /dev/null +++ b/erp24/views/marketplace-order-items/_search.php @@ -0,0 +1,57 @@ + + + diff --git a/erp24/views/marketplace-order-items/index.php b/erp24/views/marketplace-order-items/index.php new file mode 100644 index 00000000..94731453 --- /dev/null +++ b/erp24/views/marketplace-order-items/index.php @@ -0,0 +1,58 @@ +title = 'Marketplace Order Items'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ 'btn btn-success']) ?> +

+ + render('_search', ['model' => $searchModel]); ?> + + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'order_id', + 'external_item_id', + 'offer_id', + 'offer_name', + //'price', + //'buyer_price', + //'buyer_price_before_discount', + //'price_before_discount', + //'count', + //'vat', + //'shop_sku', + //'subsidy', + //'partner_warehouse_id', + //'promos:ntext', + //'subsidies:ntext', + [ + 'class' => ActionColumn::className(), + 'urlCreator' => function ($action, MarketplaceOrderItems $model, $key, $index, $column) { + return Url::toRoute([$action, 'id' => $model->id]); + } + ], + ], + ]); ?> + + +
diff --git a/erp24/views/marketplace-order-items/view.php b/erp24/views/marketplace-order-items/view.php new file mode 100644 index 00000000..fc19e381 --- /dev/null +++ b/erp24/views/marketplace-order-items/view.php @@ -0,0 +1,51 @@ +title = $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Marketplace Order Items', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+ +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'order_id', + 'external_item_id', + 'offer_id', + 'offer_name', + 'price', + 'buyer_price', + 'buyer_price_before_discount', + 'price_before_discount', + 'count', + 'vat', + 'shop_sku', + 'subsidy', + 'partner_warehouse_id', + 'promos:ntext', + 'subsidies:ntext', + ], + ]) ?> + +
diff --git a/erp24/views/marketplace-orders/_search.php b/erp24/views/marketplace-orders/_search.php index 6765db5e..29c17ad7 100644 --- a/erp24/views/marketplace-orders/_search.php +++ b/erp24/views/marketplace-orders/_search.php @@ -17,13 +17,17 @@ use yii\widgets\ActiveForm; field($model, 'id') ?> - field($model, 'marketplace_id') ?> + field($model, 'marketplace_order_id') ?> field($model, 'store_id') ?> - field($model, 'status_history_id') ?> + field($model, 'status_id') ?> - field($model, 'creation_date') ?> + field($model, 'substatus_id') ?> + + field($model, 'warehouse_guid') ?> + + field($model, 'creation_date') ?> field($model, 'updated_at') ?> diff --git a/erp24/views/marketplace-orders/index.php b/erp24/views/marketplace-orders/index.php index 6702300f..c842bdf4 100644 --- a/erp24/views/marketplace-orders/index.php +++ b/erp24/views/marketplace-orders/index.php @@ -30,10 +30,12 @@ $this->params['breadcrumbs'][] = $this->title; ['class' => 'yii\grid\SerialColumn'], 'id', - 'marketplace_id', + 'marketplace_order_id', 'store_id', - 'status_history_id', - 'creation_date', + 'status_id', + 'substatus_id', + //'warehouse_guid', + //'creation_date', //'updated_at', //'total', //'delivery_total', diff --git a/erp24/views/marketplace-orders/view.php b/erp24/views/marketplace-orders/view.php index 9781711b..9afbae35 100644 --- a/erp24/views/marketplace-orders/view.php +++ b/erp24/views/marketplace-orders/view.php @@ -30,9 +30,11 @@ $this->params['breadcrumbs'][] = $this->title; 'model' => $model, 'attributes' => [ 'id', - 'marketplace_id', + 'marketplace_order_id', 'store_id', - 'status_history_id', + 'status_id', + 'substatus_id', + 'warehouse_guid', 'creation_date', 'updated_at', 'total', -- 2.39.5