post(); $count = Db::name('worker') ->alias('w') ->join('user u','u.id=w.user_id') ->join('user_org uo','uo.user_id=u.id') ->where('u.del',0) ->where('u.enable',1) ->where('uo.org_id',$post['orgid']) ->count(); $serverNums = Db::name('ph_todo') ->where('org_id',$post['orgid']) ->where('status',1) ->group('worker_id') ->count(); $leisureNums = $count-$serverNums>0?$count-$serverNums:0; $data = [ ['name'=>'服务中','bl'=>round($serverNums/$count*100,2),'value'=>$serverNums], ['name'=>'空闲中','bl'=>round($leisureNums/$count*100,2),'value'=>$leisureNums], ]; HelpHander::success($data); } public function workerNums(){ $post = request()->post(); $count = Db::name('worker') ->alias('w') ->join('user u','u.id=w.user_id') ->join('user_org uo','uo.user_id=u.id') ->where('u.del',0) ->where('u.enable',1) ->where('uo.org_id',$post['orgid']) ->count(); $serverNums = Db::name('ph_todo') ->where('org_id',$post['orgid']) ->where('status',1) ->group('worker_id') ->count(); $leisureNums = $count-$serverNums>0?$count-$serverNums:0; $data = [ 'count'=>$count, 'kxz'=>$leisureNums, 'fwz'=>$serverNums, ]; HelpHander::success($data); } //今日订单数 public function orderNums(){ $post = request()->post(); $day = date('Y-m-d'); $start = $day.' 00:00:00'; $end = $day.' 23:59:59'; $orderCount = Db::name('ph_orders')->where('org_id',$post['orgid'])->count(); $map[] =['create_time','>=',$start]; $map[] =['create_time','<=',$end]; $map[] =['org_id','=',$post['orgid']]; $map1[] =['settlement_time','>=',$start]; $map1[] =['settlement_time','<=',$end]; $map1[] =['org_id','=',$post['orgid']]; $count = Db::name('ph_orders')->where($map)->count(); $serverCount = Db::name('ph_orders')->where('org_id',$post['orgid'])->where('status',1)->count(); $jsCount = Db::name('ph_orders')->where($map1)->where('status',4)->count(); $data = [ 'count'=>$count, 'serverCount'=>$serverCount, 'jsCount'=>$jsCount, 'orderCount'=>$orderCount ]; HelpHander::success($data); } public function worderList(){ $post = request()->post(); $worker = Db::name('worker') ->alias('w') ->field('w.id,u.real_name') ->join('user u','u.id=w.user_id') ->join('user_org uo','uo.user_id=u.id') ->where('u.del',0) ->where('u.enable',1) ->where('uo.org_id',$post['orgid']) ->select(); foreach ($worker as $k=>$v){ $worker[$k]['servicesNum'] =Db::name('ph_todo') ->where('worker_id',$v['id']) ->where('org_id',$post['orgid']) ->group('user_id') ->count(); $worker[$k]['servicesDay'] = Db::name('ph_todo') ->where('worker_id',$v['id']) ->where('org_id',$post['orgid']) ->where('status',2) ->sum('day'); } HelpHander::success($worker); } public function commentList(){ $post = request()->post(); $firstDay = date('Y-m-01 00:00:00', time()); $lastDay = date('Y-m-d 23:59:59', strtotime("$firstDay +1 month -1 day")); $map[] = ['create_time','>',$firstDay]; $map[] = ['create_time','<=',$lastDay]; $map[] = ['org_id','=',$post['orgid']]; $work = Db::name('worker') ->alias('w') ->field('w.id,u.real_name') ->join('user u','u.id=w.user_id') ->join('user_org uo','uo.user_id=u.id') ->where('u.del',0) ->where('u.enable',1) ->where('uo.org_id',$post['orgid']) ->select(); $work = $work?$work:[]; foreach ($work as $k=>$v){ $jxz = Db::name('ph_todo') ->where($map) ->where('status',1) ->where('worker_id',$v['id']) ->count(); $ywc = Db::name('ph_todo') ->where($map) ->where('status',2) ->where('worker_id',$v['id']) ->count(); $work[$k]['jxz'] = $jxz; $work[$k]['ywc'] = $ywc; } $work = list_sort_by($work,'ywc','desc'); HelpHander::success($work); } public function sevenDayOrder(){ $post = request()->post(); $dlist = [ date('Y-m-d',strtotime('-6 days')), date('Y-m-d',strtotime('-5 days')), date('Y-m-d',strtotime('-4 days')), date('Y-m-d',strtotime('-3 days')), date('Y-m-d',strtotime('-2 days')), date('Y-m-d',strtotime('-1 days')), date('Y-m-d'), ]; $xdata = []; $count2= []; $count3 = []; foreach ($dlist as $v){ $tt = date('Y-m-d',strtotime($v)); $st = $tt.' 00:00:00'; $et = $tt.' 23:59:59'; $countTwo = Db::name('ph_orders') ->where('create_time','>=',$st) ->where('create_time','<=',$et) ->where('status',1) ->where('org_id',$post['orgid']) ->count(); $countThere = Db::name('ph_orders') ->where('create_time','>=',$st) ->where('create_time','<=',$et) ->where('org_id',$post['orgid']) ->count(); $count2[] = $countTwo; $count3[] = $countThere; $xdata[] = date('m-d',strtotime($v)); } $data = [ 'xdata' => $xdata, 'count2' => $count2, 'count3' => $count3, ]; HelpHander::success($data); } public function orderMessageList(){ $post = request()->post(); $ret = Db::name('ph_orders') ->where('org_id',$post['orgid']) ->order('id','desc') ->select(); $ret = $ret?$ret:[]; foreach ($ret as $k=>$v){ $userInfo = Db::name('user') ->where('id',$v['user_id']) ->value('real_name'); $cateInfo = Db::name('cate') ->where('id',$v['cate_id']) ->value('title'); $ret[$k]['content'] = '用户'.$userInfo.$cateInfo; } HelpHander::success($ret); } }