where('type', CommonConstant::TYPE_1) ->where('is_special', CommonConstant::IS_SPECIAL_1) ->where('special_user_id', $userid) ->field($field) ->find(); if ($approve) { $approve_user_ids = $approve['user_ids']; } else { $approve_info = ApproveFlow::where('module', $module) ->where('type', CommonConstant::TYPE_1) ->where('is_special', CommonConstant::IS_SPECIAL_0) ->field($field) ->find(); $approve_user_ids = $approve_info['user_ids']; } $approve_user = self::get_user_list($approve_user_ids); // 抄送 $copy = ApproveFlow::where('module', $module) ->where('type', CommonConstant::TYPE_2) ->where('is_special', CommonConstant::IS_SPECIAL_1) ->where('special_user_id', $userid) ->field($field) ->find(); if ($copy) { $copy_user_ids = $copy['user_ids']; } else { $copy_info = ApproveFlow::where('module', $module) ->where('type', CommonConstant::TYPE_2) ->where('is_special', CommonConstant::IS_SPECIAL_0) ->field($field) ->find(); $copy_user_ids = $copy_info['user_ids']; } $copy_user = self::get_user_list($copy_user_ids); return compact('approve_user', 'copy_user'); } protected static function get_user_list($user_ids) { if (!$user_ids) { return []; } return User::field('userid,headimg,name')->where('userid', 'in', $user_ids)->select(); } }