]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Переименование таблиц feature_fomichev_erp-263_kogort_download_page
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 25 Dec 2024 14:40:51 +0000 (17:40 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 25 Dec 2024 14:40:51 +0000 (17:40 +0300)
erp24/commands/CronController.php
erp24/controllers/UsersMessageManagementController.php
erp24/migrations/m241224_140248_create_users_telegram_chat_id_table.php [deleted file]
erp24/migrations/m241224_140248_create_users_telegram_table.php [new file with mode: 0644]
erp24/records/Users.php
erp24/records/UsersTelegram.php [new file with mode: 0644]
erp24/records/UsersTelegramChatId.php [deleted file]

index 45f54d9061ec4f561c8ea7d1b81aec0a214b93db..20831862c36e58c55726151e2755c5998091c0b0 100644 (file)
@@ -16,7 +16,7 @@ use yii_app\records\ReplacementInvoiceProducts;
 use yii_app\records\SentKogort;
 use yii_app\records\Users;
 use yii_app\records\UsersMessageManagement;
-use yii_app\records\UsersTelegramChatId;
+use yii_app\records\UsersTelegram;
 use yii_app\records\UsersTelegramLog;
 
 class CronController extends Controller
@@ -384,10 +384,10 @@ class CronController extends Controller
                 $isBlocked = (int)$remoteUser['is_blocked'];
                 $isRegistered = (int)$remoteUser['is_registered'];
 
-                $user = UsersTelegramChatId::findOne(['chat_id' => $chatId]);
+                $user = UsersTelegram::findOne(['chat_id' => $chatId]);
 
                 if (!$user) {
-                    $user = new UsersTelegramChatId([
+                    $user = new UsersTelegram([
                         'chat_id' => $chatId,
                         'phone' => $phone,
                         'username' => $username ?? 'Клиент из чатбота',
index 05e0d98d96f19636536a0eac31e496f091e9f615..da9daa0ce6e17adfd73fdefe8727ba06d856faf8 100644 (file)
@@ -21,7 +21,7 @@ use yii_app\records\Users;
 use yii_app\records\UsersEvents;
 use yii_app\records\UsersMessageManagement;
 use yii_app\records\UsersMessageManagementLogs;
-use yii_app\records\UsersTelegramChatId;
+use yii_app\records\UsersTelegram;
 use yii_app\records\UsersTelegramLog;
 
 class UsersMessageManagementController extends Controller
@@ -420,10 +420,10 @@ class UsersMessageManagementController extends Controller
                 $isBlocked = (int)$remoteUser['is_blocked'];
                 $isRegistered = (int)$remoteUser['is_registered'];
 
-                $user = UsersTelegramChatId::findOne(['chat_id' => $chatId]);
+                $user = UsersTelegram::findOne(['chat_id' => $chatId]);
 
                 if (!$user) {
-                    $user = new UsersTelegramChatId([
+                    $user = new UsersTelegram([
                         'chat_id' => $chatId,
                         'phone' => $phone,
                         'username' => $username ?? 'Клиент из чатбота',
diff --git a/erp24/migrations/m241224_140248_create_users_telegram_chat_id_table.php b/erp24/migrations/m241224_140248_create_users_telegram_chat_id_table.php
deleted file mode 100644 (file)
index 53217ec..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-use yii\db\Migration;
-
-/**
- * Class m241224_140248_add_telegram_chat_id_to_users_table
- */
-class m241224_140248_create_users_telegram_chat_id_table extends Migration
-{
-    const TABLE_NAME = 'erp24.users_telegram_chat_id';
-
-    /**
-     * {@inheritdoc}
-     */
-    public function safeUp()
-    {
-        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
-
-        if (!isset($tableSchema)) {
-            $this->createTable(self::TABLE_NAME, [
-                'chat_id' => $this->string()->notNull()->comment('Chat ID'),
-                'phone' => $this->string()->null()->comment('Телефон'),
-                'username' => $this->string()->null()->comment('Имя пользователя в Телеграм'),
-                'first_name' => $this->string()->null()->comment('Имя пользователя'),
-                'is_blocked' => $this->integer(1)->notNull()->defaultValue(0)->comment(
-                    'Заблокирован: 0 - нет, 1 - да'
-                ),
-                'is_registered' => $this->integer(1)->notNull()->defaultValue(0)->comment(
-                    'Зарегистрирован: 0 - нет, 1 - да'
-                ),
-            ]);
-        }
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function safeDown()
-    {
-        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
-        if (isset($tableSchema)) {
-            $this->dropTable(self::TABLE_NAME);
-        }
-    }
-
-    /*
-    // Use up()/down() to run migration code without a transaction.
-    public function up()
-    {
-
-    }
-
-    public function down()
-    {
-        echo "m241224_140248_add_telegram_chat_id_to_users_table cannot be reverted.\n";
-
-        return false;
-    }
-    */
-}
diff --git a/erp24/migrations/m241224_140248_create_users_telegram_table.php b/erp24/migrations/m241224_140248_create_users_telegram_table.php
new file mode 100644 (file)
index 0000000..075758d
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m241224_140248_add_telegram_chat_id_to_users_table
+ */
+class m241224_140248_create_users_telegram_table extends Migration
+{
+    const TABLE_NAME = 'erp24.users_telegram';
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        if (!isset($tableSchema)) {
+            $this->createTable(self::TABLE_NAME, [
+                'chat_id' => $this->string()->notNull()->comment('Chat ID'),
+                'phone' => $this->string()->null()->comment('Телефон'),
+                'username' => $this->string()->null()->comment('Имя пользователя в Телеграм'),
+                'first_name' => $this->string()->null()->comment('Имя пользователя'),
+                'is_blocked' => $this->integer(1)->notNull()->defaultValue(0)->comment(
+                    'Заблокирован: 0 - нет, 1 - да'
+                ),
+                'is_registered' => $this->integer(1)->notNull()->defaultValue(0)->comment(
+                    'Зарегистрирован: 0 - нет, 1 - да'
+                ),
+            ]);
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+        if (isset($tableSchema)) {
+            $this->dropTable(self::TABLE_NAME);
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m241224_140248_add_telegram_chat_id_to_users_table cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}
index 0084b30f5d604eb6ee160ee4093d0badbb6a8dbf..9f9860c162cb5e5ede15752464b2a5a8664ade51 100755 (executable)
@@ -515,7 +515,7 @@ class Users extends \yii\db\ActiveRecord
 
         $step1 = $messagesSettings ? $messagesSettings->day_before_step1 : 10;
         $step2 = $messagesSettings ? $messagesSettings->day_before_step2 : 4;
-        $usersQuery = UsersTelegramChatId::find()->andWhere(['phone' => $phones]);
+        $usersQuery = UsersTelegram::find()->andWhere(['phone' => $phones]);
         $usersQuery->andWhere(['is_blocked' => 0]);
         $usersQuery->andWhere(['is_registered' => 1]);
 
@@ -546,7 +546,7 @@ class Users extends \yii\db\ActiveRecord
         $step3 = $messagesSettings ? $messagesSettings->day_before_step3 : 2;
 
         // Подзапрос базы пользователей с учетом подписки на телеграм
-        $usersQuery = UsersTelegramChatId::find()->andWhere(['phone' => $phones]);
+        $usersQuery = UsersTelegram::find()->andWhere(['phone' => $phones]);
         $usersQuery->andWhere(['is_blocked' => 0]);
         $usersQuery->andWhere(['is_registered' => 1]);
 
@@ -595,7 +595,7 @@ class Users extends \yii\db\ActiveRecord
             }, $phones);
         }
 
-        $users = UsersTelegramChatId::find()
+        $users = UsersTelegram::find()
             ->where(['phone' => $phones])
             ->all();
 
diff --git a/erp24/records/UsersTelegram.php b/erp24/records/UsersTelegram.php
new file mode 100644 (file)
index 0000000..4659879
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "users_telegram_chat_id".
+ *
+ * @property string $chat_id Chat ID
+ * @property string|null $phone Телефон
+ * @property string|null $username Имя пользователя в Телеграм
+ * @property string|null $first_name Имя пользователя
+ * @property int $is_blocked Заблокирован: 0 - нет, 1 - да
+ * @property int $is_registered Зарегистрирован: 0 - нет, 1 - да
+ */
+class UsersTelegram extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'users_telegram';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['chat_id'], 'required'],
+            [['is_blocked', 'is_registered'], 'default', 'value' => null],
+            [['is_blocked', 'is_registered'], 'integer'],
+            [['chat_id', 'phone', 'username', 'first_name'], 'string', 'max' => 255],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'chat_id' => 'Chat ID',
+            'phone' => 'Телефон',
+            'username' => 'Имя пользователя в Телеграм',
+            'first_name' => 'Имя пользователя',
+            'is_blocked' => 'Заблокирован: 0 - нет, 1 - да',
+            'is_registered' => 'Зарегистрирован: 0 - нет, 1 - да',
+        ];
+    }
+}
diff --git a/erp24/records/UsersTelegramChatId.php b/erp24/records/UsersTelegramChatId.php
deleted file mode 100644 (file)
index 43740d4..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-namespace yii_app\records;
-
-use Yii;
-
-/**
- * This is the model class for table "users_telegram_chat_id".
- *
- * @property string $chat_id Chat ID
- * @property string|null $phone Телефон
- * @property string|null $username Имя пользователя в Телеграм
- * @property string|null $first_name Имя пользователя
- * @property int $is_blocked Заблокирован: 0 - нет, 1 - да
- * @property int $is_registered Зарегистрирован: 0 - нет, 1 - да
- */
-class UsersTelegramChatId extends \yii\db\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return 'users_telegram_chat_id';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['chat_id'], 'required'],
-            [['is_blocked', 'is_registered'], 'default', 'value' => null],
-            [['is_blocked', 'is_registered'], 'integer'],
-            [['chat_id', 'phone', 'username', 'first_name'], 'string', 'max' => 255],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'chat_id' => 'Chat ID',
-            'phone' => 'Телефон',
-            'username' => 'Имя пользователя в Телеграм',
-            'first_name' => 'Имя пользователя',
-            'is_blocked' => 'Заблокирован: 0 - нет, 1 - да',
-            'is_registered' => 'Зарегистрирован: 0 - нет, 1 - да',
-        ];
-    }
-}