error('筛选时间不能为空'); } $whereStaff2=[]; if ($type == 1) {//我的 $whereStaff2['staff_id'] = $this->auth->id; } elseif ($type == 2) {//下属 $whereStaff2['staff_id'] = ['in', Staff::getLowerStaffId()]; } else { $whereStaff2['staff_id'] = ['in', Staff::getMyStaffIds()]; } $times = setTimes($times, 'datetime'); $startTime = strtotime($times[0]); $endTime = strtotime($times[1]); $where = ['createtime' => ['between', [$startTime, $endTime]]]; //拜访次数 $baifang = Event::where(['type' => ['neq',4]])->where($where)->where($whereStaff2)->count(); $where = [ 'createtime' => ['between', [$startTime, $endTime]] ]; $whereC = [ 'order_date' => ['between', [date('Y-m-d 00:00:00',$startTime), date('Y-m-d 23:59:59',$endTime)]] ]; $whereR = [ 'return_time' => ['between', [date('Y-m-d 00:00:00',$startTime), date('Y-m-d 23:59:59',$endTime)]] ]; if ($type == 1) { $where['owner_staff_id'] = $this->auth->id; $whereC['owner_staff_id'] = $this->auth->id; $whereR['owner_staff_id'] = $this->auth->id; } elseif ($type == 2) { $where['owner_staff_id'] = ['in', Staff::getLowerStaffId()]; $whereC['owner_staff_id'] = ['in', Staff::getLowerStaffId()]; $whereR['owner_staff_id'] = ['in', Staff::getLowerStaffId()]; } else { $where['owner_staff_id'] = ['in', Staff::getMyStaffIds()]; $whereC['owner_staff_id'] = ['in', Staff::getMyStaffIds()]; $whereR['owner_staff_id'] = ['in', Staff::getMyStaffIds()]; } //报价次数 $quote = Quote::where($where)->count(); //客户 线索 联系人 合同 回款 跟进次数 处理审批 $leads = Leads::where($where)->count(); $customer = Customer::where($where)->count(); $contacts = Contacts::where($where)->count(); $contract = Contract::where(['check_status'=>2])->where($whereC)->count(); $contract_money = Contract::where(['check_status' => 2])->where($whereC)->sum('money'); $receivables_money = Receivables::where(['check_status' => 2])->where($whereR)->sum('money'); $record = Record::where([ 'create_staff_id' => $where['owner_staff_id'], 'createtime' => $where['createtime'] ])->where(['follow_type' => ['neq', '其它']])->count(); //商机总数 $business = Business::where($where)->count(); //客户成交量 $customer_complate = Customer::where($where)->where(['contract_status' => 1])->count(); //客户未成交量 $customer_nocomplate = Customer::where($where)->where(['contract_status' => 0])->count(); //商机成交总数 $business_complate = Business::where($where)->where(['contract_status' => 1])->count(); //商机未成交总数 $business_nocomplate = Business::where($where)->where(['contract_status' => 0])->count(); //商机成交金额 $business_complate_money = Business::where($where)->where(['contract_status' => 1])->sum('money'); //商机未成交金额 $business_nocomplate_money = Business::where($where)->where(['contract_status' => 0])->sum('money'); $this->success('请求成功', [ 'baifang' => $baifang, 'quote' => $quote, 'leads' => $leads, 'customer' => $customer, 'contacts' => $contacts, 'contract' => $contract, 'contract_money' => $contract_money, 'receivables' => $receivables_money, 'record' => $record, 'business' => $business, 'customer_complate' => $customer_complate, 'customer_nocomplate' => $customer_nocomplate, 'business_complate' => $business_complate, 'business_nocomplate' => $business_nocomplate, 'business_complate_money' => $business_complate_money, 'business_nocomplate_money' => $business_nocomplate_money,]); } //售后数据简报 public function afterBriefing() { $todayStart = strtotime(date('Y-m-d')); $todayEnd = strtotime(date('Y-m-d')) + 86400 - 1; $where = function ($query) { $query->where('create_staff_id|owner_staff_id', 'in', Staff::getMyStaffIds()) ->whereOr('', 'exp', "FIND_IN_SET({$this->auth->id},show_staff_id)"); }; $peisong = Workorder::where([ 'createtime' => ['between', [$todayStart, $todayEnd]], 'workorder_type' => '产品发货'])->where($where)->count(); $anzhuang = Workorder::where([ 'createtime' => ['between', [$todayStart, $todayEnd]], 'workorder_type' => '上门安装'])->where($where)->count(); $shangmeng = Workorder::where([ 'createtime' => ['between', [$todayStart, $todayEnd]], 'workorder_type' => '上门维修'])->where($where)->count(); $fanchang = Workorder::where([ 'createtime' => ['between', [$todayStart, $todayEnd]], 'workorder_type' => '返厂维修'])->where($where)->count(); $this->success('请求成功', ['peisong' => $peisong, 'anzhuang' => $anzhuang, 'shangmeng' => $shangmeng, 'fanchang' => $fanchang]); } //获取售后目标 public function getAfterAchievement() { $times = input('times');//2021-01,2021-07 $team_type = input('type', 2);//3我的 2我的团队 if (empty($times)) { $this->error('筛选时间不能为空'); } if ($team_type == 3) {//我的 $whereStaff['create_staff_id'] = $this->auth->id; } elseif ($team_type == 2) {//团队 $whereStaff = function ($query) { $query->where('create_staff_id|owner_staff_id', 'in', Staff::getMyStaffIds()) ->whereOr('', 'exp', "FIND_IN_SET({$this->auth->id},show_staff_id)"); }; } else { $this->error('参数错误'); } $times = setTimes($times, 'datetime'); $startTime = strtotime($times[0]); $endTime = strtotime($times[1]); $where = []; $where['createtime']= ['between', [$startTime, $endTime]]; $peisong = Workorder::where(['workorder_type' => '产品发货'])->where($where)->where($whereStaff)->count(); $anzhuang = Workorder::where(['workorder_type' => '上门安装'])->where($where)->where($whereStaff)->count(); $shangmeng = Workorder::where(['workorder_type' => '上门维修'])->where($where)->where($whereStaff)->count(); $fanchang = Workorder::where(['workorder_type' => '返厂维修'])->where($where)->where($whereStaff)->count(); $peisong_w = Workorder::where(['workorder_type' => '产品发货', 'status' => 3])->where($where)->where($whereStaff)->count(); $anzhuang_w = Workorder::where(['workorder_type' => '上门安装', 'status' => 3])->where($where)->where($whereStaff)->count(); $shangmeng_w = Workorder::where(['workorder_type' => '上门维修', 'status' => 3])->where($where)->where($whereStaff)->count(); $fanchang_w = Workorder::where(['workorder_type' => '返厂维修', 'status' => 3])->where($where)->where($whereStaff)->count(); $this->success('请求成功', [ 'peisong' => [ 'achievement' => $peisong, 'count' => $peisong_w, 'ratio' => getRatio($peisong_w, $peisong) ], 'anzhuang' => [ 'achievement' => $anzhuang, 'count' => $anzhuang_w, 'ratio' => getRatio($anzhuang_w, $anzhuang) ], 'shangmeng' => [ 'achievement' => $shangmeng, 'count' => $shangmeng_w, 'ratio' => getRatio($shangmeng_w, $shangmeng) ], 'fanchang' => [ 'achievement' => $fanchang, 'count' => $fanchang_w, 'ratio' => getRatio($fanchang_w, $fanchang) ], ]); } //首页目标完成情况 public function getAchievement() { $times = input('times');//2021-01,2021-07 $team_type = input('team_type', 3);//3我的 2我的团队 if (empty($times)) { $this->error('筛选时间不能为空'); } $times = setTimes($times, 'datetime'); // $times = explode(',', $times); //业绩目标 $contractAchievement = Achievement::getStaffTeamAchievement($times[0], $times[1], $this->auth, Achievement::CONTRACT_TYPE, $team_type) ?? 0; //获客目标 $customerAchievement = Achievement::getStaffTeamAchievement($times[0], $times[1], $this->auth, Achievement::CUSTOMER_TYPE, $team_type) ?? 0; //拜访目标 $visitAchievement = Achievement::getStaffTeamAchievement($times[0], $times[1], $this->auth, Achievement::VISIT_TYPE, $team_type) ?? 0; //工单目标 $workorderAchievement = Achievement::getStaffTeamAchievement($times[0], $times[1], $this->auth, Achievement::WORKORDER_TYPE, $team_type) ?? 0; $startTime = strtotime($times[0] . '-1'); $endTime = strtotime(date('Y-m-t', strtotime($times[1]))) + 86400 - 1; if ($team_type == 3) {//我的 $showStaffIds = [$this->auth->id]; } elseif ($team_type == 2) {//团队 $showStaffIds = Staff::getLowerStaffId(); } else { $this->error('参数错误'); } //业绩 $contractCount = Contract::where(['check_status' => 2, 'create_staff_id' => ['in', $showStaffIds], 'createtime' => ['between', [$startTime, $endTime]]])->sum('money'); //获客 $customerCount = Customer::where(['createtime' => ['between',[$startTime, $endTime]], 'create_staff_id' => ['in', $showStaffIds]])->count(); //拜访 $visitCount = Event::where(['type' => 1, 'status' => 2, 'actual_end_time' => ['between', [$startTime, $endTime]], 'staff_id' => ['in', $showStaffIds]])->count(); //工单 $workorderCount = Workorder::where(['status' => 3, 'end_time' => ['between', [$startTime, $endTime]], 'owner_staff_id' => ['in', $showStaffIds]])->count(); $this->success('请求成功', [ 'contract' => [ 'achievement' => $contractAchievement, 'count' => $contractCount, 'ratio' => getRatio($contractCount, $contractAchievement) ], 'customer' => [ 'achievement' => $customerAchievement, 'count' => $customerCount, 'ratio' => getRatio($customerCount, $customerAchievement) ], 'event' => [ 'achievement' => $visitAchievement, 'count' => $visitCount, 'ratio' => getRatio($visitCount, $visitAchievement) ], 'workorder' => [ 'achievement' => $workorderAchievement, 'count' => $workorderCount, 'ratio' => getRatio($workorderCount, $workorderAchievement) ], ]); } //财务简报 public function financeBriefing() { $todayStart = strtotime(date('Y-m-d')); $todayEnd = strtotime(date('Y-m-d')) + 86400 - 1; $approval = Approval::where(['createtime' => ['between', [$todayStart, $todayEnd]]])->where('', 'exp', Db::raw('FIND_IN_SET(' . $this->auth->id . ',flow_staff_id)'))->count(); $consume = Consume::where(['createtime' => ['between', [$todayStart, $todayEnd]]])->where('', 'exp', Db::raw('FIND_IN_SET(' . $this->auth->id . ',flow_staff_id)'))->count(); $receivables = Receivables::where(['createtime' => ['between', [$todayStart, $todayEnd]]])->where('', 'exp', Db::raw('FIND_IN_SET(' . $this->auth->id . ',flow_staff_id)'))->count(); $contract = Contract::where(['createtime' => ['between', [$todayStart, $todayEnd]]])->where('', 'exp', Db::raw('FIND_IN_SET(' . $this->auth->id . ',flow_staff_id)'))->count(); $this->success('请求成功', [ 'approval' => $approval, 'consume' => $consume, 'receivables' => $receivables, 'contract' => $contract ]); } //报价单 public function quote() { $where = function ($query) { $query->where('create_staff_id|owner_staff_id', 'in', Staff::getMyStaffIds()) ->whereOr('', 'exp', "FIND_IN_SET({$this->auth->id},show_staff_id)"); }; $daishenhe = Quote::where([ 'check_status' => ['in', [0, 1]]]) ->where($where)->count(); $shenhetongguo = Quote::where([ 'check_status' => 2]) ->where($where)->count(); $shenhejujue = Quote::where([ 'check_status' => 3]) ->where($where)->count(); $zuofei = Quote::where([ 'check_status' => 4]) ->count(); $this->success('请求成功', ['daishenhe' => $daishenhe, 'shenhetongguo' => $shenhetongguo, 'shenhejujue' => $shenhejujue, 'zuofei' => $zuofei]); } //合同 public function contract() { $where = function ($query) { $query->where('create_staff_id|owner_staff_id', 'in', Staff::getMyStaffIds()) ->whereOr('', 'exp', "FIND_IN_SET({$this->auth->id},show_staff_id)"); }; $daishenhe = Contract::where([ 'check_status' => ['in', [0, 1]]])->where($where)->count(); $shenhetongguo = Contract::where([ 'check_status' => 2])->where($where)->count(); $shenhejujue = Contract::where([ 'check_status' => 3])->where($where)->count(); $zuofei = Contract::where([ 'check_status' => 4])->where($where)->count(); $zongzhi = Contract::where([ 'check_status' => 9])->where($where)->count(); $this->success('请求成功', ['daishenhe' => $daishenhe, 'shenhetongguo' => $shenhetongguo, 'shenhejujue' => $shenhejujue, 'zuofei' => $zuofei, 'zongzhi' => $zongzhi]); } //费用 public function consume() { $where=[]; $where['staff_id']=$this->auth->id; $daishenhe = Consume::where([ 'check_status' => ['in', [0, 1]]]) ->where($where)->count(); $shenhetongguo = Consume::where([ 'check_status' => 2]) ->where($where)->count(); $shenhejujue = Consume::where([ 'check_status' => 3]) ->where($where)->count(); $zuofei = Consume::where([ 'check_status' => 4]) ->where($where)->count(); $this->success('请求成功', ['daishenhe' => $daishenhe, 'shenhetongguo' => $shenhetongguo, 'shenhejujue' => $shenhejujue, 'zuofei' => $zuofei]); } //工单统计 public function workorder_count() { $workorder_type = input('workorder_type'); $where = function ($query) { $query->where('create_staff_id|owner_staff_id', 'in', Staff::getMyStaffIds()) ->whereOr('', 'exp', "FIND_IN_SET({$this->auth->id},show_staff_id)"); }; $daichuli = Workorder::where([ 'status' => ['in', [0, 1]], 'workorder_type' => $workorder_type])->where($where)->count(); $chulizhong = Workorder::where([ 'status' => 2, 'workorder_type' => $workorder_type])->where($where)->count(); $yiwancheng = Workorder::where([ 'status' => ['in', [3, 9]], 'workorder_type' => $workorder_type])->where($where)->count(); $this->success('请求成功', ['daichuli' => $daichuli, 'chulizhong' => $chulizhong, 'yiwancheng' => $yiwancheng]); } //工单 public function workorder() { $team_type = input('team_type', 3);//3我的 2我的团队 if ($team_type == 3) {//我的 $showStaffIds = [$this->auth->id]; } elseif ($team_type == 2) {//团队 $showStaffIds = Staff::getLowerStaffId(); } else { $this->error('参数错误'); } //未完成 所有未完成 $weiwancheng = Workorder::where(['status' => ['in', [0, 1, 2]], 'owner_staff_id' => ['in', $showStaffIds]])->count(); //进行中 $jinxingzhong = Workorder::where(['status' => ['in', [1, 2]], 'owner_staff_id' => ['in', $showStaffIds]])->count(); //待指派 $daizhipai = Workorder::where(['status' => ['in', [0]], 'owner_staff_id' => ['in', $showStaffIds]])->count(); //异常工单 $yichang = Workorder::where([ 'status' => ['in', [0, 1, 2]], 'owner_staff_id' => ['in', $showStaffIds], 'is_pause|is_timeout' => 1, ])->count(); $this->success('请求成功', ['weiwancheng' => $weiwancheng, 'jinxingzhong' => $jinxingzhong, 'daizhipai' => $daizhipai, 'yichang' => $yichang]); } //备件 public function parts() { $whereFlow = []; $whereFlow[] = ['exp', Db::raw('FIND_IN_SET(' . $this->auth->id . ',flow_staff_id)')]; $ruku = PartsStockReload::where(['type' => 1, 'check_status' => ['in', [0, 1]]])->where($whereFlow)->count(); $chuku = PartsStockReload::where(['type' => 2, 'check_status' => ['in', [0, 1]]])->where($whereFlow)->count(); $quejian = Parts::where(['status' => '上架'])->where('stock <= warning_stock')->count(); $all = Parts::where(['status' => '上架'])->count(); $this->success('请求成功', ['ruku' => $ruku, 'chuku' => $chuku, 'quejian' => $quejian, 'all' => $all]); } //审批 public function examine() { $wofaqi = Approval::where([ 'check_status' => ['in', [0, 1]], 'create_staff_id' => $this->auth->id])->count(); $whereFlow = []; $whereFlow[] = ['exp', Db::raw('FIND_IN_SET(' . $this->auth->id . ',flow_staff_id)')]; $whereFlow[] = ['exp', Db::raw('!FIND_IN_SET(' . $this->auth->id . ',check_staff_ids)')]; $daishenhe = Approval::where([ 'check_status' => ['in', [0, 1]] ])->where($whereFlow)->count(); $this->success('请求成功', ['wofaqi' => $wofaqi, 'daishenhe' => $daishenhe]); } //排行 public function ranking() { //1 获客 2拜访 3业绩 4回款 5工单 $ranking = input('ranking'); $times = input('times');//2021-01,2021-07 if (empty($times)) { $this->error('筛选时间不能为空'); } $times = setTimes($times, 'time'); $startTime = $times[0]; $endTime = $times[1]; $where = []; if ($ranking == 1) {//获客 $rankingList = Customer::where(['createtime' => ['between', [$startTime, $endTime]]])->where($where) ->with(['createStaff']) ->field('count(*) as number,create_staff_id')->order('number desc')->group('create_staff_id')->select(); $rankingList = collection($rankingList)->toArray(); $rankingList = array_slice($rankingList, 0, 10); foreach ($rankingList as $k => &$v) { $v['ranking'] = $k + 1; $v['staff'] = $v['create_staff']; unset($v['create_staff']); } } elseif ($ranking == 2) {//拜访 $rankingList = Event::where(['type' => 3, 'status' => 2, 'actual_end_time' => ['between', [$startTime, $endTime]]])->where($where) ->with(['staff'])->field('count(*) as number,staff_id')->order('number desc')->group('staff_id')->select(); $rankingList = collection($rankingList)->toArray(); $rankingList = array_slice($rankingList, 0, 10); foreach ($rankingList as $k => &$v) { $v['ranking'] = $k + 1; } } elseif ($ranking == 3) {//业绩 $rankingList = Contract::where(['check_status' => 2, 'createtime' => ['between', [$startTime, $endTime]]])->where($where)->with(['staff'])->field('count(*) as number,owner_staff_id')->order('number desc')->group('owner_staff_id')->select(); $rankingList = collection($rankingList)->toArray(); $rankingList = array_slice($rankingList, 0, 10); foreach ($rankingList as $k => &$v) { $v['ranking'] = $k + 1; } } elseif ($ranking == 4) {//回款 $rankingList = Receivables::where(['check_status' => 2, 'createtime' => ['between', [$startTime, $endTime]]])->where($where) ->with(['staff'])->field('count(*) as number,owner_staff_id')->order('number desc')->group('owner_staff_id')->select(); $rankingList = collection($rankingList)->toArray(); $rankingList = array_slice($rankingList, 0, 10); foreach ($rankingList as $k => &$v) { $v['ranking'] = $k + 1; } } elseif ($ranking == 5) {//工单 $rankingList = Workorder::where(['status' => 3, 'createtime' => ['between', [$startTime, $endTime]]]) ->where($where) ->with(['ownerStaff'])->field('count(*) as number,owner_staff_id')->order('number desc')->group('owner_staff_id')->select(); $rankingList = collection($rankingList)->toArray(); $rankingList = array_slice($rankingList, 0, 10); foreach ($rankingList as $k => &$v) { $v['ranking'] = $k + 1; $v['staff'] = $v['owner_staff']; unset($v['create_staff']); } } foreach ($rankingList as $kes => $ves) { if(empty($ves['staff'])){ unset($rankingList[$kes]); } } $this->success('请求成功', array_values($rankingList)); } //搜索 public function search() { $keywords = input('keywords'); $type = input('type'); if (empty($keywords)) { $this->error('筛选字段不能为空'); } //客户 $customer = Customer::where([ 'name' => ['like', "%$keywords%"], 'owner_staff_id' => ['in', Staff::getMyStaffIds()], ])->with([ 'ownerStaff', 'contacts' ])->field('id,name,next_time,owner_staff_id,level,follow')->select(); //联系人 $contacts = Contacts::where([ 'name' => ['like', "%$keywords%"], 'owner_staff_id' => ['in', Staff::getMyStaffIds()], ])->with(['customer'])->field('id,name,mobile,customer_id')->select(); //线索 $leads = Leads::where([ 'name' => ['like', "%$keywords%"], 'owner_staff_id' => ['in', Staff::getMyStaffIds()], ])->with(['ownerStaff'])->field('id,owner_staff_id,name,follow,mobile')->select(); $this->success('请求成功', [ 'customer' => $customer, 'contacts' => $contacts, 'leads' => $leads ]); } //反馈 public function feedback() { $content = input('content', ''); $file = input('file', ''); if (empty($content)) { $this->error('请输入反馈内容!'); } $model = new Feedback(); $model->save([ 'staff_id' => $this->auth->id, 'content' => $content, 'file_ids' => $file ]); $this->success('反馈成功'); } //服务协议 public function serviceContent() { $this->success('请求成功', [ 'content' => "

用户服务协议

", 'name' => '青动', 'logo' => '/assets/img/logo.png' ]); } //待办事项 public function agent() { $where['create_staff_id'] = $this->auth->id; $where['next_time'] = array(array('egt',date('Y-m-d 00:00:00')),array('lt',date('Y-m-d 23:59:59'))); $where['follow_type'] = ['neq', '其它']; $where['status'] = 0; // 待跟进客户 $where1['relation_type'] = 1; $customerlist = Record::where($where)->where($where1)->column('id'); $customerlist1 = 0; if($customerlist){ $whereExit['id'] = array('in',$customerlist); $whereExit['next_time'] = array('gt',date('Y-m-d 23:59:59')); $customerlist1 = Record::where($whereExit)->count(); } $customer = count($customerlist) - $customerlist1; //待跟进合同 $where2['relation_type'] = 3; $contractlist = Record::where($where)->where($where2)->column('id'); $contractlist1 = 0; if($contractlist){ $whereExitC['id'] = array('in',$contractlist); $whereExitC['next_time'] = array('gt',date('Y-m-d 23:59:59')); $contractlist1 = Record::where($whereExitC)->count(); } $contract = count($contractlist)-$contractlist1; //待跟进线索 $where3['relation_type'] = 4; $leadlist = Record::where($where)->where($where3)->column('id'); $leadlist1 = 0; if($leadlist){ $whereExitL['id'] = array('in',$leadlist); $whereExitL['next_time'] = array('gt',date('Y-m-d 23:59:59')); $leadlist1 = Record::where($whereExitL)->count(); } $lead = count($leadlist)-$leadlist1; //待跟进联系人 $where4['relation_type'] = 2; $contactslist = Record::where($where)->where($where4)->column('id'); $contactslist1 = 0; if($contactslist1){ $whereExitCs['id'] = array('in',$contactslist); $whereExitCs['next_time'] = array('gt',date('Y-m-d 23:59:59')); $contactslist1 = Record::where($whereExitCs)->count(); } $contacts = count($contactslist)-$contactslist1; //待跟进商机 $where5['relation_type'] = 5; $businesslist = Record::where($where)->where($where5)->column('id'); $businesslist1 = 0; if($businesslist1){ $whereExitB['id'] = array('in',$businesslist); $whereExitB['next_time'] = array('gt',date('Y-m-d 23:59:59')); $businesslist1 = Record::where($whereExitB)->count(); } $business = count($businesslist)-$businesslist1; //待审核合同 $examine = ExamineRecord::where([ 'relation_type' => ExamineRecord::CONTRACT_TYPE, 'status' => 0, 'check_staff_id' => $this->auth->id ])->count(); //待审核回款 $receivables = ExamineRecord::where([ 'relation_type' => ExamineRecord::RECEIVABLES_TYPE, 'status' => 0, 'check_staff_id' => $this->auth->id ])->count(); //待回款提醒 $receivablesPlan = ReceivablesPlan::where([ 'remind_date' => ['elt', date('Y-m-d')], 'status' => 0, 'owner_staff_id' => $this->auth->id ])->count(); //待处理日程 $eventOne = Event::where([ 'type' => 1, 'status' => ['in', [0, 1]], 'start_time' => ['lt', date('Y-m-d', strtotime('+1 day'))], 'staff_id|owner_staff_id' => $this->auth->id, ])->count(); $this->success('请求成功', [ 'customer' => $customer, 'business' => $business, 'contract' => $contract, 'lead' => $lead, 'contacts' => $contacts, 'event_one' => $eventOne, 'examine' => $examine, 'receivables' => $receivables, 'receivables_plan' => $receivablesPlan ]); } //待处理日程 public function event_one() { //待办日程 $eventWhere = [ 'status' => ['in', [0, 1]], 'start_time' => ['lt', date('Y-m-d', strtotime('+1 day'))], 'end_time' => ['gt', date('Y-m-d H:i:s')], 'staff_id' => $this->auth->id, ]; $event = Event::where($eventWhere)->with([ 'staff', 'customer', ])->order('id desc')->select(); $event=collection($event)->toArray(); foreach ($event as $k => $v) { $v['level'] = Event::getLevel($v['level']); $v['status'] = Event::getStatus($v['status']); $event[$k] = $v; } $this->success('请求成功', $event); } //待回款提醒 public function examine_receivables_plan() { //待回款提醒 $receivablesPlan = ReceivablesPlan::where([ 'remind_date' => ['elt', date('Y-m-d')], 'status' => 0, 'owner_staff_id' => $this->auth->id, ])->order('id desc')->with(['contract', 'customer'])->select(); $this->success('请求成功', $receivablesPlan); } }