Browse Source

确认订单 地址

master
Lemon 5 years ago
parent
commit
443b5d56f7
  1. 36
      app/Controller/v3/OrderOnlineController.php
  2. 4
      app/Service/v3/Implementations/DistributionPriceService.php

36
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,24 @@ class OrderOnlineController extends BaseController
->orderByDesc('is_default')
->orderByDesc('updated_at')
->first();
$res['location'] = [
'address' => $address,
'distribution_price' => 0
];
$market = Market::find($marketId);
$distance = $this->locationService->getDistanceByTencent($address->lng,$address->lat,$market->lng,$market->lat);
if($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);

4
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:

Loading…
Cancel
Save