field('id as value,parent_id as pid,name as label') ->select(); $lists = linear_to_tree($lists, 'children', 'value'); Cache::set('dev_region_tree', $lists); return $lists; } } //获取站长段的订单 public static function recruit_order($get){ $lists = Db::name('order')->where('mobile',$get['phone'])->select(); foreach ($lists as &$item){ $item['time_payorder']= date('Y-m',$item['create_time']); $goods=Db::name('goods')->where('id',$item['goods_id'])->field('name')->find(); $item['goods_name']=$goods['name']; $item['dai_order']=$item['number']-$item['code']; $item['slect_order']=Db::name('order_exe')->where('order_sn',$item['order_sn'])->where('staff_status',3)->count(); } return $lists; } //站长端口空余的保洁师 public static function staff_list($get){ $lists =Db::name('staff')->where('onwork',1)->select(); return $lists; } //站长派单数据统计 public static function recruit_index($get){ $today = date('Y-m-d'); $tomorrow = date('Y-m-d', strtotime($today . ' +1 day')); $recruit=Db::name('staff_grouping')->where('admin_id',$get['uid'])->find(); $staff=Db::name('staff')->where('grouping_id',$recruit['id'])->field('id')->select(); //获取站长下面的员工 $Array = array_column($staff, 'id'); //二维数组转换一位数组 $data['unassigned']=Db::name('order_exe') ->where('staff_id','in',$Array) ->where('staff_status',0) ->whereTime('autotime', 'between', ["$today 00:00:00", "$tomorrow 23:59:59"]) ->count(); //未接单的数据统计 $data['service']=Db::name('order_exe') ->where('staff_id','in',$Array) ->where('staff_status',1) ->whereTime('autotime', 'between', ["$today 00:00:00", "$tomorrow 23:59:59"]) ->count(); //统计未点击开始 $data['start']=Db::name('order_exe') ->where('staff_id','in',$Array) ->where('staff_status',2) ->whereTime('autotime','today') ->count(); //统计待开始 $data['end']=Db::name('order_exe') ->where('staff_id','in',$Array) ->where('staff_status',3) ->whereTime('autotime','today') ->count(); //统计待完成 $data['number']=Db::name('order_exe') ->where('staff_id',0) ->whereTime('autotime','today') ->count(); //统计是有的未派单 $data['images']=Db::name('order_exe') ->where('staff_status',4) ->where('is_images',0) ->count(); //统计是有的未派单 $data['number']=Db::name('order_exe') ->where('staff_id',0) ->whereTime('autotime', 'between', ["$today 00:00:00", "$tomorrow 23:59:59"]) //->where('is_images',0) ->count(); //统计是有的未派单 return $data; } //首页统计所有的订单内容 public static function recruit_listorder($get){ $status=intval($get['status']); $today = date('Y-m-d'); $tomorrow = date('Y-m-d', strtotime($today . ' +1 day')); $recruit=Db::name('staff_grouping')->where('admin_id',$get['staff_id'])->find(); $staff=Db::name('staff')->where('grouping_id',$recruit['id'])->field('id')->select(); //获取站长下面的员工 $Array = array_column($staff, 'id'); //二维数组转换一位数组 if($status==0){ $lists=Db::name('order_exe') ->where('staff_status',$get['status']) ->where('staff_id','in',$Array) // ->where($status==0,function($query){ // $query->whereTime('autotime', 'between', ["$today 00:00:00", "$tomorrow 23:59:59"]); // }) // ->where($get['status']=1,function($query){ // $query->whereTime('autotime','today'); // }) ->whereTime('autotime', 'between', ["$today 00:00:00", "$tomorrow 23:59:59"]) ->select(); } if($status==1){ $lists=Db::name('order_exe') ->where('staff_status',$get['status']) ->where('staff_id','in',$Array) ->whereTime('autotime', 'between', ["$today 00:00:00", "$tomorrow 23:59:59"]) ->select(); } if($status==2){ $lists=Db::name('order_exe') ->where('staff_status',$get['status']) ->where('staff_id','in',$Array) ->whereTime('autotime', 'today') ->select(); } if($status==3){ $lists=Db::name('order_exe') ->where('staff_status',$get['status']) ->where('staff_id','in',$Array) ->whereTime('autotime', 'today') ->select(); } if($status==4){ $lists=Db::name('order_exe') ->where('is_images',0) ->where('staff_id','in',$Array) ->whereTime('autotime', 'today') ->select(); } if($status==5){ $lists=Db::name('order_exe') ->where('staff_id',0) ->whereTime('autotime', 'between', ["$today 00:00:00", "$tomorrow 23:59:59"]) ->select(); } foreach ($lists as $k => $v){ $order_info=Db::name('order')->where('order_sn',$lists[$k]['order_sn'])->find(); $lists[$k]['order_sn']=$order_info['order_sn']; $lists[$k]['name']=$order_info['consignee']; $lists[$k]['phone']=$order_info['mobile']; $goods=Db::name('goods')->where('id',$order_info['goods_id'])->find(); $lists[$k]['goods_name']= $goods['name']; $lists[$k]['address']= $order_info['address']; $lists[$k]['lat']= $order_info['lat']; $lists[$k]['lng']= $order_info['lng']; if($lists[$k]['addtime']==1){ $lists[$k]['sw']='上午'; $lists[$k]['sw_time']='8:00-12:00'; }else{ $lists[$k]['sw']='下午'; $lists[$k]['sw_time']='14:00-18:00'; } $staff=Db::name('staff')->where('id',$lists[$k]['staff_id'])->find(); if($staff){ $lists[$k]['staff_name']=$staff['name']; $lists[$k]['staff_phone']=$staff['mobile']; $lists[$k]['autotime']=date('Y-m-d',$lists[$k]['autotime']); } } return $lists; } }