Jiance.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 检测下发
  7. */
  8. class Jiance extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['info'];
  12. protected $table = 'jiance';
  13. public function index(){
  14. $search = [];
  15. $bianhao = input('bianhao','');
  16. $uc_id = input('uc_id','');
  17. $worker_id = input('worker_id','');
  18. if(!empty($bianhao)){
  19. $search['jiance.bianhao'] = ['LIKE','%'.$bianhao.'%'];
  20. }
  21. if(!empty($uc_id)){
  22. $search['jiance.uc_id'] = $uc_id;
  23. }
  24. if(!empty($worker_id)){
  25. $search['jiance.worker_id'] = $worker_id;
  26. }
  27. $list = Db::name($this->table)
  28. ->field('jiance.*,uc.projectname,worker.truename as worker_truename,worker.mobile as worker_mobile')
  29. ->join('worker','jiance.worker_id = worker.id','LEFT')
  30. ->join('user_company uc','jiance.uc_id = uc.id','LEFT')
  31. ->where('jiance.company_id',$this->auth->company_id)
  32. ->where('jiance.deletetime',NULL)
  33. ->where($search)
  34. ->order('jiance.id desc')
  35. ->paginate();
  36. $total = $list->total();
  37. $list = $list->items();
  38. foreach($list as $key => $val){
  39. $list[$key]['pdfurl'] = config('pay_notify_url').'/company/jiancepdf/getpdf/id/'.$val['id'];
  40. }
  41. $rs = [
  42. 'list' => $list,
  43. 'total'=> $total,
  44. ];
  45. $this->success(1,$rs);
  46. }
  47. public function add(){
  48. $project_ids = input('project_ids','');
  49. $jiance_number = 0;
  50. if(!empty($project_ids)){
  51. $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count();
  52. }
  53. $data = [
  54. 'company_id' => $this->auth->company_id,
  55. 'uc_id' => input('uc_id',''),
  56. 'worker_id' => input('worker_id',''),
  57. 'bianhao' => input('bianhao',''),
  58. 'status' => 0,
  59. 'jiance_number' => $jiance_number,
  60. 'project_ids' => $project_ids,
  61. 'tongjitime' => input('tongjitime',date('Y-m-d'),'strtotime'),
  62. ];
  63. Db::name($this->table)->insertGetId($data);
  64. $this->success();
  65. }
  66. public function info(){
  67. $id = input('id',0);
  68. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
  69. $this->success(1,$info);
  70. }
  71. public function edit(){
  72. $id = input('id',0);
  73. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
  74. if(empty($info)){
  75. $this->error('没找到该信息,请刷新重试');
  76. }
  77. //
  78. $project_ids = input('project_ids','');
  79. $jiance_number = 0;
  80. if(!empty($project_ids)){
  81. $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count();
  82. }
  83. $data = [
  84. 'uc_id' => input('uc_id',''),
  85. 'worker_id' => input('worker_id',''),
  86. 'bianhao' => input('bianhao',''),
  87. 'jiance_number' => $jiance_number,
  88. 'project_ids' => $project_ids,
  89. 'tongjitime' => input('tongjitime',date('Y-m-d'),'strtotime'),
  90. ];
  91. Db::name($this->table)->where('id',$id)->update($data);
  92. $this->success();
  93. }
  94. public function del(){
  95. $ids = input('ids','');
  96. $ids = explode(',',$ids);
  97. if (empty($ids)) {
  98. $this->error();
  99. }
  100. Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]);
  101. $this->success();
  102. }
  103. }