From 1308d6fe246a08ee88ffc024fe59614977db1de4 Mon Sep 17 00:00:00 2001 From: fomichev Date: Thu, 17 Jul 2025 17:38:53 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5?= =?utf8?q?=D0=BC=20=D0=BA=D0=BB=D1=8E=D1=87=20=D0=BE=D1=82=D0=BF=D1=80?= =?utf8?q?=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BE=D1=82=D0=BC=D0=B5=D0=BD=D0=B5?= =?utf8?q?=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7?= =?utf8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/DataController.php | 3 +- ...sent_field_to_marketplace_orders_table.php | 50 +++++++++++++++++++ erp24/records/MarketplaceOrders.php | 6 ++- erp24/views/marketplace-orders/index.php | 1 + erp24/views/marketplace-orders/view.php | 6 +++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 erp24/migrations/m250717_142552_add_cancelled_order_sent_field_to_marketplace_orders_table.php diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index d087bd2a..5def553f 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -905,6 +905,7 @@ class DataController extends BaseController ->where([ 'status_id' => $canceledStatusId ]) + ->andWhere(['cancelled_order_sent' => MarketplaceOrders::STATUSES_1C_CANCELLED_ORDER_NOT_SENT_IN_1C]) ->andWhere([ 'between', 'creation_date', @@ -917,7 +918,7 @@ class DataController extends BaseController /* @var MarketplaceOrders $marketplaceOrder */ $result[] = [ 'order_id' => $marketplaceOrder->guid ]; - + $marketplaceOrder->cancelled_order_sent = MarketplaceOrders::STATUSES_1C_CANCELLED_ORDER_SENT_IN_1C; } return $result; } diff --git a/erp24/migrations/m250717_142552_add_cancelled_order_sent_field_to_marketplace_orders_table.php b/erp24/migrations/m250717_142552_add_cancelled_order_sent_field_to_marketplace_orders_table.php new file mode 100644 index 00000000..785fa377 --- /dev/null +++ b/erp24/migrations/m250717_142552_add_cancelled_order_sent_field_to_marketplace_orders_table.php @@ -0,0 +1,50 @@ +db->schema->getTableSchema(self::TABLE_NAME); + if ($table === null) { + return; + } + + if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('cancelled_order_sent')) { + $this->addColumn( + self::TABLE_NAME, + 'cancelled_order_sent', + $this->integer()->defaultValue(0)->comment('Флаг отправки отмененного заказа в 1С') + ); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('cancelled_order_sent')) { + $this->dropColumn(self::TABLE_NAME, 'cancelled_order_sent'); + } + } + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m250717_142552_add_cancelled_order_sent_field_to_marketplace_orders_table cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/erp24/records/MarketplaceOrders.php b/erp24/records/MarketplaceOrders.php index 5452066b..c3d002e8 100644 --- a/erp24/records/MarketplaceOrders.php +++ b/erp24/records/MarketplaceOrders.php @@ -46,6 +46,7 @@ use yii\db\Expression; * @property string|null $manager_link Ссылка на панели менеджера заказов * @property string|null $sent_1c_at Время отправки заказа в 1С * @property int|null $attempts_number Количество попыток отправки заказа в 1С + * @property int $cancelled_order_sent Флаг отправки отмененного заказа в 1С */ class MarketplaceOrders extends \yii\db\ActiveRecord { @@ -58,6 +59,8 @@ class MarketplaceOrders extends \yii\db\ActiveRecord const STATUSES_1C_CREATED_IN_ERP = 1; const STATUSES_1C_SENDED_TO_1C = 2; const STATUSES_1C_CREATED_IN_1C = 3; + const STATUSES_1C_CANCELLED_ORDER_SENT_IN_1C = 1; + const STATUSES_1C_CANCELLED_ORDER_NOT_SENT_IN_1C = 0; const STATUSES_1C = [ self::STATUSES_1C_CREATED_IN_ERP => 'Создан в ЕРП', @@ -96,7 +99,7 @@ class MarketplaceOrders extends \yii\db\ActiveRecord [['marketplace_order_id', 'marketplace_id', 'marketplace_name', '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', 'fake', 'cancel_requested', 'status_1c', 'status_processing_1c', 'order_link', 'delivery_to', 'order_photo'], 'default', 'value' => null], [[ 'fake'], 'default', 'value' => 0], - [['store_id', 'status_id', 'substatus_id', 'fake', 'cancel_requested', 'status_1c', 'marketplace_id', 'status_telegram', 'status_processing_1c', 'readyto_1c', 'attempts_number'], 'integer'], + [['store_id', 'status_id', 'substatus_id', 'fake', 'cancel_requested', 'status_1c', 'marketplace_id', 'status_telegram', 'status_processing_1c', 'readyto_1c', 'attempts_number', 'cancelled_order_sent'], 'integer'], [['creation_date', 'updated_at', 'returned_at', 'sent_1c_at'], 'safe'], [['return_data', 'raw_data', 'marketplace_name', 'telegram_error', 'order_link', 'delivery_to', 'order_photo', 'manager_link'], 'string'], [['total', 'delivery_total', 'buyer_total_before_discount'], 'number'], @@ -152,6 +155,7 @@ class MarketplaceOrders extends \yii\db\ActiveRecord 'check_guid' => 'GUID чека заказа МП', 'sent_1c_at' => 'Время отправки заказа в 1С', 'attempts_number' => 'Количество попыток отправки заказа в 1С', + 'cancelled_order_sent' => 'Флаг отправки отмененного заказа в 1С', ]; } diff --git a/erp24/views/marketplace-orders/index.php b/erp24/views/marketplace-orders/index.php index 5cd1082f..92732abd 100644 --- a/erp24/views/marketplace-orders/index.php +++ b/erp24/views/marketplace-orders/index.php @@ -42,6 +42,7 @@ YiiAsset::register($this); 'btn btn-success']) ?> 'btn btn-success']) ?> 'btn btn-success']) ?> + 'btn btn-success']) ?>

diff --git a/erp24/views/marketplace-orders/view.php b/erp24/views/marketplace-orders/view.php index 06220c60..89d6db21 100644 --- a/erp24/views/marketplace-orders/view.php +++ b/erp24/views/marketplace-orders/view.php @@ -127,6 +127,12 @@ $this->params['breadcrumbs'][] = $this->title; return $model->status1c->status ?? null; } ], + [ + 'attribute' => 'cancelled_order_sent', + 'value' => function ($model) { + return $model->cancelled_order_sent === 0 ? 'Нет' : 'Да'; + } + ], [ 'label' => 'Фото заказа', 'format' => 'raw', -- 2.39.5