From 47f5a1cedf729a8683069f23dc0aa75fcc1c4090 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 16 Sep 2020 11:34:05 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=B7=9D=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Commons/TencentMap.php | 76 ------------------- .../v3/Implementations/LocationService.php | 19 +++-- config/config.php | 3 + 3 files changed, 17 insertions(+), 81 deletions(-) delete mode 100644 app/Commons/TencentMap.php diff --git a/app/Commons/TencentMap.php b/app/Commons/TencentMap.php deleted file mode 100644 index 13b78c1..0000000 --- a/app/Commons/TencentMap.php +++ /dev/null @@ -1,76 +0,0 @@ -clientFactory = $clientFactory; - } - - public function getClient() - { - // $options 等同于 GuzzleHttp\Client 构造函数的 $config 参数 - $options = [ - 'timeout' => 2.0, - ]; - // $client 为协程化的 GuzzleHttp\Client 对象 - $client = $this->clientFactory->create($options); - - return $client; - } - - public function event($labels=null,$datas){ - - co(function () use ($labels,$datas){ - - $client = $this->getClient(); - $kv = []; - foreach ($datas as $key => $value) { - $kv[] = $key."=".$value; - } - $pushLabels = []; - - $event_name = 'event_'.env('APP_ENV'); - if(!empty($labels)) $pushLabels[$event_name] = $labels; - - /* - * data format: - curl -v -H "Content-Type: application/json" -XPOST -s "http://39.96.12.39:3100/loki/api/v1/push" --data-raw \ - '{"streams": [{ "stream": { "foo": "bar2" }, "values": [ [ "1596274538882028800", "fizzbuzz" ] ] }]}' - */ - $ts = $this->getMsecTime() . '000000'; - $datas = implode("&",$kv); - $values = [[$ts,$datas]]; - $app_name = env('APP_NAME').'_'.env('APP_ENV'); - - $pushLabels['app']= $app_name; - $pushDatas = [ - 'streams'=>[ - [ - 'stream'=>$pushLabels, - 'values'=>$values, - ] - ] - ]; - $client->post( - env('LOG_HOST','http://39.96.12.39:3100').'/loki/api/v1/push', - [ - 'headers'=>[ - 'Content-Type'=>'application/json' - ], - 'body' => json_encode($pushDatas) - ] - ); - //var_dump(json_encode($pushDatas) ); - }); - } - -} diff --git a/app/Service/v3/Implementations/LocationService.php b/app/Service/v3/Implementations/LocationService.php index 1a19c7b..bfcaaae 100644 --- a/app/Service/v3/Implementations/LocationService.php +++ b/app/Service/v3/Implementations/LocationService.php @@ -8,6 +8,8 @@ use App\Model\v3\UserCollection; use App\Service\v3\Interfaces\LocationServiceInterface; use App\Model\v3\Area; use App\Model\v3\Market; +use GuzzleHttp\Client; + class LocationService implements LocationServiceInterface { @@ -146,13 +148,20 @@ class LocationService implements LocationServiceInterface * $tyep driving 驾车 walking 步行 bicycling 骑行 transit 公交 */ $type = 'bicycling'; - $key = 'GB3BZ-7W2CU-LW3VH-B7ZIF-XRKSF-D3FOL'; - $result = file_get_contents($url.$type.'/?from='.$lat1.','.$lng1.'&to='.$lat2.','.$lng2.'&output=json&key='.$key); - $resultArr = json_decode($result,true); + $key = config('map.tencent'); + $client = new Client([ + // Base URI is used with relative requests + 'base_uri' => 'https://apis.map.qq.com/ws/direction/v1/bicycling/', + // You can set any number of default request options. + 'timeout' => 2.0, + ]); + $response = $client->request('GET', $url.$type.'/?from='.$lat1.','.$lng1.'&to='.$lat2.','.$lng2.'&output=json&key='.$key); + $response = $response->getBody()->getContents(); + $resultArr = json_decode($response,true); if($resultArr['status'] > 0) { - return 1000; - //throw new ErrorCodeException(ErrorCode::LOCATION_ERROR,$resultArr['message']); + //return 1000; + throw new ErrorCodeException(ErrorCode::LOCATION_ERROR,$resultArr['message']); } $distance = $resultArr['result']['routes'][0]['distance']; return $distance; diff --git a/config/config.php b/config/config.php index 86de642..8654778 100644 --- a/config/config.php +++ b/config/config.php @@ -55,4 +55,7 @@ return [ 'lgoin' => [ 'authkey' => env('STORE_LOGIN_AUTHKEY', ''), ], + 'map' => [ + 'tencent' => env('TENCENT_MAP_KEY', ''), + ], ]; From c0b5aca6a1286d70ce2accf0765c73e5a52bff7c Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 16 Sep 2020 12:06:18 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=80=81=E8=BE=BE=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/AppointmentTimeService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Service/v3/Implementations/AppointmentTimeService.php b/app/Service/v3/Implementations/AppointmentTimeService.php index 5c18d2b..6230fe1 100644 --- a/app/Service/v3/Implementations/AppointmentTimeService.php +++ b/app/Service/v3/Implementations/AppointmentTimeService.php @@ -68,7 +68,7 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface }else{ $endTime = $time2; } - if(($nowTime+60*30) > $endTime){ + if($nowTime > $endTime){ throw new ErrorCodeException(ErrorCode::STORE_REST); } array_push($time1Arr,$time1); @@ -77,13 +77,14 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface $res = []; $time1Max = max($time1Arr); $time2Min = min($time2Arr); - if($time2Min > $nowTime) { + if($time2Min > $nowTime+60*30) { $res = array_merge($res,$this->calculateTime($time1Max, $time2Min)); } if(!empty($time3Arr) && !empty($time4Arr)){ + var_dump($time3Arr,$time4Arr); $time3Max = max($time3Arr); $time4Min = min($time4Arr); - if($time4Min > $nowTime) { + if($time4Min > $nowTime+60*30) { $res = array_merge($res,$this->calculateTime($time3Max, $time4Min)); } } @@ -102,7 +103,6 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface $peakPeriodEnd = strtotime('18:00'); //取得订单下所有店铺时间段 交集 并计算时间段横跨单位区间长度 $length = ceil(($endTime - $startTime) / (30*60)); - print_r($length); for ($i=1;$i<=$length;$i++){ $addTime = $startTime + (30*60*$i); if($addTime >= $peakPeriod && $addTime < $peakPeriodEnd){ From 1ee430b8e7a6242819de19b87680244b3a892eff Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 16 Sep 2020 12:20:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AF=86=E9=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/StoreLoginService.php | 2 +- config/config.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Service/v3/Implementations/StoreLoginService.php b/app/Service/v3/Implementations/StoreLoginService.php index 7cb4954..abbed09 100644 --- a/app/Service/v3/Implementations/StoreLoginService.php +++ b/app/Service/v3/Implementations/StoreLoginService.php @@ -32,7 +32,7 @@ class StoreLoginService implements StoreLoginServiceInterface function stringHash($password,$salt) { - $authkey = config('lgoin.authkey'); + $authkey = config('login.authkey'); $password = "{$password}-{$salt}-{$authkey}"; return sha1($password); } diff --git a/config/config.php b/config/config.php index 8654778..4b89b60 100644 --- a/config/config.php +++ b/config/config.php @@ -52,7 +52,7 @@ return [ 'alioss' => [ 'img_host' => env('OSS_IMG_HOST', ''), ], - 'lgoin' => [ + 'login' => [ 'authkey' => env('STORE_LOGIN_AUTHKEY', ''), ], 'map' => [