lizhen_gitee 7 miesięcy temu
rodzic
commit
75984ce913

+ 29 - 5
application/api/controller/Maintain.php

@@ -13,6 +13,7 @@ class Maintain extends Api
     protected $noNeedLogin = ['*'];
     protected $noNeedRight = ['*'];
 
+    //报修
     public function addone()
     {
         $info     = input('info','');
@@ -49,7 +50,7 @@ class Maintain extends Api
         ];
 
         $order_id = Db::name('maintain')->insertGetId($data);
-        $this->success('保修成功请等待审核', $order_id);
+        $this->success('提交成功', $order_id);
     }
 
     public function lists(){
@@ -145,7 +146,8 @@ class Maintain extends Api
     public function baojia_info(){
         $order_id = input('order_id',0);
         //找出最新报价日志
-        $baojia_log = Db::name('maintain_baojia')->where('order_id',$order_id)->where('status',30)->order('id desc')->find();
+        $baojia_log = Db::name('maintain_baojia')->field('id,baojia_filename,baojia_file')->where('order_id',$order_id)->where('status',30)->order('id desc')->find();
+        $baojia_log = info_domain_image($baojia_log,['baojia_file']);
 
         $this->success(1,$baojia_log);
     }
@@ -291,16 +293,20 @@ class Maintain extends Api
             $this->error('请输入拒绝原因');
         }
 
+        Db::startTrans();
+
         //检查订单
         $map = [
             'user_id' => $this->auth->id,
             'id'      => $id,
         ];
-        $info = Db::name('maintain')->where($map)->find();
+        $info = Db::name('maintain')->where($map)->lock(true)->find();
         if(empty($info)){
+            Db::rollback();
             $this->error('不存在的订单');
         }
         if($info['status'] != 90){ //师傅完成
+            Db::rollback();
             $this->success('订单错误,请刷新重试');
         }
 
@@ -339,14 +345,32 @@ class Maintain extends Api
             $remark = '验收已通过';
         }
 
-        Db::startTrans();
+        //最后一个轮回,追加验收进度
+        $jindu = [
+            'order_id'   => $info['id'],
+            'company_id' => $info['company_id'],
+            'user_id'    => $info['user_id'],
+            'worker_id'  => $info['worker_id'],
+
+            'weixiu_times' => $info['weixiu_times'],
+            'weixiu_id'    => $info['weixiu_id'],
+
+            'title'       => $remark,
+            'createtime'  => $nowtime,
+        ];
+        $jindu_id = Db::name('maintain_jindu')->insertGetId($jindu);
+        if(!$jindu_id){
+            Db::rollback();
+            $this->error('验收失败');
+        }
+
         $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);
+        $rs2 = Db::name('maintain_weixiu')->where('id',$info['weixiu_id'])->update($update_weixiu);
         if($rs2 === false){
             Db::rollback();
             $this->error('验收失败');

+ 21 - 15
application/api/controller/worker/Maintain.php

@@ -69,31 +69,36 @@ class Maintain extends Api
             $this->error();
         }
 
+        Db::startTrans();
+
         //订单
         $map = [
             'worker_id' => $this->auth->id,
             'id'        => $order_id,
         ];
-        $info = Db::name('maintain')->where($map)->find();
+        $info = Db::name('maintain')->where($map)->lock(true)->find();
         if(empty($info)){
+            Db::rollback();
             $this->error('不存在的订单');
         }
         if($info['status'] != 50){
+            Db::rollback();
             $this->error('状态不正确,请刷新重试');
         }
 
+        $nowtime = time();
+
         //准备数据
         foreach($data as $key => $val){
             $val['order_id']   = $info['id'];
             $val['company_id'] = $info['company_id'];
             $val['user_id']    = $info['user_id'];
             $val['worker_id']  = $info['worker_id'];
-            $val['createtime'] = time();
+            $val['createtime'] = $nowtime;
 
             $data[$key] = $val;
         }
 
-        Db::startTrans();
         $id = Db::name('maintain_cailiao')->insertAll($data);
         if(!$id){
             Db::rollback();
@@ -102,8 +107,8 @@ class Maintain extends Api
 
         $update = [
             'status' => 60,
-            'updatetime' => time(),
-            'cailiao_time' => time(), //材料申请时间
+            'updatetime' => $nowtime,
+            'cailiao_time' => $nowtime, //材料申请时间
         ];
         $rs2 = Db::name('maintain')->where('id',$order_id)->update($update);
         if($rs2 === false){
@@ -147,11 +152,12 @@ class Maintain extends Api
             $this->error('状态不正确,请刷新重试');
         }
 
+        $nowtime = time();
         //
         $update = [
             'status' => 70,
-            'updatetime' => time(),
-            'lingqu_time' => time(), //材料申请时间
+            'updatetime' => $nowtime,
+            'lingqu_time' => $nowtime, //材料申请时间
             'lingqu_images' => $images,
         ];
         $rs2 = Db::name('maintain')->where('id',$order_id)->update($update);
@@ -227,8 +233,8 @@ class Maintain extends Api
         //修改订单
         $update = [
             'status' => 80,
-            'updatetime' => time(),
-            'shangmen_time' => time(), //上门时间
+            'updatetime' => $nowtime,
+            'shangmen_time' => $nowtime, //上门时间
             'weixiu_times' => $weixiu['weixiu_times'],
             'weixiu_id' => $weixiu_id,
         ];
@@ -239,7 +245,7 @@ class Maintain extends Api
         }
 
         Db::commit();
-        $this->success('操作成功');
+        $this->success('已上门');
     }
 
     //新增维修进度
@@ -282,16 +288,16 @@ class Maintain extends Api
             'createtime' => $nowtime,
         ];
 
-        $id = Db::name('maintain_jindu')->insertAll($jindu);
+        $id = Db::name('maintain_jindu')->insertGetId($jindu);
         if(!$id){
-            $this->error('操作失败');
+            $this->error('记录失败');
         }
 
-        $this->success('操作成功');
+        $this->success('记录成功');
     }
 
     //确认完成
-    public function finish(){
+    public function wancheng(){
         $order_id = input('order_id',0);
 
         Db::startTrans();
@@ -326,7 +332,7 @@ class Maintain extends Api
             $this->error('操作失败,重试一下吧');
         }
 
-        //最后一个轮回,最后一个进度
+        //最后一个轮回,追加完成进度
         $jindu = [
             'order_id'   => $info['id'],
             'company_id' => $info['company_id'],