236 lines
8.0 KiB
PHP
236 lines
8.0 KiB
PHP
<?php
|
||
include_once("../../inc/class.php");
|
||
include_once("../../inc/admin.smarty.php");
|
||
$db = new myConn;
|
||
$db->links();
|
||
$GG=$db->getpost($GG);
|
||
$userinfo = $db->fetch_one("select a.UserID,a.GameID,a.NickName,a.SpreaderID,c.ConsumeScore,c.InsureScore,c.PlayCount,c.Grade,c.YuanBao,c.UnionID from AccountsInfo as a LEFT JOIN QPTreasureDB.dbo.GameScoreInfo AS c ON(a.UserID=c.UserID) where a.GameID='".$GG['gameid']."'");
|
||
if(!$userinfo){
|
||
echo "没有找到用户";//系统错误
|
||
exit;
|
||
}
|
||
if($GG['ty'] == 'join'){//加入工会
|
||
$union = $db->fetch_one("select * from QPTreasureDB.dbo.GameUnion where UserID='".$userinfo['UserID']."'");
|
||
if(!$union){
|
||
echo "工会出错!";
|
||
exit;
|
||
}
|
||
if($union['People'] >= 500){
|
||
echo "您的公会人数<br>已经超出500人限制!";
|
||
exit;
|
||
}
|
||
$user = $db->fetch_one("select a.UserID,c.UnionID from AccountsInfo as a LEFT JOIN QPTreasureDB.dbo.GameScoreInfo AS c ON(a.UserID=c.UserID) where a.GameID='".$GG['gid']."'");
|
||
if(!$user){
|
||
echo "没有找到游戏ID!";
|
||
exit;
|
||
}
|
||
$un_user = $db->fetch_one("select UserID from QPTreasureDB.dbo.GameUnionMember where UserID='".$user['UserID']."' and UnionID='".$union['UnionID']."'");
|
||
if($un_user){
|
||
echo "该玩家已经是您公会成员!";
|
||
exit;
|
||
}
|
||
$hit = $db->fetch_abc("select count(*) from QPTreasureDB.dbo.GameUnionMember where UserID='".$user['UserID']."'");
|
||
if($hit >= 10){
|
||
echo "该玩家已加入10个公会<br>超出限制!";
|
||
exit;
|
||
}
|
||
$open = $GG['opens'] ? 1 : 0;
|
||
$db->insert("QPTreasureDB.dbo.GameUnionMember",[
|
||
"UnionID"=>$union['UnionID'],
|
||
"UserID"=>$user['UserID'],
|
||
"UnionOpen"=>$open
|
||
]);
|
||
$db->update("QPTreasureDB.dbo.GameUnion",["People"=>$union['People']+1],"UnionID='".$union['UnionID']."'");
|
||
if(!$user['UnionID']){//修改UnionID
|
||
$db->update("QPTreasureDB.dbo.GameScoreInfo",["UnionID"=>$union['UnionID']],"UserID='".$user['UserID']."'");
|
||
}
|
||
echo "ok";
|
||
exit;
|
||
}elseif($GG['ty'] == 'add' && $GG['uname'] && $GG['ucard']){//创建工会
|
||
$bxkf = 80;//最少房卡
|
||
$uname = trim(str_replace([' ',' ','\'','"'], "", iconv("utf-8", "gbk", $GG['uname'])));
|
||
if($userinfo['InsureScore'] < $bxkf){
|
||
echo "必须要有".$bxkf."张房卡!<br>请联系客服充卡";
|
||
exit;
|
||
}
|
||
if($userinfo['InsureScore'] < intval($GG['ucard'])){
|
||
echo "您的当前房卡少于".intval($GG['ucard'])."张<br>请联系客服充卡";
|
||
exit;
|
||
}
|
||
if(in_array("integer",$GG['ucard'])){
|
||
echo "房卡输入错误";
|
||
exit;
|
||
}
|
||
if(intval($GG['ucard']) < $bxkf){
|
||
echo "输入房卡必须大于".$bxkf."张";
|
||
exit;
|
||
}
|
||
if(strlen($uname)>10){
|
||
echo " 公会名称太长!";
|
||
exit;
|
||
}
|
||
$notice = $db->fetch_one("select * from QPTreasureDB.dbo.GameUnion where UnionName='".$uname."' or UnionCode='".$userinfo['GameID']."'");
|
||
if($notice){
|
||
if($userinfo['GameID'] == $notice['UnionCode']){
|
||
echo "公会码重复,请联系管理员注册";
|
||
}else{
|
||
echo "公会名称,已被注册";
|
||
}
|
||
}else{
|
||
if($userinfo['UnionID']){
|
||
echo "已经是公会成员";
|
||
exit;
|
||
}
|
||
$db->insert("QPTreasureDB.dbo.GameUnion",[
|
||
"UserID"=>$userinfo['UserID'],
|
||
"UnionCode"=>$userinfo['GameID'],
|
||
"UnionCard"=>intval($GG['ucard']+50),
|
||
"UnionName"=>$uname,
|
||
"People"=>1
|
||
]);
|
||
$card = $userinfo['InsureScore']-intval($GG['ucard']);
|
||
$idd = $db->fetch_abc("select UnionID from QPTreasureDB.dbo.GameUnion where UserID='".$userinfo['UserID']."'");
|
||
$db->insert("QPTreasureDB.dbo.GameUnionMember",[
|
||
"UnionID"=>$idd,
|
||
"UserID"=>$userinfo['UserID'],
|
||
"UnionOpen"=>1
|
||
]);
|
||
$db->update("QPTreasureDB.dbo.GameScoreInfo",['InsureScore'=>$card,"UnionID"=>$idd],"UserID='".$userinfo['UserID']."'");
|
||
//添加转卡记录
|
||
$db->insert("QPTreasureDB.dbo.GameUnionCard",[
|
||
"UnionID"=>$idd,
|
||
"UserID"=>$userinfo['UserID'],
|
||
"Fang"=>$userinfo['InsureScore'],
|
||
"LeftCard"=>0,
|
||
"OperCard"=>intval($GG['ucard'])
|
||
]);
|
||
echo "ok";
|
||
}
|
||
}elseif($GG['ty'] == 'edit'){//修改公会信息
|
||
$union = $db->fetch_one("select * from QPTreasureDB.dbo.GameUnion where UserID='".$userinfo['UserID']."'");
|
||
if(!$union){
|
||
echo "工会出错!";
|
||
exit;
|
||
}
|
||
if(!$GG['names']){
|
||
echo "请输入公会名称!";
|
||
exit;
|
||
}
|
||
$uname = trim(iconv('UTF-8','GBK',$GG['names']));
|
||
if($union['UnionName'] != $uname){
|
||
$notice = $db->fetch_one("select * from QPTreasureDB.dbo.GameUnion where UnionName='".$uname."'");
|
||
if($notice){
|
||
echo "公会名称已被注册!";
|
||
exit;
|
||
}
|
||
}
|
||
$db->update("QPTreasureDB.dbo.GameUnion",[
|
||
"UnionName"=>$uname
|
||
],"UnionID='".$union['UnionID']."'");
|
||
echo "ok";
|
||
}elseif($GG['ty'] == 'out' && $GG['uid'] && $GG['unid']){//退出公会
|
||
$union = $db->fetch_one("select * from QPTreasureDB.dbo.GameUnion where UnionID='".$GG['unid']."'");
|
||
$um = $db->fetch_one("select * from QPTreasureDB.dbo.GameUnionMember where UnionID='".$GG['unid']."' and UserID='".$GG['uid']."'");
|
||
if($um['UnionMemberGold'] == 0){
|
||
$userr = $db->fetch_one("select UserID,UnionID from QPTreasureDB.dbo.GameScoreInfo where UserID='".$GG['uid']."'");
|
||
if($union && $userr){
|
||
$db->update("QPTreasureDB.dbo.GameUnion",["People"=>$union['People']-1],"UnionID='".$union['UnionID']."'");
|
||
$db->deldate("QPTreasureDB.dbo.GameUnionMember","UnionID='".$union['UnionID']."' and UserID='".$userr['UserID']."'");
|
||
if($userr['UnionID'] == $union['UnionID']){
|
||
$uid = $db->fetch_abc("select UnionID from QPTreasureDB.dbo.GameUnionMember where UserID='".$userr['UserID']."'");
|
||
if(!$uid){
|
||
$uid = 0;
|
||
}
|
||
$db->update("QPTreasureDB.dbo.GameScoreInfo",["UnionID"=>$uid],"UserID='".$userr['UserID']."'");
|
||
}
|
||
echo "ok";
|
||
}else{
|
||
echo "公会已解散";
|
||
}
|
||
}else{
|
||
echo "欢乐分清零才能退出公会!";
|
||
}
|
||
}elseif($GG['ty'] == 'zhuan'){//用户房卡转公会房卡
|
||
$union = $db->fetch_one("select * from QPTreasureDB.dbo.GameUnion where UserID='".$userinfo['UserID']."'");
|
||
if(!$union){
|
||
echo "工会出错!";
|
||
exit;
|
||
}
|
||
if(intval($GG['fang']) < 10){
|
||
echo "转入房卡最少10张起";
|
||
exit;
|
||
}
|
||
if(intval($userinfo['InsureScore']) < 10){
|
||
echo "您的当前房卡少于10张";
|
||
exit;
|
||
}
|
||
if(intval($userinfo['InsureScore']) < intval($GG['fang'])){
|
||
echo "您没有".intval($GG['fang'])."张房卡!";
|
||
exit;
|
||
}
|
||
$card = $userinfo['InsureScore']-intval($GG['fang']);
|
||
$db->update("QPTreasureDB.dbo.GameScoreInfo",["InsureScore"=>$card],"UserID='".$userinfo['UserID']."'");
|
||
$fang = $union['UnionCard']+intval($GG['fang']);
|
||
$db->update("QPTreasureDB.dbo.GameUnion",["UnionCard"=>$fang],"UnionID='".$union['UnionID']."'");
|
||
//添加转卡记录
|
||
$db->insert("QPTreasureDB.dbo.GameUnionCard",[
|
||
"UnionID"=>$union['UnionID'],
|
||
"UserID"=>$userinfo['UserID'],
|
||
"Fang"=>$userinfo['InsureScore'],
|
||
"LeftCard"=>$union['UnionCard'],
|
||
"OperCard"=>intval($GG['fang'])
|
||
]);
|
||
echo "ok";
|
||
}elseif($GG['ty'] == 'huan'){//修改欢乐场游戏配置
|
||
$union = $db->fetch_one("select * from QPTreasureDB.dbo.GameUnion where UserID='".$userinfo['UserID']."'");
|
||
if(!$union){
|
||
echo "工会出错!";
|
||
exit;
|
||
}
|
||
if($GG['tys'] == 'limit'){
|
||
$save = ['UnionGoldLimit'=>intval($GG['va'])];
|
||
}elseif($GG['tys'] == 'score'){
|
||
$save = ['ScoreMultiple'=>intval($GG['va'])];
|
||
}else{
|
||
$save = ['GameGold'=>intval($GG['va'])];
|
||
}
|
||
$db->update("QPTreasureDB.dbo.GameUnionKind",$save,"UnionID='".$union['UnionID']."' and KindID='".$GG['kid']."'");
|
||
echo "ok";
|
||
}elseif($GG['ty'] == 'goldopen'){//开启关闭欢乐场
|
||
$union = $db->fetch_one("select * from QPTreasureDB.dbo.GameUnion where UserID='".$userinfo['UserID']."'");
|
||
if(!$union){
|
||
echo "工会出错!";
|
||
exit;
|
||
}
|
||
$kind_arr = ['2'=>'牛牛','6'=>'炸金花','200'=>'斗地主','210'=>'跑得快','430'=>'打炸','502'=>'十三张','558'=>'麻将'];
|
||
if($union['UnionGoldOpen']){
|
||
$hsave=['UnionGoldOpen'=>0];
|
||
//关闭欢乐场
|
||
$db->deldate("QPTreasureDB.dbo.GameUnionKind","UnionID='".$union['UnionID']."'");
|
||
}else{
|
||
$hsave=['UnionGoldOpen'=>1];
|
||
//开启欢乐场
|
||
foreach ($kind_arr as $key => $val){
|
||
$db->insert("QPTreasureDB.dbo.GameUnionKind",['UnionID' => $union['UnionID'],
|
||
'KindID' => $key,
|
||
'UnionGoldLimit' => 100,
|
||
'ScoreMultiple' => 1,
|
||
'GameGold' => 3]);
|
||
}
|
||
}
|
||
$db->update('QPTreasureDB.dbo.GameUnion',$hsave,"UnionID='".$union['UnionID']."'");
|
||
echo "ok";
|
||
}elseif($GG['ty'] == 'dels'){//解散公会
|
||
|
||
}elseif($GG['ty'] == 'del_date'){//删除日期数据
|
||
if($GG['idd']){
|
||
$db->update('QPTreasureDB.dbo.GameUnionMonth',['Del'=>1],"UnionMonthID='".$GG['idd']."'");
|
||
echo "ok";
|
||
}else{
|
||
echo "系统错误";
|
||
}
|
||
}else{
|
||
echo "系统错误";
|
||
}
|
||
unset($GG,$ppxq);
|
||
?>
|