From b03d5eed13896ba86b6412bdc4675068984db908 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Sat, 12 Sep 2020 21:11:17 +0800 Subject: [PATCH] =?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/Controller/v3/HomeController.php | 5 +- app/Controller/v3/OrderOnlineController.php | 62 +++++++++---------- .../AppointmentTimeService.php | 27 ++++++++ .../AppointmentTimeServiceInterface.php | 2 + 4 files changed, 63 insertions(+), 33 deletions(-) diff --git a/app/Controller/v3/HomeController.php b/app/Controller/v3/HomeController.php index e33c45e..e8186b5 100644 --- a/app/Controller/v3/HomeController.php +++ b/app/Controller/v3/HomeController.php @@ -216,12 +216,13 @@ class HomeController extends BaseController $data['order_offline']['total'] = 0; $revenueByOrder = $this->revenueListService->getRevenueByUser($userId,$type,$dayStartTime,$dayEndTime); foreach ($revenueByOrder as $order){ + var_dump($order['money']); if($order['money_type'] == FinancialRecord::MONEY_TYPE_STORE_OL_ORDER_COMP){ //线上订单 $data['order_online']['total'] = bcadd($data['order_online']['total'],$order['money'],2); - }else if($order->money_type == FinancialRecord::MONEY_TYPE_STORE_OFL_ORDER_COMP){ + }else if($order['money_type'] == FinancialRecord::MONEY_TYPE_STORE_OFL_ORDER_COMP){ //线下订单 - $data['order_offline']['total'] = bcadd($data['order_online']['total'],$order['money'],2); + $data['order_offline']['total'] = bcadd($data['order_offline']['total'],$order['money'],2); } } //统计新增用户 无法筛选时间 所以和订单分开查询 diff --git a/app/Controller/v3/OrderOnlineController.php b/app/Controller/v3/OrderOnlineController.php index 4924fad..2049f56 100644 --- a/app/Controller/v3/OrderOnlineController.php +++ b/app/Controller/v3/OrderOnlineController.php @@ -82,39 +82,39 @@ class OrderOnlineController extends BaseController $shopcartIds = $this->request->input('shopcart_ids'); //判断用户有没有绑定手机 - $telExists = $this->userBindTelService->check($userId); - if(!$telExists){ - throw new ErrorCodeException(ErrorCode::NOT_BIND_TEL_ERROR); - } - //获取用户收货地址 - $address = UserAddress::query()->where('user_id',$userId) - ->orderByDesc('is_default') - ->orderByDesc('updated_at') - ->first(); - $res['location'] = [ - 'address' => $address, - 'distribution_price' => 0 - ]; + // $telExists = $this->userBindTelService->check($userId); + // if(!$telExists){ + // throw new ErrorCodeException(ErrorCode::NOT_BIND_TEL_ERROR); + // } + // //获取用户收货地址 + // $address = UserAddress::query()->where('user_id',$userId) + // ->orderByDesc('is_default') + // ->orderByDesc('updated_at') + // ->first(); + // $res['location'] = [ + // 'address' => $address, + // 'distribution_price' => 0 + // ]; //返回预约送达时间 数组 - $res['appointment_time'] = $this->appointmentTimeService->do(); + $res['appointment_time'] = $this->appointmentTimeService->get($shopcartIds); // - $res['store_list'] = $this->shopCartService->getGoodsByShopcartId($shopcartIds); - //获取用户优惠券 - $res['coupon'] = $this->couponRecService->allForOnlineOrderAvailable($userId, $marketId); - //增值服务接口 - $res['value_added_service'] = [ - 'text' => '买鸡买鸭,免费帮杀;买瓜买黇,包熟包甜', - 'select' => 1, - 'price' => 3.50 - ]; - $total = 0; - foreach ($res['store_list'] as $store) - { - $total = bcadd($total,$store['subtotal'],2); - } - $total = bcadd($total,$res['value_added_service']['price'],2); - $total = bcadd($total,$res['location']['distribution_price'],2); - $res['total'] = $total; + // $res['store_list'] = $this->shopCartService->getGoodsByShopcartId($shopcartIds); + // //获取用户优惠券 + // $res['coupon'] = $this->couponRecService->allForOnlineOrderAvailable($userId, $marketId); + // //增值服务接口 + // $res['value_added_service'] = [ + // 'text' => '买鸡买鸭,免费帮杀;买瓜买黇,包熟包甜', + // 'select' => 1, + // 'price' => 3.50 + // ]; + // $total = 0; + // foreach ($res['store_list'] as $store) + // { + // $total = bcadd($total,$store['subtotal'],2); + // } + // $total = bcadd($total,$res['value_added_service']['price'],2); + // $total = bcadd($total,$res['location']['distribution_price'],2); + // $res['total'] = $total; return $this->success($res); } diff --git a/app/Service/v3/Implementations/AppointmentTimeService.php b/app/Service/v3/Implementations/AppointmentTimeService.php index 510af38..c115d47 100644 --- a/app/Service/v3/Implementations/AppointmentTimeService.php +++ b/app/Service/v3/Implementations/AppointmentTimeService.php @@ -2,6 +2,8 @@ namespace App\Service\v3\Implementations; +use App\Model\v3\ShoppingCart; +use App\Model\v3\Store; use App\Service\v3\Interfaces\AppointmentTimeServiceInterface; use phpDocumentor\Reflection\Types\Object_; @@ -27,4 +29,29 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface { // TODO: Implement undo() method. } + + public function get($shopcartIds) + { + $shopcartIds = explode(',',$shopcartIds); + $sotreIds = ShoppingCart::query()->whereIn('id',$shopcartIds)->pluck('store_id'); + $stores = Store::query()->whereIn('id',$sotreIds)->get()->toArray(); + // return $stores; + $time1 = array_values(array_column($stores,'time1')); + $time2 = array_values(array_column($stores,'time2')); + $time3 = array_values(array_column($stores,'time3')); + $time4 = array_values(array_column($stores,'time4')); + $startTimeArr = array_merge($time1,$time3); + $endTimeArr = array_merge($time2,$time4); + array_filter($startTimeArr); + array_filter($endTimeArr); + $startTime = max($startTimeArr); + $endTime = min($endTimeArr); + // foreach ($stores as $store){ + // + // } + return [ + 'start_time' => $startTimeArr, + 'end_time' => $endTimeArr + ]; + } } \ No newline at end of file diff --git a/app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php b/app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php index 63ae2d4..cb384de 100644 --- a/app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php +++ b/app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php @@ -9,4 +9,6 @@ interface AppointmentTimeServiceInterface public function check(); public function undo(); + + public function get($shopcartIds); } \ No newline at end of file