123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- namespace app\company\controller;
- use app\common\controller\Apic;
- use think\Db;
- /**
- * 检测下发
- */
- class Jiance extends Apic
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['info'];
- protected $table = 'jiance';
- public function index(){
- $search = [];
- $bianhao = input('bianhao','');
- $uc_id = input('uc_id','');
- $worker_id = input('worker_id','');
- if(!empty($bianhao)){
- $search['jiance.bianhao'] = ['LIKE','%'.$bianhao.'%'];
- }
- if(!empty($uc_id)){
- $search['jiance.uc_id'] = $uc_id;
- }
- if(!empty($worker_id)){
- $search['jiance.worker_id'] = $worker_id;
- }
- $list = Db::name($this->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();
- }
- }
|