Silent 6 년 전
부모
커밋
ac32b94487
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 10 1
      app/Http/Controllers/WeChat/ApiController.php

+ 10 - 1
app/Http/Controllers/WeChat/ApiController.php

@@ -67,6 +67,15 @@ class ApiController extends Controller
         $url = 'https://apis.map.qq.com/ws/distance/v1/?from=' . $from . '&to=' . $to . '&key=' . env('TECENT_POSITION_KEY');
         $url = 'https://apis.map.qq.com/ws/distance/v1/?from=' . $from . '&to=' . $to . '&key=' . env('TECENT_POSITION_KEY');
         $res = $client->get($url);
         $res = $client->get($url);
         $res = json_decode((string)$res->getBody());
         $res = json_decode((string)$res->getBody());
-        return response()->json(['status' => 'success', 'data' => $res]);
+        $result = 'no';
+        if($res->status == 0) {
+            $radius = Setting::where('key', 'check_card_radius')->first();
+            $radius = empty($radius) ? 1000 : $radius->value;
+            $distance = $res->result->elements[0]->distance;
+            if($distance <= $radius) {
+                $result = 'ok';
+            }
+        }
+        return response()->json(['status' => 'success', 'result' => $result]);
     }
     }
 }
 }