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.

452 lines
19 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 Sdk\Controller;
use Think\Controller;
class GameController extends BaseController{
/**
* 读取游戏客服qq
* @param int $game_id 游戏ID
* @return mixed
* 小纯洁
*/
public function get_game_ccustom_service_qq(){
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
$request = json_decode(base64_decode(file_get_contents("php://input")),true);
$gameModel = new \Admin\Model\GameModel();
$result = $gameModel->get_table_fields("ccustom_service_qq",$request['game_id']);
$qq = empty($result)?"":$result;
if($request['promote_id']!=0){
$res=M('site_base','tab_')->field('site_qq')->where(['promote_id'=>$request['promote_id']])->find();
if($res['site_qq']){
$data = array(
"status"=>200,
"ccustom_service_qq"=>$res['site_qq'],
);
echo base64_encode(json_encode($data));die;
}
}
$data = array(
"status"=>200,
"ccustom_service_qq"=>C(APP_QQ),
);
echo base64_encode(json_encode($data));
}
/**
* 初始化SDK接口
*/
public function init_sdk() {
$data = json_decode(base64_decode(file_get_contents("php://input")), true);
$game = M('game', 'tab_')->where([
'id' => $data['game_id']
])->order('sort desc')->find();
$contact_cs = M('tool','tab_')->where(['name' => 'contact_cs'])->find();
$contact_cs = json_decode($contact_cs['config'],true);
foreach($contact_cs as $k => &$v) {
if ($game['kefu_qq_type'] == 0)
$kefuQQ = C('APP_QQ');
if ($game['kefu_qq_type'] == 1)
$kefuQQ = '';
if ($game['kefu_qq_type'] == 2)
$kefuQQ = $game['kefu_qq'];
// if (isset($data['api_ver']) && $data['api_ver'] >= 3)
// $kefuQQ = "https://wpa1.qq.com/WQoPWu26?_type=wpa&qidian=true";
//
$contact_cs[$k]['act'] = $kefuQQ;
$contact_cs[$k]['ios_url'] = $kefuQQ;
$contact_cs[$k]['icon'] = C('ADMIN_DOMAIN') . $contact_cs[$k]['icon'];
//
if (substr($contact_cs[$k]['url'], 0, 7) == "http://" || substr($contact_cs[$k]['url'], 0, 8) == "https://") {
$contact_cs[$k]['url'] = $contact_cs[$k]['url'] . "/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
} else {
$contact_cs[$k]['url'] = C('H5_DOMAIN') . $v['url'] . "/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
}
if ($contact_cs[$k]['type'] == 1) {// 原生
$contact_cs[$k]['ios_url'] = "?action=".$contact_cs[$k]['name'];
} else if ($contact_cs[$k]['type'] == 0) { // H5
$contact_cs[$k]['ios_url'] = $contact_cs[$k]['url']."?action=push";
if ($data['sdk_version'] == 1 && $contact_cs[$k]['name'] == 'suppersign')
unset($contact_cs[$k]);
} else if ($contact_cs[$k]['type'] == 2) { // 外部链接
if (strpos($contact_cs[$k]['ios_url'], "?") === false) {
$gap = "?";
} else {
$gap = "&";
}
if($contact_cs[$k]['name'] == 'support') {
$contact_cs[$k]['act'] = "mqq://im/chat?chat_type=wpa&uin=" . $contact_cs[$k]['act'] . "&version=1&src_type=web";
$contact_cs[$k]['ios_url'] = "mqq://im/chat?chat_type=wpa&uin=" . $contact_cs[$k]['ios_url'] . "&version=1&src_type=web&action=openurl";
// $contact_cs[$k]['act'] = $contact_cs[$k]['act'];
// $contact_cs[$k]['ios_url'] = $contact_cs[$k]['act']."{$gap}action=openurl";
if ($data['game_id'] == 227 || $data['game_id'] == 228) { // 仗剑八方
$contact_cs[$k]['act'] = "mqq://im/chat?chat_type=wpa&uin=496722145&version=1&src_type=web";
$contact_cs[$k]['ios_url'] = "mqq://im/chat?chat_type=wpa&uin=496722145&version=1&src_type=web&action=openurl";
}
} else {
$contact_cs[$k]['ios_url'] = $contact_cs[$k]['ios_url']."{$gap}action=openurl";
}
// 魔幻游戏 隐藏客服
if ($data['game_id'] == 197 || $data['game_id'] == 198
|| $data['game_id'] == 201 || $data['game_id'] == 202 // 马踏乱世
|| $data['game_id'] == 211 || $data['game_id'] == 212 // 盛世龙城
|| $data['game_id'] == 217 || $data['game_id'] == 218 // 天道情缘录
// || $data['game_id'] == 227 || $data['game_id'] == 228 // 仗剑八方
) {
// android
$contact_cs[$k]['act'] = "";
$contact_cs[$k]['type'] = -1;
// IOS
$contact_cs[$k]['ios_url'] = "";
}
}
}
if ($game['kefu_qq_type'] == 1) {
$contact_cs[$k]['act'] = "";
$contact_cs[$k]['ios_url'] = "";
}
array_multisort(array_column($contact_cs,'sort'),SORT_ASC,$menus);
$ret = [
'contact_cs' => $contact_cs[$k],
];
re_msg(200,'获取成功',$ret);
}
// 1版本的api
public function get_suspend_1(){
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
$request = json_decode(base64_decode(file_get_contents("php://input")),true);
if($request['promote_id']!=0){
$res=M('site_base','tab_')->field('sites_ball_logo,ball_status')->where(['promote_id'=>$request['promote_id']])->find();
if($res){
/*
适配oss路径
*/
if($res['sites_ball_logo']==0){
$res['sites_ball_logo']=C(WAP_SUSPEND_ICON);
}
$cover1 = get_cover($res['sites_ball_logo'] ,'path');
if(strpos($cover1, 'http')!==false){
$cover1 = $cover1;
}else{
$cover1 = 'http://'.$_SERVER['HTTP_HOST'].$cover1;
}
if($res['ball_status'] == '') {
$res['ball_status'] = 1;
}
$data = array(
"status"=>200,
"sites_ball_logo"=>$cover1,
"ball_status"=>$res['ball_status'],
);
echo base64_encode(json_encode($data));die;
}
}
/*
适配oss路径
*/
$cover2 = get_cover( C(WAP_SUSPEND_ICON) ,'path');
if(strpos($cover2, 'http')!==false){
$cover2 = $cover2;
}else{
$cover2 = 'http://'.$_SERVER['HTTP_HOST'].$cover2;
}
$data = array(
"status"=>200,
"sites_ball_logo"=>$cover2,
"ball_status"=>C(WAP_SUSPEND_SHWO_STATUS)==2?0:1,
);
echo base64_encode(json_encode($data));die;
}
/**
* 获取渠道悬浮球图
* @param int $game_id 游戏ID
* @return mixed
* 小纯洁
*/
public function get_suspend(){
$data = json_decode(base64_decode(file_get_contents("php://input")), true);
if (!isset($data['api_ver'])) {
$this->get_suspend_1();
return ;
}
// 美国IP 贝塔版
$ip = get_client_ip();
$isUSIP = ip_is_country($ip);
if(empty($data['user_id'])) {
re_msg(1004, 'fail', '用户不存在');
}
// 白名单用户显示
$isWhite = M('forbit_ip', 'tab_')->where([
'user_id' => $data['user_id'],
'type' => 1
])->find();
// 测试白名单用户一定走内购支付
$testWhite = M('forbit_ip', 'tab_')->where([
'user_id' => $data['user_id'],
'type' => 2
])->find();
$user = M('user','tab_')->field('account,balance')->where(['id' => $data['user_id']])->find();
$user['user_token'] = $data['user_token'];
if (!$user['user_token']) {
re_msg(1004, 'fail', '数据有误');
}
$sdkMenus = M('tool','tab_')->where(['name' => 'sdk_menu'])->find();
$menus = json_decode($sdkMenus['config'],true);
$rmenus = array();
foreach($menus as $k => $v) {
if(!empty($v['menu_version']) && $data['sdk_version'] != 0 && $v['menu_version'] != $data['sdk_version']){
unset($menus[$k]);
continue;
}
if(!empty($v['game_status'])) {
$game_status = explode(',', $v['game_status']);
if(in_array($data['game_id'], $game_status)) {
unset($menus[$k]);
continue;
}
}
if(isset($v['status']) && $v['status'] == 0) {
unset($menus[$k]);
continue;
}
//测试账号苹果审核
$game_user = ['test11', 'test12', 'test13', 'test142', 'test171','test830','test1003','test1002','test170','test169'];
if(isset($data['app_type']) && $data['app_type'] == 2 && !get_game_appstatus2($data['game_id']) && !in_array($user['account'], $game_user)) {
if($v['name'] == 'gift' || $v['name'] == 'suppersign') {
unset($menus[$k]);
continue;
}
}
//判断是否开启苹果内购beta包美国ip且是否在白名单当中
if (isset($data['app_type']) && $data['app_type'] == 2 && $isUSIP && !$isWhite) {
if ($v['name'] == 'gift' || $v['name'] == 'suppersign') {
unset($menus[$k]);
continue;
}
}
// 测试白名单用户不显示
if (isset($data['app_type']) && $data['app_type'] == 2 && $testWhite) {
if ($v['name'] == 'gift' || $v['name'] == 'suppersign') {
unset($menus[$k]);
continue;
}
}
//测试账号苹果审核
$menus[$k]['icon'] = (substr($v['icon'], 0, 7) == "http://" || substr($v['icon'], 0, 8) == "https://" ) ? $v['icon'] :
C('ADMIN_DOMAIN') . $v['icon'];
if($v['type'] != 3){ //
if (substr($menus[$k]['url'], 0, 7) == "http://" || substr($menus[$k]['url'], 0, 8) == "https://") {
$menus[$k]['url'] = $menus[$k]['url'] . '/user_token/' . $user['user_token']."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'].'/api_ver/2';
} else {
$menus[$k]['url'] = C('H5_DOMAIN') . $v['url'] . '/user_token/' . $user['user_token']."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'].'/api_ver/2';
}
}
//$menus[$k]['url'] = C('H5_DOMAIN') . $v['url'] . '/user_token/' . $user['user_token']."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
if ($menus[$k]['type'] == 1) {// 原生
$menus[$k]['ios_url'] = "?action=".$menus[$k]['name'];
} else if ($menus[$k]['type'] == 0) { // H5
$menus[$k]['ios_url'] = $menus[$k]['url']."?action=push";
} else if ($menus[$k]['type'] == 2) { // 外部链接
$menus[$k]['ios_url'] = $menus[$k]['ios_url']."?action=openurl";
}
if ($data['sdk_version'] == 1 && $menus[$k]['name'] == 'suppersign'){
unset($menus[$k]);
continue;
}elseif($data['sdk_version'] != 1 && $v['name'] == 'suppersign'){
// $menus[$k]['url'] = $v['url'] . '/user_token/' . $user['user_token'] . "/game_id/". $data['game_id'];
$menus[$k]['ios_url'] = $v['ios_url'] . '/user_token/' . $user['user_token'] . '/user_id/' . $data['user_id'] . '/game_id/' . $data['game_id'] . '.html?action=openurl';
}elseif($v['name'] == 'balance'){
$str = urlencode("余额");
$menus[$k]['ios_url'] = C('H5_DOMAIN') . $v['ios_url'] . '/user_token/' . $user['user_token']."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'].'/api_ver/2' . '?action=pay&nav_title=' . $str;
}
}
$personalMenu = M('tool','tab_')->where(['name' => 'personal_menu'])->getField('config');
$personalMenu = json_decode($personalMenu, true);
foreach($personalMenu as $k => $v) {
if(!empty($v['menu_version']) && $data['sdk_version'] != 0 && $v['menu_version'] != $data['sdk_version']){
unset($personalMenu[$k]);
continue;
}
if(!empty($v['game_status'])) {
$game_status = explode(',', $v['game_status']);
if(in_array($data['game_id'], $game_status)) {
unset($personalMenu[$k]);
continue;
}
}
if(isset($v['status']) && $v['status'] == 0) {
unset($personalMenu[$k]);
continue;
}
//测试账号苹果审核
$game_user = ['test11', 'test12', 'test13', 'test142', 'test171','test830','test1003','test1002','test170','test169'];
if(isset($data['app_type']) && $data['app_type'] == 2 && !get_game_appstatus2($data['game_id']) && !in_array($user['account'], $game_user)) {
if($v['name'] == 'gift' || $v['name'] == 'balance') {
unset($personalMenu[$k]);
continue;
}
}
// 测试白名单用户不显示
if (isset($data['app_type']) && $data['app_type'] == 2 && $testWhite) {
if ($v['name'] == 'gift' || $v['name'] == 'balance') {
unset($personalMenu[$k]);
continue;
}
}
if (isset($data['app_type']) && $data['app_type'] == 2 && $isUSIP && !$isWhite) {
if ($v['name'] == 'gift' || $v['name'] == 'balance') {
unset($personalMenu[$k]);
continue;
}
}
//测试账号苹果审核
$personalMenu[$k]['icon'] = (substr($v['icon'], 0, 7) == "http://" || substr($v['icon'], 0, 8) == "https://" ) ? $v['icon'] : C('ADMIN_DOMAIN') . $v['icon'];
if($v['type'] != 3){
if (substr($personalMenu[$k]['url'], 0, 7) == "http://" || substr($personalMenu[$k]['url'], 0, 8) == "https://") {
$personalMenu[$k]['url'] = $personalMenu[$k]['url'] . '/user_token/' . $user['user_token']."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'].'/api_ver/2';
} else {
$personalMenu[$k]['url'] = C('H5_DOMAIN') . $v['url'] . '/user_token/' . $user['user_token']."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'].'/api_ver/2';
}
}
//$personalMenu[$k]['url'] = C('H5_DOMAIN') . $v['url'] . '/user_token/' . $user['user_token']."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'];
if ($personalMenu[$k]['type'] == 1) {// 原生
$personalMenu[$k]['ios_url'] = "?action=".$personalMenu[$k]['name'];
} else if ($personalMenu[$k]['type'] == 0) { // H5
$personalMenu[$k]['ios_url'] = $personalMenu[$k]['url']."?action=push";
} else if ($personalMenu[$k]['type'] == 2) { // 外部链接
$personalMenu[$k]['ios_url'] = $personalMenu[$k]['ios_url']."?action=openurl";
}
if ($data['sdk_version'] == 1 && $personalMenu[$k]['name'] == 'suppersign'){
unset($personalMenu[$k]);
}elseif($data['sdk_version'] != 1 && $v['name'] == 'suppersign'){
// $personalMenu[$k]['url'] = C('H5_DOMAIN') . $v['url'] . 'user_token/' . $user['user_token'];
$personalMenu[$k]['ios_url'] = $v['ios_url'] . '/user_token/' . $user['user_token'] . '/user_id/' . $data['user_id'] . '/game_id/' . $data['game_id'] . '.html?action=openurl';
}elseif($v['name'] == 'balance'){
$str = urlencode("余额");
$personalMenu[$k]['ios_url'] = C('H5_DOMAIN') . $v['ios_url'] . '/user_token/' . $user['user_token']."/game_id/".$data['game_id'].'/sdk_version/'.$data['sdk_version'].'/api_ver/2' . '?action=pay&nav_title=' . $str;
}
}
// 2456623.96
array_multisort(array_column($menus,'sort'), SORT_ASC, $menus);
array_multisort(array_column($personalMenu,'sort'),SORT_ASC,$personalMenu);
$menusArr = [];
foreach($menus as $k => $v){
$menusArr[] = $menus[$k];
}
$personalMenuArr = [];
foreach($personalMenu as $k => $v){
$personalMenuArr[] = $personalMenu[$k];
}
$ball_status = M('config','sys_')->where(['name' => 'WAP_SUSPEND_SHWO_STATUS'])->getField('value');
$sites_ball_logo = M('config','sys_')->where(['name' => 'WAP_SUSPEND_ICON'])->getField('value');
$ball = get_cover( $sites_ball_logo ,'path');
$sites_ball_logo = (substr($ball, 0, 7) == "http://" || substr($ball, 0, 8) == "https://" ) ? $ball : C('ADMIN_DOMAIN') . $ball;
$ret = [
'sites_ball_logo' => $sites_ball_logo,
'ball_status' => $ball_status,
'menus' => $menusArr,
'mine_features' => $personalMenuArr,
];
re_msg(200,'获取成功',$ret);
}
//获取游戏域名
//yyh 2018 10 23
public function get_game_domain(){
$request = json_decode(base64_decode(file_get_contents("php://input")),true);
$game_id = $request['game_id'];
$list = M('Game','tab_')
->field('tab_game.id,login_notify_url')
->where(['tab_game.id'=>$game_id])
->join('tab_game_set on game_id = tab_game.id')
->find();
$login_notify_url = $list['login_notify_url'];
if(empty($login_notify_url)){
$url = $_SERVER['HTTP_HOST'];
}else{
$arr = parse_url($login_notify_url);
$scheme = $arr['scheme']?:'http';
$host = $arr['host'];
$url = $host;
}
$this->new_set_message(200,"成功",['url'=>$url]);
}
//获取sdk分享链接
public function get_sdk_share_url(){
$request = json_decode(base64_decode(file_get_contents("php://input")),true);
$game_id = $request['game_id'];
$user_id = $request['user_id'];
$user_data = M('User','tab_')->field('account')->find($user_id);
if (empty($user_data)) {
$this->new_set_message(1001, "用户数据不存在", []);
}
$param = M('param','tab_')->field('openid,wx_appid,type')->where(['game_id'=>$game_id])->select();
$qqappid = '';
$wxappid = '';
if(is_array($param)) {
foreach($param as $k=>$v) {
if($v['type']==2) {
$wxappid = $v['wx_appid'];
}elseif($v['type']==1) {
$qqappid = $v['openid'];
}
}
}
$logo = get_cover(C('WAP_APP_ICON'),'path');
$pointtype = M('point_type','tab_')->field('title,description')->where(['key'=>'invite_friend'])->find();
$url = 'http://'.$_SERVER['HTTP_HOST'].'/app.php/Share/register/invite_account/'.$user_data['account'].'/game_id/'.$game_id;
$title = $pointtype['title']?$pointtype['title']:'邀请好友注册得奖励';
$content = $pointtype['description']?$pointtype['description']:'邀请好友注册可获得积分奖励,还有机会获得平台币奖励哦~';
$logo = $logo?$logo:'/Uploads/Picture/yaoqing.png';
if(strpos($logo,'http')===false){
$logo = 'http://'.$_SERVER['HTTP_HOST'].$logo;
}
$data = ['url'=>$url,'title'=>$title,'logo'=>$logo,'content'=>$content,'qqAPPid'=>$qqappid,'wxAPPid'=>$wxappid];
$this->new_set_message(200, "success", $data);
}
}