Ver Fonte

维保流程

lizhen_gitee há 8 meses atrás
pai
commit
5f16298632

+ 127 - 1
application/api/controller/Maintain.php

@@ -150,7 +150,7 @@ class Maintain extends Api
         $this->success(1,$baojia_log);
     }
 
-    //报价审核
+    //报价审核,已作废,改用 baojia_confirm
     public function baojia_audit(){
         $id = input('order_id',0);
         $status = input('status',2);//1=通过,2=拒绝
@@ -225,9 +225,135 @@ class Maintain extends Api
         $this->success($remark);
     }
 
+    //报价确认
+    public function baojia_confirm(){
+        $id = input('order_id',0);
+
+        Db::startTrans();
+
+        //检查订单
+        $map = [
+            'user_id' => $this->auth->id,
+            'id'      => $id,
+        ];
+        $info = Db::name('maintain')->where($map)->lock(true)->find();
+        if(empty($info)){
+            Db::rollback();
+            $this->error('不存在的订单');
+        }
+        if($info['status'] != 30){ //用户待确认
+            Db::rollback();
+            $this->success('订单错误,请刷新重试');
+        }
+
+        //找出最新报价日志
+        $baojia_log = Db::name('maintain_baojia')->where('order_id',$id)->where('status',30)->order('id desc')->find();
+
+        //更新订单
+        $update = [
+            'status' => 40,
+            'updatetime' => time(),
+            'baojia_confirmtime' => time(),  //报价确认时间
+        ];
+
+        //更新报价记录
+        $update_baojia = [
+            'status' => 40,
+            'updatetime' => time(),
+
+            'baojia_useraudit_time' => time(),
+        ];
+
+        $rs1 = Db::name('maintain')->where('id',$id)->update($update);
+        if($rs1 === false){
+            Db::rollback();
+            $this->error('确认失败');
+        }
+
+        $rs2 = Db::name('maintain_baojia')->where('id',$baojia_log['id'])->update($update_baojia);
+        if($rs2 === false){
+            Db::rollback();
+            $this->error('确认失败');
+        }
+
+        Db::commit();
+        $this->success('报价已确认');
+    }
+
     //验收
     public function yanshou(){
+        $id = input('order_id',0);
+        $status = input('status',2);//1=通过,2=拒绝
+        $reason = input('reason','','trim');
 
+        //必填
+        if($status == 2 && empty($reason)){
+            $this->error('请输入拒绝原因');
+        }
+
+        //检查订单
+        $map = [
+            'user_id' => $this->auth->id,
+            'id'      => $id,
+        ];
+        $info = Db::name('maintain')->where($map)->find();
+        if(empty($info)){
+            $this->error('不存在的订单');
+        }
+        if($info['status'] != 90){ //师傅完成
+            $this->success('订单错误,请刷新重试');
+        }
+
+        $nowtime = time();
+
+        //更新订单
+        //更新维修
+        if($status == 2){
+            $update = [
+                'status' => 92,  // '用户验收驳回'
+                'updatetime' => $nowtime,
+                'finishtime' => $nowtime,
+            ];
+            $update_weixiu = [
+                'status' => 92,  // '用户验收驳回'
+                'updatetime' => $nowtime,
+
+                'audit_time' => $nowtime,
+                'audit_reason' => $reason,
+            ];
+
+            $remark = '验收已驳回';
+        }else{
+            $update = [
+                'status' => 100, //用户验收通过
+                'updatetime' => $nowtime,
+                'finishtime' => $nowtime,
+            ];
+            $update_weixiu = [
+                'status' => 100, //用户验收通过
+                'updatetime' => $nowtime,
+
+                'audit_time' => $nowtime,
+            ];
+
+            $remark = '验收已通过';
+        }
+
+        Db::startTrans();
+        $rs1 = Db::name('maintain')->where('id',$id)->update($update);
+        if($rs1 === false){
+            Db::rollback();
+            $this->error('验收失败');
+        }
+
+        $rs2 = Db::name('maintain_weiuxiu')->where('id',$info['weixiu_id'])->update($update_weixiu);
+        if($rs2 === false){
+            Db::rollback();
+            $this->error('验收失败');
+        }
+
+        Db::commit();
+        $this->success($remark);
     }
 
     //评价

+ 1 - 1
application/api/controller/worker/Maintain.php

@@ -179,7 +179,7 @@ class Maintain extends Api
             Db::rollback();
             $this->error('不存在的订单');
         }
-        if(!in_array($info['status'],[50,70])){
+        if(!in_array($info['status'],[50,70,92])){
             Db::rollback();
             $this->error('状态不正确,请刷新重试');
         }