]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Исправлены миграцию users_bonus_levels origin/feature-fomichev_erp-303_bonus_levels
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 6 Feb 2025 09:05:42 +0000 (12:05 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 6 Feb 2025 09:05:42 +0000 (12:05 +0300)
erp24/api2/controllers/BonusController.php
erp24/migrations/m250203_113244_create_users_bonus_levels_table.php
erp24/records/UsersBonusLevels.php

index bda04b76084c6859b9aad369eed25efdf030a3fe..db238364d6b1abf5e643c71cb03483dab802cdf2 100644 (file)
@@ -1215,7 +1215,7 @@ class BonusController extends BaseController
         $bonusRecord->phone = $user->phone;
         $bonusRecord->user_id = $user->id;
         $bonusRecord->bonus_level = $bonusLevel;
-        $bonusRecord->created_at = $createdAt;
+        $bonusRecord->date_from = $createdAt;
         $bonusRecord->check_id = $check_id;
         $bonusRecord->check_name = $check_name;
         $bonusRecord->active = 1;
@@ -1269,7 +1269,7 @@ class BonusController extends BaseController
 
             if ($existingHistoryLevel) {
                 $existingHistoryLevel->active = 0;
-                $existingHistoryLevel->updated_at = $now;
+                $existingHistoryLevel->date_to = $now;
                 if (!$existingHistoryLevel->save()) {
                     LogService::apiErrorLog(
                         json_encode(
@@ -1281,8 +1281,6 @@ class BonusController extends BaseController
             }
 
             $this->createBonusHistoryRecord($user, $newBonusLevel, $check_id, $check_name, $now);
-        } elseif (!empty($user->bonus_level) && !$existingHistoryLevel) {
-            $this->createBonusHistoryRecord($user, $user->bonus_level, $check_id, $check_name, $now);
         }
     }
 
index c971437a6b5399a42e39d7c01b96f506a7ce0bf4..d4b2ee52da460b4558c32406b860becec4df70c8 100644 (file)
@@ -23,12 +23,10 @@ class m250203_113244_create_users_bonus_levels_table extends Migration
                 'bonus_level' => $this->string()->notNull()->comment('Уровань клиента в БС'),
                 'check_id' => $this->string()->null()->comment('Основание для повышения уровня - GUID'),
                 'check_name' => $this->string()->null()->comment('Основание для повышения уровня - номер чека'),
-                'created_at' => $this->timestamp()
-                    ->defaultExpression('CURRENT_TIMESTAMP')
-                    ->notNull()->comment('Дата создания'),
                 'active' => $this->tinyInteger(1)
                     ->notNull()->defaultValue(1)->comment('Активность записи'),
-                'updated_at' => $this->timestamp()->null()->comment('Дата изменения'),
+                'date_from' => $this->string()->notNull()->comment('Дата создания'),
+                'date_to' => $this->string()->null()->comment('Дата окончания'),
             ]);
         }
     }
index 6b307391659ffaabf5db02fca3fc867e9097a21a..c6beeeabb85bd83bc4c995193e4046ba9408bf70 100644 (file)
@@ -11,11 +11,11 @@ use Yii;
  * @property string $phone Телефон клиента
  * @property int $user_id ID клиента
  * @property string $bonus_level Уровань клиента в БС
- * @property string $created_at Дата создания
+ * @property string $date_from Дата создания
  * @property string|null $check_id Дата создания
  * @property string|null $check_name Дата создания
  * @property int $active Активность записи
- * @property string|null $updated_at Дата изменения
+ * @property string|null $date_to Дата изменения
  */
 class UsersBonusLevels extends \yii\db\ActiveRecord
 {
@@ -36,8 +36,8 @@ class UsersBonusLevels extends \yii\db\ActiveRecord
             [['phone', 'user_id', 'bonus_level'], 'required'],
             [['user_id', 'active'], 'default', 'value' => null],
             [['user_id', 'active'], 'integer'],
-            [['check_id', 'check_name', 'created_at', 'updated_at'], 'safe'],
-            [['check_id', 'check_name', 'phone', 'bonus_level'], 'string', 'max' => 255],
+            [['check_id', 'check_name', 'date_from', 'date_to'], 'safe'],
+            [['check_id', 'check_name', 'phone', 'bonus_level', 'date_from', 'date_to'], 'string', 'max' => 255],
         ];
     }
 
@@ -51,9 +51,9 @@ class UsersBonusLevels extends \yii\db\ActiveRecord
             'phone' => 'Телефон клиента',
             'user_id' => 'ID клиента',
             'bonus_level' => 'Уровань клиента в БС',
-            'created_at' => 'Дата создания',
+            'date_from' => 'Дата создания',
             'active' => 'Активность записи',
-            'updated_at' => 'Дата изменения',
+            'date_to' => 'Дата изменения',
             'check_id' => 'Основание для повышения уровня - GUID',
             'check_name' => 'Основание для повышения уровня - номер чека',
         ];