瀏覽代碼

工作流添加

cqp 10 月之前
父節點
當前提交
3b96f16cfc
共有 1 個文件被更改,包括 41 次插入5 次删除
  1. 41 5
      app/Service/WorkFlowService.php

+ 41 - 5
app/Service/WorkFlowService.php

@@ -68,12 +68,25 @@ class WorkFlowService extends Service
 
     public function del($data, $user){
         if($this->isEmpty($data,'id')) return [false,'请选择工作流'];
+
         $workFlow = WorkFlow::where('del_time',0)
             ->where('id',$data['id'])
             ->first();
         if(empty($workFlow)) return [false,'工作流不存在或已被删除'];
-        $workFlow->del_time = time();
-        $workFlow->save();
+
+        try {
+            DB::beginTransaction();
+
+            $time = time();
+            $workFlow->del_time = $time;
+            $workFlow->save();
+            $this->updateSonModel($data, $time);
+
+            DB::commit();
+        }catch (\Throwable $e){
+            DB::rollBack();
+            return [false, $e->getFile() . '|' . $e->getLine() . '|' . $e->getMessage()];
+        }
 
         return [true, ''];
     }
@@ -480,13 +493,36 @@ class WorkFlowService extends Service
         list($status, $msg) = $this->createRule($data, $user);
         if(! $status) return [false, $msg];
 
+        try {
+            //生成
+            list($status, $msg) = $this->createWorkFlowDetail($data, $user);
+
+            DB::commit();
+        } catch (\Exception $e) {
+            DB::rollBack();
+            return [false, $e->getFile() . '|' . $e->getLine() . '|' . $e->getMessage()];
+        }
+
+        return [true, ''];
     }
 
     public function createRule($data, $user){
+        if(empty($data['menu_id'])) return [false, '菜单ID不能为空'];
+        if(empty($data['order_number'])) return [false, 'order_number不能为空'];
+        if(empty($data['opt_case'])) return [false, 'opt_case不能为空'];
+
         $oa = config('oa');
-        dd($oa);
-        foreach ($oa as $key => $value){
+        if(empty($oa)) return [false, '工作流配置未设置,请联系开发者'];
+        $menu_id = array_column($oa,'menu_id');
+        if(! in_array($data['menu_id'], $menu_id)) return [false, '该菜单暂不支持工作流'];
+    }
+
+    public function createWorkFlowDetail($data, $user){
+        $workFlow = WorkFlow::where('del_time',0)
+            ->where('menu_id', $data['menu_id'])
+            ->first();
+        if(empty($workFlow)) return [true, ''];
+
 
-        }
     }
 }