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_first_login` int(11) NOT NULL DEFAULT '0' COMMENT '每天是否第一次登陆',
`daily_time` 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 '每日免费宝箱', `free_box` int(11) NOT NULL DEFAULT '0' COMMENT '每日免费宝箱',
`chapingcount` int(11) NOT NULL DEFAULT '0' COMMENT '每日插屏次数',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),
UNIQUE KEY `accountid` (`accountid`) UNIQUE KEY `accountid` (`accountid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) 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 ':accountid' => $account_id
)); ));
if (!$row) { 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) ' . $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) ' . ' 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;', ' 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( array(
':accountid' => $account_id, ':accountid' => $account_id,
':user_name' => $user_name, ':user_name' => $user_name,
@ -155,7 +155,8 @@ class RoleController{
'recharge_times_total' => 0, 'recharge_times_total' => 0,
'first_login' => 0, 'first_login' => 0,
'daily_first_login' => 0, 'daily_first_login' => 0,
'free_box' => 0 'free_box' => 0,
'chapingcount' => 0
)); ));
} else { } else {
$ret = $conn->execScript('UPDATE user SET first_login=1 ' . $ret = $conn->execScript('UPDATE user SET first_login=1 ' .
@ -189,8 +190,9 @@ class RoleController{
} }
$nowTime = phpcommon\getdayseconds(time()); $nowTime = phpcommon\getdayseconds(time());
$daily_first_login = $row['daily_first_login']; $daily_first_login = $row['daily_first_login'];
$chapingcount = $row['chapingcount'];
if ($row['daily_time'] == 0 || ($nowTime - phpcommon\getdayseconds($row['daily_time']) > 0)) { 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;', 'modify_time=:modify_time WHERE accountid=:accountid;',
array( array(
':accountid' => $account_id, ':accountid' => $account_id,
@ -201,6 +203,7 @@ class RoleController{
return; return;
} }
$daily_first_login = 0; $daily_first_login = 0;
$chapingcount = 0;
} }
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
@ -230,7 +233,8 @@ class RoleController{
'vip_score' => $row['vip_score'], 'vip_score' => $row['vip_score'],
'coin_nums' => $row['coin_num'], 'coin_nums' => $row['coin_num'],
'diamond_nums' => $row['diamond_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() public function fightReward()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
$room_uuid = $_REQUEST['room_uuid']; $coin_num = $_REQUEST['coin'];
//登录校验 //登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']); $login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) { if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return; return;
} }
$conn = $this->getMysql($account_id); // $conn = $this->getMysql($account_id);
$record_list = array(); // $record_list = array();
if (!$conn) { // if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); // phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return; // return;
} // }
$row = $conn->execQueryOne('SELECT * FROM history_record WHERE accountid=:accountid AND room_uuid=:room_uuid;', // $row = $conn->execQueryOne('SELECT * FROM history_record WHERE accountid=:accountid AND room_uuid=:room_uuid;',
array( // array(
':accountid' => $account_id, // ':accountid' => $account_id,
':room_uuid' => $room_uuid // ':room_uuid' => $room_uuid
)); // ));
if (!$row) { // if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这场战斗记录'); // phpcommon\sendError(ERR_USER_BASE + 2, '没有这场战斗记录');
return; // return;
} // }
if ($row['status'] == 1) { // if ($row['status'] == 1) {
phpcommon\sendError(ERR_USER_BASE + 3, '战斗奖励已领取'); // phpcommon\sendError(ERR_USER_BASE + 3, '战斗奖励已领取');
return; // return;
} // }
$coin_num = $row['coin']; // $coin_num = $row['coin'];
$p = $this->getParameter(REWARD_TIMES); // $p = $this->getParameter(REWARD_TIMES);
$times = $p['param_value'] - 1; // //$times = $p['param_value'] - 1;
$coin_num = $row['coin'] * $times; // $times = 1;
$d = $this->getDrop(24004); // $coin_num = $row['coin'] * $times;
if (!$d) { // $d = $this->getDrop(24004);
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); // if (!$d) {
return; // phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
} // return;
$skin_id_array = $this->getExplode($d['item_id']); // }
$weight_sum = 0; // $skin_id_array = $this->getExplode($d['item_id']);
$keys = 0; // $weight_sum = 0;
$skin_num_array = $this->getExplode($d['num']); // $keys = 0;
$weight_array = $this->getExplode($d['weight']); // $skin_num_array = $this->getExplode($d['num']);
for ($i = 0; $i < count($weight_array); $i++) { // $weight_array = $this->getExplode($d['weight']);
$weight_sum += $weight_array[$i][0]; // for ($i = 0; $i < count($weight_array); $i++) {
} // $weight_sum += $weight_array[$i][0];
srand($room_uuid); // }
$random = Rand(0, $weight_sum); // srand($room_uuid);
$weight = 0; // $random = Rand(0, $weight_sum);
for ($i = 0; $i < count($weight_array); $i++) { // $weight = 0;
$weight += $weight_array[$i][0]; // for ($i = 0; $i < count($weight_array); $i++) {
if ($weight > $random) { // $weight += $weight_array[$i][0];
$keys = $i; // if ($weight > $random) {
break; // $keys = $i;
} // break;
} // }
$skin_id = $skin_id_array[$keys][0]; // }
$skin_num = $skin_num_array[$keys][0]; // $skin_id = $skin_id_array[$keys][0];
$p_battle_reward = $this->getParameter(MAX_BATTLE_REWARD); // $skin_num = $skin_num_array[$keys][0];
// $p_battle_reward = $this->getParameter(MAX_BATTLE_REWARD);
$addreward = new classes\AddReward(); $addreward = new classes\AddReward();
$addreward->addReward(10001, $coin_num, $account_id); $addreward->addReward(10001, $coin_num, $account_id);
$rowUser = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;', // $rowUser = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
array( // array(
':accountid' => $account_id // ':accountid' => $account_id
)); // ));
if ($rowUser['battle_re_times'] < $p_battle_reward['param_value']) { // if ($rowUser['battle_re_times'] < $p_battle_reward['param_value']) {
$keys_num = $rowUser['keys_num'] + 1; // $keys_num = $rowUser['keys_num'] + 1;
$battle_re_times = $rowUser['battle_re_times'] + 1; // $battle_re_times = $rowUser['battle_re_times'] + 1;
$addreward->addReward($skin_id, $skin_num, $account_id); // $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 ' . // $ret = $conn->execScript('UPDATE user SET battle_re_times=:battle_re_times, keys_num=:keys_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;', // ' WHERE accountid=:accountid;',
array( // array(
':keys_num' => $keys_num, // ':keys_num' => $keys_num,
':battle_re_times' => $battle_re_times, // ':battle_re_times' => $battle_re_times,
':modify_time' => time(), // ':modify_time' => time(),
':accountid' => $account_id // ':accountid' => $account_id
)); // ));
if (!$ret) { // if (!$ret) {
die(); // die();
return; // return;
} // }
} // }
$coin_nums = $addreward->getCoinNum($account_id);
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'coin_nums' => $coin_nums,
)); ));
} }
@ -873,5 +880,47 @@ class RoleController{
$switch = json_decode($user_db_str, true); $switch = json_decode($user_db_str, true);
return $switch; 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,
));
}
} }
?> ?>