Browse Source

Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix

* 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf:
  更新购物车
  营业时间
  计算距离
master
Mike 5 years ago
parent
commit
e4eb0350c8
  1. 4
      app/Constants/v3/ErrorCode.php
  2. 3
      app/Controller/v3/StoreController.php
  3. 3
      app/Service/v3/Implementations/BusinessHoursService.php
  4. 11
      app/Service/v3/Implementations/LocationService.php
  5. 1
      app/Service/v3/Implementations/OrderListService.php
  6. 2
      app/Service/v3/Implementations/ShopCartUpdateService.php
  7. 8
      app/Service/v3/Implementations/UserAddressService.php
  8. 2
      app/Service/v3/Interfaces/BusinessHoursServiceInterface.php

4
app/Constants/v3/ErrorCode.php

@ -278,8 +278,8 @@ class ErrorCode extends AbstractConstants
const LOCATION_ERROR = 1301; const LOCATION_ERROR = 1301;
/** /**
* 定位失败
* @Message("超出配送范围")
* 超出配送范围
* @Message("您的地址超出配送范围,请重新选择地址")
*/ */
const LOCATION_LONG_DISTANCE= 1302; const LOCATION_LONG_DISTANCE= 1302;
} }

3
app/Controller/v3/StoreController.php

@ -66,11 +66,12 @@ class StoreController extends BaseController
public function updateBusinessHours() public function updateBusinessHours()
{ {
$storeId = $this->request->input('store_id'); $storeId = $this->request->input('store_id');
$isRest = $this->request->input('is_rest','');
$time1 = $this->request->input('time1',''); $time1 = $this->request->input('time1','');
$time2 = $this->request->input('time2',''); $time2 = $this->request->input('time2','');
$time3 = $this->request->input('time3',''); $time3 = $this->request->input('time3','');
$time4 = $this->request->input('time4',''); $time4 = $this->request->input('time4','');
$res = $this->businessHoursService->do($storeId,$time1,$time2,$time3,$time4);
$res = $this->businessHoursService->do($storeId,$isRest,$time1,$time2,$time3,$time4);
return $this->success($res); return $this->success($res);
} }
} }

3
app/Service/v3/Implementations/BusinessHoursService.php

@ -8,9 +8,10 @@ use \App\Service\v3\Interfaces\BusinessHoursServiceInterface;
class BusinessHoursService implements BusinessHoursServiceInterface class BusinessHoursService implements BusinessHoursServiceInterface
{ {
public function do($storeId,$time1,$time2,$time3 = '',$time4 = '')
public function do($storeId,$isRest,$time1,$time2,$time3 = '',$time4 = '')
{ {
$store = Store::query()->find($storeId); $store = Store::query()->find($storeId);
$store->is_rest = $isRest;
$store->time1 = $time1; $store->time1 = $time1;
$store->time2 = $time2; $store->time2 = $time2;
$store->time3 = $time3; $store->time3 = $time3;

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

@ -2,6 +2,8 @@
namespace App\Service\v3\Implementations; namespace App\Service\v3\Implementations;
use App\Constants\v3\ErrorCode;
use App\Exception\ErrorCodeException;
use App\Service\v3\Interfaces\LocationServiceInterface; use App\Service\v3\Interfaces\LocationServiceInterface;
use App\Model\v3\Area; use App\Model\v3\Area;
use App\Model\v3\Market; use App\Model\v3\Market;
@ -88,6 +90,13 @@ class LocationService implements LocationServiceInterface
*/ */
$type = 'bicycling'; $type = 'bicycling';
$key = 'GB3BZ-7W2CU-LW3VH-B7ZIF-XRKSF-D3FOL'; $key = 'GB3BZ-7W2CU-LW3VH-B7ZIF-XRKSF-D3FOL';
return file_get_contents($url.$type.'/?from='.$lat1.','.$lng1.'&to='.$lat2.','.$lng2.'&output=json&key='.$key);
$result = file_get_contents($url.$type.'/?from='.$lat1.','.$lng1.'&to='.$lat2.','.$lng2.'&output=json&key='.$key);
$resultArr = json_decode($result,true);
if($resultArr['status'] > 0)
{
throw new ErrorCodeException(ErrorCode::LOCATION_ERROR,$resultArr['message']);
}
$distance = $resultArr['result']['routes'][0]['distance'];
return $distance;
} }
} }

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

@ -60,6 +60,7 @@ class OrderListService implements OrderListServiceInterface
$builder = Order::join('lanzu_order_main','lanzu_order.order_main_id','lanzu_order_main.id') $builder = Order::join('lanzu_order_main','lanzu_order.order_main_id','lanzu_order_main.id')
->select( ->select(
'lanzu_order.*', 'lanzu_order.*',
'lanzu_order_main.state',
'lanzu_order_main.address', 'lanzu_order_main.address',
'lanzu_order_main.name', 'lanzu_order_main.name',
'lanzu_order_main.delivery_time_note', 'lanzu_order_main.delivery_time_note',

2
app/Service/v3/Implementations/ShopCartUpdateService.php

@ -15,7 +15,7 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface
{ {
$goodsType = ''; $goodsType = '';
//判断是普通商品还是特价商品 //判断是普通商品还是特价商品
if(isset($params['activity']) && $params['activity'] == GoodsConstants::IS_ACTIVITY){
if($activity_type == GoodsConstants::IS_ACTIVITY){
$builder = GoodsActivity::query(); $builder = GoodsActivity::query();
$goodsType = GoodsActivity::class; $goodsType = GoodsActivity::class;
}else{ }else{

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

@ -75,13 +75,7 @@ class UserAddressService implements UserAddressServiceInterface
{ {
$address = $this->get($userAddressId); $address = $this->get($userAddressId);
$market = Market::query()->select('lng','lat')->find($marketId); $market = Market::query()->select('lng','lat')->find($marketId);
$result = $this->locationService->getDistanceByTencent($address->lng,$address->lat,$market->lng,$market->lat);
$resultArr = json_decode($result,true);
if($resultArr['status'] > 0)
{
throw new ErrorCodeException(ErrorCode::LOCATION_ERROR,$resultArr['message']);
}
$distance = $resultArr['result']['routes'][0]['distance'];
$distance = $this->locationService->getDistanceByTencent($address->lng,$address->lat,$market->lng,$market->lat);
$distributionRrice = $this->calculateDistributionRrice($distance); $distributionRrice = $this->calculateDistributionRrice($distance);
$res['address'] = $address; $res['address'] = $address;
$res['distribution_price'] = $distributionRrice; $res['distribution_price'] = $distributionRrice;

2
app/Service/v3/Interfaces/BusinessHoursServiceInterface.php

@ -6,7 +6,7 @@ namespace App\Service\v3\Interfaces;
interface BusinessHoursServiceInterface interface BusinessHoursServiceInterface
{ {
public function do($storeId,$time1,$time2,$time3 = '',$time4 = '');
public function do($storeId,$isRest,$time1,$time2,$time3 = '',$time4 = '');
public function check($storeId); public function check($storeId);
public function undo(); public function undo();
} }
Loading…
Cancel
Save