get_one("select * from tb_user where id = '{$uid}'"); $area_id = intval($user['area_id']); $dining_hall_id = intval($user['dining_hall_id']); $sql = "SELECT distinct n.* FROM tb_notice n left JOIN tb_notice_push p on n.id = p.notice_id WHERE n.enabled = '1' and n.showIndex = '1' and (p.user_id = {$uid} or locate({$area_id},n.area_id) > 0 or locate({$dining_hall_id},n.dining_hall_id) > 0) order by n.id desc LIMIT 10"; $noticeList = $db->get_all($sql); foreach($noticeList as $n => $item) { $notice_id = $item['id']; $type = $item['type']; $row = $db->get_one("select * from tb_notice_push where notice_id = {$notice_id} and user_id = {$uid}"); if(!$row) { $db->query("insert into tb_notice_push set notice_id = '".$notice_id."', user_id = '".$uid."', status = '1'"); } if($type == '1') { $noticeList[$n]['type'] = '公告'; } else if($type == '2') { $noticeList[$n]['type'] = '公示'; } else if($type == '3') { $noticeList[$n]['type'] = '养生知识'; } else { $noticeList[$n]['type'] = '公告'; } $row = $db->get_one("select status from tb_notice_push where notice_id = ".$notice_id." and user_id = {$uid}"); $noticeList[$n]['readstatus'] = $row['status']; $noticeList[$n]['adminId'] = $item['admin_id']; unset($noticeList[$n]['admin_id']); $noticeList[$n]['companyId'] = $item['company_id']; unset($noticeList[$n]['company_id']); $noticeList[$n]['areaId'] = $item['area_id']; unset($noticeList[$n]['area_id']); $noticeList[$n]['diningHallId'] = $item['dining_hall_id']; unset($noticeList[$n]['dining_hall_id']); } $row = $db->get_one("SELECT count(p.id) as c FROM `tb_notice_push` p INNER JOIN tb_notice n on p.notice_id = n.id WHERE p.user_id = {$uid} and p.`status` != '2' and n.showIndex = '1' and n.enabled = '1'"); $unreadCount = $row['c']; $arr = array('code' => 0, 'content' => array( 'unreadCount' => $unreadCount, 'notice' => $noticeList ), 'err_msg' => ''); echo json_encode($arr, JSON_UNESCAPED_UNICODE); exit; } if($act == 'gdj_findDininghallByNow') { $user = check_token(); $uid = $user['id']; $uInfo = $db->get_one("select * from tb_user where id = '{$uid}'"); $area_id = intval($user['area_id']); $dining_hall_id = intval($user['dining_hall_id']); $row = $db->get_one("select IFNULL(MAX(dining_hall_id),0) as dininghall from tb_user_temp_dininghall where user_id = {$uid} and DATE_FORMAT(valid_datetime,'%Y-%m-%d') = CURDATE()"); $dininghall = intval($row['dininghall']); $arr = array('code' => 0, 'content' => array( 'dininghall' => ($dininghall==0?null:$dininghall), ), 'err_msg' => ''); echo json_encode($arr, JSON_UNESCAPED_UNICODE); exit; } if($act == 'gdj_findApprovalByUser') { $user = check_token(); $uid = $user['id']; $uInfo = $db->get_one("select * from tb_user where id = '{$uid}'"); $area_id = intval($user['area_id']); $dining_hall_id = intval($user['dining_hall_id']); $status = $post['status'].''; $sql = " select d.*,u.username as username,u2.username as verifyName,h.name as dininghallName from tb_user_apply_dininghall d inner join tb_user u on u.id = d.uid left join tb_user u2 on u2.id = d.verify_uid inner join tb_dining_hall h on h.id = d.dining_hall_id and d.uid = {$uid} "; if($status !== '') { $sql .= " and d.status = '".addslashes($status)."' "; } $sql .= "order by id desc"; $list = $db->get_all($sql); $arr = array('code' => 0, 'content' => $list , 'err_msg' => ''); echo json_encode($arr, JSON_UNESCAPED_UNICODE); exit; }