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
56
57
58
59
60
61
62
<?php
 
namespace app\api\controller\plus\vip;
 
use app\api\controller\Controller;
use app\api\model\plus\vip\User as VipUserModel;
use app\common\model\plus\vip\Referee as VipRefereeModel;
 
/**
 * VIP团队控制器
 */
class Team extends Controller
{
    // 用户
    private $user;
    // VIP用户
    private $vip;
    
    /**
     * 构造方法
     */
    public function initialize()
    {
        // 用户信息
        $this->user = $this->getUser();
        // VIP用户信息
        $this->vip = VipUserModel::detail($this->user['user_id']);
    }
    
    /**
     * 团队列表
     */
    public function lists()
    {
        // 判断用户是否是VIP
        if (!$this->vip || $this->vip['is_delete']) {
            return $this->renderError('您不是VIP用户');
        }
        
        // 获取团队成员列表
        $model = new VipRefereeModel();
        $team_list = $model->getList($this->user['user_id']);
        
        return $this->renderSuccess('', compact('team_list'));
    }
    
    /**
     * 团队统计信息
     */
    public function statistics()
    {
        // 判断用户是否是VIP
        if (!$this->vip || $this->vip['is_delete']) {
            return $this->renderError('您不是VIP用户');
        }
        
        // 获取团队统计信息
        $statistics = VipRefereeModel::getStatistics($this->user['user_id']);
        
        return $this->renderSuccess('', compact('statistics'));
    }
}