diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 971fb7e..cf4e537 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -82,7 +82,7 @@ CREATE TABLE `t_hero_skin` ( `skin_state` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤状态 0=已经购,1 = 试用状态', `get_from` int(11) NOT NULL DEFAULT '0' COMMENT '获得方式 0 = 系统赠送 1 = 金币购买', `consume_num` int(11) NOT NULL DEFAULT '0' COMMENT '消耗货币的具体数量', - `trytime` int(11) NOT NULL DEFAULT '0' COMMENT '试用开始时间', + `deadline` int(11) NOT NULL DEFAULT '0' COMMENT '试用截止时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), @@ -100,10 +100,9 @@ CREATE TABLE `t_bag` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', - `color_id` int(11) NOT NULL DEFAULT '0' COMMENT '颜色id', - `status` int(11) NOT NULL DEFAULT '0' COMMENT '状态(0:上阵中,1:已获得,2:未获得)', - `active_time` varchar(50) NOT NULL DEFAULT '' COMMENT '有效时间(体验时间)', `item_num` int(11) NOT NULL DEFAULT '0' COMMENT '数量', + `item_state` int(11) NOT NULL DEFAULT '0' COMMENT '状态(0:上阵中,1:已获得,2:未获得)', + `deadline` int(11) NOT NULL DEFAULT '0' COMMENT '试用截止时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php deleted file mode 100644 index a55bf40..0000000 --- a/webapp/controller/ShareController.class.php +++ /dev/null @@ -1,647 +0,0 @@ - $box_meta['box_type'], - 'item_id' => $box_meta['item_id'], - 'num' => $box_meta['num'], - 'weight' => $box_meta['weight'], - 'type' => $box_meta['type'], - 'time' => $box_meta['time'], - ); - return $b; - } - - protected function getShare($share_id) - { - $share_meta_table = require('../res/share@share.php'); - $share_meta = getShareConfig($share_meta_table, $share_id); - $sh = array( - 'id' => $share_meta['id'], - 'rewards' => $share_meta['rewards'], - 'people' => $share_meta['people'], - 'type' => $share_meta['type'], - ); - return $sh; - } - - protected function subCoin($num, $account_id, $rmb_num) - { - $conn = $this->getMysql($account_id); - if ($rmb_num < $num) { - phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足'); - die(); - } - $ret = $conn->execScript('UPDATE user SET rmb_num=:rmb_num, modify_time=:modify_time ' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':rmb_num' => $rmb_num - $num, - ':modify_time' => phpcommon\getNowTime() - )); - if (!$ret) { - die(); - } - } - - protected function randBoxReward($drop_id, $times) - { - //随机奖励 - $item_list = array(); - if ($times == 0) { - $b = $this->getbox($drop_id); - $item_id_array = $this->getExplode($b['item_id']); - $times = count($item_id_array); - } - for ($j = 0; $j < $times; $j++) { - $b = $this->getbox($drop_id); - if (!$b) { - phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); - die(); - } - $item_id_array = $this->getExplode($b['item_id']); - $weight_sum = 0; - $keys = 0; - $item_num_array = $this->getExplode($b['num']); - $weight_array = $this->getExplode($b['weight']); - $time_array = $this->getExplode($b['time']); - for ($i = 0; $i < count($weight_array); $i++) { - $weight_sum += $weight_array[$i][0]; - } - $random = Rand(0, $weight_sum); - $weight = 0; - for ($i = 0; $i < count($weight_array); $i++) { - $weight += $weight_array[$i][0]; - if ($weight > $random) { - $keys = $i; - break; - } - } - $item_id = $item_id_array[$keys][0]; - $item_num = $item_num_array[$keys][0]; - $time = $time_array[$keys][0]; - array_push($item_list, array( - 'item_id' => $item_id, - 'item_num' => $item_num, - 'time' => $time - )); - } - return $item_list; - } - - public function beeReward() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $row = $conn->execQueryOne('SELECT first_bee FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); - return; - } - $item_list = array(); - if ($row['first_bee'] == 0) { - array_push($item_list, array( - 'item_id' => 12119, - 'item_num' => 1, - 'time' => 1 - )); - $ret = $conn->execScript('UPDATE user SET first_bee=1, ' . - 'modify_time=:modify_time WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':modify_time' => phpcommon\getNowTime(), - )); - } else { - $item_list = $this->randBoxReward(4, 1); - } - $all_item_list = array(); - foreach ($item_list as $item) { - $addreward = new classes\AddReward(); - $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); - $num = $addreward->getRmbNum($account_id); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'item_list' => $item_list, - 'rmb_nums' => $num, - 'all_item_list' => $all_item_list - )); - } - - public function keyBoxInfo() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $free = $_REQUEST['free']; - $drop_id = 0; - //随机奖励 - $row = $conn->execQueryOne('SELECT free_lot_ticket, free_dou_lot_ticket, free_box FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); - return; - } - $item_list = array(); - $rmb_num = 0; - if ($free != 0) { - if ($row['free_dou_lot_ticket'] <= 0) { - $p = mt\Parameter::getOldParam(DIAMONDBOX10); - $rmb_num = $p['param_value']; - } else { - $ret = $conn->execScript('UPDATE user SET free_dou_lot_ticket=:free_dou_lot_ticket, ' . - 'modify_time=:modify_time WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':modify_time' => phpcommon\getNowTime(), - ':free_dou_lot_ticket' => $row['free_dou_lot_ticket'] - 1, - )); - } - $item_list = $this->randBoxReward(2, 10); - } else { - $rmb_num = 0; - $item_list = $this->randBoxReward(1, 1); - if ($row['free_lot_ticket'] <= 0) { - if ($row['free_box'] >= 5) { - phpcommon\sendError(ERR_USER_BASE + 2, '今日免费次数已达上限'); - die(); - return; - } - $ret = $conn->execScript('UPDATE user SET free_box=:free_box, ' . - 'modify_time=:modify_time WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':modify_time' => phpcommon\getNowTime(), - ':free_box' => $row['free_box'] + 1, - )); - } else { - $ret = $conn->execScript('UPDATE user SET free_lot_ticket=:free_lot_ticket, ' . - 'modify_time=:modify_time WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':modify_time' => phpcommon\getNowTime(), - ':free_lot_ticket' => $row['free_lot_ticket'] - 1, - )); - } - - } - $row = $conn->execQueryOne('SELECT rmb_num FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); - die(); - } - //扣除钻石 - $this->subCoin($rmb_num, $account_id, $row['rmb_num']); - $num = $row['rmb_num'] - $rmb_num; - //保存开宝箱奖励 - $boxreward_uuid = 'game2005api_boxreward_uuid:' . $_REQUEST['account_id']; - $boxreward_list = array(); - $r = $this->getRedis($boxreward_uuid); - $user_db_str = $r->get($boxreward_uuid); - if (!$r) { - die(); - return; - } - if (empty($user_db_str)) { - $boxreward_db = array( - 'boxreward_uuid' => $boxreward_uuid, - 'boxreward_list' => $item_list, - ); - $r -> set($boxreward_uuid, json_encode($boxreward_db)); - $r -> pexpire($boxreward_uuid, 1000 * 7200); - } else { - $boxreward_db = array( - 'boxreward_uuid' => $boxreward_uuid, - 'boxreward_list' => $item_list, - ); - $r -> set($boxreward_uuid, json_encode($boxreward_db)); - $r -> pexpire($boxreward_uuid, 1000 * 7200); - } - $all_item_list = array(); - //$quest = new classes\Quest(); - //$quest->triggerQuest(71004, 1, 1, $account_id); - foreach ($item_list as $item) { - $addreward = new classes\AddReward(); - $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'], - )); - } - } - $addreward = new classes\AddReward(); - $coin_num = $addreward->getCoinNum($account_id); - $num = $addreward->getRmbNum($account_id); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'item_list' => $item_list, - 'rmb_nums' => $num, - 'all_item_list' => $all_item_list - )); - } - - public function keyBoxDoubleReward() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $row = $conn->execQueryOne('SELECT keys_num FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); - return; - } - - $boxreward_uuid = 'game2005api_boxreward_uuid:' . $_REQUEST['account_id']; - $r = $this->getRedis($boxreward_uuid); - $user_db_str = $r->get($boxreward_uuid); - if (empty($user_db_str)) { - phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); - return; - } - $user_db = json_decode($user_db_str, true); - if (empty($user_db)) { - phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); - return; - } - $p = mt\Parameter::getOldParam(REWARD_TIMES); - $times = $p['param_value'] - 1; - foreach ($user_db['boxreward_list'] as $boxreward) { - //增加奖励 - $addreward = new classes\AddReward(); - $addreward->addReward($boxreward['item_id'], $boxreward['item_num'] * $times, $account_id); - } - $r->del($boxreward_uuid, json_encode($user_db)); - $addreward = new classes\AddReward(); - $coin_num = $addreward->getCoinNum($account_id); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'coin_nums' => $coin_num, - )); - } - - public function shareFriendInfo() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $info_list = array(); - $rows = $conn->execQuery('SELECT ach_id, status FROM share_achievement WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - $share_meta_table = require('../res/share@share.php'); - if (count($rows) == 0) { - $num = count($rows) + 1; - $type = 1; - for ($i = $num; $i <= count($share_meta_table); $i++) { - $s = $this->getShare($i); - if (!$s || $s['type'] != $type) { - continue; - } - $id = $i; - $ret = $conn->execScript('INSERT INTO share_achievement(accountid, ach_id, status, create_time, modify_time) ' . - ' VALUES(:account_id, :ach_id, :status, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:account_id, ach_id=:ach_id, status=:status, modify_time=:modify_time;', - array( - ':account_id' => $account_id, - ':ach_id' => $id, - ':status' => 0, - ':create_time' => phpcommon\getNowTime(), - ':modify_time' => phpcommon\getNowTime() - )); - if(!$ret){ - die(); - return; - } - } - } - $rows = $conn->execQuery('SELECT ach_id, status FROM share_achievement WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - foreach ($rows as $row) { - $item_list = array(); - $sh = $this->getShare($row['ach_id']); - $array = $this->getExplode($sh['rewards']); - for ($i = 0; $i < count($array); $i++) { - array_push($item_list, array( - 'item_id' => $array[$i][0], - 'num' => $array[$i][1], - 'time' => $array[$i][2], - )); - } - array_push($info_list, array( - 'achivement_id' => $row['ach_id'], - 'status' => $row['status'], - 'item_list' => $item_list, - 'people_num' => $sh['people'], - )); - } - - - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'info_list' => $info_list - )); - } - - public function shareFriendReward() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $ach_id = $_REQUEST['ach_id']; - $row = $conn->execQueryOne('SELECT status FROM share_achievement WHERE accountid=:accountid AND ach_id=:ach_id;', - array( - ':accountid' => $account_id, - ':ach_id' => $ach_id, - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); - return; - } - if ($row['status'] != 0) { - phpcommon\sendError(ERR_USER_BASE + 3, '奖励已领取'); - return; - } - //获取奖励信息 - $url = ''; - if (SERVER_ENV == _ONLINE) { - $url = 'https://service.kingsome.cn/webapp/index.php?c=DailyMission&a=getInviteeNum&'; - } else { - $url = 'https://service-test.kingsome.cn/webapp/index.php?c=DailyMission&a=getInviteeNum&'; - } - $timestamp = phpcommon\getNowTime(); - $params = array( - 'account_id' => $_REQUEST['account_id'], - 'session_id' => $_REQUEST['session_id'], - 'activity_param' => $_REQUEST['activity_param'], - ); - $response = ''; - if (!phpcommon\HttpClient::get($url, $params, $response)) { - phpcommon\sendError(ERR_RETRY, '系统繁忙'); - return; - } - //领取奖励 - $data = json_decode($response, true); - $peo_num = $data['invitee_num']; - $sh = $this->getShare($ach_id); - if ($peo_num < $sh['people']) { - phpcommon\sendError(ERR_USER_BASE + 4, '未达到人数要求'); - return; - } - $item_list = array(); - $addreward = new classes\AddReward(); - $array = $this->getExplode($sh['rewards']); - for ($i = 0; $i < count($array); $i++) { - array_push($item_list, array( - 'item_id' => $array[$i][0], - 'item_num' => $array[$i][1], - 'time' => $array[$i][2], - )); - $all_item_list = $addreward->addReward($array[0][0], $array[0][1], $account_id, $array[0][2], 0); - } - //更新状态 - $ret = $conn->execScript('UPDATE share_achievement SET status=1, modify_time=:modify_time ' . - ' WHERE accountid=:accountid AND ach_id=:ach_id;', - array( - ':accountid' => $account_id, - ':modify_time' => phpcommon\getNowTime(), - ':ach_id' => $ach_id - )); - if (!$ret) { - die(); - return; - } - $addreward = new classes\AddReward(); - $coin_num = $addreward->getCoinNum($account_id); - $rmb_num = $addreward->getRmbNum($account_id); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'item_list' => $item_list, - 'all_item_list' => $all_item_list, - 'coin_nums' => $coin_num, - 'rmb_nums' => $rmb_num - )); - } - - public function shareDobleReward() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $ach_id = $_REQUEST['ach_id']; - //获取奖励信息 - $url = ''; - if (SERVER_ENV == _ONLINE) { - $url = 'https://service.kingsome.cn/webapp/index.php?c=DailyMission&a=getInviteeNum&'; - } else { - $url = 'https://service-test.kingsome.cn/webapp/index.php?c=DailyMission&a=getInviteeNum&'; - } - $timestamp = phpcommon\getNowTime(); - $params = array( - 'account_id' => $_REQUEST['account_id'], - 'session_id' => $_REQUEST['session_id'], - 'activity_param' => $_REQUEST['activity_param'], - ); - $response = ''; - if (!phpcommon\HttpClient::get($url, $params, $response)) { - phpcommon\sendError(ERR_RETRY, '系统繁忙'); - return; - } - //领取奖励 - $data = json_decode($response, true); - $peo_num = $data['invitee_num']; - $sh = $this->getShare($ach_id); - if ($peo_num < $sh['people']) { - phpcommon\sendError(ERR_USER_BASE + 4, '未达到人数要求'); - return; - } - $p = mt\Parameter::getOldParam(REWARD_TIMES); - $times = $p['param_value'] - 1; - $addreward = new classes\AddReward(); - if ($ach_id != 6) { - $array = $this->getExplode($sh['rewards']); - $addreward->addReward($array[0][0], $array[0][1] * $times, $account_id, $array[0][2], 0); - } else if ($ach_id == 6) { - $addreward->addReward(10003, 50 * $times, $account_id, 0, 0); - } - $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 - )); - } - - - public function getKefuReward() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $mail_id = $_REQUEST['mail_ids']; - - $url = ''; - if (SERVER_ENV == _ONLINE) { - $url = 'https://gamemail.kingsome.cn/webapp/index.php?c=Mail&a=getAttachment&'; - } else { - $url = 'https://gamemail-test.kingsome.cn/webapp/index.php?c=Mail&a=getAttachment&'; - } - $params = array( - 'account_id' => $_REQUEST['account_id'], - 'mail_ids' => $mail_id, - 'session_id' => $_REQUEST['session_id'] - ); - if (!phpcommon\HttpClient::get($url, $params, $response)) { - phpcommon\sendError(ERR_RETRY, '系统繁忙'); - return; - } - $row = $conn->execQueryOne('SELECT kefu_status FROM user WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); - return; - } - if ($row['kefu_status'] != 0) { - phpcommon\sendError(ERR_USER_BASE + 3, '客服奖励已领取'); - die(); - return; - } - $item_list = array(); - $item_id = 0; - $item_num = 0; - $data = json_decode($response, true); - $errcode = $data['errcode']; - $errmsg = $data['errmsg']; - if ($errcode == 0) { - foreach($data['attachments'] as $kefu){ - $item_id = $kefu['itemid']; - $item_num = $kefu['itemnum']; - } - $addreward = new classes\AddReward(); - $addreward->addReward($item_id, $item_num, $account_id,0,0); - array_push($item_list, array( - 'item_id' => $item_id, - 'item_num' => $item_num, - 'time' => 0 - )); - - //保存客服奖励 - $kefureward_uuid = 'game2005api_kefureward_uuid:' . $_REQUEST['account_id']; - $kefureward_list = array(); - $r = $this->getRedis($kefureward_uuid); - $user_db_str = $r->get($kefureward_uuid); - if (!$r) { - die(); - return; - } - if (empty($user_db_str)) { - $kefureward_db = array( - 'kefureward_uuid' => $kefureward_uuid, - 'kefureward_list' => $item_list, - ); - $r -> set($kefureward_uuid, json_encode($kefureward_db)); - $r -> pexpire($kefureward_uuid, 1000 * 7200); - } else { - $kefureward_db = array( - 'kefureward_uuid' => $kefureward_uuid, - 'kefureward_list' => $item_list, - ); - $r -> set($kefureward_uuid, json_encode($kefureward_db)); - $r -> pexpire($kefureward_uuid, 1000 * 7200); - } - - //更新状态 - $ret = $conn->execScript('UPDATE user SET kefu_status=1, modify_time=:modify_time ' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':modify_time' => phpcommon\getNowTime(), - )); - if (!$ret) { - die(); - return; - } - } - $addreward = new classes\AddReward(); - $coin_num = $addreward->getCoinNum($account_id); - $rmb_num = $addreward->getRmbNum($account_id); - echo json_encode(array( - 'errcode' => $errcode, - 'errmsg' => $errmsg, - 'item_list' => $item_list, - 'coin_nums' => $coin_num, - 'rmb_nums' => $rmb_num - )); - } - - public function kefuDoubleReward() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $mail_id = $_REQUEST['mail_ids']; - $kefureward_uuid = 'game2005api_kefureward_uuid:' . $_REQUEST['account_id']; - $r = $this->getRedis($kefureward_uuid); - $user_db_str = $r->get($kefureward_uuid); - if (empty($user_db_str)) { - phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); - return; - } - $user_db = json_decode($user_db_str, true); - if (empty($user_db)) { - phpcommon\sendError(ERR_USER_BASE + 1,'session失效'); - return; - } - $p = mt\Parameter::getOldParam(REWARD_TIMES); - $times = $p['param_value'] - 1; - foreach ($user_db['kefureward_list'] as $kefureward) { - //增加奖励 - $addreward = new classes\AddReward(); - $addreward->addReward($kefureward['item_id'], $kefureward['item_num'] * $times, $account_id, 0,0); - } - $r->del($kefureward_uuid, json_encode($user_db)); - $addreward = new classes\AddReward(); - $coin_num = $addreward->getCoinNum($account_id); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'coin_nums' => $coin_num, - )); - } -}