소스 검색

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

kevinElken 10 달 전
부모
커밋
f4cc43019d
2개의 변경된 파일11개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      backendApi/modules/v1/controllers/ShopController.php
  2. 6 0
      backendApi/modules/v1/controllers/SiteController.php

+ 5 - 1
backendApi/modules/v1/controllers/ShopController.php

@@ -184,7 +184,11 @@ class ShopController extends BaseController {
         $adminId = Yii::$app->getUser()->getUserInfo()['id'];
         $adminCountry = AdminCountry::getCountry($adminId);
 
-        $countries = array_filter($countries, fn($country) => in_array($country['ID'], $adminCountry));
+        foreach ($countries as $key => $country) {
+            if (!in_array($country['ID'], $adminCountry)) {
+                unset($countries[$key]);
+            }
+        }
 
         foreach ($countries as &$country) {
             // 货币

+ 6 - 0
backendApi/modules/v1/controllers/SiteController.php

@@ -188,6 +188,12 @@ class SiteController extends BaseController
                 $adminCountry = AdminCountry::getCountry($adminId);
 
                 $countries = array_filter($countries, fn($country) => in_array($country['ID'], $adminCountry));
+
+                foreach ($countries as $key => $country) {
+                    if (!in_array($country['ID'], $adminCountry)) {
+                        unset($countries[$key]);
+                    }
+                }
             }
         }