<?php /** * 跨域处理 */ header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Methods:GET,POST"); /** * 返回随机用户列表 */ include "Common/JsonResponse.php"; include "Common/mysqlHelper.php"; include "Common/WechatHelper.php"; include "Common/Encrypter.php"; $mysql = new mysqlHelper(); $userList = $mysql->fetchAll("SELECT id,realname,headimg,prize_no FROM user WHERE status = 1"); // 查询已中奖用户 $lotteryUserIds = []; $lotteryUser = $mysql->fetchAll("SELECT user_id FROM lottery "); if(!empty($lotteryUser)){ $lotteryUserIds = array_column($lotteryUser,'user_id'); } // 去除已中奖用户 foreach ($userList as $key => &$value){ $value['id'] = (int)$value['id']; if(in_array($value['id'],$lotteryUserIds)){ unset($userList[$key]); } } $userList = array_values($userList); // 将用户排序进行两次打乱 shuffle($userList); shuffle($userList); $res = [ 'data' => $userList ]; // 返回桌位列表 JsonResponse::result($res);