فهرست منبع

修改工单分配和取消工单

dongxiaoqin 10 ماه پیش
والد
کامیت
7f5712b371
2فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 12 2
      app/adminapi/logic/works/ServiceWorkLogic.php
  2. 1 1
      app/workerapi/controller/WorksController.php

+ 12 - 2
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -116,6 +116,9 @@ class ServiceWorkLogic extends BaseLogic
             if($work->isEmpty()){
                 throw new Exception('工单不存在');
             }
+            if ($work->work_status > 1 && $work->receive_time > 0){
+                throw new Exception('工单已领取,请勿重复点击');
+            }
             $receive_time = time();
             $work->work_status = 2;//待联系
             $work->service_status = 1;//服务中
@@ -1080,7 +1083,14 @@ class ServiceWorkLogic extends BaseLogic
         }
     }
 
-    public static function cancelAllocation($params,$userInfo){
+    /**
+     * 取消分配
+     * @param $params
+     * @param $userInfo
+     * @param $type:1后台管理员取消;2工程师端取消
+     * @return bool
+     */
+    public static function cancelAllocation($params,$userInfo,$type = 1){
         Db::startTrans();
         try {
 
@@ -1095,7 +1105,7 @@ class ServiceWorkLogic extends BaseLogic
             if($worker->isEmpty()){
                 throw new \Exception('工程师不存在');
             }
-            if ($worker->type == 2) {          
+            if ($type == 2 && $worker->type == 2) {          
                 throw new \Exception('您当前无权限取消分配');  
             }
 

+ 1 - 1
app/workerapi/controller/WorksController.php

@@ -383,7 +383,7 @@ class WorksController extends BaseApiController
             'user_id' => $this->userId,
             'user_info' => $this->userInfo
         ]);
-        $result = ServiceWorkLogic::cancelAllocation(['id'=>$params['id'],'master_worker_id'=>$this->userId],['admin_id'=>$this->userId,'name'=>'工程师-'.$this->userInfo['mobile']]);
+        $result = ServiceWorkLogic::cancelAllocation(['id'=>$params['id'],'master_worker_id'=>$this->userId],['admin_id'=>$this->userId,'name'=>'工程师-'.$this->userInfo['mobile']], 2);
         if (false === $result) {
             return $this->fail(ServiceWorkLogic::getError());
         }