Просмотр исходного кода

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

kevin 1 год назад
Родитель
Сommit
caa951bb8b
2 измененных файлов с 2 добавлено и 14 удалено
  1. 2 9
      common/models/FreeTemplate.php
  2. 0 5
      common/models/forms/FreeTemplateForm.php

+ 2 - 9
common/models/FreeTemplate.php

@@ -12,7 +12,6 @@ use Yii;
  * @property string country_id 国家ID
  * @property double freight 运费
  * @property double free_shipping 免运费阈值
- * @property int currency_id 币种ID
  * @property int created_at 创建时间
  * @property int updated_at 更新时间
  */
@@ -32,8 +31,8 @@ class FreeTemplate extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['country_id',  'freight', 'free_shipping', 'currency_id'], 'required'],
-            [['freight', 'free_shipping', 'currency_id'], 'number'],
+            [['country_id',  'freight', 'free_shipping'], 'required'],
+            [['freight', 'free_shipping'], 'number'],
             [['country_id'], 'unique'],
         ];
     }
@@ -48,7 +47,6 @@ class FreeTemplate extends \common\components\ActiveRecord
             'country_id' => '国家ID',
             'freight' => '运费',
             'free_shipping' => '免运费阈值',
-            'currency_id' => '币种ID',
             'created_at' => '创建时间',
             'updated_at' => '更新时间',
         ];
@@ -59,11 +57,6 @@ class FreeTemplate extends \common\components\ActiveRecord
         return $this->hasOne(Countries::class, ['id' => 'country_id']);
     }
 
-    public function currency()
-    {
-        return $this->hasOne(Currency::class, ['id' => 'currency_id']);
-    }
-
     /**
      * 从缓存获取信息
      * @return array|mixed|\yii\db\ActiveRecord[]

+ 0 - 5
common/models/forms/FreeTemplateForm.php

@@ -16,7 +16,6 @@ class FreeTemplateForm extends Model
     public $countryId;
     public $freight;
     public $freeShipping;
-    public $currencyId;
 
     /**
      * @inheritdoc
@@ -35,7 +34,6 @@ class FreeTemplateForm extends Model
             'country_id' => 'Country',
             'freight' => 'Freight',
             'free_shipping' => 'FreeShipping',
-            'currency_id' => 'currency',
         ];
     }
 
@@ -58,8 +56,6 @@ class FreeTemplateForm extends Model
         if (!$country) {
             $this->addError($attribute, Yii::t('ctx', 'countryDoesNotExist'));
         }
-
-        $this->currencyId = $country['LOCAL_CURRENCY_ID'];
     }
 
     /**
@@ -82,7 +78,6 @@ class FreeTemplateForm extends Model
             $model->country_id = $this->countryId;
             $model->freight = $this->freight;
             $model->free_shipping = $this->freeShipping;
-            $model->currency_id = $this->currencyId;
             if (!$model->save()) {
                 $transaction->rollBack();
                 throw new Exception(Form::formatErrorsForApi($model->getErrors()));