table) ->field('jiance.*,uc.projectname,worker.truename as worker_truename,worker.mobile as worker_mobile') ->join('worker','jiance.worker_id = worker.id','LEFT') ->join('user_company uc','jiance.uc_id = uc.id','LEFT') ->where('jiance.company_id',$this->auth->company_id) ->where('jiance.deletetime',NULL) ->where($search) ->order('jiance.id desc') ->paginate(); $total = $list->total(); $list = $list->items(); foreach($list as $key => $val){ $list[$key]['pdfurl'] = config('pay_notify_url').'/company/jiancepdf/getpdf/id/'.$val['id']; } $rs = [ 'list' => $list, 'total'=> $total, ]; $this->success(1,$rs); } public function add(){ $project_ids = input('project_ids',''); $jiance_number = 0; if(!empty($project_ids)){ $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count(); } $data = [ 'company_id' => $this->auth->company_id, 'uc_id' => input('uc_id',''), 'worker_id' => input('worker_id',''), 'bianhao' => input('bianhao',''), 'status' => 0, 'jiance_number' => $jiance_number, 'project_ids' => $project_ids, 'tongjitime' => input('tongjitime',date('Y-m-d'),'strtotime'), ]; Db::name($this->table)->insertGetId($data); $this->success(); } public function info(){ $id = input('id',0); $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find(); $this->success(1,$info); } public function edit(){ $id = input('id',0); $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find(); if(empty($info)){ $this->error('没找到该信息,请刷新重试'); } // $project_ids = input('project_ids',''); $jiance_number = 0; if(!empty($project_ids)){ $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count(); } $data = [ 'uc_id' => input('uc_id',''), 'worker_id' => input('worker_id',''), 'bianhao' => input('bianhao',''), 'jiance_number' => $jiance_number, 'project_ids' => $project_ids, 'tongjitime' => input('tongjitime',date('Y-m-d'),'strtotime'), ]; Db::name($this->table)->where('id',$id)->update($data); $this->success(); } public function del(){ $ids = input('ids',''); $ids = explode(',',$ids); if (empty($ids)) { $this->error(); } Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]); $this->success(); } }