Wentihuizong.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 问题汇总
  7. */
  8. class Wentihuizong extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['info'];
  12. protected $table = 'wentihuizong';
  13. public function index(){
  14. $map = [];
  15. $uc_id = input('uc_id',0);
  16. if($uc_id){
  17. $map['uc_id'] = $uc_id;
  18. }
  19. $list = Db::name($this->table)->alias('hz')
  20. ->join('user_company uc','hz.uc_id = uc.id','LEFT')
  21. ->field('hz.*,uc.projectname')
  22. ->where('hz.company_id',$this->auth->company_id)
  23. ->where($map)
  24. ->order('hz.id desc')
  25. ->paginate();
  26. $total = $list->total();
  27. $list = $list->items();
  28. $rs = [
  29. 'list' => $list,
  30. 'total'=> $total,
  31. ];
  32. $this->success(1,$rs);
  33. }
  34. public function add(){
  35. $uc_id = input('uc_id','');
  36. $uc_info = Db::name('user_company')->where('id',$uc_id)->where('company_id',$this->auth->company_id)->find();
  37. if(empty($uc_info)){
  38. $this->error('不存在的客户');
  39. }
  40. $data = [
  41. 'company_id' => $this->auth->company_id,
  42. 'uc_id' => $uc_id,
  43. 'createtime' => time(),
  44. 'title' => input('title',''),
  45. 'finishtime' => input('finishtime','','strtotime'),
  46. 'remark' => input('remark',''),
  47. 'status' => input('status',1),
  48. ];
  49. Db::name($this->table)->insertGetId($data);
  50. $this->success();
  51. }
  52. public function info(){
  53. $id = input('id',0);
  54. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  55. $this->success(1,$info);
  56. }
  57. public function edit(){
  58. $id = input('id',0);
  59. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  60. if(empty($info)){
  61. $this->error('没找到该信息,请刷新重试');
  62. }
  63. $data = [
  64. 'title' => input('title',''),
  65. 'finishtime' => input('finishtime','','strtotime'),
  66. 'remark' => input('remark',''),
  67. 'status' => input('status',1),
  68. ];
  69. Db::name($this->table)->where('id',$id)->update($data);
  70. $this->success();
  71. }
  72. public function del(){
  73. $ids = input('ids','');
  74. $ids = explode(',',$ids);
  75. if (empty($ids)) {
  76. $this->error();
  77. }
  78. Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->delete();
  79. $this->success();
  80. }
  81. }