Commit b105008b51b9a4ba469b879de579e2227d8fb57e
1 parent
4cc0fefe
添加中奖记录接口中奖列表接口投票接口
Showing
3 changed files
with
92 additions
and
0 deletions
phpapi/apicp.AddLottery.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 | + if(!isset($_POST['user_id'])){ | |
12 | + JsonResponse::error('userID参数不能为空'); | |
13 | + } | |
14 | + | |
15 | + if(!isset($_POST['prize_id'])){ | |
16 | + JsonResponse::error('奖项Id不能为空'); | |
17 | + } | |
18 | + | |
19 | + $mysql = new mysqlHelper(); | |
20 | + $user_id = $_POST['user_id']; | |
21 | + $prize_id = $_POST['prize_id']; | |
22 | + | |
23 | + $mysql->insert('lottery',['user_id' => $user_id, 'prize_id' => $prize_id , 'created' => time() ]); | |
24 | + | |
25 | + JsonResponse::result([]); | |
26 | + | ... | ... |
phpapi/apicp.ItemVote.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 | + | |
13 | + if(!isset($_POST['user_id'])){ | |
14 | + JsonResponse::error('userID参数不能为空'); | |
15 | + } | |
16 | + | |
17 | + if(!isset($_POST['item_ids'])){ | |
18 | + JsonResponse::error('请选择投票节目Id'); | |
19 | + } | |
20 | + | |
21 | + if(!is_array($_POST['item_ids'])){ | |
22 | + JsonResponse::error('投票节目Id类型有误'); | |
23 | + } | |
24 | + | |
25 | + $mysql = new mysqlHelper(); | |
26 | + $user_id = $_POST['user_id']; | |
27 | + | |
28 | + | |
29 | + // 查询用户是否投过票了 | |
30 | + $userItemVoteInfo = $mysql->fetch("SELECT id FROM item_vote WHERE user_id = ?", [ $user_id ]); | |
31 | + if(!empty($userItemVoteInfo)){ | |
32 | + JsonResponse::error('您已经投过票了不可再重复操作'); | |
33 | + } | |
34 | + | |
35 | + foreach ($_POST['item_ids'] as $item_id){ | |
36 | + $mysql->insert('item_vote',['item_id' => $item_id, 'user_id' => $user_id ]); | |
37 | + } | |
38 | + | |
39 | + // 返回桌位列表 | |
40 | + JsonResponse::result([]); | |
41 | + | ... | ... |
phpapi/apicp.LotteryList.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 | + if(!isset($_GET['prize_id'])){ | |
12 | + JsonResponse::error('prize_id参数不能为空'); | |
13 | + } | |
14 | + | |
15 | + $mysql = new mysqlHelper(); | |
16 | + $prize_id = $_GET['prize_id']; | |
17 | + | |
18 | + $prizeList = $mysql->fetchAll( | |
19 | + "SELECT l.id,l.user_id,u.realname,u.headimg,u.prize_no FROM lottery as l | |
20 | + LEFT JOIN user as u on u.id = l.user_id | |
21 | + WHERE prize_id = {$prize_id}"); | |
22 | + | |
23 | + $prizeList = $prizeList ?? []; | |
24 | + JsonResponse::result(['data' => $prizeList]); | |
25 | + | ... | ... |