123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\common\model;
- use think\Model;
- // 审批流程设置
- class ApproveFlow extends Model
- {
- // 获取审批人
- public static function getApproveUser($module,$user_id){
- $check_flow = ApproveFlow::where('user_id',$user_id)->where('type',1)->where('module',$module)->find();
- $where = [];
- $where[] = ['l.type','=',1];
- $where[] = ['l.module','=',$module];
- if($check_flow)$where[] = ['l.sort','>',$check_flow->sort];
- $list = static::field('l.user_id,u.name user_name,u.headimg')->alias('l')
- ->where($where)
- ->order('l.sort asc')
- ->leftJoin('StoreMember u','u.id = l.user_id')
- ->select()->toArray();
- return $list;
- }
- // 获取抄送人
- public static function getCopyTo($module)
- {
- return static::where('type',2)->where('module',$module)->order('sort asc ,id asc')->select()->toArray();
- }
- // 获取审批流程数据
- public static function getApproveData($flow_user,$copy_user,$info_id)
- {
- $flow_data = [];// 审批流程
- $flow_num = 0;
- // 审批人
- foreach (explode(',',$flow_user) as $fk=>$fv) {
- if(!$fv) continue;
- $flow_num++;
- $flow_data[] = [
- 'info_id' => $info_id,
- 'approve_user' => $fv,
- 'flow' =>$flow_num,
- 'create_at'=>date('Y-m-d H:i:s'),
- 'start_time'=> $flow_num == 1 ? date('Y-m-d H:i:s'):null,
- 'status'=> $flow_num == 1 ? 1 : 0,
- ];
- }
- // 抄送人
- foreach (explode(',',$copy_user) as $ck=>$cv) {
- if(!$cv) continue;
- $flow_data[] = [
- 'info_id' => $info_id,
- 'approve_user' => $cv,
- 'approve_type' =>2
- ];
- }
- return ['flow_data'=>$flow_data,'flow_num'=>$flow_num];
- }
- }
|