From 5ecdfe5dc81f4791f73ea609eb8e30f1f7cf4c52 Mon Sep 17 00:00:00 2001 From: marina Date: Mon, 3 Mar 2025 09:19:44 +0300 Subject: [PATCH] =?utf8?q?ERP-302=20=D0=9D=D0=BE=D0=B2=D1=8B=D0=B9=20?= =?utf8?q?=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=20=D0=B4?= =?utf8?q?=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20?= =?utf8?q?=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=B0=D0=BC=D0=B8=20=D0=BC=D0=BF?= =?utf8?q?=20=D0=B8=20=D0=B0=D0=BC=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../MarketplaceOrdersController.php | 86 +++++++++++++++++++ erp24/views/marketplace-orders/all-orders.php | 29 +++++++ 2 files changed, 115 insertions(+) create mode 100644 erp24/views/marketplace-orders/all-orders.php diff --git a/erp24/controllers/MarketplaceOrdersController.php b/erp24/controllers/MarketplaceOrdersController.php index d655767a..add0fd36 100644 --- a/erp24/controllers/MarketplaceOrdersController.php +++ b/erp24/controllers/MarketplaceOrdersController.php @@ -4,12 +4,15 @@ namespace app\controllers; use Yii; use yii\base\Exception; +use yii\data\ArrayDataProvider; +use yii\db\Query; use yii_app\records\MarketplaceOrders; use yii_app\records\MarketplaceOrdersSearch; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use yii_app\records\MarketplaceOrderStatusTypes; +use yii_app\records\OrdersAmo; use yii_app\services\MarketplaceService; /** @@ -232,4 +235,87 @@ class MarketplaceOrdersController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } + + + public function actionAllOrders() + { + $queryAmo = (new Query()) + ->select([ + new \yii\db\Expression("'amo' AS source"), + 'id', + new \yii\db\Expression('store_id::VARCHAR AS store_id'), + new \yii\db\Expression('status_id::BIGINT AS status_id'), + 'updated_at', + new \yii\db\Expression('NULL::VARCHAR AS marketplace_order_id'), + new \yii\db\Expression('NULL::VARCHAR AS substatus_id'), + new \yii\db\Expression('NULL::VARCHAR AS warehouse_guid'), + new \yii\db\Expression('NULL::TIMESTAMP AS creation_date'), + new \yii\db\Expression('NULL::TIMESTAMP AS returned_at'), + new \yii\db\Expression('NULL::TEXT AS return_data'), + new \yii\db\Expression('NULL::INTEGER AS fake'), + new \yii\db\Expression('NULL::NUMERIC AS total'), + new \yii\db\Expression('NULL::NUMERIC AS delivery_total'), + new \yii\db\Expression('NULL::NUMERIC AS buyer_total_before_discount'), + new \yii\db\Expression('NULL::VARCHAR AS tax_system'), + new \yii\db\Expression('NULL::VARCHAR AS payment_type'), + new \yii\db\Expression('NULL::VARCHAR AS payment_method'), + new \yii\db\Expression('NULL::BOOLEAN AS cancel_requested'), + new \yii\db\Expression('NULL::TEXT AS raw_data'), + new \yii\db\Expression('NULL::VARCHAR AS guid'), + new \yii\db\Expression('NULL::VARCHAR AS status_1c') + ]) + ->from(OrdersAmo::tableName()); + + $queryMarketplace = (new Query()) + ->select([ + new \yii\db\Expression("'marketplace' AS source"), + 'id', + new \yii\db\Expression('store_id::VARCHAR AS store_id'), + new \yii\db\Expression('status_id::BIGINT AS status_id'), + 'updated_at', + 'marketplace_order_id', + new \yii\db\Expression('substatus_id::VARCHAR AS substatus_id'), + 'warehouse_guid', + 'creation_date', + 'returned_at', + 'return_data', + new \yii\db\Expression('fake::INTEGER AS fake'), + 'total', + 'delivery_total', + 'buyer_total_before_discount', + 'tax_system', + 'payment_type', + 'payment_method', + new \yii\db\Expression(" + CASE + WHEN cancel_requested = 1 THEN TRUE + WHEN cancel_requested = 0 THEN FALSE + ELSE NULL + END AS cancel_requested + "), + 'raw_data', + 'guid', + new \yii\db\Expression('status_1c::VARCHAR AS status_1c') + ]) + ->from(MarketplaceOrders::tableName()); + + $unionQuery = (new Query()) + ->from(['orders' => $queryAmo->union($queryMarketplace, true)]); // UNION ALL для скорости + + $orders = $unionQuery->all(); + + $dataProvider = new ArrayDataProvider([ + 'allModels' => $orders, + 'pagination' => [ + 'pageSize' => 20 + ], + 'sort' => [ + 'attributes' => ['id', 'store_id', 'status_id', 'updated_at'], + ], + ]); + + return $this->render('all-orders', [ + 'dataProvider' => $dataProvider, + ]); + } } diff --git a/erp24/views/marketplace-orders/all-orders.php b/erp24/views/marketplace-orders/all-orders.php new file mode 100644 index 00000000..d20c486f --- /dev/null +++ b/erp24/views/marketplace-orders/all-orders.php @@ -0,0 +1,29 @@ +title = 'Все заказы'; +?> + +

title) ?>

+ + $dataProvider, + 'filterModel' => null, + 'columns' => [ + [ + 'attribute' => 'source', + 'label' => 'Источник', + ], + 'id', + 'store_id', + 'status_id', + [ + 'attribute' => 'updated_at', + 'format' => ['date', 'php:Y-m-d H:i'], + ], + ], +]); ?> -- 2.39.5