Просмотр исходного кода

师傅端-用户确认服务完成

whitefang 1 год назад
Родитель
Сommit
d68b49501b

+ 36 - 0
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -212,4 +212,40 @@ class ServiceWorkLogic extends BaseLogic
             return false;
         }
     }
+
+    /**
+     * 师傅确认服务完成
+     * @param $params
+     * @return false|void
+     */
+    public static function confirmServiceFinish($params)
+    {
+        Db::startTrans();
+        try {
+            $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+
+            if($work->user_confirm_status !=2){
+                throw new Exception('请勿重复操作');
+            }
+
+            $work->user_confirm_status = 3;//待确认服务完成
+            $work->save();
+
+            //添加变更日志
+            $work_log = [
+                'work_id'=>$work->id,
+                'master_worker_id'=>$work->master_worker_id,
+                'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'于'.date('Y-m-d H:i:s',time()).'提交了待用户确认服务完成',
+            ];
+            ServiceWorkLogLogic::add($work_log);
+            Db::commit();
+        }
+        catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
 }

+ 17 - 0
app/api/controller/ServiceOrderController.php

@@ -87,4 +87,21 @@ class ServiceOrderController extends BaseApiController
         }
         return $this->success('已确认报价,师傅即将开始服务', [], 1, 1);
     }
+
+    /**
+     * 用户确认服务完成
+     * @return \think\response\Json
+     */
+    public function confirmServiceFinish()
+    {
+        $params = (new ServiceOrderValidate())->post()->goCheck('finished', [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ]);
+        $result = ServiceOrderLogic::confirmServiceFinish($params);
+        if (false === $result) {
+            return $this->fail(ServiceOrderLogic::getError());
+        }
+        return $this->success('已确认报价,师傅即将开始服务', [], 1, 1);
+    }
 }

+ 42 - 1
app/api/logic/ServiceOrderLogic.php

@@ -234,7 +234,7 @@ class ServiceOrderLogic extends BaseLogic
 
             //更新工单状态为已取消
             $service_work = ServiceWork::find($work_id);
-            if($service_work->user_confirm_status==2){
+            if($service_work->user_confirm_status==1){
                 throw new Exception('请勿重复操作');
             }
             $service_work->work_status = 5;
@@ -254,4 +254,45 @@ class ServiceOrderLogic extends BaseLogic
             return false;
         }
     }
+
+    /**
+     * 用户确认服务完成
+     * @param $params
+     * @return false|void
+     */
+    public static function confirmServiceFinish($params)
+    {
+        Db::startTrans();
+        try {
+            $work_id =  \app\common\model\recharge\RechargeOrder::where([
+                'order_type' => 0,
+                'user_id' => $params['user_id'],
+                'sn'=>$params['sn']
+            ])->value('work_id');
+            if(empty($work_id)){
+                throw new Exception('订单不存在');
+            }
+
+            //更新工单状态为已取消
+            $service_work = ServiceWork::find($work_id);
+            if($service_work->user_confirm_status!=3){
+                throw new Exception('请勿重复操作');
+            }
+            $service_work->work_status = 6;
+            $service_work->user_confirm_status = 4;
+            $service_work->save();
+
+            $work_log = [
+                'work_id'=>$work_id,
+                'master_worker_id'=>$service_work->master_worker_id,
+                'opera_log'=>'用户'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'于'.date('Y-m-d H:i:s',time()).'确认服务完成',
+            ];
+            ServiceWorkLogLogic::add($work_log);
+            Db::commit();
+        }
+        catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
 }

+ 7 - 0
app/api/validate/ServiceOrderValidate.php

@@ -52,4 +52,11 @@ class ServiceOrderValidate extends BaseValidate
         return $this->only(['sn']);
     }
 
+    public function sceneFinished()
+    {
+        return $this->only(['sn']);
+    }
+
+
+
 }

+ 17 - 0
app/workerapi/controller/WorksController.php

@@ -90,6 +90,23 @@ class WorksController extends BaseApiController
         return $this->success('操作成功,师傅已填写报价单,等待用户确认中', [], 1, 1);
     }
 
+    /**
+     * 师傅确认服务完成
+     * @return \think\response\Json
+     */
+    public function confirmServiceFinish()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('finished', [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ]);
+        $result = ServiceWorkLogic::confirmServiceFinish($params);
+        if (false === $result) {
+            return $this->fail(ServiceWorkLogic::getError());
+        }
+        return $this->success('操作成功,师傅已确认服务完成,等待用户确认中', [], 1, 1);
+    }
+
     /**
      * 投诉工单列表
      *

+ 5 - 0
app/workerapi/validate/ServiceWorkValidate.php

@@ -98,4 +98,9 @@ class ServiceWorkValidate extends BaseValidate
         return $this->only(['work_sn','amount']);
     }
 
+    public function sceneFinished()
+    {
+        return $this->only(['work_sn']);
+    }
+
 }