Ver código fonte

feat: EK-856: 管理员增加“Country”属性.

kevinElken 10 meses atrás
pai
commit
242146d41a

+ 5 - 7
backendApi/modules/v1/controllers/SiteController.php

@@ -188,7 +188,11 @@ class SiteController extends BaseController
                 $adminCountry = AdminCountry::getCountry($adminId);
 
                 $countries = array_filter($countries, fn($country) => in_array($country['ID'], $adminCountry));
-                $countries = array_values($countries);
+                foreach ($countries as $key => $country) {
+                    if (!in_array($country['ID'], $adminCountry)) {
+                        unset($countries[$key]);
+                    }
+                }
             }
         }
 
@@ -199,12 +203,6 @@ class SiteController extends BaseController
         $currenciesConversions = CurrencyConversions::getFromCache();
         $currenciesConversions = array_column($currenciesConversions, NULL, 'TO_CURRENCY_ID');
 
-//        $countries = array_map(fn($country) => [
-//            ...$country,
-//            'LOCAL_CURRENCY_NAME' => $currencies[$country['LOCAL_CURRENCY_ID']]['NAME'] ?? '',
-//            'CURRENCY_PRODUCT_RATE' => $currenciesConversions[$country['LOCAL_CURRENCY_ID']]['PRODUCT_RATE'] ?? 0;
-//        ], $countries);
-
         foreach ($countries as &$country) {
             $country['LOCAL_CURRENCY_NAME'] = $currencies[$country['LOCAL_CURRENCY_ID']]['NAME'] ?? '';
             $country['CURRENCY_PRODUCT_RATE'] = $currenciesConversions[$country['LOCAL_CURRENCY_ID']]['PRODUCT_RATE'] ?? 0;