zhanglinxin il y a 1 an
Parent
commit
aa510ec4b1
1 fichiers modifiés avec 59 ajouts et 85 suppressions
  1. 59 85
      application/common/service/ApproveInfoService.php

+ 59 - 85
application/common/service/ApproveInfoService.php

@@ -782,78 +782,8 @@ class ApproveInfoService
             ]);
             $info = $info->find($id);
             if ($info) {
-                $module = $info['module'];
-                if ($group == CommonConstant::IS_WHO_1) {
-                    // 先默认当前是提交人
-                    $create_user = [
-                        'id' => $user['id'],
-                        'userid' => $user['userid'],
-                        'name' => $user['name'],
-                        'avatar' => $user['avatar'],
-                    ];
-                    $apply_user = $create_user;
-                    if (in_array($module, [CommonConstant::MODULE_5, CommonConstant::MODULE_6, CommonConstant::MODULE_7])) {
-                        if($user['userid'] == $info['user_id']){
-                            // 当前是提交人
-                            if ($info['user_id'] != $info['apply_user_id']) {
-                                $apply_user_info = User::field('id,userid,name,avatar')
-                                    ->where('userid', $info['apply_user_id'])
-                                    ->find();
-                                $apply_user = [
-                                    'id' => $apply_user_info['id'],
-                                    'userid' => $apply_user_info['userid'],
-                                    'name' => $apply_user_info['name'],
-                                    'avatar' => $apply_user_info['avatar'],
-                                ];
-                            }
-                        }
-                        if($user['userid'] == $info['apply_user_id']){
-                            //  当前是申请人
-                            if ($info['user_id'] != $info['apply_user_id']) {
-                                $apply_user_info = User::field('id,userid,name,avatar')
-                                    ->where('userid', $info['user_id'])
-                                    ->find();
-                                $create_user = [
-                                    'id' => $apply_user_info['id'],
-                                    'userid' => $apply_user_info['userid'],
-                                    'name' => $apply_user_info['name'],
-                                    'avatar' => $apply_user_info['avatar'],
-                                ];
-                            }
-                        }
-                    }
-                }
-                if ($group == CommonConstant::IS_WHO_0) {
-                    // 审批人
-                    $apply_user = User::field('id,userid,name,avatar')
-                        ->where('userid', $info['apply_user_id'])
-                        ->find();
-                    $create_user = [
-                        'id' => $apply_user['id'],
-                        'userid' => $apply_user['userid'],
-                        'name' => $apply_user['name'],
-                        'avatar' => $apply_user['avatar'],
-                    ];
-                    $apply_user = $create_user;
-                    if (in_array($module, [CommonConstant::MODULE_5, CommonConstant::MODULE_6, CommonConstant::MODULE_7])) {
-
-                        if ($info['user_id'] != $info['apply_user_id']) {
-                            $apply_user_info = User::field('id,userid,name,avatar')
-                                ->where('userid', $info['user_id'])
-                                ->find();
-                            $create_user = [
-                                'id' => $apply_user_info['id'],
-                                'userid' => $apply_user_info['userid'],
-                                'name' => $apply_user_info['name'],
-                                'avatar' => $apply_user_info['avatar'],
-                            ];
-                        }
-                    }
-                }
                 // 部门列表
                 $department_data = UserService::get_user_department_list($info['department']);
-                $info['create_user'] = $create_user;
-                $info['apply_user'] = $apply_user;
                 $info['department_data'] = $department_data;
             }
         } else {
@@ -862,35 +792,79 @@ class ApproveInfoService
                 'moduleInfo'
             ]);
             $info = $info->find($id);
-            if ($info) {
-                $module = $info['module'];
-                if ($group == CommonConstant::IS_WHO_1) {
-                    // 先默认当前是提交人
-                    $apply_user = [
-                        'id' => $user['id'],
-                        'userid' => $user['userid'],
-                        'name' => $user['name'],
-                        'avatar' => $user['avatar'],
-                    ];
-                    $create_user = $apply_user;
-                    if (in_array($module, [CommonConstant::MODULE_5, CommonConstant::MODULE_6, CommonConstant::MODULE_7])) {
+        }
+        if ($info) {
+            $module = $info['module'];
+            if ($group == CommonConstant::IS_WHO_1) {
+                // 先默认当前是提交人
+                $create_user = [
+                    'id' => $user['id'],
+                    'userid' => $user['userid'],
+                    'name' => $user['name'],
+                    'avatar' => $user['avatar'],
+                ];
+                $apply_user = $create_user;
+                if (in_array($module, [CommonConstant::MODULE_5, CommonConstant::MODULE_6, CommonConstant::MODULE_7])) {
+                    if($user['userid'] == $info['user_id']){
+                        // 当前是提交人
                         if ($info['user_id'] != $info['apply_user_id']) {
                             $apply_user_info = User::field('id,userid,name,avatar')
                                 ->where('userid', $info['apply_user_id'])
                                 ->find();
                             $apply_user = [
-                                'id' => $apply_user['id'],
+                                'id' => $apply_user_info['id'],
+                                'userid' => $apply_user_info['userid'],
+                                'name' => $apply_user_info['name'],
+                                'avatar' => $apply_user_info['avatar'],
+                            ];
+                        }
+                    }
+                    if($user['userid'] == $info['apply_user_id']){
+                        //  当前是申请人
+                        if ($info['user_id'] != $info['apply_user_id']) {
+                            $apply_user_info = User::field('id,userid,name,avatar')
+                                ->where('userid', $info['user_id'])
+                                ->find();
+                            $create_user = [
+                                'id' => $apply_user_info['id'],
                                 'userid' => $apply_user_info['userid'],
                                 'name' => $apply_user_info['name'],
                                 'avatar' => $apply_user_info['avatar'],
                             ];
                         }
                     }
-                    $info['create_user'] = $create_user;
-                    $info['apply_user'] = $apply_user;
                 }
             }
+            if ($group == CommonConstant::IS_WHO_0) {
+                // 审批人
+                $apply_user = User::field('id,userid,name,avatar')
+                    ->where('userid', $info['apply_user_id'])
+                    ->find();
+                $create_user = [
+                    'id' => $apply_user['id'],
+                    'userid' => $apply_user['userid'],
+                    'name' => $apply_user['name'],
+                    'avatar' => $apply_user['avatar'],
+                ];
+                $apply_user = $create_user;
+                if (in_array($module, [CommonConstant::MODULE_5, CommonConstant::MODULE_6, CommonConstant::MODULE_7])) {
+                    if ($info['user_id'] != $info['apply_user_id']) {
+                        $apply_user_info = User::field('id,userid,name,avatar')
+                            ->where('userid', $info['user_id'])
+                            ->find();
+                        $create_user = [
+                            'id' => $apply_user_info['id'],
+                            'userid' => $apply_user_info['userid'],
+                            'name' => $apply_user_info['name'],
+                            'avatar' => $apply_user_info['avatar'],
+                        ];
+                    }
+                }
+            }
+            $info['create_user'] = $create_user;
+            $info['apply_user'] = $apply_user;
         }
+
         $info = self::get_item($info, $type);
         return $info;
     }