123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\common\service;
- use app\common\constant\CommonConstant;
- use app\common\model\ApproveFlow;
- use app\common\model\User;
- use think\Db;
- use think\Exception;
- /**
- * 审批流程服务类
- */
- class ApproveFlowService
- {
- /**
- * 获取流程
- *
- * @param $module
- * @param $user
- **/
- public static function get_data($module, $user)
- {
- $userid = $user['userid'];
- $field = 'id,user_ids';
- // 审批
- $approve = ApproveFlow::where('module', $module)
- ->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();
- }
- }
|