]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление created_at и фильтрация по marketplace_name origin/feature_fomichev_erp-20250506_add_created_at_column_to_mp_orders
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 6 May 2025 10:00:53 +0000 (13:00 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 6 May 2025 10:00:53 +0000 (13:00 +0300)
erp24/migrations/m250506_091013_add_created_at_column_to_marketplace_orders_table.php [new file with mode: 0644]
erp24/records/MarketplaceOrders.php
erp24/records/MarketplaceOrdersSearch.php
erp24/views/marketplace-orders/index.php
erp24/views/marketplace-orders/view.php

diff --git a/erp24/migrations/m250506_091013_add_created_at_column_to_marketplace_orders_table.php b/erp24/migrations/m250506_091013_add_created_at_column_to_marketplace_orders_table.php
new file mode 100644 (file)
index 0000000..7a162c3
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles adding columns to table `{{%marketplace_orders}}`.
+ */
+class m250506_091013_add_created_at_column_to_marketplace_orders_table extends Migration
+{
+    const TABLE_NAME = 'erp24.marketplace_orders';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $table = $this->db->schema->getTableSchema(self::TABLE_NAME);
+        if ($table === null) {
+            return;
+        }
+
+        if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('created_at')) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'created_at',
+                $this->timestamp()->null()->defaultExpression('CURRENT_TIMESTAMP')->comment('Время создания заказа в ERP'),
+            );
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('created_at')) {
+            $this->dropColumn(self::TABLE_NAME, 'created_at');
+        }
+    }
+}
index 91971a4ee88f23d6a017735d8cbdc699deede4df..d2152a888b490894f95662ba408b0f803c4c55fd 100644 (file)
@@ -3,6 +3,8 @@
 namespace yii_app\records;
 
 use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\Expression;
 
 /**
  * This is the model class for table "marketplace_orders".
@@ -38,6 +40,7 @@ use Yii;
  * @property string|null $delivery_to Сроки доставки заказа
  * @property int $readyto_1c Готовность к отправке в 1С: 0 - не готов, 1 - готов. Зависит от наполения $delivery_to
  * @property string|null $order_photo Ссылка на фото собранного заказа для МП
+ * @property string|null $created_at Время создания заказа в ERP
  */
 class MarketplaceOrders extends \yii\db\ActiveRecord
 {
@@ -71,8 +74,15 @@ class MarketplaceOrders extends \yii\db\ActiveRecord
         'Отказ' => ["CANCELLED", "SHOP_FAILED"],
     ];
 
-
-
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'value' => new Expression('CURRENT_TIMESTAMP'),
+            ],
+        ];
+    }
     /**
      * {@inheritdoc}
      */
@@ -131,7 +141,7 @@ class MarketplaceOrders extends \yii\db\ActiveRecord
             'raw_data' => 'Полный сырой ответ API',
             'guid' => 'GUID заказа в 1С',
             'status_1c' => 'Статус заказа в 1С',
-            'marketplace_name' => 'Наименование маркетплейса',
+            'marketplace_name' => 'Наименование маркетплейса: ФлауВау ЯндексМаркет',
             'marketplace_id' => 'ID маркетплейса: 1 - Flowwow, 2 - YandexMarket',
             'error_text' => 'Ошибка',
             'number_1c' => 'Номер документа в 1с',
@@ -142,6 +152,7 @@ class MarketplaceOrders extends \yii\db\ActiveRecord
             'delivery_to' => 'Сроки доставки заказа',
             'readyto_1c' => 'Готовность к отправке в 1С',
             'order_photo' => 'Ссылка на фото собранного заказа для МП',
+            'created_at' => 'Время создания заказа в ERP',
         ];
     }
 
index b5b1a8190c06b8b5985503723b09a8998e776209..1bd1a2a8763bce0dc1720c7753b0cf7446731a05 100644 (file)
@@ -23,7 +23,19 @@ class MarketplaceOrdersSearch extends MarketplaceOrders
     {
         return [
             [['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','store_name', 'status_code', 'substatus_code'], 'safe'],
+            [['marketplace_order_id',
+                'warehouse_guid',
+                'creation_date',
+                'updated_at',
+                'tax_system',
+                'payment_type',
+                'payment_method',
+                'raw_data',
+                'guid',
+                'marketplace_name',
+                'store_name',
+                'status_code',
+                'substatus_code'], 'safe'],
             [['total', 'delivery_total', 'buyer_total_before_discount'], 'number'],
         ];
     }
@@ -73,6 +85,7 @@ class MarketplaceOrdersSearch extends MarketplaceOrders
             'buyer_total_before_discount' => $this->buyer_total_before_discount,
             'cancel_requested' => $this->cancel_requested,
             'status_1c' => $this->status_1c,
+            'marketplace_name' => $this->marketplace_name,
         ]);
 
         // Фильтрация по строковым полям
index e0d38e727266f883dd9ce84d9d39f9195eb0ae7a..2807dd07df18069b9dda9bc205655f73bc42b02f 100644 (file)
@@ -132,7 +132,7 @@ YiiAsset::register($this);
             'warehouse_guid',
             'marketplace_name',
             'creation_date',
-            'updated_at',
+            'created_at',
             'total',
             'delivery_total',
             'buyer_total_before_discount',
index 65a0c2a0b70cf7cfd7f9f9b3fcd2623ab33c3d4d..6a79c3594c9602a51445ed8afa9401f36acd972c 100644 (file)
@@ -57,6 +57,7 @@ $this->params['breadcrumbs'][] = $this->title;
             ],
             'warehouse_guid',
             'creation_date',
+            'created_at',
             'updated_at',
             'delivery_to',
             'total',