Browse Source

Merge branch 'phoenix' of ssh://120.24.33.109:11022/hyzjshwo/lanzu_api_hyperf into phoenix

# Conflicts:
#	app/Service/v3/Implementations/UserAddressService.php
master
weigang 5 years ago
parent
commit
1d90e9beeb
  1. 4
      app/Controller/v3/OrderOnlineController.php
  2. 11
      app/Service/v3/Implementations/AppointmentTimeService.php
  3. 10
      app/Service/v3/Implementations/DistributionPriceService.php
  4. 3
      app/Service/v3/Implementations/GoodsActivityService.php
  5. 3
      app/Service/v3/Implementations/GoodsService.php
  6. 7
      config/config.php

4
app/Controller/v3/OrderOnlineController.php

@ -106,8 +106,8 @@ class OrderOnlineController extends BaseController
if(!empty($address->lng) && !empty($address->lat)){ if(!empty($address->lng) && !empty($address->lat)){
$distance = $this->locationService->getDistanceByTencent($market->lng,$market->lat,$address->lng,$address->lat); $distance = $this->locationService->getDistanceByTencent($market->lng,$market->lat,$address->lng,$address->lat);
} }
if(isset($distance) && $distance < 8000){
$deliveryDistance = config('distance.delivery_distance');
if(isset($distance) && $distance < $deliveryDistance){
$distributionPrice = $this->distributionPriceService->do($distance); $distributionPrice = $this->distributionPriceService->do($distance);
$res['location'] = [ $res['location'] = [
'address' => $address, 'address' => $address,

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

@ -37,6 +37,9 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface
$shopcartIds = explode(',',$shopcartIds); $shopcartIds = explode(',',$shopcartIds);
$sotreIds = ShoppingCart::query()->whereIn('id',$shopcartIds)->pluck('store_id'); $sotreIds = ShoppingCart::query()->whereIn('id',$shopcartIds)->pluck('store_id');
$stores = Store::query()->whereIn('id',$sotreIds)->get()->toArray(); $stores = Store::query()->whereIn('id',$sotreIds)->get()->toArray();
if(empty($stores)){
throw new ErrorCodeException(ErrorCode::STORE_NOT_AVAILABLE);
}
$time1Arr = []; $time1Arr = [];
$time2Arr = []; $time2Arr = [];
$time3Arr = []; $time3Arr = [];
@ -44,7 +47,7 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface
$nowTime = time(); $nowTime = time();
//服务站最晚营业时间 //服务站最晚营业时间
if (env('APP_ENV') === 'prod') { if (env('APP_ENV') === 'prod') {
$closedTime = strtotime(config('market_rest_time'));
$closedTime = strtotime(config('market.rest_time'));
if($nowTime > $closedTime){ if($nowTime > $closedTime){
throw new ErrorCodeException(ErrorCode::MARKET_REST); throw new ErrorCodeException(ErrorCode::MARKET_REST);
} }
@ -97,6 +100,12 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface
if($nowTime > $startTime){ if($nowTime > $startTime){
$startTime = ceil($nowTime / (30*60)) * (30*60); $startTime = ceil($nowTime / (30*60)) * (30*60);
} }
if (env('APP_ENV') === 'prod') {
$closedTime = strtotime(config('market.rest_time'));
if($closedTime < $endTime){
$endTime = $closedTime;
}
}
//高峰段 区间 //高峰段 区间
$peakPeriod = strtotime('16:00'); $peakPeriod = strtotime('16:00');
$peakPeriodEnd = strtotime('18:00'); $peakPeriodEnd = strtotime('18:00');

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

@ -7,28 +7,28 @@ use App\Constants\v3\ErrorCode;
use App\Exception\ErrorCodeException; use App\Exception\ErrorCodeException;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\DistributionPriceServiceInterface; use App\Service\v3\Interfaces\DistributionPriceServiceInterface;
class DistributionPriceService implements DistributionPriceServiceInterface class DistributionPriceService implements DistributionPriceServiceInterface
{ {
public function do($distance) public function do($distance)
{ {
$deliveryDistance = config('distance.delivery_distance');
$deliveryDistance = ceil($deliveryDistance/1000);
$km = ceil($distance/1000); $km = ceil($distance/1000);
switch ($km){
switch (true){
case ($km > 3 && $km < 5) : case ($km > 3 && $km < 5) :
$distributionRrice = bcmul(0.70,($km-3),2); $distributionRrice = bcmul(0.70,($km-3),2);
break; break;
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 < 8) :
case ($km >= 7 && $km < $deliveryDistance) :
$distributionRrice = bcmul(1.50,($km-3),2); $distributionRrice = bcmul(1.50,($km-3),2);
break; break;
case ($km >= 8) :
case ($km >= $deliveryDistance) :
throw new ErrorCodeException(ErrorCode::LOCATION_LONG_DISTANCE); throw new ErrorCodeException(ErrorCode::LOCATION_LONG_DISTANCE);
break; break;
default: default:
$distributionRrice = 0; $distributionRrice = 0;
break;
} }
$distributionRrice = bcadd($distributionRrice,3.50,2); $distributionRrice = bcadd($distributionRrice,3.50,2);
return (float) $distributionRrice; return (float) $distributionRrice;

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

@ -49,7 +49,8 @@ class GoodsActivityService implements GoodsActivityServiceInterface
// 商品库存不足 // 商品库存不足
// 获取冻结的库存 // 获取冻结的库存
$inventoryFrozen = (int)$redis->get($inventoryKey);
//$inventoryFrozen = (int)$redis->get($inventoryKey);
$inventoryFrozen = 0;
if($goods->is_infinite != 1 && $goods->inventory < ($num+$inventoryFrozen)){ if($goods->is_infinite != 1 && $goods->inventory < ($num+$inventoryFrozen)){
return ErrorCode::GOODS_ACTIVITY_INVENTORY_ERROR; return ErrorCode::GOODS_ACTIVITY_INVENTORY_ERROR;
} }

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

@ -40,7 +40,8 @@ class GoodsService implements GoodsServiceInterface
} }
// 商品库存不足 // 商品库存不足
// 获取冻结的库存 // 获取冻结的库存
$inventoryFrozen = (int)$redis->get($inventoryKey);
//$inventoryFrozen = (int)$redis->get($inventoryKey);
$inventoryFrozen = 0;
if($goods->is_infinite != 1 && $goods->inventory < ($num+$inventoryFrozen)){ if($goods->is_infinite != 1 && $goods->inventory < ($num+$inventoryFrozen)){
return ErrorCode::GOODS_INVENTORY_ERROR; return ErrorCode::GOODS_INVENTORY_ERROR;
} }

7
config/config.php

@ -55,8 +55,13 @@ return [
'login' => [ 'login' => [
'authkey' => env('STORE_LOGIN_AUTHKEY', ''), 'authkey' => env('STORE_LOGIN_AUTHKEY', ''),
], ],
'market_rest_time' => env('MARKET_REST_TIME', '19:30'),
'market' => [
'rest_time' => env('MARKET_REST_TIME', '19:30'),
],
'map' => [ 'map' => [
'tencent' => env('TENCENT_MAP_KEY', ''), 'tencent' => env('TENCENT_MAP_KEY', ''),
], ],
'distance' => [
'delivery_distance' => env('DELIVERY_DISTANCE', '8000')
],
]; ];
Loading…
Cancel
Save