Commit 4cc0fefed48520e1ccdf1979fe6115ef0c32b675

Authored by 程雨佳
1 parent 47988279

添加新接口

phpapi/apicp.PrizeList.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * 返回节目列表
  4 + */
  5 +
  6 + include "Common/JsonResponse.php";
  7 + include "Common/mysqlHelper.php";
  8 + include "Common/WechatHelper.php";
  9 + include "Common/Encrypter.php";
  10 +
  11 +
  12 + $mysql = new mysqlHelper();
  13 + $data = $mysql->fetchAll("SELECT * FROM prize");
  14 +
  15 + foreach ($data as $key => &$value){
  16 + $value['id'] = (int)$value['id'];
  17 + }
  18 +
  19 + $res = [
  20 + 'data' => $data
  21 + ];
  22 + // 返回桌位列表
  23 + JsonResponse::result($res);
  24 +
... ...
phpapi/apicp.UserList.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * 返回节目列表
  4 + */
  5 +
  6 + include "Common/JsonResponse.php";
  7 + include "Common/mysqlHelper.php";
  8 + include "Common/WechatHelper.php";
  9 + include "Common/Encrypter.php";
  10 +
  11 +
  12 + $mysql = new mysqlHelper();
  13 + $userList = $mysql->fetchAll("SELECT id,realname,headimg,prize_no FROM user WHERE headimg <> '' AND status = 1");
  14 +
  15 + // 查询已中奖用户
  16 + $lotteryUserIds = [];
  17 + $lotteryUser = $mysql->fetchAll("SELECT user_id FROM lottery ");
  18 + if(!empty($lotteryUser)){
  19 + $lotteryUserIds = array_column($lotteryUser,'user_id');
  20 + }
  21 +
  22 + // 去除已中奖用户
  23 + foreach ($userList as $key => &$value){
  24 + $value['id'] = (int)$value['id'];
  25 + if(in_array($value['id'],$lotteryUserIds)){
  26 + unset($userList[$key]);
  27 + }
  28 + }
  29 + $userList = array_values($userList);
  30 +
  31 + // 将用户排序进行两次打乱
  32 + shuffle($userList);
  33 + shuffle($userList);
  34 +
  35 + $res = [
  36 + 'data' => $userList
  37 + ];
  38 + // 返回桌位列表
  39 + JsonResponse::result($res);
  40 +
... ...