Kaynağa Gözat

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

kevin 1 yıl önce
ebeveyn
işleme
4b39553692

+ 0 - 1
backendApi/modules/v1/controllers/TransportationController.php

@@ -33,7 +33,6 @@ class TransportationController extends BaseController
             $country['freight'] = $transportation[$country['ID']]['freight'] ?? 0;
             $country['free_shipping'] = $transportation[$country['ID']]['free_shipping'] ?? 0;
             $country['currency_id'] = $transportation[$country['ID']]['currency_id'] ?? 0;
-//            $country['currency'] = $currencies[$transportation[$country['ID']]['currency_id']]['NAME'] ?? '';
         }
 
         return static::notice(['data' => $countries]);

+ 10 - 1
common/models/Countries.php

@@ -77,7 +77,7 @@ class Countries extends \common\components\ActiveRecord
      */
     public static function getAllData()
     {
-        return static::find()->where('ACTIVE=1')->orderBy('ACTIVE DESC, NAME ASC')->asArray()->all();
+        return static::find()->with('currency')->where('ACTIVE=1')->orderBy('ACTIVE DESC, NAME ASC')->asArray()->all();
     }
 
     /**
@@ -112,4 +112,13 @@ class Countries extends \common\components\ActiveRecord
         $record = self::findOneAsArray('ID=:ID', [':ID' => $id]);
         return $record['LOCAL_CURRENCY_ID'] ?? 0;
     }
+
+    /**
+     * 关联currency.
+     * @return \yii\db\ActiveQuery
+     */
+    public function currency()
+    {
+        return $this->hasOne(Currency::className(), ['ID' => 'LOCAL_CURRENCY_ID']);
+    }
 }