--- /dev/null
+<?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');
+ }
+ }
+}
namespace yii_app\records;
use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\Expression;
/**
* This is the model class for table "marketplace_orders".
* @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
{
'Отказ' => ["CANCELLED", "SHOP_FAILED"],
];
-
-
+ public function behaviors()
+ {
+ return [
+ [
+ 'class' => TimestampBehavior::class,
+ 'value' => new Expression('CURRENT_TIMESTAMP'),
+ ],
+ ];
+ }
/**
* {@inheritdoc}
*/
'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с',
'delivery_to' => 'Сроки доставки заказа',
'readyto_1c' => 'Готовность к отправке в 1С',
'order_photo' => 'Ссылка на фото собранного заказа для МП',
+ 'created_at' => 'Время создания заказа в ERP',
];
}
{
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'],
];
}
'buyer_total_before_discount' => $this->buyer_total_before_discount,
'cancel_requested' => $this->cancel_requested,
'status_1c' => $this->status_1c,
+ 'marketplace_name' => $this->marketplace_name,
]);
// Фильтрация по строковым полям
'warehouse_guid',
'marketplace_name',
'creation_date',
- 'updated_at',
+ 'created_at',
'total',
'delivery_total',
'buyer_total_before_discount',
],
'warehouse_guid',
'creation_date',
+ 'created_at',
'updated_at',
'delivery_to',
'total',