This commit is contained in:
aozhiwei 2020-06-10 10:42:08 +08:00
parent cab9c67531
commit 04d069dd49
3 changed files with 133 additions and 77 deletions

View File

@ -85,6 +85,7 @@ CREATE TABLE `user` (
`daily_first_login` int(11) NOT NULL DEFAULT '0' COMMENT '每天是否第一次登陆',
`daily_time` int(11) NOT NULL DEFAULT '0' COMMENT '每日刷新时间',
`free_box` int(11) NOT NULL DEFAULT '0' COMMENT '每日免费宝箱',
`chapingcount` int(11) NOT NULL DEFAULT '0' COMMENT '每日插屏次数',
PRIMARY KEY (`idx`),
UNIQUE KEY `accountid` (`accountid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

View File

@ -0,0 +1,6 @@
begin;
alter table user add column `chapingcount` int(11) NOT NULL DEFAULT '0' COMMENT '每日插屏次数';
insert into version (version) values(20200610);
commit;

View File

@ -115,9 +115,9 @@ class RoleController{
':accountid' => $account_id
));
if (!$row) {
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box) ' .
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0) ' .
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=0, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0;',
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, chapingcount) ' .
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0, 0) ' .
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=0, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, chapingcount=0;',
array(
':accountid' => $account_id,
':user_name' => $user_name,
@ -155,7 +155,8 @@ class RoleController{
'recharge_times_total' => 0,
'first_login' => 0,
'daily_first_login' => 0,
'free_box' => 0
'free_box' => 0,
'chapingcount' => 0
));
} else {
$ret = $conn->execScript('UPDATE user SET first_login=1 ' .
@ -189,8 +190,9 @@ class RoleController{
}
$nowTime = phpcommon\getdayseconds(time());
$daily_first_login = $row['daily_first_login'];
$chapingcount = $row['chapingcount'];
if ($row['daily_time'] == 0 || ($nowTime - phpcommon\getdayseconds($row['daily_time']) > 0)) {
$ret = $conn->execScript('UPDATE user SET daily_first_login=0, ' .
$ret = $conn->execScript('UPDATE user SET daily_first_login=0, chapingcount=0, ' .
'modify_time=:modify_time WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
@ -201,6 +203,7 @@ class RoleController{
return;
}
$daily_first_login = 0;
$chapingcount = 0;
}
echo json_encode(array(
'errcode' => 0,
@ -230,7 +233,8 @@ class RoleController{
'vip_score' => $row['vip_score'],
'coin_nums' => $row['coin_num'],
'diamond_nums' => $row['diamond_num'],
'free_box' => $row['free_box']
'free_box' => $row['free_box'],
'chapingcount' => $chapingcount
));
}
}
@ -603,89 +607,92 @@ class RoleController{
public function fightReward()
{
$account_id = $_REQUEST['account_id'];
$room_uuid = $_REQUEST['room_uuid'];
$coin_num = $_REQUEST['coin'];
//登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$conn = $this->getMysql($account_id);
$record_list = array();
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$row = $conn->execQueryOne('SELECT * FROM history_record WHERE accountid=:accountid AND room_uuid=:room_uuid;',
array(
':accountid' => $account_id,
':room_uuid' => $room_uuid
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这场战斗记录');
return;
}
// $conn = $this->getMysql($account_id);
// $record_list = array();
// if (!$conn) {
// phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
// return;
// }
// $row = $conn->execQueryOne('SELECT * FROM history_record WHERE accountid=:accountid AND room_uuid=:room_uuid;',
// array(
// ':accountid' => $account_id,
// ':room_uuid' => $room_uuid
// ));
// if (!$row) {
// phpcommon\sendError(ERR_USER_BASE + 2, '没有这场战斗记录');
// return;
// }
if ($row['status'] == 1) {
phpcommon\sendError(ERR_USER_BASE + 3, '战斗奖励已领取');
return;
}
$coin_num = $row['coin'];
$p = $this->getParameter(REWARD_TIMES);
$times = $p['param_value'] - 1;
$coin_num = $row['coin'] * $times;
$d = $this->getDrop(24004);
if (!$d) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
return;
}
$skin_id_array = $this->getExplode($d['item_id']);
$weight_sum = 0;
$keys = 0;
$skin_num_array = $this->getExplode($d['num']);
$weight_array = $this->getExplode($d['weight']);
for ($i = 0; $i < count($weight_array); $i++) {
$weight_sum += $weight_array[$i][0];
}
srand($room_uuid);
$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;
}
}
$skin_id = $skin_id_array[$keys][0];
$skin_num = $skin_num_array[$keys][0];
$p_battle_reward = $this->getParameter(MAX_BATTLE_REWARD);
// if ($row['status'] == 1) {
// phpcommon\sendError(ERR_USER_BASE + 3, '战斗奖励已领取');
// return;
// }
// $coin_num = $row['coin'];
// $p = $this->getParameter(REWARD_TIMES);
// //$times = $p['param_value'] - 1;
// $times = 1;
// $coin_num = $row['coin'] * $times;
// $d = $this->getDrop(24004);
// if (!$d) {
// phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
// return;
// }
// $skin_id_array = $this->getExplode($d['item_id']);
// $weight_sum = 0;
// $keys = 0;
// $skin_num_array = $this->getExplode($d['num']);
// $weight_array = $this->getExplode($d['weight']);
// for ($i = 0; $i < count($weight_array); $i++) {
// $weight_sum += $weight_array[$i][0];
// }
// srand($room_uuid);
// $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;
// }
// }
// $skin_id = $skin_id_array[$keys][0];
// $skin_num = $skin_num_array[$keys][0];
// $p_battle_reward = $this->getParameter(MAX_BATTLE_REWARD);
$addreward = new classes\AddReward();
$addreward->addReward(10001, $coin_num, $account_id);
$rowUser = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if ($rowUser['battle_re_times'] < $p_battle_reward['param_value']) {
$keys_num = $rowUser['keys_num'] + 1;
$battle_re_times = $rowUser['battle_re_times'] + 1;
$addreward->addReward($skin_id, $skin_num, $account_id);
$ret = $conn->execScript('UPDATE user SET battle_re_times=:battle_re_times, keys_num=:keys_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':keys_num' => $keys_num,
':battle_re_times' => $battle_re_times,
':modify_time' => time(),
':accountid' => $account_id
));
if (!$ret) {
die();
return;
}
}
// $rowUser = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
// array(
// ':accountid' => $account_id
// ));
// if ($rowUser['battle_re_times'] < $p_battle_reward['param_value']) {
// $keys_num = $rowUser['keys_num'] + 1;
// $battle_re_times = $rowUser['battle_re_times'] + 1;
// $addreward->addReward($skin_id, $skin_num, $account_id);
// $ret = $conn->execScript('UPDATE user SET battle_re_times=:battle_re_times, keys_num=:keys_num, modify_time=:modify_time ' .
// ' WHERE accountid=:accountid;',
// array(
// ':keys_num' => $keys_num,
// ':battle_re_times' => $battle_re_times,
// ':modify_time' => time(),
// ':accountid' => $account_id
// ));
// if (!$ret) {
// die();
// return;
// }
// }
$coin_nums = $addreward->getCoinNum($account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'coin_nums' => $coin_nums,
));
}
@ -873,5 +880,47 @@ class RoleController{
$switch = json_decode($user_db_str, true);
return $switch;
}
public function addChapingCount()
{
$account_id = $_REQUEST['account_id'];
//登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$row = $conn->execQueryOne('SELECT chapingcount FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$chapingcount = $row['chapingcount'] + 1;
$ret = $conn->execScript('UPDATE user SET chapingcount=:chapingcount, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':modify_time' => time(),
':accountid' => $account_id,
':chapingcount' => $chapingcount
));
if (!$ret) {
die();
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'chapingcount' => $chapingcount,
));
}
}
?>