diff --git a/webapp/controller/PayController.class.php b/webapp/controller/PayController.class.php deleted file mode 100644 index a8ec972..0000000 --- a/webapp/controller/PayController.class.php +++ /dev/null @@ -1,525 +0,0 @@ -vipTableCache == null) { - $this->vipTableCache = require('../res/vip@vip.php'); - } - $vip_meta = getVipConfig($this->vipTableCache, $vip_id); - $vip = array( - 'level' => $vip_meta['level'], - 'require' => $vip_meta['require'], - 'reward' => $vip_meta['reward'], - 'dailyreward' => $vip_meta['weekreward'], - 'vipicon' => $vip_meta['vipicon'], - 'viplist' => $vip_meta['viplist'], - 'vipcolor' => $vip_meta['color'], - ); - return $vip; - } - - protected function getDiamondShop($diamond_id) - { - $diamond_meta_table = require('../res/diamondshop@diamondshop.php'); - $diamond_meta = getDiamondShopConfig($diamond_meta_table, $diamond_id); - $diamond = array( - 'shop_id' => $diamond_meta['shop_id'], - 'shop_type' => $diamond_meta['shop_type'], - 'item_id' => $diamond_meta['item_id'], - 'coin_type' => $diamond_meta['coin_type'], - 'coin_num' => $diamond_meta['coin_num'], - 'open_time' => $diamond_meta['open_time'], - 'continue_time' => $diamond_meta['continute_time'], - 'limit_num' => $diamond_meta['limit_num'], - 'limit_type' => $diamond_meta['limit_type'], - 'sort' => $diamond_meta['sort'], - ); - return $diamond; - } - - protected function getItemInfo($itemid) - { - $d = mt\Drop::getOldDrop($itemid); - if (!$d) { - phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); - die(); - } - $item_list = array(); - $item_id_array = $this->getExplode($d['item_id']); - $weight_sum = 0; - $keys = 0; - $item_num_array = $this->getExplode($d['num']); - $weight_array = $this->getExplode($d['weight']); - for ($i = 0; $i < count($weight_array); $i++) { - $random = Rand(0, 10000); - if ($weight_array[$i][0] > $random) { - $item_id = $item_id_array[$i][0]; - $item_num = $item_num_array[$i][0]; - array_push($item_list, array( - 'itemid' => $item_id, - 'itemnum' => $item_num, - )); - } - } - return $item_list; - } - - public function getPayInfo() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $rowUser = $conn->execQueryOne('SELECT create_time, free_coin, free_diamond FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - )); - if (!$rowUser) { - phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); - return; - } - $times = 0; - $info_list = array(); - $diamond_meta_table = require('../res/diamondshop@diamondshop.php'); - for ($i = 1; $i <= count($diamond_meta_table); $i++) { - $diamond = $this->getDiamondShop($i); - $item = mt\Item::getOldItem($diamond['item_id']); - $item_list = $this->getItemInfo($item['fuctionindex']); - if (!$item || !$diamond) { - continue; - } - $row = $conn->execQueryOne('SELECT today_times FROM buy_his ' . - ' WHERE accountid=:accountid AND itemid=:itemid;', - array( - ':accountid' => $account_id, - ':itemid' => $diamond['item_id'] - )); - if (!$row) { - $times = $diamond['limit_num']; - } else { - //无限次数 - if ($diamond['limit_num'] == -1) { - $times = $diamond['limit_num']; - } else { - //限定次数 - $times = $diamond['limit_num'] - $row['today_times']; - if ($times < 0) { - $times = 0; - } - } - } - //开启结束时间 - $sub_item = array(); - $coin_icon = ''; - $open_time = '-1'; - $end_time = '-1'; - if ($diamond['coin_type'] != 0) { - $sub_item = mt\Item::getOldItem($diamond['coin_type']); - $coin_icon = $sub_item['icon']; - } else { - //免费金币钻石领取次数及有效时间 - if ($diamond['shop_type'] == 2) { - $times = $diamond['limit_num'] - $rowUser['free_coin']; - } - if ($diamond['shop_type'] == 1) { - $times = $diamond['limit_num'] - $rowUser['free_diamond']; - } - if ($times == 0) { - $end_time = phpcommon\getdayseconds(phpcommon\getNowTime()) + 24 * 3600; - } - } - if ($diamond['open_time'] != '-1') { - if ($diamond['open_time'] != '1') { - $open_time = strtotime($diamond['open_time']); - }else { - $open_time = $rowUser['create_time']; - } - $end_time = $open_time + $diamond['continue_time']; - if (phpcommon\getNowTime() > $end_time || phpcommon\getNowTime() < $open_time) { - $end_time = '-1'; - } - } - array_push($info_list, array( - 'shop_type' => $diamond['shop_type'], - 'item_id' => $diamond['item_id'], - 'item_icon' => $item['icon'], - 'coin_type' => $diamond['coin_type'], - 'coin_num' => $diamond['coin_num'], - 'coin_icon' => $coin_icon, - 'open_time' => $open_time, - 'end_time' => $end_time, - 'buy_num' => $times, - 'sort' => $diamond['sort'], - 'item_list' => $item_list, - )); - } - echo json_encode(array( - 'errcode' => 0, - 'errmsg'=> '', - 'info_list' => $info_list - )); - } - - public function getVipInfo() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $row = $conn->execQueryOne('SELECT sum_coin FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); - return; - } - $vip_list = array(); - $vip_level = 0; - $vip_icon = ''; - $vip_item_list = array(); - $vip_today_item_list = array(); - $vip_meta_table = require('../res/vip@vip.php'); - for ($i = 0; $i < count($vip_meta_table); $i++) { - $vip_status = 0; - $vip_today_status = 0; - $vip = $this->getVip($i); - $max_level = $vip['level']; - if ($row['sum_coin'] >= $vip['require']) { - $vip_level = $vip['level']; - $vip_icon = $vip['vipicon']; - } - $rowVip = $conn->execQueryOne('SELECT reward_id, vipid, reward_status, today_reward_id, today_reward_status ' . - ' FROM vipinfo WHERE accountid=:accountid AND vipid=:vipid;', - array( - ':accountid' => $account_id, - ':vipid' => $vip['level'] - )); - if ($rowVip) { - $vip_status = $rowVip['reward_status']; - $vip_today_status = $rowVip['today_reward_status']; - } - $vip_item_list = $this->getVipItemInfo($vip['reward']); - $vip_today_item_list = $this->getVipItemInfo($vip['dailyreward']); - $vip_tequan_list = $this->getExplode($vip['viplist']); - array_push($vip_list, array( - 'vip_id' => $vip['level'], - 'require' => $vip['require'], - 'vip_color' => $vip['vipcolor'], - 'vip_status' => $vip_status, - 'vip_item_list' => $vip_item_list, - 'vip_today_status' => $vip_today_status, - 'vip_today_item_list' => $vip_today_item_list, - 'vip_tequan_list' => $vip_tequan_list, - )); - } - - if ($vip_level >= $max_level) { - $v = $this->getVip($vip_level); - } else { - $v = $this->getVip($vip_level + 1); - } - $sum = $v['require']; - $exp = $sum - $row['sum_coin']; - echo json_encode(array( - 'errcode' => 0, - 'errmsg'=> '', - 'vip_level' => $vip_level, - 'vip_icon' => $vip_icon, - 'exp' => $exp, - 'sum' => $sum, - 'vip_list' => $vip_list - )); - } - - protected function getVipItemInfo($id) - { - $item = mt\Item::getOldItem($id); - if (!$item) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); - die(); - } - $d = mt\Drop::getOldDrop($item['fuctionindex']); - if (!$d) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); - die(); - } - $item_list = array(); - $item_id_array = $this->getExplode($d['item_id']); - $weight_sum = 0; - $keys = 0; - $item_num_array = $this->getExplode($d['num']); - $weight_array = $this->getExplode($d['weight']); - $time_array = $this->getExplode($d['time']); - for ($i = 0; $i < count($weight_array); $i++) { - $random = Rand(0, 10000); - if ($weight_array[$i][0] > $random) { - $item_id = $item_id_array[$i][0]; - $item_num = $item_num_array[$i][0]; - $time = $time_array[$i][0]; - array_push($item_list, array( - 'item_id' => $item_id, - 'item_num' => $item_num, - 'time' => $time, - )); - } - } - return $item_list; - } - - public function getVipReward() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $vip_id = $_REQUEST['vip_id']; - $type = $_REQUEST['reward_type']; - $status = 0; - $vip = $this->getVip($vip_id); - if (!$vip) { - phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); - return; - } - $rowVip = $conn->execQueryOne('SELECT reward_status, today_reward_status ' . - ' FROM vipinfo WHERE accountid=:accountid AND vipid=:vipid;', - array( - ':accountid' => $account_id, - ':vipid' => $vip['level'] - )); - if ($rowVip) { - if ($type == 1) { - $status = $rowVip['today_reward_status']; - } - if ($type == 2) { - $status = $rowVip['reward_status']; - } - if ($status == 1) { - phpcommon\sendError(ERR_USER_BASE + 2, '该奖励已领取'); - return; - } - } - $row = $conn->execQueryOne('SELECT sum_coin FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); - return; - } - - if ($vip['require'] > $row['sum_coin']) { - phpcommon\sendError(ERR_USER_BASE + 4, '没有达到vip要求'); - return; - } - - if (!$rowVip) { - $ret = $conn->execScript('INSERT INTO vipinfo(accountid, vipid, reward_id, reward_status, today_reward_id, today_reward_status, create_time, modify_time) ' . - ' VALUES(:accountid, :vipid, :reward_id, 0, :today_reward_id, 0, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:accountid, vipid=0, reward_id=0, reward_status=0, today_reward_id=0, today_reward_status=0, modify_time=:modify_time;', - array( - ':accountid' => $account_id, - ':vipid' => $vip['level'], - ':reward_id' => $vip['reward'], - ':today_reward_id' => $vip['dailyreward'], - ':create_time' => phpcommon\getNowTime(), - ':modify_time' => phpcommon\getNowTime() - )); - if (!$ret) { - die(); - return; - } - } - $this->updateStatus($account_id, $vip_id, $type); - //发送奖励 - $item_list = array(); - if ($type == 2) { - $item_list = $this->getVipItemInfo($vip['reward']); - } - if ($type == 1) { - $item_list = $this->getVipItemInfo($vip['dailyreward']); - } - $addreward = new classes\AddReward(); - $all_item_list = array(); - foreach ($item_list as $item) { - //增加奖励 - $items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time'], 0); - foreach($items as $i) { - array_push($all_item_list, array( - 'item_id' => $i['item_id'], - 'item_num' => $i['item_num'], - 'time' => $i['time'], - )); - } - } - $coin_num = $addreward->getCoinNum($account_id); - $rmb_num = $addreward->getRmbNum($account_id); - echo json_encode(array( - 'errcode' => 0, - 'errmsg'=> '', - 'coin_nums' => $coin_num, - 'rmb_nums' => $rmb_num, - 'item_list' => $item_list, - 'all_item_list' => $all_item_list, - )); - } - - protected function updateStatus($accountid, $vipid, $type) - { - $conn = $this->getMysql($accountid); - $vip = $this->getVip($vipid); - if (!$vip) { - phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); - return; - } - if ($type == 1) { - $ret = $conn->execScript('UPDATE vipinfo SET today_reward_status=1, modify_time=:modify_time ' . - ' WHERE accountid=:accountid AND vipid=:vipid;', - array( - ':accountid' => $accountid, - ':vipid' => $vipid, - ':modify_time' => phpcommon\getNowTime() - )); - if (!$ret) { - die(); - return; - } - } - if ($type == 2) { - $ret = $conn->execScript('UPDATE vipinfo SET reward_status=1, modify_time=:modify_time ' . - ' WHERE accountid=:accountid AND vipid=:vipid;', - array( - ':accountid' => $accountid, - ':vipid' => $vipid, - ':modify_time' => phpcommon\getNowTime() - )); - if (!$ret) { - die(); - return; - } - } - } - - public function buyItem() - { - $itemid = $_REQUEST['itemid']; - $itemnum = $_REQUEST['itemnum']; - - $item_meta_table = require('../res/item@item.php'); - $item_meta = getItemConfig($item_meta_table, $itemid); - if (!$item_meta || $item_meta['rmbprice'] < 0.001) { - phpcommon\sendError(ERR_USER_BASE + 2, '参数错误'); - die(); - } - - $params = array( - 'account_id' => $_REQUEST['account_id'], - 'itemid' => $itemid, - 'itemnum' => 1, - 'price' => (float)$item_meta['rmbprice'] - ); - $timestamp = phpcommon\getNowTime(); - $params['sign'] = phpcommon\md5Sign($params, '06ba97e28ea905b0b7ed5477746b07f1', $timestamp); - $params['timestamp'] = $timestamp; - $iv = '1dd2f605f4f8496b'; - $key = 'c868a478c81ff3c168b35d703f787d3c'; - $str_encoded = '2004_' . base64_encode(phpcommon\aesEncrypt(json_encode($params), $iv, $key)); - echo json_encode(array( - 'errcode' => 0, - 'errmsg'=> '', - 'data' => $str_encoded - )); - } - - public function getOrderInfo() - { - - $conn = $this->getMysql($_REQUEST['account_id']); - $row = $conn->execQueryOne('SELECT orderid, status, item_list, itemid ' . - 'FROM orderinfo WHERE orderid=:orderid;', - array( - ':orderid' => $_REQUEST['orderid'] - )); - if (!$row || $row['status'] == 0) { - echo json_encode(array( - 'errcode' => 0, - 'errmsg'=> '', - 'order_state' => 1, - )); - die(); - } - echo json_encode(array( - 'errcode' => 0, - 'errmsg'=> '', - 'order_state' => 0, - 'buy_itemid' => $row[3], - 'buy_itemnum' => 1, - 'item_list' => json_decode($row[2], true) - )); - } - - public function addADtimes() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $row = $conn->execQueryOne('SELECT vip_score, shop_view_times, game_times, newhand, newhand2, view_times2, act_ad_status, game_times2, first_day_ad FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); - return; - } - $newhand = $row['newhand']; - $newhand2 = $row['newhand2']; - $rview_times2 = $row['view_times2']; - $p1 = mt\Parameter::getOldParam(NEWHAND_NUM1); - $fight_times = $p1['value']; - $p2 = mt\Parameter::getOldParam(NEWHAND_NUM2); - $view_times = $p2['value']; - $p3 = mt\Parameter::getOldParam(CREAM_TASK_01); - $fight_times2 = $p3['value']; - $p4 = mt\Parameter::getOldParam(CREAM_TASK_02); - $view_times2 = $p4['value']; - if ($row['game_times'] >= $fight_times && $row['vip_score'] + 1 == $view_times && $newhand == 0) { - $newhand = 1; - } - if ($newhand == 2) { - if ($row['game_times2'] >= $fight_times2 && $row['view_times2'] + 1 == $view_times2 && $newhand2 == 0) { - $newhand2 = 1; - } - $rview_times2++; - } - $status = $row['act_ad_status']; - if ($row['vip_score'] + 1 >= 5 && $row['act_ad_status'] < 1){ - $status = 1; - } - $ret = $conn->execScript('UPDATE user SET vip_score=:vip_score, shop_view_times=:shop_view_times, modify_time=:modify_time, newhand=:newhand, act_ad_status=:act_ad_status, newhand2=:newhand2, view_times2=:view_times2, first_day_ad=:first_day_ad ' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':modify_time' => phpcommon\getNowTime(), - ':vip_score' => $row['vip_score'] + 1, - ':newhand' => $newhand, - ':act_ad_status' => $status, - ':shop_view_times' => $row['shop_view_times'] + 1, - ':newhand2' => $newhand2, - ':view_times2' => $rview_times2, - ':first_day_ad' => $row['first_day_ad'] + 1 - )); - if (!$ret) { - die(); - return; - } - echo json_encode(array( - 'errcode' => 0, - 'errmsg'=> '', - )); - } - -} diff --git a/webapp/controller/ServerSwitchController.class.php b/webapp/controller/ServerSwitchController.class.php index 7b136e7..7ccad54 100644 --- a/webapp/controller/ServerSwitchController.class.php +++ b/webapp/controller/ServerSwitchController.class.php @@ -2,90 +2,8 @@ class ServerSwitchController extends BaseAuthedController { - - private function isForbidCity() - { - return false; - /*if (in_array(strtolower($_REQUEST['province']), - array( - strtolower('Shanghai'), - strtolower('Beijing'), - '上海', - '北京' - )) || - in_array(strtolower($_REQUEST['city']), - array( - strtolower('Guangzhou'), - strtolower('Shenzhen'), - strtolower('Chengdu'), - '广州', - '深圳', - '成都' - )) - ) { - return true; - } - return false;*/ - } - public function getSwitch() { - /*if (SERVER_ENV != _ONLINE) { - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'payable' => 1 - )); - die(); - }*/ - //error_log(json_encode($_REQUEST)); - $payable = 0; - /* - 1:玩家进入第一天,战斗7次,开放充值(除北上广深成)。 - 2:玩家进入第二天,战斗7次,已充值玩家战斗2次(除北上广深成)。 - 3:玩家进入第三天,战斗7次,已充值玩家战斗2次。 - */ - /*if (phpcommon\isValidSessionId($_REQUEST['account_id'], - $_REQUEST['session_id'])) { - $recharge_times = 0; - $conn = $this->getMysql($_REQUEST['account_id']); - $row = $conn->execQueryOne('SELECT recharge_times_total FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $_REQUEST['account_id'] - )); - if ($row) { - $recharge_times = $row['recharge_times_total']; - } - $register_time = phpcommon\extractRegisterTimeFromSessionId($_REQUEST['session_id']); - $nowtime = phpcommon\getNowTime(); - - $register_time = phpcommon\getdayseconds($register_time); - $nowtime = phpcommon\getdayseconds($nowtime); - if ($nowtime - $register_time > 3600 * 24 * 2) { - //第三天 - if ($_REQUEST['battle_times'] >= 2) { - $payable = 1; - } else if ($recharge_times > 0 && $_REQUEST['battle_times'] >= 1) { - $payable = 1; - } - } else if ($nowtime - $register_time > 3600 * 24 * 1) { - //第二天 - if ($this->isForbidCity()) { - } else { - if ($_REQUEST['battle_times'] >= 2) { - $payable = 1; - } else if ($recharge_times > 0 && $_REQUEST['battle_times'] >= 2) { - $payable = 1; - } - } - } else { - //第一天 - if ($this->isForbidCity()) { - } else if ($_REQUEST['battle_times'] >= 3) { - $payable = 1; - } - } - }*/ $payable = 0; echo json_encode(array( 'errcode' => 0,