123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <?php
- namespace app\company\controller;
- use app\common\controller\Apic;
- use think\Db;
- /**
- * 维保流程
- */
- class Maintain extends Apic
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = [];
- protected $table = 'maintain';
- //待审核 0
- //报价评估 20,22
- //报价审核 30
- //待处理 40,50,60,70,80,90,92
- //已完成 100
- //首页统计
- public function index(){
- $rs = [
- 'status_0' => 0,
- 'status_20' => 0,
- 'status_30' => 0,
- 'status_40' => 0,
- 'status_100' => 0,
- 'score' => 5,
- ];
- $list = Db::name($this->table)->field('status,count(id) as number')
- ->where('status','NEQ',2)->where('company_id',$this->auth->company_id)->group('status')->select();
- if(!empty($list)){
- foreach($list as $key => $val){
- if($val['status'] == 0){
- $rs['status_0'] = $val['number'];
- }
- if(in_array($val['status'],[20,22])){
- $rs['status_20'] += $val['number'];
- }
- if($val['status'] == 30){
- $rs['status_30'] = $val['number'];
- }
- if(in_array($val['status'],[40,50,60,70,80,90,92])){
- $rs['status_40'] += $val['number'];
- }
- if($val['status'] == 100){
- $rs['status_100'] = $val['number'];
- }
- }
- }
- //本周服务评分
- $score = Db::name($this->table)
- ->where('status',100)
- ->where('company_id',$this->auth->company_id)
- ->whereTime('eva_time','week')
- /*->select(false);echo $score;exit;*/
- ->avg('eva_score');
- $rs['score'] = $score;
- $this->success(1,$rs);
- }
- public function lists(){
- $orderno = input('orderno','');
- $projectname = input('projectname','');
- $header = input('header','');
- $status = input('status','ALL'); //默认ALL
- $map = [
- 'mt.company_id' => $this->auth->company_id,
- ];
- if(!empty($orderno)){
- $map['mt.orderno'] = $orderno;
- }
- if(!empty($projectname)){
- $map['uc.projectname'] = $projectname;
- }
- if(!empty($header)){
- $map['uc.header'] = $header;
- }
- if($status != 'ALL'){
- $map['mt.status'] = $status;
- if($status == 20){
- $map['mt.status'] = ['IN',[20,22]];
- }
- if($status == 40){
- $map['mt.status'] = ['IN',[40,50,60,70,80,90,92]];
- }
- }
- $field = ['mt.id','mt.orderno','uc.projectname','mt.info','uc.header','mt.status'];
- $list = Db::name($this->table)->alias('mt')
- ->join('user_company uc','mt.uc_id = uc.id','LEFT')
- ->field($field)
- ->where($map)->order('mt.id desc')
- ->autopage()->select();
- $this->success(1,$list);
- }
- //详情
- public function info(){
- $id = input('id',0);
- $info = Db::name($this->table)->alias('mt')
- ->join('user_company uc','mt.uc_id = uc.id','LEFT')
- ->field('mt.*,uc.projectname,uc.header,uc,projectaddress')
- ->where('id',$id)->where('company_id',$this->auth->company_id)
- ->find();
- $this->success(1,$info);
- }
- //提交报价
- public function baojia(){
- }
- //审核报价
- public function baojia_audit(){
- }
- //指派师傅
- public function zhipai(){
- }
- public function edit(){
- $id = input('id',0);
- $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
- if(empty($info)){
- $this->error('没找到该信息,请刷新重试');
- }
- $data = [
- 'brand' => input('brand',''),
- 'logo_image' => input('logo_image',''),
- 'typename' => input('typename',''),
- 'name' => input('name',''),
- 'password' => input('password',''),
- ];
- Db::name($this->table)->where('id',$id)->update($data);
- $this->success();
- }
- }
|