Maintain.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 维保流程
  7. */
  8. class Maintain extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = [];
  12. protected $table = 'maintain';
  13. //待审核 0
  14. //报价评估 20,22
  15. //报价审核 30
  16. //待处理 40,50,60,70,80,90,92
  17. //已完成 100
  18. //首页统计
  19. public function index(){
  20. $rs = [
  21. 'status_0' => 0,
  22. 'status_20' => 0,
  23. 'status_30' => 0,
  24. 'status_40' => 0,
  25. 'status_100' => 0,
  26. 'score' => 5,
  27. ];
  28. $list = Db::name($this->table)->field('status,count(id) as number')
  29. ->where('status','NEQ',2)->where('company_id',$this->auth->company_id)->group('status')->select();
  30. if(!empty($list)){
  31. foreach($list as $key => $val){
  32. if($val['status'] == 0){
  33. $rs['status_0'] = $val['number'];
  34. }
  35. if(in_array($val['status'],[20,22])){
  36. $rs['status_20'] += $val['number'];
  37. }
  38. if($val['status'] == 30){
  39. $rs['status_30'] = $val['number'];
  40. }
  41. if(in_array($val['status'],[40,50,60,70,80,90,92])){
  42. $rs['status_40'] += $val['number'];
  43. }
  44. if($val['status'] == 100){
  45. $rs['status_100'] = $val['number'];
  46. }
  47. }
  48. }
  49. //本周服务评分
  50. $score = Db::name($this->table)
  51. ->where('status',100)
  52. ->where('company_id',$this->auth->company_id)
  53. ->whereTime('eva_time','week')
  54. /*->select(false);echo $score;exit;*/
  55. ->avg('eva_score');
  56. $rs['score'] = $score;
  57. $this->success(1,$rs);
  58. }
  59. public function lists(){
  60. $orderno = input('orderno','');
  61. $projectname = input('projectname','');
  62. $header = input('header','');
  63. $status = input('status','ALL'); //默认ALL
  64. $map = [
  65. 'mt.company_id' => $this->auth->company_id,
  66. ];
  67. if(!empty($orderno)){
  68. $map['mt.orderno'] = $orderno;
  69. }
  70. if(!empty($projectname)){
  71. $map['uc.projectname'] = $projectname;
  72. }
  73. if(!empty($header)){
  74. $map['uc.header'] = $header;
  75. }
  76. if($status != 'ALL'){
  77. $map['mt.status'] = $status;
  78. if($status == 20){
  79. $map['mt.status'] = ['IN',[20,22]];
  80. }
  81. if($status == 40){
  82. $map['mt.status'] = ['IN',[40,50,60,70,80,90,92]];
  83. }
  84. }
  85. $field = ['mt.id','mt.orderno','uc.projectname','mt.info','uc.header','mt.status'];
  86. $list = Db::name($this->table)->alias('mt')
  87. ->join('user_company uc','mt.uc_id = uc.id','LEFT')
  88. ->field($field)
  89. ->where($map)->order('mt.id desc')
  90. ->autopage()->select();
  91. $this->success(1,$list);
  92. }
  93. //详情
  94. public function info(){
  95. $id = input('id',0);
  96. $info = Db::name($this->table)->alias('mt')
  97. ->join('user_company uc','mt.uc_id = uc.id','LEFT')
  98. ->field('mt.*,uc.projectname,uc.header,uc,projectaddress')
  99. ->where('id',$id)->where('company_id',$this->auth->company_id)
  100. ->find();
  101. $this->success(1,$info);
  102. }
  103. //提交报价
  104. public function baojia(){
  105. }
  106. //审核报价
  107. public function baojia_audit(){
  108. }
  109. //指派师傅
  110. public function zhipai(){
  111. }
  112. public function edit(){
  113. $id = input('id',0);
  114. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
  115. if(empty($info)){
  116. $this->error('没找到该信息,请刷新重试');
  117. }
  118. $data = [
  119. 'brand' => input('brand',''),
  120. 'logo_image' => input('logo_image',''),
  121. 'typename' => input('typename',''),
  122. 'name' => input('name',''),
  123. 'password' => input('password',''),
  124. ];
  125. Db::name($this->table)->where('id',$id)->update($data);
  126. $this->success();
  127. }
  128. }