]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Исправление миграции sent_kogort и добавление hold
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 26 Dec 2024 08:22:03 +0000 (11:22 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 26 Dec 2024 08:22:03 +0000 (11:22 +0300)
erp24/migrations/m241220_131428_create_sent_kogort_table.php
erp24/records/Users.php
erp24/records/UsersMessageManagement.php

index 24389c0255312b93973637cc320b78cc33faea75..cde25f6cd885f9719627ff7148912e5a4a604252 100644 (file)
@@ -17,7 +17,7 @@ class m241220_131428_create_sent_kogort_table extends Migration
 
         if (!isset($tableSchema)) {
             $this->createTable(self::TABLE_NAME, [
-                'id' => $this->primaryKey(),
+                'id' => $this->bigInteger(),
                 'phone' => $this->string(15)->notNull()->comment('Телефон пользователя'),
                 'kogort_number' => $this->integer()->notNull()->comment('Номер типа когорты когорты'),
                 'kogort_date' => $this->date()->notNull()->comment('Дата когорты'),
@@ -27,6 +27,7 @@ class m241220_131428_create_sent_kogort_table extends Migration
                 'purchase' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('Покупка'),
                 'created_at' => $this->dateTime()->notNull()->defaultExpression('CURRENT_TIMESTAMP')->comment('Дата создания записи'),
             ]);
+            $this->addPrimaryKey('pk_sent_kogort', self::TABLE_NAME, 'id');
         }
     }
 
index b0096fb142b14516364bab8c6d452cad0745c15c..3e437051c3b6c81485f301fddaa65a0e1fd78f62 100755 (executable)
@@ -470,6 +470,8 @@ class Users extends \yii\db\ActiveRecord
             ->one();
 
         $step1 = $messagesSettings ? $messagesSettings->day_before_step1 : 10;
+        $hold =  $messagesSettings ? $messagesSettings->hold : 10;
+        $holdActive =  $messagesSettings ? $messagesSettings->hold_active : 1;
 
         $salesPhone = Sales::find()
             ->where(new \yii\db\Expression("TO_CHAR(date, 'MM-DD') = :monthDay", [':monthDay' => $monthDay]))
@@ -485,12 +487,17 @@ class Users extends \yii\db\ActiveRecord
 
         $usersArray = array_unique(array_merge($salesPhone, $memorableDate));
 
-        $phonesSent = SentKogort::find()
-            ->select('phone')
-            ->where(['between', 'kogort_date',
-                date('Y-m-d', strtotime("$startDate -$step1 days")),
-                date('Y-m-d', strtotime("$startDate -1 days"))])
-            ->column();
+        if ($holdActive == 1) {
+            $phonesSent = SentKogort::find()
+                ->select('phone')
+                ->where(['between', 'kogort_date',
+                    date('Y-m-d', strtotime("$startDate -$hold days")),
+                    date('Y-m-d', strtotime("$startDate -1 days"))])
+                ->column();
+        } else {
+            $phonesSent =[];
+        }
+
 
         $filteredUsers = array_diff($usersArray, $phonesSent);
         $kogortData = array_values($filteredUsers);
index 7e44123f67955ee05d3a2a353b2f0466d24192a6..ebe801f47083affc6b7b1cf1fd889644c8cc7c55 100644 (file)
@@ -23,6 +23,7 @@ use Yii;
  * @property int $created_by ID создателя записи
  * @property string $updated_at Дата обновления
  * @property int $updated_by ID обновления записи
+ * @property int $hold Количество дней удержания номера от рассылки
  * @property int $hold_active 0 - поле деактивировано, 1 - поле активировано
  * @property int $day_before_step1_active 0 - поле деактивировано, 1 - поле активировано
  * @property int $day_before_step2_active 0 - поле деактивировано, 1 - поле активировано