705 lines
16 KiB
PHP
705 lines
16 KiB
PHP
<?php
|
|
|
|
require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'BaseMethodHelper.php';
|
|
require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'game_config.inc.php';
|
|
require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'Tangjian.php';
|
|
|
|
class Admin extends Tangjian
|
|
{
|
|
/**
|
|
* 校验管理员信息
|
|
* @param $params
|
|
* @throws Exception
|
|
*/
|
|
protected function _checkAdmin($params)
|
|
{
|
|
if($params['account'] !== 'tiansheng' || $params['password'] !== 'tiansheng88!')
|
|
throw new Exception('账号密码错误', 2000);
|
|
}
|
|
|
|
|
|
/**
|
|
* manage 登录
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function login($request, &$return)
|
|
{
|
|
try {
|
|
/*$params = $this->checkParams($request, array(
|
|
'account/R', 'password/R'
|
|
));*/
|
|
|
|
//$this->_checkAdmin($params);
|
|
|
|
$return->biz_content = ['ok'];
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取所有代理商
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function agentList($request, &$return)
|
|
{
|
|
try {
|
|
$Agent = new \models\Agent();
|
|
$agent_list = $Agent->getAllAgentList();
|
|
|
|
$return->biz_content = $agent_list;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取所有渠道
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function channelList($request, &$return)
|
|
{
|
|
try {
|
|
/*$params = $this->checkParams($request, array(
|
|
'account/R', 'password/R'
|
|
));*/
|
|
|
|
//$this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$channel_list = $Agent->getAllChannelList();
|
|
|
|
$return->biz_content = $channel_list;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 查询代理信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function salesInfo($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/ 'salesid/R', 'agentid/R', 'channelid/R'
|
|
));
|
|
|
|
//$this->_checkAdmin($params);
|
|
|
|
$Sales = new \models\SalesUser();
|
|
$result = $Sales->querySalesInfo($params);
|
|
|
|
if(empty($result)) throw new Exception('暂无该代理信息', 1100);
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 修改代理信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function changeSalesInfo($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'salesid/R', 'agentid/R', 'channelid/R', 'parentid/0', 'global_power/0', 'statistic_type/0', 'is_vip/0', 'announcement/'
|
|
));
|
|
|
|
//$this->_checkAdmin($params);
|
|
|
|
$Sales = new \models\SalesUser();
|
|
$Sales->setSalesInfo($params);
|
|
|
|
|
|
$return->biz_content = ['ok'];
|
|
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 生成新代理商
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function createAgent($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'agentid/R', 'name/R', 'power/R'
|
|
));
|
|
|
|
//$this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$Agent->addAgent($params);
|
|
|
|
$return->biz_content = ['ok'];
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 生成新渠道
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function createChannel($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'agentid/R', 'channelid/R', 'parentid/R', 'name/R', 'logo/R', 'qq/', 'wechat/',
|
|
'is_show_recharge_star/1', 'recharge_roomcard_to_sales/1',
|
|
'become_sales_mode/0', 'invitation_model/0', 'buy_card_mode/0', 'is_open/0'
|
|
));
|
|
|
|
//$this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$Agent->addChannel($params);
|
|
|
|
$return->biz_content = ['ok'];
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 游戏列表
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function gameList($request, &$return)
|
|
{
|
|
try {
|
|
$Agent = new \models\Agent();
|
|
$result = $Agent->getAllGameList();
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 添加游戏
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function createGame($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'channelid/R', 'gameid/R', 'gamename/R', 'logo/R', 'description/R',
|
|
'ios_download_url/R', 'ios_market_type/2', 'ios_app_size/R', 'android_download_url/R', 'android_app_size/R',
|
|
'is_open/1'
|
|
));
|
|
|
|
//$this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$Agent->addGame($params);
|
|
|
|
$return->biz_content = ['ok'];
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 修改游戏
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function saveGame($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'channelid/R', 'gameid/R', 'gamename/R', 'logo/R', 'description/R',
|
|
'ios_download_url/R', 'ios_market_type/2', 'ios_app_size/R', 'android_download_url/R', 'android_app_size/R',
|
|
'is_open/1', 'id/R'
|
|
));
|
|
|
|
//$this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$Agent->setGameInfo($params);
|
|
|
|
$return->biz_content = ['ok'];
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 获取代理商信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function queryAgentInfo($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'id/R'
|
|
));
|
|
|
|
// $this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$result = $Agent->getAgentInfo($params);
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取渠道信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function queryChannelInfo($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'id/R'
|
|
));
|
|
|
|
// $this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$result = $Agent->getChannelInfo($params);
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取游戏信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function queryGameInfo($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'id/R'
|
|
));
|
|
|
|
// $this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$result = $Agent->getGameInfo($params);
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 修改代理商信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function changeAgentInfo($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'agentid/R', 'name/R', 'power/R', 'id/R'
|
|
));
|
|
|
|
// $this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$result = $Agent->setAgentInfo($params);
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 修改渠道信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function changeChannelInfo($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
/*'account/R', 'password/R',*/
|
|
'agentid/R', 'channelid/R', 'parentid/R', 'name/R', 'logo/R', 'qq/', 'wechat/',
|
|
'is_show_recharge_star/1', 'recharge_roomcard_to_sales/1',
|
|
'become_sales_mode/0', 'invitation_model/0', 'buy_card_mode/0', 'share_title/', 'share_desc/',
|
|
'share_img/', 'share_text/', 'pay_desc/', 'announcement/', 'is_open/0', 'id/R'
|
|
));
|
|
|
|
// $this->_checkAdmin($params);
|
|
|
|
$Agent = new \models\Agent();
|
|
$result = $Agent->setChannelInfo($params);
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 管理员 给 (代理、玩家) 充 (房卡、星星)
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function recharge($request, &$return)
|
|
{
|
|
try {
|
|
/**
|
|
* userid userid 充值人(代理、玩家)
|
|
* u_type user_type 1:玩家 2:代理
|
|
* p_type production_type 1:房卡 2:金币
|
|
*/
|
|
$params = $this->checkParams($request, array(
|
|
'agentid/R', 'channelid/R', 'userid/R', 'adminid/R',
|
|
'u_type/0', 'p_type/0', 'amount/0'
|
|
));
|
|
|
|
if($params['amount'] < 1)
|
|
throw new Exception('数量必须大于0', 2001);
|
|
|
|
$Sales = new \models\SalesUser();
|
|
if($params['u_type'] === 1) {
|
|
$Sales->playerRecharge($params);
|
|
} elseif ($params['u_type'] === 2) {
|
|
$Sales->salesRecharge($params);
|
|
} else {
|
|
throw new Exception('用户类型错误', 2000);
|
|
}
|
|
|
|
$return->biz_content = ['ok'];
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 指定渠道的商品列表
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function productList($request, &$return)
|
|
{
|
|
try {
|
|
$Agent = new \models\Agent();
|
|
|
|
$params = $this->checkParams($request, array(
|
|
'agentid/R'
|
|
));
|
|
|
|
$return->biz_content = $Agent->getAllProductList($params['agentid']);
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 单个产品信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function productInfo($request, &$return)
|
|
{
|
|
try {
|
|
$Agent = new \models\Agent();
|
|
|
|
$params = $this->checkParams($request, array(
|
|
'idx/R'
|
|
));
|
|
|
|
$return->biz_content = $Agent->getProductInfo($params['idx']);
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 单个商品信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function changeProductInfo($request, &$return)
|
|
{
|
|
try {
|
|
$Agent = new \models\Agent();
|
|
|
|
$params = $this->checkParams($request, array(
|
|
'sapr_agentid/R', 'sapr_type/r', 'sapr_name/R', 'sapr_amount/R', 'sapr_money/R', 'sapr_memo/',
|
|
'sapr_state/r', 'product_type/r', 'parent_id/', 'sort/0', 'make_vip/r', 'idx/R'
|
|
));
|
|
|
|
$return->biz_content = $Agent->setProductInfo($params);
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 添加商品
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function addProductInfo($request, &$return)
|
|
{
|
|
try {
|
|
$Agent = new \models\Agent();
|
|
|
|
$params = $this->checkParams($request, array(
|
|
'sapr_agentid/R', 'sapr_type/r', 'sapr_name/R', 'sapr_amount/R', 'sapr_money/R', 'sapr_memo/',
|
|
'sapr_state/r', 'product_type/r', 'parent_id/', 'sort/0', 'make_vip/r'
|
|
));
|
|
|
|
$return->biz_content = $Agent->addProductInfo($params);
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 茶水费配置
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function agentServiceConfig($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
'agentid/R', 'channelid/R'
|
|
));
|
|
|
|
$Agent = new \models\Agent();
|
|
$result = $Agent->getAgentServiceConfig($params);
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 单个茶水费配置
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function agentServiceConfigSingle($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
'id/R'
|
|
));
|
|
|
|
$Agent = new \models\Agent();
|
|
$result = $Agent->getAgentServiceConfigSingle($params['id']);
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 单个茶水费配置
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function agentServiceConfigSave($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
'id/R', 'min_value/r', 'max_value/r', 'type/r', 'value/r'
|
|
));
|
|
|
|
$Agent = new \models\Agent();
|
|
$Agent->getAgentServiceConfigSave($params);
|
|
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 玩家的上级信息
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function playerParentInfo($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
'agentid/R', 'channelid/R', 'playerid/R'
|
|
));
|
|
|
|
$User = new \models\SalesUser();
|
|
$result = $User->getPlayerParentInfo($params);
|
|
|
|
$return->biz_content = $result;
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 修改玩家上级
|
|
* @param $request
|
|
* @param $return
|
|
* @return bool
|
|
*/
|
|
public function setPlayerParent($request, &$return)
|
|
{
|
|
try {
|
|
$params = $this->checkParams($request, array(
|
|
'agentid/R', 'channelid/R', 'playerid/R', 'parentid/r'
|
|
));
|
|
|
|
$User = new \models\SalesUser();
|
|
$User->setPlayerParent($params);
|
|
|
|
//if(!$result) throw new Exception('修改失败', 1000);
|
|
|
|
$return->biz_content = ['ok'];
|
|
return true;
|
|
}
|
|
catch (Exception $e) {
|
|
$return->SetErrors($e->getCode(), $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
} |