]));
}
}
-
+ //TODO - перенос в отправку
$updatedCount = SentKogort::updateAll(
- ['status' => SentKogort::STATUSES['first']], // Устанавливаем статус "первая рассылка"
+ [
+ 'status' => SentKogort::STATUSES['first'], // Устанавливаем статус "первая рассылка"
+ 'updated_at' => date('Y-m-d H:i:s'),
+
+ ],
[
'kogort_date' => $kogortDate,
'target_date' => $targetDate,
]));
}
}
+ //TODO - перенос в отправку
$updatedCount = SentKogort::updateAll(
- ['status' => SentKogort::STATUSES['second']], // Устанавливаем статус "вторая рассылка"
+ [
+ 'status' => SentKogort::STATUSES['second'], // Устанавливаем статус "вторая рассылка"
+ 'updated_at' => date('Y-m-d H:i:s'),
+ ],
[
'target_date' => $targetDate,
'kogort_number' => SentKogort::KOGORT_NUMBERS['target'],
if ($result == "OK") {
try {
$result = TelegramService::saveSentMessageToDB($this->messageData);
-
+ //TODO - перенос сюда обновления статусов записей когорт
if ($result) {
Yii::warning("Сообщение успешно сохранено для пользователя с ID {$chatId} телефон {$phone}", 'telegram');
} else {
--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles adding columns to table `{{%sent_kogort}}`.
+ */
+class m250123_133454_add_updated_at_column_to_sent_kogort_table extends Migration
+{
+ const TABLE_NAME = 'erp24.sent_kogort';
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ if ($this->db->schema->getTableSchema(self::TABLE_NAME) === null) {
+ return;
+ }
+
+ if ($this->db->schema->getTableSchema(self::TABLE_NAME)->getColumn('updated_at') === null) {
+ $this->addColumn(
+ self::TABLE_NAME,
+ 'updated_at',
+ $this->timestamp()
+ ->null()
+ ->defaultExpression('CURRENT_TIMESTAMP')
+ ->comment('Дата обновления')
+ );
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ if ($this->db->schema->getTableSchema(self::TABLE_NAME) === null) {
+ return;
+ }
+
+ if ($this->db->schema->getTableSchema(self::TABLE_NAME)->getColumn('updated_at') !== null) {
+ $this->dropColumn(self::TABLE_NAME, 'updated_at');
+ }
+ }
+}
[['kogort_unixtime', 'status', 'contact', 'purchase'], 'default', 'value' => null],
[['kogort_unixtime', 'status', 'contact', 'purchase', 'kogort_number'], 'integer'],
[['phone'], 'string', 'max' => 15],
+ [['updated_at'], 'safe'],
];
}
'contact' => 'Контакт с клиентом',
'purchase' => 'Покупка',
'created_at' => 'Дата создания записи',
+ 'updated_at' => 'Дата обновления записи',
];
}
{
return ['id'];
}
+
+ public function afterSave($insert, $changedAttributes)
+ {
+ parent::afterSave($insert, $changedAttributes);
+
+ if (!$insert) {
+ $this->updateAttributes(['updated_at' => date('Y-m-d H:i:s')]);
+ }
+ }
}