From 7629aad5f0de72a90d445395af218580f7ee74d5 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Thu, 17 Sep 2020 21:25:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=80=81=E8=BE=BE=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/AppointmentTimeService.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Service/v3/Implementations/AppointmentTimeService.php b/app/Service/v3/Implementations/AppointmentTimeService.php index a59b7ce..37714c8 100644 --- a/app/Service/v3/Implementations/AppointmentTimeService.php +++ b/app/Service/v3/Implementations/AppointmentTimeService.php @@ -100,7 +100,12 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface if($nowTime > $startTime){ $startTime = ceil($nowTime / (30*60)) * (30*60); } - //if(isset($closedTime) && ) + if (env('APP_ENV') === 'prod') { + $closedTime = strtotime(config('market.rest_time')); + if($closedTime < $endTime){ + $endTime = $closedTime; + } + } //高峰段 区间 $peakPeriod = strtotime('16:00'); $peakPeriodEnd = strtotime('18:00'); From f8f50ff4732314392f9e65f269b1ec236cbf5770 Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 17 Sep 2020 21:26:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/OrderOnlineController.php | 2 +- .../v3/Implementations/OrderOnlineService.php | 28 ++++++++++--------- .../v3/Implementations/UserAddressService.php | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/Controller/v3/OrderOnlineController.php b/app/Controller/v3/OrderOnlineController.php index 9c74126..14f22b3 100644 --- a/app/Controller/v3/OrderOnlineController.php +++ b/app/Controller/v3/OrderOnlineController.php @@ -183,7 +183,7 @@ class OrderOnlineController extends BaseController json_decode($params['store_list']), $params['total_money'], $params['delivery_time_note'], - ($params['service_money'] ?: 0), + ($params['service_money'] ?? 0), $couponIds, $params['plat'] ?: '' ); diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index a2824dd..babe919 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -121,6 +121,10 @@ class OrderOnlineService implements OrderOnlineServiceInterface Db::beginTransaction(); try { + // 获取分布式全局ID + $generator = ApplicationContext::getContainer()->get(IdGeneratorInterface::class); + $globalOrderId = $generator->generate(); + $mainTable = ApplicationContext::getContainer()->get(OrderMain::class)->getTable(); $childTable = ApplicationContext::getContainer()->get(Order::class)->getTable(); @@ -240,15 +244,16 @@ class OrderOnlineService implements OrderOnlineServiceInterface // 计算红包折扣金额 foreach ($canRealUseCoupons as $key => &$coupon) { - if (!in_array($coupon['id'], $receiveCouponIds)) { - unset($coupon); + + if (!in_array($coupon->id, $receiveCouponIds)) { + unset($canRealUseCoupons[$key]); continue; } - if ($coupon['coupon']['discount_type'] == Coupon::DISCOUNT_TYPE_CASH) { - $couponMoney = bcadd($couponMoney, $coupon['coupon']['discounts'], 2); - } elseif ($coupon['coupon']['discount_type'] == Coupon::DISCOUNT_TYPE_RATE) { - $discountRate = bcdiv($coupon['coupon']['discounts'],10); + if ($coupon->coupon->discount_type == Coupon::DISCOUNT_TYPE_CASH) { + $couponMoney = bcadd($couponMoney, $coupon->coupon->discounts, 2); + } elseif ($coupon->coupon->discount_type == Coupon::DISCOUNT_TYPE_RATE) { + $discountRate = bcdiv($coupon->coupon->discounts,10); $discountRate = bcsub(1,$discountRate); $discountMoney = bcmul($orderAmount, $discountRate); $couponMoney = bcadd($couponMoney, $discountMoney, 2); @@ -257,10 +262,6 @@ class OrderOnlineService implements OrderOnlineServiceInterface } - // 获取分布式全局ID - $generator = ApplicationContext::getContainer()->get(IdGeneratorInterface::class); - $globalOrderId = $generator->generate(); - $orderAmount = bcadd((string)$orderAmount, '0', 2); $totalAmount = bcadd((string)$totalAmount, (string)$orderAmount); $totalAmount = bcadd((string)$totalAmount, (string)$deliveryAmount); @@ -333,11 +334,12 @@ class OrderOnlineService implements OrderOnlineServiceInterface } } - // 优惠券红包使用记录 - $this->couponService->orderUseCoupons($globalOrderId, $canRealUseCoupons); - Db::commit(); + if (!empty($receiveCouponIds)) { + $this->couponService->orderUseCoupons($globalOrderId, $canRealUseCoupons); + } + // 清除购物车 $this->shopCartUpdateService->doClear($userId, $marketId); diff --git a/app/Service/v3/Implementations/UserAddressService.php b/app/Service/v3/Implementations/UserAddressService.php index 0851fe2..eef1807 100644 --- a/app/Service/v3/Implementations/UserAddressService.php +++ b/app/Service/v3/Implementations/UserAddressService.php @@ -88,7 +88,7 @@ class UserAddressService implements UserAddressServiceInterface 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;