You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1310 lines
56 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace Admin\Controller;
use User\Api\UserApi as UserApi;
use OSS\OssClient;
use OSS\Core\OSsException;
use Qiniu\Storage\BucketManager;
use Qiniu\Auth;
use Think\Controller;
use BaiduBce\BceClientConfigOptions;
use BaiduBce\Util\Time;
use BaiduBce\Util\MimeTypes;
use BaiduBce\Http\HttpHeaders;
use BaiduBce\Services\Bos\BosClient;
use BaiduBce\Services\Bos\CannedAcl;
use BaiduBce\Services\Bos\BosOptions;
use BaiduBce\Auth\SignOptions;
use BaiduBce\Log\LogFactory;
use Admin\Model\AuthRuleModel;
use Admin\Model\AuthGroupModel;
use Base\Service\GameService;
/**
* 后台首页控制器
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
class GameController extends ThinkController
{
//private $table_name="Game";
const model_name = 'game';
/**
*游戏信息列表
*/
public function lists()
{
if (isset($_REQUEST['game_name'])) {
$extend['game_name'] = ['like', "{$_REQUEST['game_name']}%"];
unset($_REQUEST['game_name']);
}
if (isset($_REQUEST['sdk_version1'])) {
$extend['sdk_version'] = $_REQUEST['sdk_version1'];
unset($_REQUEST['sdk_version1']);
}
if (!empty($_REQUEST['server_type'])) {
$extend['server_type'] = intval($_REQUEST['server_type']);
unset($_REQUEST['server_type']);
}
if (isset($_REQUEST['recommend_status'])) {
$extend['recommend_status'] = $_REQUEST['recommend_status'];
unset($_REQUEST['recommend_status']);
}
if (isset($_REQUEST['game_status'])) {
$extend['game_status'] = $_REQUEST['game_status'];
unset($_REQUEST['game_status']);
}
if (isset($_REQUEST['apply_status'])) {
$extend['apply_status'] = $_REQUEST['apply_status'];
unset($_REQUEST['apply_status']);
}
if (isset($_REQUEST['online_status'])) {
$extend['online_status'] = $_REQUEST['online_status'];
unset($_REQUEST['online_status']);
}
if ($_GET['type'] == 1 || $_GET['type'] == '') {
//$extend['apply_status']=1;
$extend['developers'] = array('EQ', 0);
} else {
$extend['developers'] = array('GT', 0);
$this->assign('show_status', 1);
}
$this->checkListOrCountAuthRestMap($map,[]);
$extend['order'] = 'sort desc, id desc';
//$extend['for_show_pic_list']='icon';//列表显示图片
$this->m_title = '游戏列表';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Game/lists', 'status' => 1])->find());
parent::lists(self::model_name, $_GET["p"], $extend);
}
public function get_game_set()
{
$map["game_id"] = $_REQUEST['game_id'];
$find = M('game_set', 'tab_')->where($map)->find();
$find['mdaccess_key'] = get_ss($find['access_key']);
echo json_encode(array("status" => 1, "data" => $find));
}
public function get_game_source()
{
$map["game_id"] = $_REQUEST['game_id'];
$data = M('GameSource', 'tab_')->field('file_url')->where($map)->find();
if (empty($data)) {
$result = array('status' => 0, 'dow_url' => '');
} else {
$result = array('status' => 1, 'dow_url' => $data['file_url']);
}
echo json_encode($result);
}
/**
*游戏原包列表
*/
public function source()
{
$extend = array('field_time' => 'create_time');
parent::lists('Source', $_GET["p"], $extend);
}
/**
*游戏更新列表
*/
public function update()
{
parent::lists('Update', $_GET["p"]);
}
/**
*添加游戏原包
*/
public function add_source()
{
if (IS_POST) {
if (empty($_POST['game_id']) || empty($_POST['file_type'])) {
$this->error('游戏名称或类型不能为空');
}
$map['game_id'] = $_POST['game_id'];
$map['file_type'] = $_POST['file_type'];
$d = D('Source')->where($map)->find();
$source = A('Source', 'Event');
if (empty($d)) {
$source->add_source();
} else {
$source->update_source($d['id']);
}
} else {
$this->display();
}
}
/**
*删除原包
*/
public function del_game_source($model = null, $ids = null)
{
$source = D("Source");
$id = array_unique((array)$ids);
$map = array('id' => array('in', $id));
$list = $source->where($map)->select();
foreach ($list as $key => $value) {
$file_url = APP_ROOT . $value['file_url'];
unlink($file_url);
}
$model = M('Model')->getByName("source"); /*通过Model名称获取Model完整信息*/
parent::del($model["id"], $ids, "tab_game_");
}
public function add()
{
if (IS_POST) {
$gameService = new GameService();
$_POST['introduction'] = str_replace(array("\r\n", "\r", "\n"), "~~", $_POST['introduction']);
if ($_POST['game_name'] == '') {
$this->error('游戏名称不能为空!');
exit;
}
if ($_POST['marking'] == '') {
$this->error('游戏标示不能为空!');
exit;
}
$downloadWays = $_POST['download_ways'] ?? [];
if (in_array(GameService::DOWNLOAD_BETA, $downloadWays)) {
if (empty($_POST['beta_url'])) {
return $this->error("请在极速版下载按钮开启的情况填写极速版下载链接");
}
if (!preg_match("/^((https|http|itms-beta)?:\/\/)[^\s]+/i", $_POST['beta_url'])) {
return $this->error("请填写正确的极速版下载链接");
}
}
if ($_POST['unique_code'] && $gameService->isUniqueCodeExists($_POST['unique_code'])) {
return $this->error("聚合游戏标识已存在");
}
$_POST['relation_game_name'] = $_POST['game_name'];
if ($_POST['sdk_version'] == 1) {
unset($_POST['ios_game_address']);
$_POST['game_name'] = $_POST['game_name'] . '(安卓版)';
} else {
unset($_POST['add_game_address']);
$_POST['game_name'] = $_POST['game_name'] . '(苹果版)';
}
if (!empty($_POST['display_site'])) {
$_POST['display_site'] = implode(',', $_POST['display_site']);
} else {
$_POST['display_site'] = '';
}
$content = $_POST['content'];
if (!empty($content)) {
$_POST['detail_content'] = $content;
} else {
$_POST['detail_content'] = '';
}
$pinyin = new \Think\Pinyin();
$num = mb_strlen($_POST['game_name'], 'UTF8');
$short = '';
for ($i = 0; $i < $num; $i++) {
$str = mb_substr($_POST['game_name'], $i, $i + 1, 'UTF8');
$short .= $pinyin->getFirstChar($str);
}
//$_POST['material_url'] = $_POST['file_url'].$_POST['file_name'];
$_POST['discount'] == '' ? $_POST['discount'] = 10 : $_POST['discount'];
$_POST['short'] = $short;
$_POST['download_ways'] = $gameService->getDownLoadWaysValue($downloadWays);
$gameBelongId = I('post.game_belong_id', 0);
$gameAssistantId = I('post.game_assistant_id', 0);
if ($gameAssistantId > 0 && $gameBelongId == 0) {
return $this->error("请选择游戏所属商务");
}
$members = M("member")
->field(['uid', 'real_name'])
->where(['uid' => ['in', [$gameBelongId, $gameAssistantId]]])
->select();
$members = index_by_column('real_name', $members);
$_POST['game_belong_name'] = $members[$gameBelongId] ?? '';
$_POST['game_assistant_name'] = $members[$gameAssistantId] ?? '';
$game = D(self::model_name);//M('$this->$model_name','tab_');
$res = $game->update();
if (!$res) {
$this->error($game->getError());
} else {
$baseData = [
'id' => $res['id'],
'name' => str_replace('(安卓版)', '', str_replace('(苹果版)', '', $_POST['game_name'])),
'sdk_version' => $_POST['sdk_version'],
];
$gameService->saveBaseGame($baseData);
M('promote_company', 'tab_')
->where(['company_belong' => ['not in', [1, 2]]])
->save(['game_ids' => ['exp', 'trim(BOTH "," FROM concat(game_ids, ",", ' . $res['relation_game_id'] . '))']]);
$subSql = M('promote_company', 'tab_')->field('id')->where(['company_belong' => ['not in', [1, 2]]])->select(false);
M('promote', 'tab_')
->where(['_string' => 'company_id in (' . $subSql . ') or company_id=0'])
->save(['game_ids' => ['exp', 'trim(BOTH "," FROM concat(game_ids, ",", ' . $res['id'] . '))']]);
\Think\Log::actionLog('Game/add', 'Game', 1);
//操作日志
addOperationLog(array(
"op_type"=>0,
"key"=>$_POST['game_name'],
"url"=>U("Game/lists",array("game_name"=>$_POST['game_name']))
));
$this->success($_POST['id'] ? '更新成功' : '新增成功', U('lists'));
}
} else {
if ($_GET['type'] == 1 || $_GET['type'] == "") {
$show_status = 1;
$this->assign('show_status', $show_status);
}
$this->meta_title = '新增游戏';
$this->m_title = '游戏列表';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Game/lists', 'status' => 1])->find());
$this->display();
}
}
public function relation()
{
if (IS_POST) {
if ($_POST['game_name'] == '') {
$this->error('游戏名称不能为空!');
exit;
}
$_POST['relation_game_name'] = $_POST['game_name'];
if ($_POST['sdk_version'] == 1) {
if ($_POST['dow_prot'] == 0) {
unset($_POST['add_game_address']);
}
$_POST['game_name'] = $_POST['game_name'] . '(安卓版)';
} else {
if ($_POST['dow_prot'] == 0) {
unset($_POST['ios_game_address']);
}
$_POST['game_name'] = $_POST['game_name'] . '(苹果版)';
}
if (!empty($_POST['display_site'])) {
$_POST['display_site'] = implode(',', $_POST['display_site']);
} else {
$_POST['display_site'] = '';
}
$relation_game_id = $_REQUEST['relation_game_id'];
$inv = D(self::model_name)->where("relation_game_id = '{$relation_game_id}'")->find();
$_POST['select_package_name'] = $inv['select_package_name'];
$pinyin = new \Think\Pinyin();
$num = mb_strlen($_POST['game_name'], 'UTF8');
for ($i = 0; $i < $num; $i++) {
$str = mb_substr($_POST['game_name'], $i, $i + 1, 'UTF8');
$short .= $pinyin->getFirstChar($str);
}
$_POST['short'] = $short;
$game = D(self::model_name);//M('$this->$model_name','tab_');
$res = $game->update();
if (!$res) {
$this->error($game->getError());
} else {
$gameService = new GameService();
$baseData = [
'id' => $res['id'],
'name' => str_replace('(安卓版)', '', str_replace('(苹果版)', '', $_POST['game_name'])),
'sdk_version' => $_POST['sdk_version'],
'relation_game_id' => $_POST['relation_game_id'],
];
$gameService->saveBaseGame($baseData);
$subSql = M('promote_company', 'tab_')->field('id')->where(['company_belong' => ['not in', [1, 2]]])->select(false);
M('promote', 'tab_')
->where(['_string' => 'company_id in (' . $subSql . ') or company_id=0'])
->save(['game_ids' => ['exp', 'trim(BOTH "," FROM concat(game_ids, ",", ' . $res['id'] . '))']]);
addOperationLog(array(
"op_type"=>0,
"key"=>$_POST['game_name'],
"url"=>U("Game/lists",array("game_name"=>$_POST['game_name']))
));
$this->success($_POST['id'] ? '更新成功' : '新增成功', U('lists'));
}
} else {
$_REQUEST['id'] || $this->error('id不能为空');
$map['relation_game_id'] = $_REQUEST['id'];
$map['id'] = $_REQUEST['id'];
$map1 = $map;
$map1['id'] = array('neq', $_REQUEST['id']);
$inv = D(self::model_name)->where($map)->find();
$invalid = D(self::model_name)->where($map1)->find();
if ($invalid || $inv == '') {
$this->error('关联数据错误');
}
if ($_GET['type'] != 2) {
$this->assign('show_status', 1);
}
$suffix = $inv['sdk_version'] == 1 ? "PGB" : "AZB";
$inv['short'] = substr($inv['short'], 0, -3) . $suffix;
$this->assign('data', $inv);
$this->meta_title = '关联游戏';
$this->display();
}
}
public function delSociatyGames() {
$res = ['code' => 10000];
$id = $_REQUEST['id'];
$delRest = M('sociaty_games','tab_')->where(['id'=>$id])->delete();
if($delRest) {
$res['code'] = 10001;
$this->ajaxReturn($res);
}
}
/*
* ALTER TABLE `tab_game`
ADD COLUMN `kefu_qq_type` tinyint(2) NULL DEFAULT 0 COMMENT '客服qq类型0跟随系统 1不显示 2其他' AFTER `select_package_name`,
ADD COLUMN `kefu_qq` varchar(255) NULL DEFAULT '' COMMENT 'kefu_qq_type为2 时有效' AFTER `kefu_qq_type`;
*/
public function edit($id = null)
{
if (IS_POST) {
$game = M('game', 'tab_')->where(['id' => $id])->find();
if (!$game) {
$this->error('游戏不存在!');
exit;
}
if ($_POST['game_score'] < 0 || $_POST['game_score'] > 5) {
$this->error('游戏评分只能为0-5之间的数字');
exit;
}
if (mb_strlen($_POST['features']) > 30) {
$this->error('一句话简介不能超过30个字');
exit;
}
$downloadWays = $_POST['download_ways'] ?? [];
if (in_array(GameService::DOWNLOAD_BETA, $downloadWays)) {
if (empty($_POST['beta_url'])) {
return $this->error("请在极速版下载按钮开启的情况填写极速版下载链接");
}
if (!preg_match("/^((https|http|itms-beta)?:\/\/)[^\s]+/i", $_POST['beta_url'])) {
return $this->error("请填写正确的极速版下载链接");
}
}
$gameService = new GameService();
if ($_POST['unique_code'] && $gameService->isUniqueCodeExists($_POST['unique_code'], $game['relation_game_id'], 'relation_game_id')) {
return $this->error("聚合游戏标识已存在");
}
/*if($_POST['apply_status']==0&&$_POST['game_status']==1){
$this->error('游戏未审核不允许显示');//游戏添加完成
}*/
$_POST['introduction'] = str_replace(array("\r\n", "\r", "\n"), "~~", $_POST['introduction']);
if (!empty($_POST['display_site'])) {
$_POST['display_site'] = implode(',', $_POST['display_site']);
} else {
$_POST['display_site'] = '';
}
$content = $_POST['content'];
$gameModel = D(self::model_name);//M('$this->$model_name','tab_');
$_POST['discount'] == '' ? $_POST['discount'] = 10 : $_POST['discount'];
$_POST['detail_content'] = $content;
$_POST['pay_config'] = json_encode($_POST['pay_config']);
$_POST['download_ways'] = $gameService->getDownLoadWaysValue($downloadWays);
$gameBelongId = I('post.game_belong_id', 0);
$gameAssistantId = I('post.game_assistant_id', 0);
if ($gameAssistantId > 0 && $gameBelongId == 0) {
return $this->error("请选择游戏所属商务");
}
$members = M("member")
->field(['uid', 'real_name'])
->where(['uid' => ['in', [$gameBelongId, $gameAssistantId]]])
->select();
$members = index_by_column('real_name', $members);
$_POST['game_belong_name'] = $members[$gameBelongId] ?? '';
$_POST['game_assistant_name'] = $members[$gameAssistantId] ?? '';
unset($_POST['apply_auth']);
$res = $gameModel->update();
$id = $res["id"];
$sibling = D("Game")->find($id);
$map['relation_game_id'] = $sibling['relation_game_id'];
$sid = $sibling['id'];
$map['id'] = array('neq', $sid);
$another = D("Game")->where($map)->find(); //获取另一个所有
$baseData = [
'id' => $id,
'name' => str_replace('(安卓版)', '', str_replace('(苹果版)', '', $sibling['game_name'])),
'relation_game_id' => $another ? $another['id'] : 0,
'sdk_version' => $sibling['sdk_version'],
];
$gameService->saveBaseGame($baseData);
$otherData = [];
$otherData['apply_auth'] = $sibling['apply_auth'];
$otherData['game_type_id'] = $sibling['game_type_id'];
$otherData['dow_num'] = $sibling['dow_num'];
$otherData['game_type_name'] = $sibling['game_type_name'];
$otherData['category'] = $sibling['category'];
$otherData['recommend_status'] = $sibling['recommend_status'];
$otherData['select_package_name']= $_POST['select_package_name'];
$otherData['sort'] = $sibling['sort'];
$otherData['game_score'] = $sibling['game_score'];
$otherData['features'] = $sibling['features'];
$otherData['flooring_page_imgs'] = $sibling['flooring_page_imgs'];
$otherData['introduction'] = $sibling['introduction'];
$otherData['icon'] = $sibling['icon'];
$otherData['cover'] = $sibling['cover'];
$otherData['screenshot'] = $sibling['screenshot'];
$otherData['material_url'] = $sibling['material_url'];
$otherData['game_detail_cover'] = $sibling['game_detail_cover'];
$otherData['first_level_name'] = $sibling['first_level_name'];
$otherData['second_level_name'] = $sibling['second_level_name'];
$otherData['third_level_name'] = $sibling['third_level_name'];
$otherData['first_level'] = $sibling['first_level'];
$otherData['second_level'] = $sibling['second_level'];
$otherData['third_level'] = $sibling['third_level'];
$otherData['display_site'] = $sibling['display_site'];
$otherData['back_describe'] = $sibling['back_describe'];
$otherData['dow_icon'] = $sibling['dow_icon'];
$otherData['back_map'] = $sibling['back_map'];
$otherData['unique_code'] = $sibling['unique_code'];
$otherData['flooring_page_video'] = $sibling['flooring_page_video'];
$otherData['flooring_page_video_cover'] = $sibling['flooring_page_video_cover'];
$otherData['kefu_qq'] = I('post.kefu_qq');
$otherData['kefu_qq_type'] = I('post.kefu_qq_type');
$otherData['data_share'] = I('post.data.share');
$otherData['game_belong_id'] = I('post.game_belong_id');
$otherData['game_belong_name'] = $_POST['game_belong_name'];
$otherData['game_assistant_id'] = I('post.game_assistant_id');
$otherData['game_assistant_name'] = $_POST['game_assistant_name'];
$otherData['data_share'] = I('post.data_share');
M('Game', 'tab_')->data($otherData)->where(array('id' => $another['id']))->save();
//同时修改代充游戏折扣
$set_fidel['status'] = 1;
$set_fidel['game_id'] = $id;
$set_fidel['discount'] = $_POST['discount'];
$promoteModel = new \Admin\Model\PromoteWelfareModel();
$promoteModel->set_game_discount($set_fidel);
if (!$res) {
$this->error($gameModel->getError());
} else {
\Think\Log::actionLog('Game/edit', 'Game', 1);
addOperationLog(array(
"op_type"=>1,
"key"=>$sibling ['game_name'],
"url"=>U("Game/lists",array("game_name"=>$sibling ['game_name']))
));
$this->success($_POST['id'] ? '更新成功' : '新增成功', U('lists', array('type' => I('post.type'), 'p' => I('request.p'))));
}
} else {
$id || $this->error('id不能为空');
$data = D(self::model_name)->detailback($id);
$data['pay_config'] = json_decode($data['pay_config'],true);
$data || $this->error('数据不存在!');
if (!empty($data['and_dow_address'])) {
$data['and_dow_address'] = ltrim($data['and_dow_address'], '.');
}
if (!empty($data['ios_dow_address'])) {
$data['ios_dow_address'] = ltrim($data['ios_dow_address'], '.');
}
if ($_GET['type'] != 2) {
$this->assign('show_status', 1);
}
if (!empty($data['flooring_page_imgs'])) {
$data['flooring_page_imgs_data'] = explode(',', $data['flooring_page_imgs']);
}
if (!empty($data['screenshot'])) {
$data['screenshot_data'] = explode(',', $data['screenshot']);
}
if (!empty($data['cover'])) {
$data['cover_data'] = explode(',', $data['cover']);
}
if (!empty($data['icon'])) {
$data['icon_data'] = explode(',', $data['icon']);
}
$apply_auth = M('game','tab_')->where(['id'=>$id])->getField('apply_auth');
$this->assign('apply_auth',$apply_auth);
$sociatyGames = M('sociaty_games','tab_')->where(['game_id'=>$id])->select();
$sociatyGamesData = [];
if(!empty($sociatyGames)) {
foreach($sociatyGames as $key => $value) {
$sociatyGamesData[$key]['id'] = $value['id'];
if($value['promote_id'] == -1) {
$sociatyGamesData[$key]['promoteAccount'] = C('OFFICIEL_CHANNEL');
}else {
$promoteAccount = M('promote','tab_')->where(['id'=>$value['promote_id']])->getField('account');
$sociatyGamesData[$key]['promoteAccount'] = $promoteAccount;
}
$sociatyGamesData[$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']);
$applyStatus = M('apply','tab_')->field('id')->where(['game_id'=>$value['game_id'],'status'=>1])->select();
if(empty($applyStatus)) {
$sociatyGamesData[$key]['isPromote'] = "";
}else {
$sociatyGamesData[$key]['isPromote'] = "";
}
}
}
$this->assign('sociatygames',$sociatyGamesData);
$data['introduction'] = str_replace("~~", "\r\n", $data['introduction']);
$this->assign('data', $data);
$this->assign('game_id', $id);
$game_ratio = M('cp_game_ratio', 'tab_')->where(array('is_del'=>"0","game_id"=>$id))->order('id asc')->select();
$this->meta_title = '编辑游戏';
$this->m_title = '游戏列表';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Game/lists', 'status' => 1])->find());
$this->assign('game_ratio',$game_ratio);
$auth_group = M('AuthGroup')->where( array('status'=>array('egt','0'),'module'=>'admin','type'=>AuthGroupModel::TYPE_ADMIN) )
->getfield('id,id,title,rules');
$empower_type = M('AuthGroup')->field('data_empower_type')->where(array('id'=>1))->find();
$this->assign('data_empower_type', $empower_type['data_empower_type']);
$this->assign('auth_group', $auth_group);
$this->display();
}
}
public function set_status($model = 'Game')
{
parent::set_status($model);
}
public function del($model = null, $ids = null)
{
$model = M('Model')->getByName(self::model_name); /*通过Model名称获取Model完整信息*/
$model = M('Model')->find($model["id"]);
$model || $this->error('模型不存在!');
$ids = array_unique((array)I('request.ids', null));
if (empty($ids)) {
$this->error('请选择要操作的数据!');
}
foreach ($ids as $key => $value) {
$id = $value;
$gda = M('Game', 'tab_')->where(array('id' => $id))->find();
$map['id'] = array('neq', $id);
$map['relation_game_id'] = $gda['relation_game_id'];
$anogame = M('Game', 'tab_')->where($map)->find();
if ($anogame) {
M('Game', 'tab_')->where($map)->data(array('relation_game_id' => $anogame['id']))->save();
}
$pic = M('Picture')->find($gda['icon']);
$count = M('Game', 'tab_')->where(array('icon' => $gda['icon']))->count();//统计icon是否为多个游戏的图标
if ($pic != '' && $count == 1) { //只有一个游戏指向这个图标
if ($pic['oss_url'] != '') {
$this->del_oss($gda['icon']); //删除oss里图片
} elseif ($pic['bos_url'] != '') {
$this->del_bos($gda['icon']); //删除bos里的图片
}
unlink('.' . $pic['path']); //删除图片
M('Picture')->where(array('id' => $gda['icon']))->delete();
}
$gs = M('GameSource', 'tab_')->where(array('game_id' => $id))->find();
if ($gs) {
unlink($gs['file_url']); //删除原包
M('GameSource', 'tab_')->where(array('game_id' => $id))->delete();
}
$apply = M('apply', 'tab_')->where(array('game_id' => $id))->find();
if ($apply) {
if (substr($apply['pack_url'], 0, 4) == 'http') {
if (strpos($apply['pack_url'], 'bcebos') !== false) { //$value['pack_url']这个字符串是否包含'bcebos'.'bcebos'可以判断是否为bos存储
$objectname = basename($apply['pack_url']);
$this->delete_bos($objectname); //删除bos里的原包
} elseif (strpos($apply['pack_url'], 'oss') !== false) {
$objectname = basename($apply['pack_url']);
$this->delete_oss($objectname);
}
}
$file_url = "./Uploads/GamePack/" . basename($apply['pack_url']);//删除本地原包
unlink($file_url);
M('Apply', 'tab_')->where(array('game_id' => $id))->delete();
}
//操作日志
addOperationLog(array(
"op_type"=>2,
"key"=>$gda['game_name'],
"url"=>U("Game/lists")
));
}
$del_map['game_id'] = ['in', $ids];
M('giftbag', 'tab_')->where($del_map)->delete();
M('server', 'tab_')->where($del_map)->delete();
\Think\Log::actionLog('Game/del', 'Game', 1);
parent::remove($model["id"], 'Set', $ids);
}
//开放类型
public function openlist()
{
$extend = array();
parent::lists("opentype", $_GET["p"], $extend);
}
//新增开放类型
public function addopen()
{
if (IS_POST) {
$game = D("opentype");
if ($game->create() && $game->add()) {
$this->success("添加成功", U('openlist'));
} else {
$this->error("添加失败", U('openlist'));
}
} else {
$this->display();
}
}
//编辑开放类型
public function editopen($ids = null)
{
$game = D("opentype");
if (IS_POST) {
if ($game->create() && $game->save()) {
$this->success("修改成功", U('openlist'));
} else {
$this->error("修改失败", U('openlist'));
}
} else {
$map['id'] = $ids;
$date = $game->where($map)->find();
$this->assign("data", $date);
$this->display();
}
}
//删除开放类型
public function delopen($model = null, $ids = null)
{
$model = M('Model')->getByName("opentype"); /*通过Model名称获取Model完整信息*/
parent::del($model["id"], $ids);
}
/**
* 文档排序
* @author huajie <banhuajie@163.com>
*/
public function sort()
{
//获取左边菜单$this->getMenus()
if (IS_GET) {
$map['status'] = 1;
$list = D('Game')->where($map)->field('id,game_name')->order('sort DESC, id DESC')->select();
$this->assign('list', $list);
$this->meta_title = '游戏排序';
$this->display();
} elseif (IS_POST) {
$ids = I('post.ids');
$ids = array_reverse(explode(',', $ids));
foreach ($ids as $key => $value) {
$res = D('Game')->where(array('id' => $value))->setField('sort', $key + 1);
}
if ($res !== false) {
$this->success('排序成功!');
} else {
$this->error('排序失败!');
}
} else {
$this->error('非法请求!');
}
}
/*
删除oss里的object
param id 图片id
*/
public function del_oss($id)
{
$data = M('picture')->where("id=$id")->find();
if (!empty($data)) {
if (!empty($data['oss_url'])) {
$objectname = basename($data['oss_url']); //返回路径中的文件名部分(带后缀)
$oss = A('Admin/Oss');
$res = $oss->delete_game_pak_oss($objectname);
}
}
}
/**
*删除OSS原包
* param name 原包名
*/
public function delete_oss($objectname)
{
/**
* 根据Config配置得到一个OssClient实例
*/
try {
Vendor('OSS.autoload');
$ossClient = new \OSS\OssClient(C("oss_storage.accesskeyid"), C("oss_storage.accesskeysecr"), C("oss_storage.domain"));
} catch (OssException $e) {
$this->error($e->getMessage());
}
$bucket = C('oss_storage.bucket');
$objectname = "GamePak/" . $objectname;
try {
$ossClient->deleteObject($bucket, $objectname);
return true;
} catch (OssException $e) {
/* 返回JSON数据 */
$this->error($e->getMessage());
}
}
/*
删除bos里的object
param id 图片id
*/
public function del_bos($id)
{
$data = M('picture')->where("id=$id")->find();
if (!empty($data)) {
if (!empty($data['bos_url'])) {
$objectname = basename($data['bos_url']); //返回路径中的文件名部分(带后缀)
$oss = A('Admin/Bos');
$res = $oss->delete_bos($objectname);
}
}
}
/*
删除bos的原包
param name 原包名
*/
public function delete_bos($name)
{
/**
* 根据Config配置得到一个OssClient实例
*/
try {
$BOS_TEST_CONFIG =
array(
'credentials' => array(
'accessKeyId' => C("bos_storage.AccessKey"),
'secretAccessKey' => C("bos_storage.SecretKey"),
),
'endpoint' => C("bos_storage.domain"),
);
require VENDOR_PATH . 'BOS/BaiduBce.phar';
$client = new BosClient($BOS_TEST_CONFIG);
} catch (Exception $e) {
$this->error($e->getMessage());
}
$bucket = C('bos_storage.bucket');
//$path ="icon/". $name; //在bos的路径
$path = "GamePak/" . $name;
$client->deleteObject($bucket, $path);
}
/**
* 商务专员状态修改
* @author 小纯洁
*/
public function changeStatus($field = null, $value = null)
{
$id = array_unique((array)I('ids', 0));
$id = is_array($id) ? implode(',', $id) : $id;
if (empty($id)) {
$this->error('请选择要操作的数据!');
}
$map['id'] = array('in', $id);
$game = M('Game', 'tab_')->where($map)->find();
//开发者游戏 上线与显示同步
if ($game['developers'] > 0 && ($field == "online_status" || $field = 'apply_status' || $field == 'game_status')) {
if ($game['apply_status'] == 0) {
//$this->error('未审核的游戏不能设置游戏状态');
}
$save['apply_status'] = $save['game_status'] = $save['online_status'] = $value;
$save['online_time'] = time();
} else {
$save[$field] = $value;
}
$result = M('Game', 'tab_')->where($map)->save($save);
$msg = "操作";
if ($result !== false) {
if ($field == "pay_status" && $value == 0) {
$this->success("操作成功用户无法在SDK内进行充值操作");
}
$this->success($msg . '成功');
} else {
$this->error($msg . '失败');
}
}
public function game_h5_show()
{
$qrcode_path = 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__ . '/Public/' . MODULE_NAME . '/images' . "/game_h5_show/admin123.png";
$content = "http://www.baidu.com";
$matrixPointSize = 4;
$matrixMarginSize = 4;
$errorCorrectionLevel = 3;
$url = false;
// /$url = __ROOT__ . '/Public/' . MODULE_NAME . '/images'."/game_h5_show/admin123.png";
$url = $this->makecode($qrcode_path, $content, $matrixPointSize, $matrixMarginSize, $errorCorrectionLevel, $url);
$this->assign('url', $url);
$this->display();
}
function makecode($qrcode_path, $content, $matrixPointSize, $matrixMarginSize, $errorCorrectionLevel, $url)
{
/** 参数详情:
* $qrcode_path:logo地址
* $content:需要生成二维码的内容
* $matrixPointSize:二维码尺寸大小
* $matrixMarginSize:生成二维码的边距
* $errorCorrectionLevel:容错级别
* $url:生成的带logo的二维码地址
* */
ob_clean();
Vendor('phpqrcode.phpqrcode');
$object = new \QRcode();
$qrcode_path_new = './Public/Admin/images/QRcode/code' . '_' . date("Ymdhis") . '.png';//定义生成二维码的路径及名称
//$filename = $pathname . "/qrcode_" . time() . ".png";
$object::png($content, $qrcode_path_new, $errorCorrectionLevel, $matrixPointSize, $matrixMarginSize);
$QR = imagecreatefromstring(file_get_contents($qrcode_path_new));//imagecreatefromstring:创建一个图像资源从字符串中的图像流
$logo = imagecreatefromstring(file_get_contents($qrcode_path));
$QR_width = imagesx($QR);// 获取图像宽度函数
$QR_height = imagesy($QR);//获取图像高度函数
$logo_width = imagesx($logo);// 获取图像宽度函数
$logo_height = imagesy($logo);//获取图像高度函数
$logo_qr_width = $QR_width / 4;//logo的宽度
$scale = $logo_width / $logo_qr_width;//计算比例
$logo_qr_height = $logo_height / $scale;//计算logo高度
$from_width = ($QR_width - $logo_qr_width) / 2;//规定logo的坐标位置
imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
/** imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )
* 参数详情:
* $dst_image:目标图象连接资源。
* $src_image:源图象连接资源。
* $dst_x:目标 X 坐标点。
* $dst_y:目标 Y 坐标点。
* $src_x:源的 X 坐标点。
* $src_y:源的 Y 坐标点。
* $dst_w:目标宽度。
* $dst_h:目标高度。
* $src_w:源图象的宽度。
* $src_h:源图象的高度。
* */
Header("Content-type: image/png");
//$url:定义生成带logo的二维码的地址及名称
imagepng($QR, $qrcode_path_new);
return $qrcode_path_new;
}
public function gameQrcodeIme()
{
}
public function companyGames($id)
{
$games = M('Game', 'tab_')
->where(['partner_id'=>$id])
->join("tab_cp_game_ratio on tab_game.id = tab_cp_game_ratio.game_id and begin_total_amount = 0 and is_del = 0", "left")
->field("relation_game_name, game_id, tab_cp_game_ratio.ratio")
->group('relation_game_id')->select();
echo M()->getLastSql();
var_dump($games);
}
public function devide_warn_list($row = 10, $p = 1)
{
$map = ['pdw.status'=>1];
if (!empty($_GET['partner_id'])) {
$map['pdw.partner_id'] = $_GET['partner_id'];
}
if (!empty($_GET['relation_game_id'])) {
$partner = M('Game', 'tab_')->field('partner_id')->where(['relation_game_id'=>$_GET['relation_game_id']])->find();
$map['pdw.partner_id'] = $partner['partner_id'];
}
$list = M('partner_divide_warn', 'tab_')
->alias('pdw')->field("pdw.*, p.partner, group_concat(distinct(g.relation_game_name)) as game_name, group_concat(distinct(g.id)) as game_id")
->join("tab_partner p on p.id = pdw.partner_id")
->join("tab_game g on pdw.partner_id = g.partner_id", 'left')
->where(array_merge($map))
->group('pdw.id, p.partner')
->order('create_time desc')
->page($p, $row)->select();
$count = M('partner_divide_warn', 'tab_')->alias('pdw')->join("tab_game g on pdw.partner_id = g.partner_id", 'left')->group('pdw.id')->where($map)->count();
if (!empty($list)) {
foreach ($list as &$item) {
$item['total_amount'] = M('game_data', 'tab_')->where(['game_id'=>['in',explode(',', $item['game_id'])]])->sum('pay_amount');
}
}
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
}
$partners = M('partner', 'tab_')->field("id, partner")->where(['status'=>1])->order('last_up_time desc')->select();
$this->assign('partners', $partners);
$this->assign('list_data', $list);
$this->display();
}
public function devide_warn_edit($id=0, $delete=0)
{
if (IS_POST) {
if (empty($_POST['advance_amount']) || empty($_POST['warming_amount']) || empty($_POST['warn_frequency']) || empty($_POST['phones'])) {
return $this->error("请填写必填数据");
}
if ($_POST['phones']) {
$_POST['phones'] = array_unique($_POST['phones']);
foreach ($_POST['phones'] as $phone) {
if (!preg_match('/^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/', $phone)) {
return $this->error("请输入正确的手机号码:{$phone}");
}
}
$_POST['phones'] = json_encode($_POST['phones']);
} else {
$_POST['phones'] = '[]';
}
if (!is_numeric($_POST['advance_amount']) || !is_numeric($_POST['warming_amount']) || !is_numeric($_POST['warn_frequency'])) {
return $this->error("金额需为数字!");
}
if ($_POST['advance_amount'] < $_POST['warming_amount']) {
return $this->error("预警金额不能大于预付金额");
}
if ($_POST['warming_amount'] < $_POST['warn_frequency']) {
return $this->error("预警金额频率不能大于预警金额");
}
//获取合作伙伴名称
@$partner_name = M('Partner', 'tab_')->field('partner')->where(['id'=>$_POST['partner_id']])->find()['partner'];
if ($id) {
if (!M('game', 'tab_')->where(['partner_id'=>$_POST['partner_id']])->count()) {
return $this->error('当前对象无关联游戏');
}
$_POST['upt_time'] = time();
$_POST['operater_id'] = is_login();
$upt = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->save($_POST);
addOperationLog(array(
"op_type"=>1,
"key"=>$partner_name,
"url"=>U("Game/devide_warn_list",array("partner_id"=>$_POST['partner_id']))
));
return $upt ? $this->success("更新成功", U('Game/devide_warn_list')) : $this->error("更新失败");
} else {
if (M('partner_divide_warn', 'tab_')->where(['partner_id'=>$_POST['partner_id'], 'status'=>1])->find()) {
return $this->error('已有当前合作伙伴的预警设置');
}
if (!M('game', 'tab_')->where(['partner_id'=>$_POST['partner_id']])->count()) {
return $this->error('当前对象无关联游戏');
}
$_POST['upt_time'] = $_POST['create_time'] = time();
$_POST['operater_id'] = is_login();
$ins = M('partner_divide_warn', 'tab_')->add($_POST);
//操作日志
addOperationLog(array(
"op_type"=>0,
"key"=>$partner_name,
"url"=>U("Game/devide_warn_list",array("partner_id"=>$_POST['partner_id'])),
"menu"=>"游戏-游戏管理-预付款预警管理-新增"
));
return $ins ? $this->success("新增成功", U('Game/devide_warn_list')) : $this->error("新增失败");
}
} else {
$partners = M('partner', 'tab_')->field("id, partner")->where(['status'=>1])->order('last_up_time desc')->select();
$this->assign('partners', $partners);
if ($id) {
if ($delete) {
$_POST['upt_time'] = $_POST['create_time'] = time();
$_POST['operater_id'] = is_login();
$_POST['status'] = 2;
$del = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->save($_POST);
//操作日志
@$partner_id = M('partner_divide_warn', 'tab_')->field('partner_id')->where(['id'=>$id])->find()['partner_id'];
@$partner_name = M('Partner', 'tab_')->field('partner')->where(['id'=>$partner_id])->find()['partner'];
addOperationLog(array(
"op_type"=>2,
"key"=>$partner_name,
"url"=>U("Game/devide_warn_list",array("partner_id"=>$_POST['partner_id'])),
"menu"=>"游戏-游戏管理-预付款预警管理-解除预警"
));
return $del ? $this->success("删除成功") : $this->error("删除失败");
} else {
$warnInfo = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->find();
if (!$warnInfo) return $this->error('未找到该记录');
$warnInfo['phones'] = json_decode($warnInfo['phones'], true);
$this->assign('warnInfo', $warnInfo);
}
}
$this->display();
}
}
/**
* 编辑CP分成比例
*/
public function edit_ratio(){
$data = $_POST;
if($data['data_id']==0 || $data['data_id']==""){ //查询初始分成比例信息
$initial_info = M('cp_game_ratio', 'tab_')->where("game_id=%d and begin_total_amount=0 and is_del=0",$data['game_id'])->find();
}
if(!is_numeric($data['game_ratio']) || $data['game_ratio']<0 || $data['game_ratio']>100){
die(json_encode(array("result"=>"0","desc"=>"分成比例为0~100之间")));
}
$game_info = M("game","tab_")->where("id=".$data['game_id'])->field("relation_game_id")->find();//根据游戏找到关联的游戏ID
$relation_game_list = M("game","tab_")->where("relation_game_id=".$game_info['relation_game_id'])->select();//根据关联ID找到游戏列表
if($data['data_type']=='initial'){ //CP初始分成比例
if($data['data_id']>0){ //修改初始CP分成比例
$where = array();
$where['is_del'] = "0";
$where['game_id'] = $data['game_id'];
$where['id'] = array("neq",$data['data_id']);
$where['ratio'] = array("elt",$data['game_ratio']);
$info = M('cp_game_ratio', 'tab_')
->where($where)
->order("ratio asc")
->find();
// if($info){
// die(json_encode(array("result"=>"0","desc"=>"CP分成比例应小于".$info['ratio']."%")));
// }
foreach ($relation_game_list as $game){
$map['game_id'] = $game['id'];
$map['is_del'] = 0;
$map['begin_total_amount'] = 0;
M('cp_game_ratio', 'tab_')->where($map)->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save();
}
//M('cp_game_ratio', 'tab_')->where("id=%d",$data['data_id'])->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save();
}else{
if($initial_info){
foreach ($relation_game_list as $game){
$map['game_id'] = $game['id'];
$map['is_del'] = 0;
$map['begin_total_amount'] = 0;
M('cp_game_ratio', 'tab_')->where($map)->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save();
}
//M('cp_game_ratio', 'tab_')->where("id=%d",$initial_info['id'])->data(array("ratio"=>$data['game_ratio'],"update_time"=>time()))->save();
}else{
foreach ($relation_game_list as $game) {
M('cp_game_ratio', 'tab_')->data(array("game_id" => $game['id'], "ratio" => $data['game_ratio'], "begin_total_amount" => 0, "add_time" => time(), "update_time" => time()))->add();
}
}
}
}else{ //CP阶梯分成档位
if(!is_numeric($data['total_amount']) || $data['total_amount']<=0){
die(json_encode(array("result"=>"0","desc"=>"流水金额应大于0")));
}
if($data['data_id']>0) { //修改阶梯分成
$where = array();
$where['game_id']= $data['game_id'];
$where['is_del'] = "0";
$where['id']=array("neq",$data['data_id']);
$exis_info = M('cp_game_ratio', 'tab_')
->where($where)
->where("begin_total_amount='%s' or ratio = '%f'",array($data['total_amount'],$data['game_ratio']))
->find();
if($exis_info){
die(json_encode(array("result"=>"0","desc"=>"分成档位已存在")));
}
// if($initial_info['game_ratio']>=$data['game_ratio']){
// die(json_encode(array("result"=>"0","desc"=>"分成比例不得小于初始比例")));
// }
$info = M('cp_game_ratio', 'tab_')->where("id=%d",$data['data_id'])->find();
foreach ($relation_game_list as $game) {
$map['ratio'] = $info['ratio'];
$map['begin_total_amount'] = $info['begin_total_amount'];
$map['is_del'] = 0;
$map['game_id']= $game['id'];
$updainfo = M('cp_game_ratio', 'tab_')->where($map)->find();
if($updainfo){
M('cp_game_ratio', 'tab_')->where("id=%d",$updainfo['id'])->data(array("instanceof"=>$data['instanceof'],"ratio"=>$data['game_ratio'],"begin_total_amount"=>$data['total_amount'],"update_time"=>time()))->save();
}
}
}else{
if(!$initial_info){
die(json_encode(array("result"=>"0","desc"=>"请先设置初始CP分成比例")));
}
$exis_info = M('cp_game_ratio', 'tab_')->where("game_id=%d and (begin_total_amount='%s' or ratio = '%f') and is_del=0",array($data['game_id'],$data['total_amount'],$data['game_ratio']))->find();
if($exis_info){
die(json_encode(array("result"=>"0","desc"=>"分成档位已存在")));
}else{
/*$max_info = M('cp_game_ratio', 'tab_')->field("max(ratio) as max_ratio,max(begin_total_amount) as max_amount")->where("game_id=%d and is_del=0",$data['game_id'])->find();
if($max_info['max_ratio'] >= $data['game_ratio'] || $max_info['max_amount']>=$data['total_amount']){
die(json_encode(array("result"=>"0","desc"=>"新增分成档位金额或分成比例需大于现有分成档位")));
}*/
foreach ($relation_game_list as $game) {
M('cp_game_ratio', 'tab_')->data(array("game_id"=>$game['id'],"ratio"=>$data['game_ratio'],"begin_total_amount"=>$data['total_amount'],"add_time"=>time(),"update_time"=>time()))->add();
}
}
}
}
echo(json_encode(array("result"=>"1","desc"=>"数据保存成功")));
}
/**
* 删除CP分成比例
*/
public function delete_ratio(){
$info = M('cp_game_ratio', 'tab_')->where("id=%d",$_POST['data_id'])->find();
$game_info = M("game","tab_")->where("id=".$info['game_id'])->field("relation_game_id")->find();//根据游戏找到关联的游戏ID
$relation_game_list = M("game","tab_")->where("relation_game_id=".$game_info['relation_game_id'])->select();//根据关联ID找到游戏列表
foreach ($relation_game_list as $game) {
$map['ratio'] = $info['ratio'];
$map['begin_total_amount'] = $info['begin_total_amount'];
$map['is_del'] = 0;
$map['game_id']= $game['id'];
$updainfo = M('cp_game_ratio', 'tab_')->where($map)->find();
if($updainfo){
M('cp_game_ratio', 'tab_')->where("id=".$updainfo['id'])->data(array("is_del"=>"1","update_time"=>time()))->save();
}
}
//M('cp_game_ratio', 'tab_')->where("id=".$_POST['data_id'])->data(array("is_del"=>"1","update_time"=>time()))->save();
echo(json_encode(array("result"=>"1","desc"=>"删除成功")));
}
public function uploadExcel1() {
Vendor("PHPExcel.PHPExcel");
$gid = $_REQUEST['game_id'];
if(@is_uploaded_file($_FILES['file']['tmp_name'])){
$upfile = $_FILES["file"];
$name = $upfile["name"];
$type = $upfile["type"];
$size = $upfile["size"];
$tmp_name = $upfile["tmp_name"];
$savePath = $_SERVER['DOCUMENT_ROOT'].__ROOT__.'/Uploads/Excel/';
move_uploaded_file($tmp_name,$savePath.$name);
$file_name = $savePath.$name;
$error=$upfile["error"];//上传后系统返回的值
$extension = strtolower( pathinfo($file_name, PATHINFO_EXTENSION) );
if($extension == 'xlsx') {
$objReader = \PHPExcel_IOFactory::createReader('excel2007');
}elseif($extension == 'csv') {
$objReader = \PHPExcel_IOFactory::createReader('csv');
}else {
$objReader = \PHPExcel_IOFactory::createReader('Excel5');//创建读取实例
}
$objPHPExcel = $objReader->load($file_name,$encode='utf-8');//加载文件
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$dataList = [];
$outPromote = []; //录入出错的会长
$outGame = []; //录入出错的游戏
$successAccount = [];
$keyPro = 0;
$keyGame = 0;
$keyData = 0;
for($i=2;$i<=$highestRow;$i++)
{
$promoteAccount = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue();
$promoteInfo = M('promote','tab_')->field('id')->where(['account' => $promoteAccount ])->find();
if($promote_id == -1) {$promoteInfo['account'] = "官方渠道"; }
if(empty($promoteInfo)) {
$outPromote[$keyPro]['promote_account'] = $promoteAccount;
$keyPro += 1;
}else {
$promote_id = $promoteInfo['id'];
}
$gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gid])->select();
$time = time();
$isSociaty = M('sociaty_games','tab_')->where(['promote_id'=>$promote_id,'game_id'=>$gid])->getField('id');
if(empty($isSociaty) && !empty($gameInfo) && !empty($promoteInfo)) {
$dataList[$keyData] = ['promote_id'=>$promote_id,'game_id'=>$gid,'status'=>$gameInfo[0]['game_status'],'create_time'=>$time];
$successAccount[$keyData] = ['account'=>$promoteAccount];
$keyData += 1;
}
}
$backData['outPromote'] = $outPromote;
$backData['datalist'] = $successAccount;
M('sociaty_games','tab_')->addAll($dataList);
$gameData['apply_auth'] = 2;
M('game','tab_')->where(['id'=>$gid])->save($gameData);
$this->ajaxReturn(json_encode($backData,TRUE));
}
}
function getRootPromote() {
$promoteData = M('promote','tab_')->field('id as value,account as title')->where(array('level'=>1,'chain'=>'/'))->select();
$data_president = M('AuthGroup')->field('data_president')->where(array('id'=>1))->find();
$promoteData = array_merge([0=>['value'=>'-1','title'=>C('OFFICIEL_CHANNEL')]],$promoteData);
$returnData = array('data_president'=>$data_president['data_president'],'list'=>$promoteData);
$this->ajaxReturn(json_encode($returnData));
}
//下载模板
public function downloadDemo() {
$game_id = $_REQUEST['game_id'];
$game_name = M('game','tab_')->where(['id'=>$game_id])->getField('game_name');
$data[] = [
'promoteid' => "官方渠道",
];
$field = array(
"promoteid"=>"会长账号",
);
data2csv($data,'【'.$game_name.'】'.'模板',$field);
}
}