|
@@ -23,6 +23,9 @@ class Maintain extends Apic
|
|
|
|
|
|
//首页统计
|
|
|
public function index(){
|
|
|
+ if($this->auth->company_id == 1){
|
|
|
+ return $this->liuzhuan_index();
|
|
|
+ }
|
|
|
|
|
|
$rs = [
|
|
|
'status_0' => 0,
|
|
@@ -72,8 +75,62 @@ class Maintain extends Apic
|
|
|
$this->success(1,$rs);
|
|
|
}
|
|
|
|
|
|
+ //首页统计
|
|
|
+ public function liuzhuan_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('liuzhuan_status',1)->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'];
|
|
|
+ }*/
|
|
|
+ if(in_array($val['status'],[2,100])){
|
|
|
+ $rs['status_100'] += $val['number'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //本周服务评分
|
|
|
+ $score = Db::name($this->table)
|
|
|
+ ->where('status',100)
|
|
|
+ ->where('liuzhuan_status',1)
|
|
|
+ ->whereTime('eva_time','week')
|
|
|
+ /*->select(false);echo $score;exit;*/
|
|
|
+ ->avg('eva_score');
|
|
|
+ $rs['score'] = $score;
|
|
|
+
|
|
|
+ $this->success(1,$rs);
|
|
|
+ }
|
|
|
+
|
|
|
//列表
|
|
|
public function lists(){
|
|
|
+ if($this->auth->company_id == 1){
|
|
|
+ return $this->liuzhuan_lists();
|
|
|
+ }
|
|
|
+
|
|
|
$orderno = input('orderno','');
|
|
|
$projectname = input('projectname','');
|
|
|
$header = input('header','');
|
|
@@ -105,9 +162,10 @@ class Maintain extends Apic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $field = ['mt.id','mt.orderno','uc.projectname','mt.info','uc.header','mt.status','mt.price'];
|
|
|
+ $field = ['mt.id','mt.orderno','uc.projectname','mt.info','uc.header','mt.status','mt.price','mt.liuzhuan_status','company.companyname'];
|
|
|
$list = Db::name($this->table)->alias('mt')
|
|
|
->join('user_company uc','mt.uc_id = uc.id','LEFT')
|
|
|
+ ->join('company','mt.company_id = company.id','LEFT')
|
|
|
->field($field)
|
|
|
->where($map)->order('mt.id desc')
|
|
|
->paginate();
|
|
@@ -119,6 +177,75 @@ class Maintain extends Apic
|
|
|
$maintain_model = new Maintainmodel();
|
|
|
foreach($list as $key => $val){
|
|
|
$list[$key]['status_text'] = $maintain_model->status_data($val['status']);
|
|
|
+
|
|
|
+ //pc用户,已流转订单,直接显示流转中
|
|
|
+ if($this->auth->company_id != 1 && in_array($val['status'],[0,20,22,30,40]) && $val['liuzhuan_status'] == 1){
|
|
|
+ $list[$key]['status_text'] = '流转中';
|
|
|
+ }
|
|
|
+
|
|
|
+ $list[$key]['status_colorType'] = $maintain_model->status_colorType($val['status']);
|
|
|
+ //假状态
|
|
|
+ $list[$key]['fake_status'] = $this->fake_status($val['status']);
|
|
|
+ $list[$key]['fake_status_text'] = $this->fake_status_data($val['status']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $rs = [
|
|
|
+ 'list' => $list,
|
|
|
+ 'total'=> $total,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $this->success(1,$rs);
|
|
|
+ }
|
|
|
+
|
|
|
+ //流转列表
|
|
|
+ public function liuzhuan_lists(){
|
|
|
+ $orderno = input('orderno','');
|
|
|
+ $projectname = input('projectname','');
|
|
|
+ $header = input('header','');
|
|
|
+ $status = input('status','ALL'); //默认ALL
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'mt.liuzhuan_status' => 1,
|
|
|
+ ];
|
|
|
+ if(!empty($orderno)){
|
|
|
+ $map['mt.orderno'] = $orderno;
|
|
|
+ }
|
|
|
+ if(!empty($projectname)){
|
|
|
+ $map['uc.projectname'] = ['LIKE','%'.$projectname.'%'];
|
|
|
+ }
|
|
|
+ if(!empty($header)){
|
|
|
+ $map['uc.header'] = ['LIKE','%'.$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]];
|
|
|
+ }
|
|
|
+ if($status == 100){
|
|
|
+ $map['mt.status'] = ['IN',[2,100]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $field = ['mt.id','mt.orderno','uc.projectname','mt.info','uc.header','mt.status','mt.price','mt.liuzhuan_status','company.companyname'];
|
|
|
+ $list = Db::name($this->table)->alias('mt')
|
|
|
+ ->join('user_company uc','mt.uc_id = uc.id','LEFT')
|
|
|
+ ->join('company','mt.company_id = company.id','LEFT')
|
|
|
+ ->field($field)
|
|
|
+ ->where($map)->order('mt.id desc')
|
|
|
+ ->paginate();
|
|
|
+
|
|
|
+ $total = $list->total();
|
|
|
+ $list = $list->items();
|
|
|
+
|
|
|
+ if(!empty($list)){
|
|
|
+ $maintain_model = new Maintainmodel();
|
|
|
+ foreach($list as $key => $val){
|
|
|
+ $list[$key]['status_text'] = $maintain_model->status_data($val['status']);
|
|
|
$list[$key]['status_colorType'] = $maintain_model->status_colorType($val['status']);
|
|
|
//假状态
|
|
|
$list[$key]['fake_status'] = $this->fake_status($val['status']);
|
|
@@ -192,11 +319,17 @@ class Maintain extends Apic
|
|
|
->join('user','mt.user_id = user.id','LEFT')
|
|
|
->join('worker','mt.worker_id = worker.id','LEFT')
|
|
|
->field('mt.*,uc.projectname,uc.header,uc.header_mobile,uc.projectaddress,user.nickname as user_nickname,user.mobile as user_mobile,worker.truename as worker_truename,worker.mobile as worker_mobile')
|
|
|
- ->where('mt.id',$id)->where('mt.company_id',$this->auth->company_id)
|
|
|
+ ->where('mt.id',$id)
|
|
|
->find();
|
|
|
|
|
|
$maintain_model = new Maintainmodel();
|
|
|
$info['status_text'] = $maintain_model->status_data($info['status']);
|
|
|
+
|
|
|
+ //pc用户,已流转订单,直接显示流转中
|
|
|
+ if($this->auth->company_id != 1 && in_array($info['status'],[0,20,22,30,40]) && $info['liuzhuan_status'] == 1){
|
|
|
+ $info['status_text'] = '流转中';
|
|
|
+ }
|
|
|
+
|
|
|
$info['status_colorType'] = $maintain_model->status_colorType($info['status']);
|
|
|
|
|
|
//假状态
|
|
@@ -385,6 +518,47 @@ class Maintain extends Apic
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
+ //流转到总公司
|
|
|
+ public function liuzhuan(){
|
|
|
+ $id = input('id',0);
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ $info = Db::name($this->table)->where('id',$id)->lock(true)->find();
|
|
|
+ if(empty($info)){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('没找到该信息,请刷新重试');
|
|
|
+ }
|
|
|
+ if($info['company_id'] != $this->auth->company_id){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('没找到该信息,请刷新重试');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!in_array($info['status'],[0,20,22,30,40])){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('当前订单状态,不能流转');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($info['worker_id'])){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('已经指派了师傅,不能流转了');
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ $update = [
|
|
|
+ 'liuzhuan_status' => 1,
|
|
|
+ 'updatetime' => time(),
|
|
|
+ ];
|
|
|
+ $rs_update = Db::name($this->table)->where('id',$id)->update($update);
|
|
|
+ if($rs_update === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('流转失败,请重试');
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ Db::commit();
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
//指派师傅
|
|
|
public function zhipai(){
|
|
|
//检查师傅
|