From: Alexander Smirnov Date: Tue, 29 Apr 2025 13:55:11 +0000 (+0300) Subject: [ERP-409] is_marketplace & marketplace_name X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=c40cf5559c650126c53f8eaa3001f0ddc54284f6;p=erp24_rep%2Fyii-erp24%2F.git [ERP-409] is_marketplace & marketplace_name --- diff --git a/erp24/media/controllers/NotificationController.php b/erp24/media/controllers/NotificationController.php index 98b92c00..29d333ee 100644 --- a/erp24/media/controllers/NotificationController.php +++ b/erp24/media/controllers/NotificationController.php @@ -215,6 +215,7 @@ class NotificationController extends Controller if ($newStatusCode == 'DELIVERED' && $newSubstatusCode == 'DELIVERY_SERVICE_DELIVERED' && $marketplaceOrder) { $createChecks = new CreateChecks; $createChecks->order_guid = $marketplaceOrder->guid; + $createChecks->marketplace_order_id = $marketplaceOrder->marketplace_order_id; $eit = ExportImportTable::find()->select(['export_val'])->where(['entity' => 'city_store', 'export_id' => 1, 'entity_id' => $marketplaceOrder->store_id])->one(); $createChecks->store_id = $eit->export_val ?? ''; @@ -238,6 +239,8 @@ class NotificationController extends Controller $createChecks->held = 1; $createChecks->comments = ''; $createChecks->date = date('Y-m-d H:i:s'); + $createChecks->is_marketplace = 1; + $createChecks->marketplace_name = 'ЯндексМаркет'; $createChecks->save(); if ($createChecks->getErrors()) { Yii::warning("ORDER_ID_: " . Json::encode($createChecks->getErrors())); diff --git a/erp24/media/notification/test.txt b/erp24/media/notification/test.txt old mode 100644 new mode 100755 diff --git a/erp24/migrations/m250428_114148_add_column_marketplace_order_id_to_table_create_check.php b/erp24/migrations/m250428_114148_add_column_marketplace_order_id_to_table_create_check.php index 28d84ead..3019cd27 100755 --- a/erp24/migrations/m250428_114148_add_column_marketplace_order_id_to_table_create_check.php +++ b/erp24/migrations/m250428_114148_add_column_marketplace_order_id_to_table_create_check.php @@ -25,6 +25,22 @@ class m250428_114148_add_column_marketplace_order_id_to_table_create_check exten ); } + if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('is_marketplace')) { + $this->addColumn( + self::TABLE_NAME, + 'is_marketplace', + $this->tinyInteger()->null()->defaultValue(0)->comment('признак продажи через маркетплейс') + ); + } + + if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('marketplace_name')) { + $this->addColumn( + self::TABLE_NAME, + 'marketplace_name', + $this->string(36)->null()->comment('название маркетплейса') + ); + } + $this->alterColumn(self::TABLE_NAME, 'kkm_id', $this->string(36)->null()->comment('kkm_id')); $this->alterColumn(self::TABLE_NAME, 'seller_id', $this->string(36)->null()->comment('seller_id')); $this->alterColumn(self::TABLE_NAME, 'order_id', $this->bigInteger()->null()->comment('order_id')); @@ -38,5 +54,11 @@ class m250428_114148_add_column_marketplace_order_id_to_table_create_check exten if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('marketplace_order_id')) { $this->dropColumn(self::TABLE_NAME, 'marketplace_order_id'); } + if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('is_marketplace')) { + $this->dropColumn(self::TABLE_NAME, 'is_marketplace'); + } + if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('marketplace_name')) { + $this->dropColumn(self::TABLE_NAME, 'marketplace_name'); + } } } diff --git a/erp24/records/CreateChecks.php b/erp24/records/CreateChecks.php index 59a278c2..a62ea1eb 100644 --- a/erp24/records/CreateChecks.php +++ b/erp24/records/CreateChecks.php @@ -28,6 +28,9 @@ use yii_app\api3\core\validators\PhoneValidator; * @property string $comments комментарий к чеку- номер телефона клиента * @property string|null $phone Телефон клиента * @property string|null $order_guid GUID заказа в МП + * @property string|null $marketplace_order_id + * @property int|null $is_marketplace признак продажи через маркетплейс + * @property string|null $marketplace_name название маркетплейса */ class CreateChecks extends \yii\db\ActiveRecord { @@ -46,10 +49,10 @@ class CreateChecks extends \yii\db\ActiveRecord { return [ [[/*'kkm_id', */'store_id', /*'order_id', */'check_id', 'guid', /*'name', 'sales_check',*/ 'items', /*'payments',*/ 'held', 'date'/*, 'comments'*/], 'required'], - [['order_id', 'held', 'status'], 'integer'], + [['order_id', 'held', 'status', 'is_marketplace'], 'integer'], [['type', 'items', 'payments', 'phone'], 'string'], [['date', 'delivery_date', 'date_up', 'phone'], 'safe'], - [['kkm_id', 'seller_id', 'store_id', 'check_id', 'guid', 'sales_check', 'order_guid'], 'string', 'max' => 36], + [['kkm_id', 'seller_id', 'store_id', 'check_id', 'guid', 'sales_check', 'order_guid', 'marketplace_order_id', 'marketplace_name'], 'string', 'max' => 36], [['name', 'comments'], 'string', 'max' => 255], [['phone'], 'string', 'max' => 20], ['phone', PhoneValidator::class], @@ -82,6 +85,9 @@ class CreateChecks extends \yii\db\ActiveRecord 'date_up' => 'Date Up', 'comments' => 'Comments', 'order_guid' => 'Order Guid', + 'marketplace_order_id' => 'Marketplace Order ID', + 'is_marketplace' => 'Is Marketplace', + 'marketplace_name' => 'Marketplace Name', ]; } } diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index 77b55127..6afc5b7f 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -1761,6 +1761,7 @@ class MarketplaceService /* @var $marketplaceOrder MarketplaceOrders */ $createChecks = new CreateChecks; $createChecks->order_guid = $marketplaceOrder->guid; + $createChecks->marketplace_order_id = $marketplaceOrder->marketplace_order_id; $eit = ExportImportTable::find()->select(['export_val'])->where(['entity' => 'city_store', 'export_id' => 1, 'entity_id' => $marketplaceOrder->store_id])->one(); $createChecks->store_id = $eit->export_val ?? ''; @@ -1784,6 +1785,8 @@ class MarketplaceService $createChecks->held = 1; $createChecks->comments = ''; $createChecks->date = date('Y-m-d H:i:s'); + $createChecks->is_marketplace = 1; + $createChecks->marketplace_name = 'ФлауВау'; $createChecks->save(); if ($createChecks->getErrors()) { Yii::warning("ORDER_ID_: " . Json::encode($createChecks->getErrors()));