quanwei
2026-01-17 e1e2fe5710a5b5cd9c19bd3aa99c998a1a613ca8
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
 
namespace app\api\controller\plus\vip;
 
use app\api\controller\Controller;
use app\api\model\plus\vip\Setting;
use app\api\model\plus\vip\User as VipUserModel;
use app\api\model\settings\Message as MessageModel;
 
/**
 * VIP专区
 */
class User extends Controller
{
    // 用户
    private $user;
    // VIP用户
    private $vip;
    // VIP设置
    private $setting;
 
    /**
     * 构造方法
     */
    public function initialize()
    {
        // 用户信息
        $this->user = $this->getUser();
        // VIP用户信息
        $this->vip = VipUserModel::detail($this->user['user_id']);
        // VIP设置
        $this->setting = Setting::getAll();
    }
 
    /**
     * VIP专区中心
     */
    public function center()
    {
        // 是否为VIP用户
        $is_vip = $this->isVipUser();
        if ($is_vip) {
            event('VipUserGrade', $this->user['user_id']);
            $this->vip = VipUserModel::detail($this->user['user_id']);
        }
        return $this->renderSuccess('', [
            // 当前是否为VIP用户
            'is_vip' => $is_vip,
            // 当前用户信息
            'user' => $this->user,
            // VIP用户信息
            'vip' => $this->vip,
            // 背景图
            'background' => $this->setting['background']['values']['index'],
            // 页面文字
            'words' => $this->setting['words']['values'],
        ]);
    }
 
    /**
     * VIP用户提现信息
     */
    public function cash($platform = '')
    {
        // 如果来源是小程序, 则获取小程序订阅消息id.获取售后通知.
        $template_arr = MessageModel::getMessageByNameArr($platform, ['agent_cash_user']);
        return $this->renderSuccess('', [
            // 分销商用户信息
            'agent' => $this->vip,
            // 结算设置
            'settlement' => $this->setting['settlement']['values'],
            // 背景图
            'background' => $this->setting['background']['values']['cash_apply'],
            // 页面文字
            'words' => $this->setting['words']['values'],
            // 小程序消息
            'template_arr' => $template_arr
        ]);
    }
 
    /**
     * 是否为VIP用户
     * @return bool
     */
    private function isVipUser()
    {
        return !!$this->vip && !$this->vip['is_delete'];
    }
}