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
$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 ?? 'Клиент из чатбота',
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
$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 ?? 'Клиент из чатбота',
+++ /dev/null
-<?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;
- }
- */
-}
--- /dev/null
+<?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;
+ }
+ */
+}
$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]);
$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]);
}, $phones);
}
- $users = UsersTelegramChatId::find()
+ $users = UsersTelegram::find()
->where(['phone' => $phones])
->all();
--- /dev/null
+<?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 - да',
+ ];
+ }
+}
+++ /dev/null
-<?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 - да',
- ];
- }
-}