alias('agu') ->join('attendance_group ag','ag.id = agu.group_id') ->where('agu.user_id',$userId) ->where('ag.del',0) ->field('ag.*') ->find(); if(!$group){ return false; } $day = date('Y-m-d'); if($group['type'] == 1){ //固定班制 $w = date('w'); $content = json_decode($group['content'],true); $week = $content['week']; $classId = 0; foreach ($week as $k=>$v){ if($w == $v['week']){ $classId = empty($v['class_id'])?0:$v['class_id']; } } // 今日是否有必打卡特殊日 $sign = $content['sign']; foreach ($sign as $k=>$v){ if($day == $v['day']){ $classId = empty($v['class_id'])?0:$v['class_id']; } } // 今日是否有不必打卡特殊日 $unsign = $content['unsign']; foreach ($unsign as $k=>$v){ if($day == $v['day']){ $classId = 0; } } $class = []; if($classId > 0){ $class = Db::name('attendance_class')->where('id',$classId)->where('del',0)->field('content,org_id,id as class_id')->find(); if($class){ $class['group_id'] = $group['id']; $class['group_name'] = $group['name']; $class['cate'] = $group['cate']; $class['addr'] = $group['addr']; } } }else{ // 排班制 $class = Db::name('attendance_group') ->alias('ag') ->join('attendance_group_class agc','ag.id = agc.group_id') ->join('attendance_class ac','ac.id = agc.class_id') ->where('ag.id',$group['id']) ->where('agc.day',$day) ->field('ac.content,agc.group_id,agc.class_id,ag.org_id,ag.name as group_name,ag.cate,ag.addr') ->find(); // 今日排班 } return $class; } }