Browse Source

Merge branch 'phoenix' into master

master
weigang 5 years ago
parent
commit
727b19a8c8
  1. 4
      app/Controller/v3/HomeController.php
  2. 33
      app/Controller/v3/OrderOnlineController.php
  3. 2
      app/Controller/v3/WithdrawController.php
  4. 12
      app/Service/v3/Implementations/CategoryService.php
  5. 4
      app/Service/v3/Implementations/DistributionPriceService.php
  6. 12
      app/Service/v3/Implementations/LocationService.php
  7. 1
      app/Service/v3/Implementations/UserAddressService.php

4
app/Controller/v3/HomeController.php

@ -263,14 +263,14 @@ class HomeController extends BaseController
'id' => 1, 'id' => 1,
'title' => '关于懒族', 'title' => '关于懒族',
'sub_title' => '懒族生活678', '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' 'path_type' => 'webview'
], ],
[ [
'id' => 1, 'id' => 1,
'title' => '隐私政策', 'title' => '隐私政策',
'sub_title' => '隐私政策123', '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' 'path_type' => 'webview'
] ]
]; ];

33
app/Controller/v3/OrderOnlineController.php

@ -7,6 +7,7 @@ use App\Constants\v3\LogLabel;
use App\Constants\v3\OrderState; use App\Constants\v3\OrderState;
use App\Controller\BaseController; use App\Controller\BaseController;
use App\Exception\ErrorCodeException; use App\Exception\ErrorCodeException;
use App\Model\v3\Market;
use App\Model\v3\OrderMain; use App\Model\v3\OrderMain;
use App\Request\v3\OrderOnlineDetailRequest; use App\Request\v3\OrderOnlineDetailRequest;
use App\Request\v3\OrderOnlineRequest; use App\Request\v3\OrderOnlineRequest;
@ -14,9 +15,10 @@ use App\Request\v3\OrderOnlineStateRequest;
use App\Request\v3\UserRequest; use App\Request\v3\UserRequest;
use App\Service\v3\Implementations\PaymentService; use App\Service\v3\Implementations\PaymentService;
use App\Service\v3\Interfaces\CouponRecServiceInterface; 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\SeparateAccountsServiceInterface;
use App\Service\v3\Interfaces\ShopCartServiceInterface; use App\Service\v3\Interfaces\ShopCartServiceInterface;
use App\Service\v3\Interfaces\UserAddressServiceInterface;
use Hyperf\DbConnection\Db; use Hyperf\DbConnection\Db;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\OrderOnlineServiceInterface; use App\Service\v3\Interfaces\OrderOnlineServiceInterface;
@ -63,9 +65,15 @@ class OrderOnlineController extends BaseController
/** /**
* @Inject * @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('is_default')
->orderByDesc('updated_at') ->orderByDesc('updated_at')
->first(); ->first();
$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'] = [ $res['location'] = [
'address' => $address, 'address' => $address,
'distribution_price' => 0
'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); $res['appointment_time'] = $this->appointmentTimeService->get($shopcartIds);

2
app/Controller/v3/WithdrawController.php

@ -194,7 +194,7 @@ class WithdrawController extends BaseController
'withdraw' => json_encode($withdraw), 'withdraw' => json_encode($withdraw),
'params' => json_encode(['balance' => $balance->balance, 'user_id' => $userId, 'store_id' => $storeId]), '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);
} }
} }

12
app/Service/v3/Implementations/CategoryService.php

@ -87,14 +87,12 @@ class CategoryService implements CategoryServiceInterface
$returnData = []; $returnData = [];
foreach ($categories as $key => &$category) { foreach ($categories as $key => &$category) {
$value = json_decode($category, true); $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);
} }
} }

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

@ -20,10 +20,10 @@ class DistributionPriceService implements DistributionPriceServiceInterface
case ($km >= 5 && $km < 7) : case ($km >= 5 && $km < 7) :
$distributionRrice = bcmul(1.00,($km-3),2); $distributionRrice = bcmul(1.00,($km-3),2);
break; break;
case ($km >= 7 && $km < 10) :
case ($km >= 7 && $km < 8) :
$distributionRrice = bcmul(1.50,($km-3),2); $distributionRrice = bcmul(1.50,($km-3),2);
break; break;
case ($km >= 10) :
case ($km >= 8) :
throw new ErrorCodeException(ErrorCode::LOCATION_LONG_DISTANCE); throw new ErrorCodeException(ErrorCode::LOCATION_LONG_DISTANCE);
break; break;
default: default:

12
app/Service/v3/Implementations/LocationService.php

@ -143,7 +143,7 @@ class LocationService implements LocationServiceInterface
//获取骑行距离 //获取骑行距离
public function getDistanceByTencent($lng1, $lat1, $lng2, $lat2) 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 公交 * $tyep driving 驾车 walking 步行 bicycling 骑行 transit 公交
*/ */
@ -151,22 +151,18 @@ class LocationService implements LocationServiceInterface
$key = config('map.tencent'); $key = config('map.tencent');
$client = new Client([ $client = new Client([
// Base URI is used with relative requests // 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. // You can set any number of default request options.
'timeout' => 2.0, '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(); $response = $response->getBody()->getContents();
$resultArr = json_decode($response,true); $resultArr = json_decode($response,true);
if($resultArr['status'] == 384)
{
return 100;
}
if($resultArr['status'] > 0) if($resultArr['status'] > 0)
{ {
throw new ErrorCodeException(ErrorCode::LOCATION_ERROR,$resultArr['message']); throw new ErrorCodeException(ErrorCode::LOCATION_ERROR,$resultArr['message']);
} }
$distance = $resultArr['result']['routes'][0]['distance'];
$distance = $resultArr['result']['rows'][0]['elements'][0]['distance'];
return $distance; return $distance;
} }
} }

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

@ -87,7 +87,6 @@ class UserAddressService implements UserAddressServiceInterface
$market = Market::query()->select('lng','lat')->find($marketId); $market = Market::query()->select('lng','lat')->find($marketId);
$distance = $this->locationService->getDistanceByTencent($address['address']->lng,$address['address']->lat,$market->lng,$market->lat); $distance = $this->locationService->getDistanceByTencent($address['address']->lng,$address['address']->lat,$market->lng,$market->lat);
$distributionPrice = $this->distributionPriceService->do($distance); $distributionPrice = $this->distributionPriceService->do($distance);
var_dump($distance);
$res['address'] = $address; $res['address'] = $address;
$res['delivery_distance'] = $distance; $res['delivery_distance'] = $distance;
$res['distribution_price'] = $distributionPrice; $res['distribution_price'] = $distributionPrice;

Loading…
Cancel
Save