From: fomichev Date: Thu, 17 Jul 2025 14:38:53 +0000 (+0300) Subject: Добавляем ключ отправки отмененного заказа X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=1308d6fe246a08ee88ffc024fe59614977db1de4;p=erp24_rep%2Fyii-erp24%2F.git Добавляем ключ отправки отмененного заказа --- 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',