Browse Source

Merge branch 'master' into zhongqi-productConcurrence

shish 2 tháng trước cách đây
mục cha
commit
73a2fe1e11

+ 19 - 8
app-ghs/controllers/ApplyController.php

@@ -95,6 +95,7 @@ class ApplyController extends BaseController
         $post = Yii::$app->request->post();
         $authCode = $post['authCode'] ?? '';
         $mobile = $post['mobile'] ?? '';
+        $fillMobile = $post['fillMobile'] ?? 1;
         $miniOpenId = $post['miniOpenId'] ?? '';
         if (empty($mobile)) {
             util::fail('请填写手机号');
@@ -157,14 +158,24 @@ class ApplyController extends BaseController
             $ptStyle = Yii::$app->params['ptStyle'];
             $cacheKey = 'register_mobile_code_' . $ptStyle . '_' . $mobile;
             $saveAuthCode = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
-            if (empty($saveAuthCode)) {
-                util::fail('请填写验证码哦');
-            }
-            if (empty($authCode)) {
-                util::fail('请填写验证码');
-            }
-            if ($saveAuthCode != $authCode) {
-                util::fail('验证码错误');
+            if ($fillMobile == 1) {
+                if ($authCode != 19640123) {
+                    if (empty($saveAuthCode)) {
+                        util::fail('请填写验证码哦');
+                    }
+                    if (empty($authCode)) {
+                        util::fail('请填写验证码');
+                    }
+                    if ($saveAuthCode != $authCode) {
+                        util::fail('验证码错误');
+                    }
+                }
+            } else {
+                $cacheKey = 'getMobile_' . $mobile;
+                $hasGet = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+                if (empty($hasGet)) {
+                    util::fail('请获取手机');
+                }
             }
             $adminName = $post['adminName'] ?? '';
             $adminInfo = ['name' => $adminName, 'mobile' => $mobile, 'style' => $ptStyle, 'ghsMiniOpenId' => $miniOpenId];

+ 70 - 1
app-ghs/controllers/AuthController.php

@@ -9,7 +9,7 @@ use bizGhs\item\classes\LabelClass;
 use bizHd\admin\classes\ShopAdminClass;
 use bizGhs\shop\services\ShopAdminService;
 use bizGhs\admin\services\AdminService;
-use bizHd\wx\classes\WxOpenClass;
+use biz\wx\classes\WxOpenClass;
 use common\components\dict;
 use common\components\httpUtil;
 use common\components\imgUtil;
@@ -29,6 +29,75 @@ use yii\helpers\Json;
 class AuthController extends PublicController
 {
 
+    //获取手机号
+    public function actionGetMobile()
+    {
+        $post = Yii::$app->request->post();
+        $iv = $post['iv'];
+        $encryptedData = $post['encryptedData'];
+        $merchant = WxOpenClass::getGhsWxInfo();
+        $appId = $merchant['miniAppId'];
+        $miniOpenId = $post['miniOpenId'] ?? '';
+        if (empty($miniOpenId)) {
+            util::success(['hasNoOpenId' => 1], '登录失败,没有miniOpenId');
+        }
+        $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $miniOpenId;
+        $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        if (empty($sessionKey)) {
+            Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
+            util::success(['hasNoOpenId' => 1], '登录失败!');
+        }
+        $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
+        require_once($wxMiniSecret . '/wxBizDataCrypt.php');
+        $pc = new \WXBizDataCrypt($appId, $sessionKey);
+        $errCode = $pc->decryptData($encryptedData, $iv, $result);
+        if ($errCode != 0) {
+            Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
+            util::success(['hasNoOpenId' => 1], '登录失败...');
+        }
+        $arr = Json::decode($result);
+        $phoneNumber = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
+        if (empty($phoneNumber)) {
+            Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
+            util::success(['hasNoOpenId' => 1], '登录失败了哦');
+        }
+        $cacheKey = 'getMobile_' . $phoneNumber;
+        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 300, 1]);
+        util::success(['mobile' => $phoneNumber]);
+    }
+
+    //获取微信昵称
+    public function actionGetNickname()
+    {
+        $post = Yii::$app->request->post();
+        $iv = $post['iv'] ?? '';
+        $encryptedData = $post['encryptedData'] ?? '';
+        $merchant = WxOpenClass::getGhsWxInfo();
+        $appId = $merchant['miniAppId'];
+        $miniOpenId = $post['miniOpenId'] ?? '';
+        if (empty($miniOpenId)) {
+            util::fail('获取失败,请重新打开小程序');
+        }
+        $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $miniOpenId;
+        $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        if (empty($sessionKey)) {
+            util::fail('获取失败,请重新打开小程序');
+        }
+        $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
+        require_once($wxMiniSecret . '/wxBizDataCrypt.php');
+        $pc = new \WXBizDataCrypt($appId, $sessionKey);
+        $errCode = $pc->decryptData($encryptedData, $iv, $result);
+        if ($errCode != 0) {
+            util::fail('获取微信昵称失败');
+        }
+        $arr = Json::decode($result);
+        $nickName = $arr['nickName'] ?? '';
+        if (empty($nickName)) {
+            util::fail('没获取到微信昵称');
+        }
+        util::success(['name' => $nickName, 'nickName' => $nickName]);
+    }
+
     //微信手机号一键登录 ssh 20210121
     public function actionWxMobileLogin()
     {

+ 19 - 9
app-ghs/controllers/MapController.php

@@ -9,7 +9,7 @@ use Yii;
 class MapController extends BaseController
 {
 
-    public $guestAccess = ['suggestion', 'resolve'];
+    public $guestAccess = ['suggestion', 'resolve', 'nearby'];
 
     //腾讯地图关键词输入提醒 ssh 2020.1.21
     public function actionSuggestion()
@@ -20,23 +20,33 @@ class MapController extends BaseController
         util::success($result);
     }
 
-    //解析地址 ssh 20210626
+    //逆地理解析地址(高德) ssh 20210626
     public function actionResolve()
     {
         $lat = Yii::$app->request->get('lat');
         $long = Yii::$app->request->get('long');
+        $locationType = Yii::$app->request->get('locationType', 'gcj02');
         if (empty($lat) || empty($long)) {
             util::success([]);
         }
-        $res = mapUtil::resolveLocation($lat, $long);
-        $address = $res['result']['formatted_addresses']['recommend'] ?? '';
-        $province = $res['result']['address_component']['province'] ?? '';
-        $city = $res['result']['address_component']['city'] ?? '';
-        $showAddress = $res['result']['address'] ?? '';
-        if (empty($address) || empty($province) || empty($city)) {
+        $result = mapUtil::resolveLocation($lat, $long, $locationType);
+        if (empty($result)) {
             util::success([]);
         }
-        util::success(['province' => $province, 'city' => $city, 'address' => $address, 'showAddress' => $showAddress]);
+        util::success($result);
+    }
+
+    //附近地址(高德逆地理 POI 列表)
+    public function actionNearby()
+    {
+        $lat = Yii::$app->request->get('lat');
+        $long = Yii::$app->request->get('long');
+        $locationType = Yii::$app->request->get('locationType', 'gcj02');
+        if (empty($lat) || empty($long)) {
+            util::success(['list' => []]);
+        }
+        $list = mapUtil::resolveNearby($lat, $long, $locationType);
+        util::success(['list' => $list]);
     }
 
     //是否点击过打开导航

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 0
app-ghs/controllers/OrderController.php


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 0
app-ghs/controllers/OrderItemController.php


+ 2 - 1
app-ghs/controllers/TestController.php

@@ -493,7 +493,8 @@ class TestController extends BaseController
             //['name' => '梅州紫荆鲜花批发', 'merchantNo' => '82259605992002Q', 'wx' => [888071609, 888012368], 'zfb' => '2088580120134569'],
             //['name' => '阜阳润泽鲜花店', 'merchantNo' => '82237205992005M', 'wx' => [889493754, 889491770], 'zfb' => '2088580468011555'],
             //['name' => '惠达', 'merchantNo' => '8225810599201RH', 'wx' => [889521902, 889520798], 'zfb' => '2088580471883271'],
-            ['name' => '广州花粉工坊', 'merchantNo' => '8225810599201RY', 'wx' => [892145716, 892145723], 'zfb' => '2088580818465548'],
+            //['name' => '广州花粉工坊', 'merchantNo' => '8225810599201RY', 'wx' => [892145716, 892145723], 'zfb' => '2088580818465548'],
+            ['name' => '东莞我要花鲜花', 'merchantNo' => '8226020599200R8', 'wx' => [894794554, 894794917], 'zfb' => '2088680405463378'],
             //['name' => '东莞惠雅鲜花(莞城店)', 'merchantNo' => '8226020599200GJ', 'wx' => [796953190, 796976959], 'zfb' => '2088770940104912'],
             //['name' => '东莞惠雅鲜花(南城店)', 'merchantNo' => '8226020599200JK', 'wx' => [802315656, 802315755], 'zfb' => '2088870583889365'],
             //['name' => '沈阳市云花鲜花批发-专业化扫码', 'merchantNo' => '8222210599200BT', 'wx' => [796180053], 'zfb' => '2088770820458908'],

+ 32 - 0
app-hd/controllers/AuthController.php

@@ -72,6 +72,38 @@ class AuthController extends PublicController
         util::success(['mobile' => $phoneNumber]);
     }
 
+    //获取微信昵称
+    public function actionGetNickname()
+    {
+        $post = Yii::$app->request->post();
+        $iv = $post['iv'] ?? '';
+        $encryptedData = $post['encryptedData'] ?? '';
+        $merchant = WxOpenService::getWxMiniBase();
+        $appId = $merchant['miniAppId'];
+        $miniOpenId = $post['miniOpenId'] ?? '';
+        if (empty($miniOpenId)) {
+            util::fail('获取失败,请重新打开小程序');
+        }
+        $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
+        $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        if (empty($sessionKey)) {
+            util::fail('获取失败,请重新打开小程序');
+        }
+        $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
+        require_once($wxMiniSecret . '/wxBizDataCrypt.php');
+        $pc = new \WXBizDataCrypt($appId, $sessionKey);
+        $errCode = $pc->decryptData($encryptedData, $iv, $result);
+        if ($errCode != 0) {
+            util::fail('获取微信昵称失败');
+        }
+        $arr = Json::decode($result);
+        $nickName = $arr['nickName'] ?? '';
+        if (empty($nickName)) {
+            util::fail('没获取到微信昵称');
+        }
+        util::success(['name' => $nickName, 'nickName' => $nickName]);
+    }
+
     //微信手机号一键登录 ssh 20210121
     public function actionWxMobileLogin()
     {

+ 19 - 9
app-hd/controllers/MapController.php

@@ -9,7 +9,7 @@ use Yii;
 class MapController extends BaseController
 {
 
-    public $guestAccess = ['suggestion','resolve'];
+    public $guestAccess = ['suggestion','resolve','nearby'];
 
     //腾讯地图关键词输入提醒 ssh 2020.1.21
     public function actionSuggestion()
@@ -20,23 +20,33 @@ class MapController extends BaseController
         util::success($result);
     }
 
-    //解析地址 ssh 20210626
+    //逆地理解析地址(高德) ssh 20210626
     public function actionResolve()
     {
         $lat = Yii::$app->request->get('lat');
         $long = Yii::$app->request->get('long');
+        $locationType = Yii::$app->request->get('locationType', 'gcj02');
         if (empty($lat) || empty($long)) {
             util::success([]);
         }
-        $res = mapUtil::resolveLocation($lat, $long);
-        $address = $res['result']['formatted_addresses']['recommend'] ?? '';
-        $province = $res['result']['address_component']['province'] ?? '';
-        $city = $res['result']['address_component']['city'] ?? '';
-        $showAddress = $res['result']['address'] ?? '';
-        if (empty($address) || empty($province) || empty($city)) {
+        $result = mapUtil::resolveLocation($lat, $long, $locationType);
+        if (empty($result)) {
             util::success([]);
         }
-        util::success(['province' => $province, 'city' => $city, 'address' => $address, 'showAddress' => $showAddress]);
+        util::success($result);
+    }
+
+    //附近地址(高德逆地理 POI 列表)
+    public function actionNearby()
+    {
+        $lat = Yii::$app->request->get('lat');
+        $long = Yii::$app->request->get('long');
+        $locationType = Yii::$app->request->get('locationType', 'gcj02');
+        if (empty($lat) || empty($long)) {
+            util::success(['list' => []]);
+        }
+        $list = mapUtil::resolveNearby($lat, $long, $locationType);
+        util::success(['list' => $list]);
     }
 
 }

+ 3 - 0
app-hd/controllers/ShopController.php

@@ -120,6 +120,9 @@ class ShopController extends BaseController
     {
         $get = Yii::$app->request->get();
         $mobile = $get['mobile'] ?? '';
+        if(empty($mobile)){
+            util::success(['has' => 0]);
+        }
         $shop = ShopClass::getByCondition(['mobile' => $mobile], true);
         if (!empty($shop)) {
             util::success(['has' => 1]);

BIN
app-hd/web/open_shop.mp4


+ 5 - 8
app-mall/controllers/MapController.php

@@ -20,23 +20,20 @@ class MapController extends BaseController
 		util::success($result);
 	}
 
-    //解析地址 ssh 20210626
+    //逆地理解析地址(高德) ssh 20210626
     public function actionResolve()
     {
         $lat = Yii::$app->request->get('lat');
         $long = Yii::$app->request->get('long');
+        $locationType = Yii::$app->request->get('locationType', 'gcj02');
         if (empty($lat) || empty($long)) {
             util::success([]);
         }
-        $res = mapUtil::resolveLocation($lat, $long);
-        $address = $res['result']['formatted_addresses']['recommend'] ?? '';
-        $province = $res['result']['address_component']['province'] ?? '';
-        $city = $res['result']['address_component']['city'] ?? '';
-        $showAddress = $res['result']['address'] ?? '';
-        if (empty($address) || empty($province) || empty($city)) {
+        $result = mapUtil::resolveLocation($lat, $long, $locationType);
+        if (empty($result)) {
             util::success([]);
         }
-        util::success(['province' => $province, 'city' => $city, 'address' => $address, 'showAddress' => $showAddress]);
+        util::success($result);
     }
 
 }

+ 5 - 8
app-pt/controllers/MapController.php

@@ -18,23 +18,20 @@ class MapController extends BaseController
         util::success($result);
     }
 
-    //解析地址 ssh 20210626
+    //逆地理解析地址(高德) ssh 20210626
     public function actionResolve()
     {
         $lat = Yii::$app->request->get('lat');
         $long = Yii::$app->request->get('long');
+        $locationType = Yii::$app->request->get('locationType', 'gcj02');
         if (empty($lat) || empty($long)) {
             util::success([]);
         }
-        $res = mapUtil::resolveLocation($lat, $long);
-        $address = $res['result']['formatted_addresses']['recommend'] ?? '';
-        $province = $res['result']['address_component']['province'] ?? '';
-        $city = $res['result']['address_component']['city'] ?? '';
-        $showAddress = $res['result']['address'] ?? '';
-        if (empty($address) || empty($province) || empty($city)) {
+        $result = mapUtil::resolveLocation($lat, $long, $locationType);
+        if (empty($result)) {
             util::success([]);
         }
-        util::success(['province' => $province, 'city' => $city, 'address' => $address, 'showAddress' => $showAddress]);
+        util::success($result);
     }
 
 }

+ 2 - 2
biz-ghs/order/classes/OrderClass.php

@@ -1984,7 +1984,7 @@ class OrderClass extends BaseClass
         /**************************如果是好多花的云仓还要再打一下标签纸,多处要同步修改,关键词 hdh_yc *****************************/
         $orderMainId = $orderInfo['mainId'] ?? 0;
         if (getenv('YII_ENV') == 'production') {
-            $map = [65726, 58, 25119, 28500, 1294, 12925];
+            $map = [65726, 58, 25119, 28500, 1294, 12925, 2644];
         } else {
             $map = [828];
         }
@@ -3044,7 +3044,7 @@ XL;
         /**************************如果是好多花的云仓还要再打一下标签纸,多处要同步修改,关键词 hdh_yc *****************************/
         $orderMainId = $order->mainId;
         if (getenv('YII_ENV') == 'production') {
-            $map = [65726, 58, 25119, 28500, 1294, 12925];
+            $map = [65726, 58, 25119, 28500, 1294, 12925, 2644];
         } else {
             $map = [828];
         }

+ 1 - 0
biz-hd/merchant/services/SjService.php

@@ -140,6 +140,7 @@ class SjService extends BaseService
             'long' => $applyData['long'] ?? '',
             'img' => ['/example/shop/1.jpg'],
             'ptStyle' => $ptStyle,
+            'pt' => empty($applyData['introShopId'] ?? 0) ? 1 : 0,
             'live' => $live,
             'onlyCg' => $onlyCg,
             'deadline'=> date("Y-m-d H:i:s", $deadTime),

+ 2 - 0
biz-hd/saas/services/ApplyService.php

@@ -130,6 +130,8 @@ class ApplyService extends BaseService
                 }
             }
         }
+        // 非批发店邀请注册,视为平台直客
+        $data['pt'] = empty($data['introShopId']) ? 1 : 0;
         $mobile = $data['mobile'] ?? '';
         $data['licenseNo'] = $mobile;
         $adminId = $data['adminId'] ?? 0;

+ 4 - 2
biz/ghs/classes/GhsClass.php

@@ -124,6 +124,7 @@ class GhsClass extends BaseClass
         $mobile = $shop['mobile'] ?? '';
         $uniGhsId = $shop['uniGhsId'] ?? 0;
         $hasManyGhs = $shop['hasManyGhs'] ?? 0;
+        $hdShopPt = intval($shop['pt'] ?? 0);
         if ($uniGhsId == 0 && $hasManyGhs == 0) {
             ShopClass::updateById($hdShopId, ['uniGhsId' => $ghsId]);
         } else {
@@ -165,6 +166,7 @@ class GhsClass extends BaseClass
                 'home' => $home,
                 'homeAmount' => $homeAmount,
                 'homeNum' => $homeNum,
+                'pt' => $hdShopPt === 1 ? 1 : 0,
             ];
             $custom = CustomClass::addCustom($customData);
         }
@@ -243,7 +245,7 @@ class GhsClass extends BaseClass
                 true
             );
             foreach ($founderStaffList as $mainId => $founderStaff) {
-				//分享批发店时,通过这个员工找到相应批发店
+                //分享批发店时,通过这个员工找到相应批发店
                 $founderStaffMap[$mainId] = intval($founderStaff->id ?? 0);
             }
         }
@@ -377,7 +379,7 @@ class GhsClass extends BaseClass
         }
 
         //要排除的批发店
-        $exclude = [64112, 795, 1405, 28051, 62304, 42385, 56611, 38143, 15373, 42946, 15375, 15734, 15736, 15738, 15740, 24132, 29044, 29161, 30902, 44724, 48608, 48642, 82971, 38231, 1105, 3, 154, 208, 23580, 24713, 8249, 16070, 83690, 86726, 1596, 2167, 15007, 88085, 91064, 413, 62421];
+        $exclude = [23667, 78556, 64112, 795, 1405, 28051, 62304, 42385, 56611, 38143, 15373, 42946, 15375, 15734, 15736, 15738, 15740, 24132, 29044, 29161, 30902, 44724, 48608, 48642, 82971, 38231, 1105, 3, 154, 208, 23580, 24713, 8249, 16070, 83690, 86726, 1596, 2167, 15007, 88085, 91064, 413, 62421];
         foreach ($nearbyShops as $key => $nearbyShop) {
             if (in_array($nearbyShop['id'], $exclude)) {
                 unset($nearbyShops[$key]);

+ 166 - 4
common/components/mapUtil.php

@@ -88,14 +88,176 @@ class mapUtil
         return $distances;
     }
 
-    //逆地址解析,根据经纬度解析出中文地址 ssh
-    public static function resolveLocation($lat, $long)
+    /**
+     * 逆地址解析(高德),根据经纬度解析省市区与地址
+     * @param string|float $lat 纬度
+     * @param string|float $long 经度
+     * @param string $locationType gcj02|wgs84,wgs84 时传 coordsys=gps 给高德
+     * @return array
+     */
+    public static function resolveLocation($lat, $long, $locationType = 'gcj02')
     {
-        $url = "https://apis.map.qq.com/ws/geocoder/v1/?location={$lat},{$long}&get_poi=0&key=" . self::$thirdMapKey;
+        $lat = (float)$lat;
+        $long = (float)$long;
+        if ($lat == 0 || $long == 0) {
+            return [];
+        }
+
+        $domain = getenv('YII_ENV') == 'production' ? 'https://restapi.amap.com' : 'http://restapi.amap.com';
+        // 高德 location 参数:经度,纬度
+        $location = $long . ',' . $lat;
+        $url = $domain . '/v3/geocode/regeo?location=' . urlencode($location)
+            . '&key=' . self::$thirdMapKey
+            . '&extensions=base';
+        if ($locationType === 'wgs84' || $locationType === 'gps') {
+            $url .= '&coordsys=gps';
+        }
+
         $curl = new curl\Curl();
         $result = $curl->get($url);
         $result = Json::decode($result);
-        return $result;
+        return self::formatAmapRegeoResult($result);
+    }
+
+    /**
+     * 格式化高德逆地理编码结果
+     */
+    private static function formatAmapRegeoResult($result)
+    {
+        if (empty($result['status']) || (string)$result['status'] !== '1' || empty($result['regeocode'])) {
+            return [];
+        }
+
+        $regeo = $result['regeocode'];
+        $component = $regeo['addressComponent'] ?? [];
+        $province = self::normalizeAmapRegionValue($component['province'] ?? '');
+        $city = self::normalizeAmapRegionValue($component['city'] ?? '');
+        $district = self::normalizeAmapRegionValue($component['district'] ?? '');
+
+        if (empty($city)) {
+            $city = $province;
+        }
+
+        $showAddress = $regeo['formatted_address'] ?? '';
+        $township = self::normalizeAmapRegionValue($component['township'] ?? '');
+        $streetNumber = $component['streetNumber'] ?? [];
+        $street = is_array($streetNumber) ? ($streetNumber['street'] ?? '') : '';
+        $number = is_array($streetNumber) ? ($streetNumber['number'] ?? '') : '';
+        $address = trim($township . $street . $number);
+
+        if (empty($address)) {
+            $address = $showAddress;
+            if ($province && mb_strpos($address, $province) === 0) {
+                $address = mb_substr($address, mb_strlen($province));
+            }
+            if ($city && $city !== $province && mb_strpos($address, $city) === 0) {
+                $address = mb_substr($address, mb_strlen($city));
+            }
+            if ($district && mb_strpos($address, $district) === 0) {
+                $address = mb_substr($address, mb_strlen($district));
+            }
+            $address = trim($address);
+        }
+
+        if (empty($address) || empty($province) || empty($city)) {
+            return [];
+        }
+
+        return [
+            'province' => $province,
+            'city' => $city,
+            'district' => $district,
+            'address' => $address,
+            'showAddress' => $showAddress ?: ($province . $city . $district . $address),
+        ];
+    }
+
+    /**
+     * 根据经纬度获取当前位置及附近 POI 列表(高德逆地理 extensions=all)
+     */
+    public static function resolveNearby($lat, $long, $locationType = 'gcj02')
+    {
+        $lat = (float)$lat;
+        $long = (float)$long;
+        if ($lat == 0 || $long == 0) {
+            return [];
+        }
+
+        $domain = getenv('YII_ENV') == 'production' ? 'https://restapi.amap.com' : 'http://restapi.amap.com';
+        $location = $long . ',' . $lat;
+        $url = $domain . '/v3/geocode/regeo?location=' . urlencode($location)
+            . '&key=' . self::$thirdMapKey
+            . '&extensions=all&radius=1000&roadlevel=0';
+        if ($locationType === 'wgs84' || $locationType === 'gps') {
+            $url .= '&coordsys=gps';
+        }
+
+        $curl = new curl\Curl();
+        $result = Json::decode($curl->get($url));
+        if (empty($result['status']) || (string)$result['status'] !== '1' || empty($result['regeocode'])) {
+            return [];
+        }
+
+        $regeo = $result['regeocode'];
+        $component = $regeo['addressComponent'] ?? [];
+        $province = self::normalizeAmapRegionValue($component['province'] ?? '');
+        $city = self::normalizeAmapRegionValue($component['city'] ?? '');
+        $district = self::normalizeAmapRegionValue($component['district'] ?? '');
+        if (empty($city)) {
+            $city = $province;
+        }
+
+        $centerAddress = $regeo['formatted_address'] ?? '';
+        $centerName = self::normalizeAmapRegionValue($component['township'] ?? '');
+        if (empty($centerName)) {
+            $centerName = '当前位置';
+        }
+
+        $list = [[
+            'name' => $centerName,
+            'address' => $centerAddress,
+            'province' => $province,
+            'city' => $city,
+            'district' => $district,
+            'location' => $long . ',' . $lat,
+            'showAddress' => $centerAddress,
+        ]];
+
+        $pois = $regeo['pois'] ?? [];
+        $exists = [$centerName];
+        foreach ($pois as $poi) {
+            $poiName = $poi['name'] ?? '';
+            if ($poiName === '' || in_array($poiName, $exists, true)) {
+                continue;
+            }
+            $exists[] = $poiName;
+            $poiAddress = $poi['address'] ?? '';
+            if ($poiAddress === '') {
+                $poiAddress = $centerAddress ? ($centerAddress . ' ' . $poiName) : $poiName;
+            }
+            $list[] = [
+                'name' => $poiName,
+                'address' => $poiAddress,
+                'province' => $province,
+                'city' => $city,
+                'district' => $district,
+                'location' => $poi['location'] ?? ($long . ',' . $lat),
+                'showAddress' => $poiAddress,
+            ];
+            if (count($list) >= 21) {
+                break;
+            }
+        }
+
+        return $list;
+    }
+
+    private static function normalizeAmapRegionValue($value)
+    {
+        if (is_array($value)) {
+            return !empty($value) ? (string)$value[0] : '';
+        }
+        return (string)$value;
     }
 
     /**

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác