491 lines
19 KiB
PHP
491 lines
19 KiB
PHP
<?php
|
|
require_once('mt/Season.php');
|
|
require_once('mt/SeasonTaskExp.php');
|
|
class NRRController extends BaseAuthedController {
|
|
|
|
public $m_testCnt = 0;
|
|
public function getGunInfo()
|
|
{
|
|
$account_id = $_REQUEST['account_id'];
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "SELECT * FROM gun_intensify WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
|
if($row) {
|
|
error_log("GunTest3======");
|
|
}
|
|
else{
|
|
error_log("GunTest4=======");
|
|
}
|
|
$this->sendDataToClient(0,"test02",$row);
|
|
}
|
|
public function test()
|
|
{
|
|
error_log("testController====".$this->m_testCnt);
|
|
$this->m_testCnt ++;
|
|
}
|
|
public function ResetRRVIP()
|
|
{
|
|
$code = 100;
|
|
$account_id = $_REQUEST['account_id'];
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "UPDATE user set passcard=:passcard WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':passcard'=>0));
|
|
|
|
$this->sendDataToClient($code,"ResetRRVIP",null);
|
|
}
|
|
public function buyRRVIP()
|
|
{
|
|
$code = 100;
|
|
$account_id = $_REQUEST['account_id'];
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "SELECT integral,season_point,passcard FROM user WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
|
if($row) {
|
|
$rrVipState = $row[0]["passcard"];//精英进阶手册是否购买
|
|
if($rrVipState > 0)
|
|
{
|
|
$code = 99;//已经购买了精英手册
|
|
}
|
|
else
|
|
{
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "UPDATE user set passcard=:passcard WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':passcard'=>1));
|
|
error_log("更新user==".json_encode($row));
|
|
}
|
|
}
|
|
$this->sendDataToClient($code,"buyRRVIP",null);
|
|
}
|
|
public function getRRInfo()
|
|
{
|
|
$seasonCfg = mt\Season::getSeasonCfg();
|
|
$curCfg = $this->getCurSeasonCfg();
|
|
$curSeason = $curCfg["season_number"];//当前赛季ID
|
|
$leftSeconds = 0;//当前赛季剩余时间
|
|
$nowTime = phpcommon\getNowTime();
|
|
$startTime =strtotime($curCfg["time1"]);
|
|
$endTime = strtotime($curCfg["time2"]);
|
|
|
|
$leftSeconds = $endTime - $nowTime;//获得剩余时间
|
|
$resultArr = array();
|
|
$account_id = $_REQUEST['account_id'];
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "SELECT integral,season_point,passcard FROM user WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
|
if($row) {
|
|
$rankPoint = $row[0]["integral"];//排位积分
|
|
$seasonPoint = $row[0]["season_point"];//赛季任务积分
|
|
$rrVipState = $row[0]["passcard"];//精英进阶手册是否购买
|
|
$userInfo = array("rankPoint"=>$rankPoint,"seasonPoint"=>$seasonPoint,"rrVIPState"=>$rrVipState,
|
|
"curSeason" => $curSeason,"leftSeconds"=>$leftSeconds);
|
|
array_push($resultArr,$userInfo);
|
|
}
|
|
//查询手册奖励领取状态开始--
|
|
$passInfoArr = array();
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "SELECT passid,active_status,honor_status FROM passinfo WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
|
error_log("Test==".json_encode($row));
|
|
if($row) {
|
|
|
|
$cnt = count($row);
|
|
for($i = 0 ; $i < $cnt; $i ++)
|
|
{
|
|
array_push($passInfoArr,$row[$i]);
|
|
}
|
|
array_push($resultArr,$passInfoArr);
|
|
}
|
|
else
|
|
{
|
|
array_push($resultArr,$passInfoArr);
|
|
}
|
|
//查询手册奖励领取状结束--
|
|
//获得任务信息开始--
|
|
$nowSeconds = $this->getNowTime();
|
|
$nextDaySeconds = phpcommon\getNextDaySeconds($nowSeconds);
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "SELECT * FROM quest WHERE accountid=:accountid AND quest_type=3 || quest_type = 4 ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
|
$taskArr = array();
|
|
if($row)
|
|
{
|
|
foreach($row as $item)
|
|
{
|
|
$taskID = $item["quest_id"];
|
|
$taskNum = $item["quest_num"];
|
|
$rewardState = $item["quest_state"];
|
|
$taskCondition = $item["quest_type"];
|
|
$modifyTime = $item["modify_time"];
|
|
if($nowSeconds >= $modifyTime)
|
|
{
|
|
$rewardState = 0;
|
|
$modifyTime = $nextDaySeconds;
|
|
$taskNum = 0;
|
|
}
|
|
$tmpData = array("id"=>$taskId,"num"=>$taskNum,"rewardState"=>$rewardStat,"condition"=>$taskCondition,"modifyTime"=>$modifyTime);
|
|
array_push($taskArr,$tampData);
|
|
|
|
}
|
|
}
|
|
array_push($resultArr,$taskArr);
|
|
//获得任务信息结束--
|
|
$this->sendDataToClient(0,"getRRInfo",$resultArr);
|
|
}
|
|
public function getAward()
|
|
{
|
|
|
|
|
|
$account_id = $_REQUEST['account_id'];
|
|
$conn = $this->getMysql($account_id);
|
|
$rewardType = $_REQUEST['rewardType'];
|
|
$sqlStr = "SELECT integral,season_point,passcard FROM user WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
|
$rrVipState = 0;
|
|
$activeState = 0;
|
|
$honorState = 0;
|
|
if($row) {
|
|
$rankPoint = $row[0]["integral"];//排位积分
|
|
$seasonPoint = $row[0]["season_point"];//赛季任务积分
|
|
$rrVipState = $row[0]["passcard"];//精英进阶手册是否购买
|
|
}
|
|
$resultItemArr = array();
|
|
$code = 100;
|
|
$allRewardArr = $this->getAwardArr();
|
|
|
|
$rewardId = $_REQUEST['rewardId'];
|
|
$rewardId = $rewardId + 1;
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "SELECT * FROM passinfo WHERE accountid=:accountid AND passid=:passid ;";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':passid' => $rewardId));
|
|
error_log("准备领取奖励===".$rewardId);
|
|
if($row) {
|
|
$tmpState = 0;//奖励是否领取
|
|
$activeState = $row[0]['active_status'];
|
|
$honorState = $row[0]['honor_status'];
|
|
if($rewardType == 1)
|
|
{
|
|
if($activeState >= 1)
|
|
{
|
|
$tmpState = 1;
|
|
}
|
|
|
|
}
|
|
else if($rewardType == 2)
|
|
{
|
|
if($honorState >= 1)
|
|
{
|
|
$tmpState = 1;
|
|
}
|
|
}
|
|
if($tmpState == 1)
|
|
{
|
|
$code = 99;//奖励已经领取
|
|
}
|
|
|
|
error_log("查询结果=======".json_encode($row));
|
|
}
|
|
if($code == 100)//未领取奖励
|
|
{
|
|
if($rewardType == 1)//领取普通的奖励
|
|
{
|
|
$activeState = 1;
|
|
}
|
|
else if($rewardType == 2)//领取精英手册奖励
|
|
{
|
|
$honorState = 1;
|
|
}
|
|
$rewardData = $allRewardArr[$rewardId-1];
|
|
//添加道具开始--
|
|
$item1 = $rewardData["item1"];
|
|
$item2 = $rewardData["item2"];
|
|
$cnt2 = count($item1);
|
|
for($i = 0 ; $i < $cnt2 ; $i ++)
|
|
{
|
|
$tmpID = $item1[$i]["id"];
|
|
if($tmpID >0)
|
|
{
|
|
$itemInfo = array("item_id"=>$item1[$i]["id"],"item_num"=>$item1[$i]["num"]);
|
|
array_push($resultItemArr,$itemInfo);
|
|
}
|
|
}
|
|
if($rrVipState >= 1)//购买了精英手册
|
|
{
|
|
$cnt2 = count($itme2);
|
|
for($i = 0 ; $i < $cnt2 ; $i ++)
|
|
{
|
|
$tmpID = $item2[$i]["id"];
|
|
if($tmpID >0)
|
|
{
|
|
$itemInfo = array("item_id"=>$item2[$i]["id"],"item_num"=>$item2[$i]["num"]);
|
|
array_push($resultItemArr,$itemInfo);
|
|
}
|
|
}
|
|
}
|
|
$this->addItem($resultItemArr);
|
|
//添加道具结束--
|
|
//插入数据到DB开始--
|
|
phpcommon\SqlHelper::insertOrUpdate
|
|
(
|
|
$this->getSelfMysql(),
|
|
'passinfo',
|
|
array(
|
|
'accountid' => $this->getAccountId(),
|
|
'passid' => $rewardId
|
|
),
|
|
array(
|
|
'accountid' => $this->getAccountId(),
|
|
'passid' => $rewardId,
|
|
'active_status' => $activeState,
|
|
'honor_status' => $honorState,
|
|
'create_time' => $this->getNowTime(),
|
|
'modify_time' => $this->getNowTime()
|
|
),
|
|
array(
|
|
'active_status' => $activeState,
|
|
'honor_status' =>$honorState,
|
|
'modify_time' =>$this->getNowTime()
|
|
)
|
|
);
|
|
//插入数据到DB结束--
|
|
}
|
|
$toClientData = array();
|
|
array_push($toClientData,$resultItemArr);
|
|
if($code == 100)
|
|
{
|
|
$tmpData2 = array("passid"=>$rewardId,"active_status"=>$activeState,"honor_status"=>$honorState);
|
|
array_push($toClientData,$tmpData2);
|
|
}
|
|
|
|
// error_log("当前赛季02==".json_encode($allRewardArr));
|
|
|
|
$this->sendDataToClient($code,"getAward",$toClientData);
|
|
}
|
|
public function getAwardArr()
|
|
{
|
|
$seasonCfg = mt\Season::getSeasonCfg();
|
|
$curCfg = $this->getCurSeasonCfg();
|
|
$baseRewardStr = $curCfg["season_reward"];
|
|
$secondRewardStr = $curCfg["season_reward2"];
|
|
$normalRewardArr = $this->getRewardArr($baseRewardStr);
|
|
$vipRewardArr = $this->getRewardArr($secondRewardStr);
|
|
$resultItemArr = array();
|
|
$cnt = count($normalRewardArr);
|
|
$allRewardArr = array();
|
|
for($i = 0; $i < $cnt ; $i ++)
|
|
{
|
|
$len1 = count($normalRewardArr[$i]);
|
|
$len2 = count($vipRewardArr[$i]);
|
|
$itemArr1 = array();
|
|
$itemArr2 = array();
|
|
for($j = 0; $j < $len1; $j++)
|
|
{
|
|
$tmpItemData = $this->getRewardByStr($normalRewardArr[$i][$j]);
|
|
array_push($itemArr1,$tmpItemData);
|
|
|
|
}
|
|
for($j = 0; $j < $len2; $j++)
|
|
{
|
|
$tmpItemData = $this->getRewardByStr($vipRewardArr[$i][$j]);
|
|
array_push($itemArr2,$tmpItemData);
|
|
}
|
|
$tmpItemCfg = array("item1"=>$itemArr1,"item2"=>$itemArr2);
|
|
array_push($allRewardArr,$tmpItemCfg);
|
|
}
|
|
return $allRewardArr;
|
|
}
|
|
public function getAllReward()//一键领取所有能领取的奖励
|
|
{
|
|
$code = 100;
|
|
$allRewardArr = $this->getAwardArr();
|
|
$account_id = $_REQUEST['account_id'];
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "SELECT season_point,passcard FROM user WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
|
$seasonTaskExpCfg = null;
|
|
$curLv = 0;
|
|
$rrVipState = 0;
|
|
$cnt1 = count($allRewardArr);
|
|
if($row)
|
|
{
|
|
$seasonPoint = $row[0]["season_point"];//赛季任务积分
|
|
$rrVipState = $row[0]["passcard"];//精英进阶手册是否购买
|
|
$seasonTaskExpCfg = mt\SeasonTaskExp::getSeasonTaskExpCfgByPoint($seasonPoint);
|
|
$curLv = $seasonTaskExpCfg["itemCfg"]["lv"];
|
|
}
|
|
$resultArr = array();
|
|
$resultItemArr = array();//要添加到DB的道具列表
|
|
if($code == 100)
|
|
{
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "SELECT * FROM passinfo WHERE accountid=:accountid ;";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
|
for($i = 0 ;$i < $curLv;$i++)
|
|
{
|
|
$active_status = 0;
|
|
$honor_status =0;
|
|
$isUpdate = 0;
|
|
for($k = 0; $k <count($row); $k ++)
|
|
{
|
|
$passid = $row[$k]["passid"];
|
|
if($passid == ($i+1))
|
|
{
|
|
$active_status = $row[$k]['active_status'];
|
|
$honor_status = $row[$k]['honor_status'];
|
|
break;
|
|
}
|
|
}
|
|
if($active_status == 0)//未领取普通奖励
|
|
{
|
|
$item1 = $allRewardArr[$i]["item1"];
|
|
$cnt2 = count($item1);
|
|
for($j = 0 ; $j < $cnt2 ; $j ++)
|
|
{
|
|
$tmpID = $item1[$j]["id"];
|
|
if($tmpID >0)
|
|
{
|
|
$itemInfo = array("item_id"=>$item1[$j]["id"],"item_num"=>$item1[$j]["num"],"passid"=>$i);
|
|
array_push($resultItemArr,$itemInfo);
|
|
}
|
|
}
|
|
$isUpdate = 1;
|
|
}
|
|
if($rrVipState > 0)//购买了精英手册
|
|
{
|
|
if($honor_status == 0)//未领取精英奖励
|
|
{
|
|
$item2 = $allRewardArr[$i]["item2"];
|
|
$cnt2 = count($item2);
|
|
for($j = 0; $j < $cnt2; $j++)
|
|
{
|
|
$tmpID = $item2[$j]["id"];
|
|
if($tmpID >0)
|
|
{
|
|
$itemInfo = array("item_id"=>$item2[$j]["id"],"item_num"=>$item2[$j]["num"],"passid"=>$i);
|
|
array_push($resultItemArr,$itemInfo);
|
|
}
|
|
}
|
|
$honor_status = 1;
|
|
$isUpdate = 1;
|
|
}
|
|
|
|
}
|
|
if($isUpdate == 1)
|
|
{
|
|
//插入数据到DB开始--
|
|
phpcommon\SqlHelper::insertOrUpdate
|
|
(
|
|
$this->getSelfMysql(),
|
|
'passinfo',
|
|
array(
|
|
'accountid' => $this->getAccountId(),
|
|
'passid' => ($i+1)
|
|
),
|
|
array(
|
|
'accountid' => $this->getAccountId(),
|
|
'passid' => ($i+1),
|
|
'active_status' => 1,
|
|
'honor_status' => $honor_status,
|
|
'create_time' => $this->getNowTime(),
|
|
'modify_time' => $this->getNowTime()
|
|
),
|
|
array(
|
|
'active_status' => 1,
|
|
'honor_status' =>$honor_status,
|
|
'modify_time' =>$this->getNowTime()
|
|
)
|
|
);
|
|
}
|
|
//插入数据到DB结束--
|
|
}
|
|
|
|
}
|
|
$tmpArr = array();
|
|
array_push($tmpArr, $allRewardArr);
|
|
array_push($tmpArr,$resultItemArr);
|
|
$cnt3 = count($resultItemArr);
|
|
if(cnt3 <= 0)
|
|
{
|
|
$code = 99;//没有奖励可以领取
|
|
}
|
|
$this->sendDataToClient($code,"getAllReward",$resultItemArr);
|
|
}
|
|
public function lvUp()//购买升级
|
|
{
|
|
$code = 100;
|
|
$resultArr = null;
|
|
$account_id = $_REQUEST['account_id'];
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "SELECT season_point FROM user WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
|
$seasonTaskExpCfg = null;
|
|
if($row) {
|
|
$seasonPoint = $row[0]["season_point"];//赛季任务积分
|
|
$seasonTaskExpCfg = mt\SeasonTaskExp::getSeasonTaskExpCfgByPoint($seasonPoint);
|
|
$curLv = $seasonTaskExpCfg["itemCfg"]["lv"];
|
|
$nextCfg = mt\SeasonTaskExp::getSeasonTaskExpCfgByLv($curLv+1);
|
|
if($nextCfg)
|
|
{
|
|
$nextLv = $nextCfg['lv'];
|
|
$nextMinPoint = $nextCfg['min_point'];
|
|
$resultArr = array("Lv"=>$nextLv,"point"=>$nextMinPoint);
|
|
//更新数据开始--
|
|
$conn = $this->getMysql($account_id);
|
|
$sqlStr = "UPDATE user set season_point =:point WHERE accountid=:accountid; ";
|
|
$row = $conn->execQuery($sqlStr,array(':point'=>$nextMinPoint,':accountid' => $account_id));
|
|
//更新数据结束--
|
|
|
|
}
|
|
else
|
|
{
|
|
$code = 98;//已经升到最大级
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
$code =99;
|
|
}
|
|
$this->sendDataToClient($code,"buyLvUp",$resultArr);
|
|
}
|
|
public function getCurSeasonCfg()
|
|
{
|
|
$seasonCfg = mt\Season::getSeasonCfg();
|
|
$tmpData = null;
|
|
foreach($seasonCfg as $item)
|
|
{
|
|
$tmpCfg = $item;
|
|
$nowTime = phpcommon\getNowTime();
|
|
$startTime =strtotime($tmpCfg["time1"]);
|
|
$endTime = strtotime($tmpCfg["time2"]);
|
|
if($nowTime >= $startTime && $nowTime <= $endTime)
|
|
{
|
|
$tmpData = $tmpCfg;
|
|
break;
|
|
}
|
|
}
|
|
return $tmpData;
|
|
}
|
|
public function getRewardArr($str)
|
|
{
|
|
$itemArr = array();
|
|
$strArr = explode("|",$str);
|
|
$cnt = count($strArr);
|
|
for($i = 0 ;$i < $cnt; $i++)
|
|
{
|
|
$strMutiArr = explode(";",$strArr[$i]);
|
|
array_push($itemArr,$strMutiArr);
|
|
}
|
|
return $itemArr;
|
|
}
|
|
public function getRewardByStr($str)
|
|
{
|
|
$strArr2 = explode(":",$str);
|
|
$itemID = $strArr2[0];
|
|
$itemNum = $strArr2[1];
|
|
$tmpItem = array("id"=>$itemID,"num"=>$itemNum,"state"=>0);
|
|
return $tmpItem;
|
|
}
|
|
|
|
}
|