<?php
|
|
namespace app\api\controller\plus\operations;
|
|
use app\api\controller\Controller;
|
use app\api\model\plus\agent\User as AgentUserModel;
|
use app\api\model\plus\operations\Setting;
|
use app\api\model\plus\operations\Operations as OperationsUserModel;
|
use app\api\model\plus\team\Order as TeamOrder;
|
use app\api\model\settings\Message as MessageModel;
|
use app\common\model\product\Product as ProductModel;
|
|
/**
|
* 运营中心
|
*/
|
class Operations extends Controller
|
{
|
// 用户
|
private $user;
|
// 运营中心用户
|
private $operations;
|
// 运营中心设置
|
private $setting;
|
/**
|
* 构造方法
|
*/
|
public function initialize()
|
{
|
// 用户信息
|
$this->user = $this->getUser();
|
// 运营中心用户信息
|
$this->operations = OperationsUserModel::detail($this->user['user_id']);
|
// 运营中心设置
|
$this->setting = Setting::getAll();
|
}
|
|
/**
|
* 运营中心
|
*/
|
public function center()
|
{
|
// 是否为运营中心用户
|
$is_operations = $this->isOperationsUser();
|
if ($is_operations) {
|
event('OperationsUserGrade', $this->user['user_id']);
|
$this->operations = OperationsUserModel::detail($this->user['user_id']);
|
}
|
$setting = $this->setting['basic']['values'];
|
// 购买商品
|
$productList = [];
|
if ($setting['become'] == '100'|| $setting['become'] == '110') {
|
if ($setting['become__buy_product_ids']) {
|
$productList = (new ProductModel)->getListByIds($setting['become__buy_product_ids']);
|
}
|
}
|
return $this->renderSuccess('', [
|
// 当前是否为运营中心用户
|
'is_operations' => $is_operations,
|
// 当前用户信息
|
'user' => $this->user,
|
// 运营中心用户信息
|
'operations' => $this->operations,
|
// 背景图
|
'background' => $this->setting['background']['values']['index'],
|
// 页面文字
|
'words' => $this->setting['words']['values'],
|
'setting' => $setting,
|
'productList' => $productList,
|
]);
|
}
|
|
/**
|
* 运营中心提现信息
|
*/
|
public function cash($platform = '')
|
{
|
// 如果来源是小程序, 则获取小程序订阅消息id.获取售后通知.
|
$template_arr = MessageModel::getMessageByNameArr($platform, ['operations_cash_user']);
|
return $this->renderSuccess('', [
|
// 运营中心用户信息
|
'operations' => $this->operations,
|
// 结算设置
|
'settlement' => $this->setting['settlement']['values'],
|
// 背景图
|
'background' => $this->setting['background']['values']['cash_apply'],
|
// 页面文字
|
'words' => $this->setting['words']['values'],
|
// 小程序消息
|
'template_arr' => $template_arr
|
]);
|
}
|
|
/**
|
* 是否为运营中心用户
|
* @return bool
|
*/
|
private function isOperationsUser()
|
{
|
return !!$this->operations && !$this->operations['is_delete'];
|
}
|
|
}
|