Browse Source

送达时间

master
Lemon 5 years ago
parent
commit
b03d5eed13
  1. 5
      app/Controller/v3/HomeController.php
  2. 62
      app/Controller/v3/OrderOnlineController.php
  3. 27
      app/Service/v3/Implementations/AppointmentTimeService.php
  4. 2
      app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php

5
app/Controller/v3/HomeController.php

@ -216,12 +216,13 @@ class HomeController extends BaseController
$data['order_offline']['total'] = 0; $data['order_offline']['total'] = 0;
$revenueByOrder = $this->revenueListService->getRevenueByUser($userId,$type,$dayStartTime,$dayEndTime); $revenueByOrder = $this->revenueListService->getRevenueByUser($userId,$type,$dayStartTime,$dayEndTime);
foreach ($revenueByOrder as $order){ foreach ($revenueByOrder as $order){
var_dump($order['money']);
if($order['money_type'] == FinancialRecord::MONEY_TYPE_STORE_OL_ORDER_COMP){ if($order['money_type'] == FinancialRecord::MONEY_TYPE_STORE_OL_ORDER_COMP){
//线上订单 //线上订单
$data['order_online']['total'] = bcadd($data['order_online']['total'],$order['money'],2); $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);
} }
} }
//统计新增用户 无法筛选时间 所以和订单分开查询 //统计新增用户 无法筛选时间 所以和订单分开查询

62
app/Controller/v3/OrderOnlineController.php

@ -82,39 +82,39 @@ class OrderOnlineController extends BaseController
$shopcartIds = $this->request->input('shopcart_ids'); $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); return $this->success($res);
} }

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

@ -2,6 +2,8 @@
namespace App\Service\v3\Implementations; namespace App\Service\v3\Implementations;
use App\Model\v3\ShoppingCart;
use App\Model\v3\Store;
use App\Service\v3\Interfaces\AppointmentTimeServiceInterface; use App\Service\v3\Interfaces\AppointmentTimeServiceInterface;
use phpDocumentor\Reflection\Types\Object_; use phpDocumentor\Reflection\Types\Object_;
@ -27,4 +29,29 @@ class AppointmentTimeService implements AppointmentTimeServiceInterface
{ {
// TODO: Implement undo() method. // 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
];
}
} }

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

@ -9,4 +9,6 @@ interface AppointmentTimeServiceInterface
public function check(); public function check();
public function undo(); public function undo();
public function get($shopcartIds);
} }
Loading…
Cancel
Save