diff --git a/app/Controller/v3/HomeController.php b/app/Controller/v3/HomeController.php index 448f41d..1b39366 100644 --- a/app/Controller/v3/HomeController.php +++ b/app/Controller/v3/HomeController.php @@ -263,14 +263,14 @@ class HomeController extends BaseController 'id' => 1, 'title' => '关于懒族', 'sub_title' => '懒族生活678', - 'path' => 'https://www.baidu.com/s?wd=%E6%87%92%E6%97%8F%E7%94%9F%E6%B4%BB', + 'path' => 'https://mp.weixin.qq.com/s/tGKIILpL2extoeKXgYNYIA', 'path_type' => 'webview' ], [ 'id' => 1, 'title' => '隐私政策', 'sub_title' => '隐私政策123', - 'path' => 'https://www.baidu.com/s?wd=%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96', + 'path' => 'https://mp.weixin.qq.com/s/HQbJyUJVUYYMIJrHOZNbpA', 'path_type' => 'webview' ] ]; diff --git a/app/Controller/v3/OrderOnlineController.php b/app/Controller/v3/OrderOnlineController.php index 4c31b06..8c717c1 100644 --- a/app/Controller/v3/OrderOnlineController.php +++ b/app/Controller/v3/OrderOnlineController.php @@ -7,6 +7,7 @@ use App\Constants\v3\LogLabel; use App\Constants\v3\OrderState; use App\Controller\BaseController; use App\Exception\ErrorCodeException; +use App\Model\v3\Market; use App\Model\v3\OrderMain; use App\Request\v3\OrderOnlineDetailRequest; use App\Request\v3\OrderOnlineRequest; @@ -14,9 +15,10 @@ use App\Request\v3\OrderOnlineStateRequest; use App\Request\v3\UserRequest; use App\Service\v3\Implementations\PaymentService; use App\Service\v3\Interfaces\CouponRecServiceInterface; +use App\Service\v3\Interfaces\DistributionPriceServiceInterface; +use App\Service\v3\Interfaces\LocationServiceInterface; use App\Service\v3\Interfaces\SeparateAccountsServiceInterface; use App\Service\v3\Interfaces\ShopCartServiceInterface; -use App\Service\v3\Interfaces\UserAddressServiceInterface; use Hyperf\DbConnection\Db; use Hyperf\Di\Annotation\Inject; use App\Service\v3\Interfaces\OrderOnlineServiceInterface; @@ -63,9 +65,15 @@ class OrderOnlineController extends BaseController /** * @Inject - * @var UserAddressServiceInterface + * @var LocationServiceInterface */ - protected $userAddressService; + protected $locationService; + + /** + * @Inject + * @var DistributionPriceServiceInterface + */ + protected $distributionPriceService; /* * 如果没有绑手机号去绑定页面 @@ -94,10 +102,27 @@ class OrderOnlineController extends BaseController ->orderByDesc('is_default') ->orderByDesc('updated_at') ->first(); - $res['location'] = [ - 'address' => $address, - 'distribution_price' => 0 - ]; + $market = Market::find($marketId); + if(!empty($address->lng) && !empty($address->lat)){ + $distance = $this->locationService->getDistanceByTencent($market->lng,$market->lat,$address->lng,$address->lat); + } + + if(isset($distance) && $distance > 8000){ + $distributionPrice = $this->distributionPriceService->do($distance); + $res['location'] = [ + 'address' => $address, + 'distribution_price' => $distributionPrice, + 'distance' => $distance, + 'within' => true + ]; + }else{ + $res['location'] = [ + 'address' => '', + 'distribution_price' => 3.5, + 'distance' => $distance, + 'within' => false + ]; + } //返回预约送达时间 数组 $res['appointment_time'] = $this->appointmentTimeService->get($shopcartIds); diff --git a/app/Controller/v3/WithdrawController.php b/app/Controller/v3/WithdrawController.php index 3671a91..fb5b2b9 100644 --- a/app/Controller/v3/WithdrawController.php +++ b/app/Controller/v3/WithdrawController.php @@ -194,7 +194,7 @@ class WithdrawController extends BaseController 'withdraw' => json_encode($withdraw), 'params' => json_encode(['balance' => $balance->balance, 'user_id' => $userId, 'store_id' => $storeId]), ]); - throw new ErrorCodeException(ErrorCode::STORE_WITHDRAW_FAIL); + throw new ErrorCodeException(ErrorCode::WITHDRAW_PAYMENT_FAIL); } } diff --git a/app/Service/v3/Implementations/CategoryService.php b/app/Service/v3/Implementations/CategoryService.php index 033b580..63fa60e 100644 --- a/app/Service/v3/Implementations/CategoryService.php +++ b/app/Service/v3/Implementations/CategoryService.php @@ -87,14 +87,12 @@ class CategoryService implements CategoryServiceInterface $returnData = []; foreach ($categories as $key => &$category) { $value = json_decode($category, true); - $iconUrl = $value['icon']; - if(strripos($iconUrl,"http") === false){ - $iconUrl = config('alioss.img_host').'/'.$value['icon']; - } - $iconUrl = $this->attachmentService->switchImgToAliOss($iconUrl, OssThumbnail::THUMBNAIL_100_Q90); - $returnData[] = ['id' => $key, 'icon' => $iconUrl , 'name' => $value['name']]; + $iconUrl = $this->attachmentService->switchImgToAliOss($value['icon'], OssThumbnail::THUMBNAIL_100_Q90); + $returnData[] = ['id' => $value['id'], 'icon' => $iconUrl , 'name' => $value['name'], 'sort' => $value['sort']]; } - return $returnData; + $returnData = collect($returnData)->sortByDesc('sort')->all(); + + return array_values($returnData); } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/DistributionPriceService.php b/app/Service/v3/Implementations/DistributionPriceService.php index d968657..5765ea8 100644 --- a/app/Service/v3/Implementations/DistributionPriceService.php +++ b/app/Service/v3/Implementations/DistributionPriceService.php @@ -20,10 +20,10 @@ class DistributionPriceService implements DistributionPriceServiceInterface case ($km >= 5 && $km < 7) : $distributionRrice = bcmul(1.00,($km-3),2); break; - case ($km >= 7 && $km < 10) : + case ($km >= 7 && $km < 8) : $distributionRrice = bcmul(1.50,($km-3),2); break; - case ($km >= 10) : + case ($km >= 8) : throw new ErrorCodeException(ErrorCode::LOCATION_LONG_DISTANCE); break; default: diff --git a/app/Service/v3/Implementations/LocationService.php b/app/Service/v3/Implementations/LocationService.php index 8308c59..ad32232 100644 --- a/app/Service/v3/Implementations/LocationService.php +++ b/app/Service/v3/Implementations/LocationService.php @@ -143,7 +143,7 @@ class LocationService implements LocationServiceInterface //获取骑行距离 public function getDistanceByTencent($lng1, $lat1, $lng2, $lat2) { - $url = 'https://apis.map.qq.com/ws/direction/v1/'; + $url = 'https://apis.map.qq.com/ws/distance/v1/matrix/?mode='; /** * $tyep driving 驾车 walking 步行 bicycling 骑行 transit 公交 */ @@ -151,22 +151,18 @@ class LocationService implements LocationServiceInterface $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/', + 'base_uri' => 'https://apis.map.qq.com/', // 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 = $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'] == 384) - { - return 100; - } if($resultArr['status'] > 0) { throw new ErrorCodeException(ErrorCode::LOCATION_ERROR,$resultArr['message']); } - $distance = $resultArr['result']['routes'][0]['distance']; + $distance = $resultArr['result']['rows'][0]['elements'][0]['distance']; return $distance; } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/UserAddressService.php b/app/Service/v3/Implementations/UserAddressService.php index ebfc46f..ed5cadc 100644 --- a/app/Service/v3/Implementations/UserAddressService.php +++ b/app/Service/v3/Implementations/UserAddressService.php @@ -87,7 +87,6 @@ class UserAddressService implements UserAddressServiceInterface $market = Market::query()->select('lng','lat')->find($marketId); $distance = $this->locationService->getDistanceByTencent($address['address']->lng,$address['address']->lat,$market->lng,$market->lat); $distributionPrice = $this->distributionPriceService->do($distance); - var_dump($distance); $res['address'] = $address; $res['delivery_distance'] = $distance; $res['distribution_price'] = $distributionPrice;