quanwei
2 days ago 04102f7237efefa744090ed7c25f7b5d0807b679
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
 
namespace app\api\controller\plus\lottery;
 
use app\api\controller\Controller;
use app\api\model\plus\lottery\Lottery as LotteryModel;
use app\api\model\plus\lottery\Record as RecordModel;
use app\shop\model\plus\lottery\LotteryPrize as LotteryPrizeModel;
 
/**
 * 转盘控制器
 */
class Lottery extends Controller
{
    /**
     * 获取数据
     * @param null $id
     */
    public function getLottery()
    {
        $model = new LotteryModel();
        $data = $model->getDetail();
        //剩余抽奖次数
        $num = $model->getNum($this->getUser());
        $nums = $data['times'] - $num;
        //抽奖播放数据
        $recordModel = new RecordModel();
        $recordList = $recordModel->getLimitList(60);
        $data['user_points'] = $this->getUser()['points'];
        return $this->renderSuccess('', compact('data', 'nums', 'recordList'));
    }
 
    /*
     * 转盘记录列表
     */
    public function record()
    {
        $model = new RecordModel();
        $list = $model->getList($this->postData(), $this->getUser());
        return $this->renderSuccess('', compact('list'));
    }
 
    /*
     * 开始抽奖
     */
    public function draw()
    {
        $model = new LotteryModel();
        $result = $model->getdraw($this->getUser());
        if ($result) {
            return $this->renderSuccess('', compact('result'));
        }
        return $this->renderError($model->getError() ?: '抽奖失败');
    }
}