From: marina Date: Mon, 3 Mar 2025 06:19:44 +0000 (+0300) Subject: ERP-302 Новый интерфейс для работы с заказами мп и амо X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=5ecdfe5dc81f4791f73ea609eb8e30f1f7cf4c52;p=erp24_rep%2Fyii-erp24%2F.git ERP-302 Новый интерфейс для работы с заказами мп и амо --- 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'], + ], + ], +]); ?>