Procházet zdrojové kódy

feat: EK-1282: 【Product Management】设置商品可售卖国家时,列表未展示Currency Type.

kevinElken před 9 měsíci
rodič
revize
c800570233

+ 13 - 0
backendApi/modules/v1/controllers/ShopController.php

@@ -28,6 +28,7 @@ use common\helpers\Date;
 use common\helpers\Form;
 use common\helpers\LoggerTool;
 use common\models\Countries;
+use common\models\Currency;
 use common\models\CurrencyConversions;
 use common\models\DeclarationPackage;
 use common\models\DecOrder;
@@ -152,6 +153,18 @@ class ShopController extends BaseController {
             $countries = array_values($countries);
         }
 
+        // 货币
+        $currencies = Cache::getCurrencies();
+        $currencies = array_column($currencies, NULL, 'ID');
+        // 货币汇率
+        $currenciesConversions = CurrencyConversions::getFromCache();
+        $currenciesConversions = array_column($currenciesConversions, NULL, 'TO_CURRENCY_ID');
+
+        foreach ($countries as $key => $country) {
+            $countries[$key]['LOCAL_CURRENCY_NAME'] = $currencies[$country['LOCAL_CURRENCY_ID']]['NAME'] ?? '';
+            $countries[$key]['CURRENCY_PRODUCT_RATE'] = $currenciesConversions[$country['LOCAL_CURRENCY_ID']]['PRODUCT_RATE'] ?? 0;
+        }
+
         return static::notice([
             'sellType' => ShopGoods::getSaleType(),
             'goodsType' => ShopGoods::getGoodType(),

+ 0 - 1
common/models/Currency.php

@@ -59,7 +59,6 @@ class Currency extends \common\components\ActiveRecord
     public static function getFromCache()
     {
         $data = Yii::$app->cache->get(Cache::CURRENCIES_KEY);
-        Yii::$app->cache->delete(Cache::CURRENCIES_KEY);
         if (!$data) {
             // 获取信息
             $data = self::getAllData();