Sfoglia il codice sorgente

是否长期停单

whitefang 1 anno fa
parent
commit
49bab89dee

+ 9 - 0
app/workerapi/controller/MasterWorkerController.php

@@ -62,6 +62,15 @@ class MasterWorkerController extends BaseApiController
         return $this->fail(MasterWorkerInfoLogic::getError());
     }
 
+    public function approvalStopWork()
+    {
+        $result = MasterWorkerInfoLogic::stopWork($this->userId);
+        if (true === $result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerInfoLogic::getError());
+    }
+
 
     /**
      * 注销账号

+ 29 - 0
app/workerapi/logic/MasterWorkerLogic.php

@@ -6,6 +6,7 @@ use app\common\logic\BaseLogic;
 use app\common\model\master_worker\MasterWorker;
 use app\common\model\master_worker\MasterWorkerAccountLog;
 use app\common\model\works\ServiceWork;
+use think\Exception;
 use think\facade\Config;
 
 /**
@@ -75,6 +76,12 @@ class MasterWorkerLogic extends  BaseLogic
             if ($user->isEmpty()) {
                 throw new \Exception('用户不存在');
             }
+            if($user->work_status == 0 ){
+                throw new Exception('请先申请长期停单');
+            }
+            if($user->work_status == 1 ){
+                throw new Exception('请等待长期停单审核');
+            }
             $user->is_disable = YesNoEnum::YES;
             $user->save();
             return true;
@@ -84,6 +91,28 @@ class MasterWorkerLogic extends  BaseLogic
         }
     }
 
+    public static function stopWork(int $userId)
+    {
+        try {
+            $user = MasterWorker::findOrEmpty($userId);
+            if ($user->isEmpty()) {
+                throw new \Exception('用户不存在');
+            }
+            if($user->work_status == 1 ){
+                throw new Exception('请等待长期停单审核');
+            }
+            if($user->work_status == 2 ){
+                throw new Exception('长期停单审核通过');
+            }
+            $user->work_status = 1;
+            $user->save();
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
      public static function detail($userId): array
     {
         $worker = MasterWorker::field('id,sn,avatar,real_avatar,real_name,nickname,account,mobile,sex,estimate_money,user_money,earnest_money,exp,worker_number,work_status')