From: fomichev Date: Wed, 25 Dec 2024 11:15:12 +0000 (+0300) Subject: Отключение записи в файл в методе крон и изменение миграции X-Git-Tag: 1.7~94^2~42 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=7734d037c9e9331e3ab7ead5d8d3b85fae8db188;p=erp24_rep%2Fyii-erp24%2F.git Отключение записи в файл в методе крон и изменение миграции --- diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index db6e1f0e..f905f466 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -360,9 +360,9 @@ class CronController extends Controller $batchSize = 500; $offset = 0; - $csvFilePath = Yii::getAlias('@runtime/missing_users.csv'); - $fileHandle = fopen($csvFilePath, 'w'); - fputcsv($fileHandle, ['phone', 'username', 'chat_id', 'is-blocked', 'is_registered', 'reason'], ';'); + // $csvFilePath = Yii::getAlias('@runtime/missing_users.csv'); + // $fileHandle = fopen($csvFilePath, 'w'); + // fputcsv($fileHandle, ['phone', 'username', 'chat_id', 'is-blocked', 'is_registered', 'reason'], ';'); while (true) { $chatbotUsers = $remoteDb @@ -382,7 +382,7 @@ class CronController extends Controller $isBlocked = (int)$remoteUser['is_blocked']; $isRegistered = (int)$remoteUser['is_registered']; if (empty($phone)) { - fputcsv($fileHandle, [$phone, $username, $chatId, $isBlocked, $isRegistered, 'Отсутствует телефон'], ';'); + // fputcsv($fileHandle, [$phone, $username, $chatId, $isBlocked, $isRegistered, 'Отсутствует телефон'], ';'); continue; } @@ -407,7 +407,7 @@ class CronController extends Controller $user = Users::findOne(['phone' => $phone]); if (!$user) { - fputcsv($fileHandle, [$phone, $username, $chatId, $isBlocked, $isRegistered, 'Пользователь не найден'], ';'); + // fputcsv($fileHandle, [$phone, $username, $chatId, $isBlocked, $isRegistered, 'Пользователь не найден'], ';'); continue; /* $user = new Users([ 'phone' => $phone, @@ -438,7 +438,7 @@ class CronController extends Controller $this->stdout("Обработано записей: {$offset}\n", BaseConsole::FG_GREEN); } - fclose($fileHandle); + // fclose($fileHandle); $this->stdout( "Синхронизация завершена успешно. Записи без пользователей сохранены в {$csvFilePath}\n", BaseConsole::FG_GREEN diff --git a/erp24/migrations/m241224_145213_create_users_telegram_log_table.php b/erp24/migrations/m241224_145213_create_users_telegram_log_table.php index bdfda56e..3d6a3359 100644 --- a/erp24/migrations/m241224_145213_create_users_telegram_log_table.php +++ b/erp24/migrations/m241224_145213_create_users_telegram_log_table.php @@ -17,7 +17,8 @@ class m241224_145213_create_users_telegram_log_table extends Migration if (!isset($tableSchema)) { $this->createTable(self::TABLE_NAME, [ - 'phone' => $this->string()->notNull()->unique()->comment('Телефон'), + 'id' => $this->primaryKey()->comment('Первичный ключ'), + 'phone' => $this->string()->notNull()->comment('Телефон'), 'is_blocked' => $this->integer(1)->notNull()->defaultValue(0)->comment( 'Заблокирован: 0 - нет, 1 - да' ), @@ -30,7 +31,7 @@ class m241224_145213_create_users_telegram_log_table extends Migration 'date_end' => $this->date()->null()->comment('Дата окончания активности'), ]); - $this->addPrimaryKey('pk_users_telegram_log', self::TABLE_NAME, 'phone'); + } }