<?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'];
|
}
|
}
|