Explorar o código

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

kevin hai 1 ano
pai
achega
635562a314

+ 1 - 1
backendApi/config/menu.php

@@ -531,7 +531,7 @@ return [
             ['name'=>'编辑报单中心级别', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'dec-role-edit', 'routePath'=>'config/dec-role-edit', 'show'=>0,],
             ['name'=>'汇率列表', 'class'=>'', 'icon'=>'', 'controller'=>'currency', 'action'=>'currencies-conversions', 'routePath'=>'currency/currencies-conversions', 'show'=>1,  'wiki' => 'exchangeRateConfig'],
             ['name'=>'汇率配置', 'class'=>'', 'icon'=>'', 'controller'=>'currency', 'action'=>'set-currencies-conversions', 'routePath'=>'currency/set-currencies-conversions', 'show'=>0],
-            ['name'=>'运费模板列表', 'class'=>'', 'icon'=>'', 'controller'=>'transportation', 'action'=>'transportation', 'routePath'=>'transportation/transportation-list', 'show'=>1,  'wiki' => 'transportationConfig'],
+            ['name'=>'运费模板列表', 'class'=>'', 'icon'=>'', 'controller'=>'transportation', 'action'=>'transportation', 'routePath'=>'transportation/transportation', 'show'=>1,  'wiki' => 'transportationConfig'],
             ['name'=>'运费模板设置', 'class'=>'', 'icon'=>'', 'controller'=>'transportation', 'action'=>'set-transportation', 'routePath'=>'transportation/set-transportation', 'show'=>0],
         ],
     ],

+ 15 - 3
backendApi/modules/v1/controllers/TransportationController.php

@@ -3,6 +3,7 @@
 namespace backendApi\modules\v1\controllers;
 
 use common\helpers\Form;
+use common\models\Countries;
 use common\models\Currency;
 use common\models\CurrencyConversions;
 use common\models\forms\CurrenciesConversionsForm;
@@ -13,13 +14,24 @@ use yii\web\HttpException;
 
 class TransportationController extends BaseController
 {
+    public $countiesModelClass = Countries::class;
     public $modelClass = FreeTemplate::class;
 
-    public function actionTransportationList()
+    public function actionTransportation()
     {
-        $data = $this->modelClass::getFromCache();
+        // 国家列表
+        $countries = $this->countiesModelClass::getFromCache();
+        // 运费列表
+        $transportation = $this->modelClass::getFromCache();
+        $transportation = array_column($transportation, NULL, 'country_id');
+
+        foreach ($countries as &$country) {
+            $country['freight'] = $transportation[$country['country_id']]['freight'] ?? 0;
+            $country['free_shipping'] = $transportation[$country['country_id']]['free_shipping'] ?? 0;
+            $country['currency_id'] = $transportation[$country['country_id']]['currency_id'] ?? 0;
+        }
 
-        return static::notice(['data' => $data]);
+        return static::notice(['data' => $countries]);
     }
 
     public function actionSetTransportation()

+ 0 - 3
common/models/forms/CurrenciesConversionsForm.php

@@ -106,9 +106,6 @@ class CurrenciesConversionsForm extends Model
                 throw new Exception(Form::formatErrorsForApi($model->getErrors()));
             }
 
-            // 刷新缓存
-            Yii::$app->cache->delete(Cache::CURRENCIES_CONVERSIONS_KEY);
-
             // 选择商品汇率同步,更新商品属性
             if ($postData['synchronize']) {
                 // 异步属性商品价格