1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\common\service;
- use app\common\constant\CommonConstant;
- use app\common\model\ApproveFlow;
- use app\common\model\User;
- /**
- * 审批流程服务类
- */
- class ApproveFlowService
- {
- /**
- * 获取流程
- *
- * @param integer $module 模块类型
- * @param mixed $user 用户信息
- **/
- public static function get_data($module, $user)
- {
- $userid = $user['userid'];
- $field = 'id,user_ids';
- // 审批
- $approve = ApproveFlow::get_where($module, CommonConstant::TYPE_1, CommonConstant::IS_SPECIAL_1, $userid)
- ->field($field)
- ->find();
- if ($approve) {
- $approve_user_ids = $approve['user_ids'];
- } else {
- $approve_info = ApproveFlow::get_where($module, CommonConstant::TYPE_1, CommonConstant::IS_SPECIAL_0)
- ->field($field)
- ->find();
- $approve_user_ids = $approve_info ? $approve_info['user_ids'] : [];
- }
- $approve_user = self::get_user_list($approve_user_ids);
- // 抄送
- $name = 'is_copy_' . $module;
- $is_copy = sysconf($name); // 是否允许用户自己添加抄送人 0=否,1=是
- if (!$is_copy) {
- $copy = ApproveFlow::get_where($module, CommonConstant::TYPE_2, CommonConstant::IS_SPECIAL_1, $userid)
- ->field($field)
- ->find();
- if ($copy) {
- $copy_user_ids = $copy['user_ids'];
- } else {
- $copy_info = ApproveFlow::get_where($module, CommonConstant::TYPE_2, CommonConstant::IS_SPECIAL_0)
- ->field($field)
- ->find();
- $copy_user_ids = $copy_info ? $copy_info['user_ids'] : [];
- }
- $copy_user = self::get_user_list($copy_user_ids);
- } else {
- $copy_user = [];
- }
- 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();
- }
- }
|