Kaynağa Gözat

feat: NG-15: 新会员注册时增加国家与语言选项.

kevin 1 yıl önce
ebeveyn
işleme
5b79083507

+ 3 - 3
common/models/UserImmigrant.php

@@ -5,8 +5,8 @@ namespace common\models;
 /**
  * This is the model class for table "{{%USER_IMMIGRANT}}".
  *
- * @property int id
- * @property int user_id 用户ID
+ * @property string ID
+ * @property string user_id 用户ID
  * @property string before_country_id 移民前国家ID
  * @property string after_country_id 移民后国家ID
  * @property int period_num 期数
@@ -40,7 +40,7 @@ class UserImmigrant extends \common\components\ActiveRecord
     public function attributeLabels()
     {
         return [
-            'id' => 'ID',
+            'ID' => 'ID',
             'user_id' => '用户ID',
             'before_country_id' => '移民前国家ID',
             'after_country_id' => '移民后国家ID',

+ 4 - 2
common/models/forms/UserBasicForm.php

@@ -7,6 +7,7 @@ use common\helpers\Cache;
 use common\helpers\Date;
 use common\helpers\Form;
 use common\helpers\LoggerTool;
+use common\helpers\snowflake\PageSnowFake;
 use common\helpers\Tool;
 use common\libs\logging\operate\AdminOperate;
 use common\models\Countries;
@@ -152,7 +153,6 @@ class UserBasicForm extends Model {
         // 移民后汇率
         $beforeCurrencyId = Countries::getCurrency($this->country);
         $afterCurrencyRate = CurrencyConversions::getToUSDRate($beforeCurrencyId);
-        LoggerTool::debug(json_encode(['modifyProfile', $beforeCountry, $this->country, $afterCurrencyRate]));
         if (!$afterCurrencyRate) {
             throw new Exception(Yii::t('app', 'currencyDoesNotExist'));
         }
@@ -185,6 +185,7 @@ class UserBasicForm extends Model {
             $userModel->LANGUAGE_ID = $this->language;
             $userModel->COUNTRY_ID = $this->country;
             if( !$userModel->save(false) ) {
+                $transaction->rollBack();
                 throw new Exception($userModel->getErrors());
             }
 
@@ -200,6 +201,7 @@ class UserBasicForm extends Model {
 
             // 移民记录
             $model = new UserImmigrant();
+            $model->ID = PageSnowFake::instance()->generateId();
             $model->user_id = $this->userId;
             $model->before_country_id = $beforeCountry;
             $model->after_country_id = $this->country;
@@ -227,7 +229,7 @@ class UserBasicForm extends Model {
             ]);
         }catch (Exception $e) {
             $transaction->rollBack();
-            return null;
+            throw new Exception($userModel->getErrors());
         }
         return $userModel;
     }