Procházet zdrojové kódy

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

kevin před 1 rokem
rodič
revize
6c8fbfa501

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

@@ -156,12 +156,31 @@ class ShopController extends BaseController {
                 return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
             }
         }
+
         $data = ShopGoods::findOneAsArray('ID=:ID', [':ID' => $id]);
         $data['SELL_TYPE'] = explode(',',$data['SELL_TYPE']);
         $data['GIFT_TYPE'] = explode(',',$data['GIFT_TYPE']);
         if ($data['TYPE'] == 1 || $data['TYPE'] == 2) {
             $data['SELL_DISCOUNT'] = ShopGoods::getGoodType()[$data['TYPE']]['discount']/100;
         }
+
+        // 商品属性
+        $shopGoodsNature = ShopGoodsNature::findAllAsArray('GOODS_ID=:GOODS_ID', [':GOODS_ID' => $id]);
+//        $shopGoodsNature = '';
+        // 国家
+        $countries = Cache::getCountries();
+        // 货币
+        $currencies = Cache::getCurrencies();
+        $currencies = array_column($currencies, NULL, 'ID');
+
+        foreach ($countries as &$country) {
+            $country['LOCAL_CURRENCY_NAME'] = $currencies[$country['LOCAL_CURRENCY_ID']]['NAME'] ?? '';
+        }
+
+
+
+        $data['SHOP_GOODS_NATURE'] = $currencies;
+
         return static::notice(
             [
                 'goodsInfo'=>$data,

+ 10 - 3
backendApi/modules/v1/controllers/SiteController.php

@@ -179,10 +179,17 @@ class SiteController extends BaseController
 
     public function actionCountries()
     {
-        // 国家列表
-        $data = Cache::getCountries();
+        // 国家
+        $countries = Cache::getCountries();
+        // 货币
+        $currencies = Cache::getCurrencies();
+        $currencies = array_column($currencies, NULL, 'ID');
+
+        foreach ($countries as &$country) {
+            $country['LOCAL_CURRENCY_NAME'] = $currencies[$country['LOCAL_CURRENCY_ID']]['NAME'] ?? '';
+        }
 
-        return static::notice(['data' => $data]);
+        return static::notice(['data' => $countries]);
     }
 
     public function actionLanguages()

+ 9 - 0
common/helpers/Cache.php

@@ -11,6 +11,7 @@ namespace common\helpers;
 use backendApi\modules\v1\models\AdminRole;
 use common\models\Config;
 use common\models\Countries;
+use common\models\Currency;
 use common\models\DealType;
 use common\models\DecRole;
 use common\models\Language;
@@ -143,6 +144,14 @@ class Cache
         return Language::getFromCache();
     }
 
+    /**
+     * 获取货币列表
+     * @return array|mixed|\yii\db\ActiveRecord[]
+     */
+    public static function getCurrencies(){
+        return Currency::getFromCache();
+    }
+
     /**
      *  更新报单级别
      * @return array|\yii\db\ActiveRecord[]

+ 0 - 1
common/models/Countries.php

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