Browse Source

配送费 错误拦截

master
Lemon 5 years ago
parent
commit
7c7af0140d
  1. 8
      app/Constants/v3/ErrorCode.php
  2. 4
      app/Service/v3/Implementations/UserAddressService.php

8
app/Constants/v3/ErrorCode.php

@ -347,5 +347,11 @@ class ErrorCode extends AbstractConstants
* 超出配送范围
* @Message("您的地址超出配送范围,请重新选择地址")
*/
const LOCATION_LONG_DISTANCE= 1302;
const LOCATION_LONG_DISTANCE = 1302;
/**
* 超出配送范围
* @Message("获取收货地址失败")
*/
const LOCATION_USER_ADDRESS = 1303;
}

4
app/Service/v3/Implementations/UserAddressService.php

@ -85,6 +85,10 @@ class UserAddressService implements UserAddressServiceInterface
{
$address = $this->get($userAddressId);
$market = Market::query()->select('lng','lat')->find($marketId);
if(empty($address['address']->lng) || empty($address['address']->lat) || empty($market->lng) || empty($market->lat)){
throw new ErrorCodeException(ErrorCode::LOCATION_USER_ADDRESS);
}
var_dump($address->lng,$market);
$distance = $this->locationService->getDistanceByTencent($address['address']->lng,$address['address']->lat,$market->lng,$market->lat);
$distributionPrice = $this->distributionPriceService->do($distance);
$res['address'] = $address;

Loading…
Cancel
Save