This commit is contained in:
wangwei01 2019-07-09 14:50:42 +08:00
parent 0601d75838
commit c4c10f0a57
7 changed files with 152 additions and 128 deletions

View File

@ -48,13 +48,11 @@ CREATE TABLE `user` (
`add_HP` int(11) NOT NULL COMMENT '所有治疗量',
`alive_time` int(11) NOT NULL COMMENT '所有生存时间',
`coin_num` bigint NOT NULL COMMENT '角色金币',
`integral` bigint NOT NULL COMMENT '角色积分',
`diamond_num` bigint NOT NULL COMMENT '角色钻石',
`kill_his` int(11) NOT NULL COMMENT '最高击杀',
`alive_time_his` int(11) NOT NULL COMMENT '最长生存时间',
`harm_his` int(11) NOT NULL COMMENT '最高伤害',
`add_HP_his` int(11) NOT NULL COMMENT '最多治疗量',
`act_share_status` int(11) NOT NULL COMMENT '分享好礼活动状态',
`act_share_time` int(11) NOT NULL COMMENT '分享好礼活动时间',
`create_time` int(11) NOT NULL COMMENT '创建时间',
`modify_time` int(11) NOT NULL COMMENT '修改时间',
`first_fight` int(11) NOT NULL COMMENT '是否是第一次战斗',
@ -63,6 +61,7 @@ CREATE TABLE `user` (
`battle_re_times` int(11) NOT NULL COMMENT '每日战斗奖励次数',
`shop_flush_times` int(11) NOT NULL COMMENT '每日商店刷新次数',
`kefu_status` int(11) NOT NULL COMMENT '客服奖励状态(0:未领取,1:已领取)',
`free_getbox` int(11) NOT NULL COMMENT '每日免费获得宝箱次数',
PRIMARY KEY (`idx`),
UNIQUE KEY `accountid` (`accountid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
@ -115,27 +114,6 @@ CREATE TABLE `equip` (
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Table structure for table `supplybox`
--
DROP TABLE IF EXISTS `supplybox`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `supplybox` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`box_id` int(11) NOT NULL COMMENT '补给箱id',
`buy_times` int(11) NOT NULL COMMENT '购买次数',
`free_times` int(11) NOT NULL COMMENT '免费获得次数',
`last_buy_time` varchar(50) NOT NULL DEFAULT '最后一次购买',
`create_time` int(11) NOT NULL COMMENT '创建时间',
`modify_time` int(11) NOT NULL COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `box_uuid` (`accountid`, `box_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
-- Table structure for table `sign`
--
@ -148,6 +126,8 @@ CREATE TABLE `sign` (
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`sign_days` int(11) NOT NULL COMMENT '已签天数',
`sign_time` varchar(50) NOT NULL DEFAULT '签到时间',
`item_id` int(11) NOT NULL COMMENT '奖励物品id',
`item_num` int(11) NOT NULL COMMENT '奖励物品数量',
`create_time` int(11) NOT NULL COMMENT '创建时间',
`modify_time` int(11) NOT NULL COMMENT '修改时间',
PRIMARY KEY (`idx`),
@ -205,8 +185,6 @@ CREATE TABLE `active` (
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`active_num` int(11) NOT NULL COMMENT '日活跃度',
`num_time` varchar(50) NOT NULL DEFAULT '日活跃度时间',
`active_sum` int(11) NOT NULL COMMENT '周活跃度',
`sum_time` varchar(50) NOT NULL DEFAULT '周活跃度时间',
`create_time` int(11) NOT NULL COMMENT '创建时间',
`modify_time` int(11) NOT NULL COMMENT '修改时间',
PRIMARY KEY (`idx`),

View File

@ -69,6 +69,9 @@ define('FREE_DRESS_MAX_TIME', 30); //免费获取皮肤次数上限
define('RAND_SHOP_GOLD', 39); //商店金币刷新价格
define('MAX_BATTLE_REWARD', 40); //战斗额外奖励次数
define('MAX_SHOP_REFRESH', 41); //每日商店刷新次数
define('FREEBOX_COST', 42); //金币开宝箱
define('KEYBOX_COST', 43); //钥匙开宝箱
define('DIAMONDBOX_COST', 44); //钻石开宝箱
require 'config_loader.php';

View File

@ -72,6 +72,41 @@ class AddReward {
if (!$ret) {
die();
}
} else if ($item_id == 10003) {
$rowDiamond = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
$ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':diamond_num' => $item_num + $rowDiamond['diamond_num'],
':modify_time' => time()
));
if (!$ret) {
die();
}
}
}
public function updateReward($item_id, $item_num, $account_id)
{
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
die();
}
$ret = $conn->execScript('UPDATE sign SET item_id=:item_id, item_num=:item_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':item_id' => $item_id,
':item_num' => $item_num,
':modify_time' => time()
));
if (!$ret) {
die();
}
}
}

View File

@ -71,6 +71,7 @@ class HangController{
$num = $num;
$addreward = new classes\AddReward();
$addreward->addReward($item_id, $num, $account_id);
$addreward->updateReward($item_id, $num, $account_id);
}
echo json_encode(array(
'errcode' => 0,

View File

@ -83,9 +83,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) ' .
' 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) ' .
' 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;',
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, diamond_num, kill_his, alive_time_his, harm_his, add_HP_his, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, free_getbox) ' .
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, create_time, :modify_time, 0, 0, 0, 0, 0, 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, diamond_num=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=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, free_getbox=0;',
array(
':accountid' => $account_id,
':user_name' => $user_name,
@ -112,7 +112,9 @@ class RoleController{
'first_fight' => 0,
'collect_status' => 0,
'keys_num' => 0,
'kefu_status' => 0
'kefu_status' => 0,
'diamond_num' => 0,
'free_getbox' => 0,
));
} else {
echo json_encode(array(
@ -131,6 +133,8 @@ class RoleController{
'collect_status' => $row['collect_status'],
'keys_num' => $row['keys_num'],
'kefu_status' => $row['kefu_status'],
'diamond_num' => $row['diamond_num'],
'free_getbox' => $row['free_getbox']
));
}
}
@ -165,7 +169,7 @@ class RoleController{
$alive_time_his = $alive_time;
$add_HP_his = $add_HP;
$coin_num = $_REQUEST['coin_num']; //金币
$integral = $_REQUEST['score']; //积分
// $diamond_num = $_REQUEST['score']; //积分
if (!$map_id) {
$map_id = 0;
@ -197,7 +201,7 @@ class RoleController{
if ($add_HP_his < $row['add_HP_his']) {
$add_HP_his = $row['add_HP_his'];
}
$ret = $conn->execScript('UPDATE user SET game_times=:game_times, win_times=:win_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, add_HP_his=:add_HP_his, coin_num=:coin_num, integral=:integral, modify_time=:modify_time, first_fight=1 ' .
$ret = $conn->execScript('UPDATE user SET game_times=:game_times, win_times=:win_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, add_HP_his=:add_HP_his, coin_num=:coin_num, modify_time=:modify_time, first_fight=1 ' .
' WHERE accountid=:accountid;',
array(
':game_times' => $row['game_times'] + 1,
@ -212,7 +216,6 @@ class RoleController{
':add_HP_his' => $add_HP_his,
':accountid' => $account_id,
':coin_num' => $row['coin_num'] + $coin_num,
':integral' => $row['integral'] + $integral,
':modify_time' => time()
));
if (!$ret) {

View File

@ -84,8 +84,10 @@ class ShareController{
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
$free = $_REQUEST['free'];
$drop_id = 0;
//扣除钥匙
$row = $conn->execQueryOne('SELECT keys_num FROM user WHERE accountid=:accountid;',
$row = $conn->execQueryOne('SELECT keys_num, coin_num, diamond_num, free_getbox FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
@ -93,33 +95,97 @@ class ShareController{
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
if ($row['keys_num'] < 1) {
phpcommon\sendError(ERR_USER_BASE + 3, '钥匙不足');
die();
return;
switch ($_REQUEST['type'])
{
//视频或金币开箱子
case 1:
{
$drop_id = 24001;
if ($row['free_getbox'] == 0) {
$ret = $conn->execScript('UPDATE user SET free_getbox=1, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => time()
));
if (!$ret) {
die();
return;
}
} else {
$p = $this->getParameter(FREEBOX_COST);
if ($row['coin_num'] < $p['param_value']) {
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
die();
return;
}
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':coin_num' => $row['coin_num'] - $p['param_value'],
':modify_time' => time()
));
if (!$ret) {
die();
return;
}
}
break;
}
$ret = $conn->execScript('UPDATE user SET keys_num=:keys_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':keys_num' => $row['keys_num'] - 1,
':modify_time' => time()
));
if (!$ret) {
die();
return;
//钥匙开箱子
case 2:
{
$drop_id = 24002;
$p = $this->getParameter(KEYBOX_COST);
if ($row['keys_num'] < $p['param_value']) {
phpcommon\sendError(ERR_USER_BASE + 4, '钥匙不足');
die();
return;
}
$ret = $conn->execScript('UPDATE user SET keys_num=:keys_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':keys_num' => $row['keys_num'] - $p['param_value'],
':modify_time' => time()
));
if (!$ret) {
die();
return;
}
break;
}
//钻石开箱子
case 3:
{
$drop_id = 24003;
$p = $this->getParameter(DIAMONDBOX_COST);
if ($row['diamond_num'] < $p['param_value']) {
phpcommon\sendError(ERR_USER_BASE + 5, '钻石不足');
die();
return;
}
$ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':diamond_num' => $row['diamond_num'] - $p['param_value'],
':modify_time' => time()
));
if (!$ret) {
die();
return;
}
break;
}
default:
break;
}
//随机奖励
$free = $_REQUEST['free'];
$drop_id = 0;
if ($free != 0) {
$drop_id = 24002;
} else {
$drop_id = 24001;
}
$d = $this->getDrop($drop_id);
if (!$d) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
phpcommon\sendError(ERR_USER_BASE + 6, '没有这个奖励');
return;
}
$item_id_array = $this->getExplode($d['item_id']);
@ -130,7 +196,6 @@ class ShareController{
for ($i = 0; $i < count($weight_array); $i++) {
$weight_sum += $weight_array[$i][0];
}
srand(crc32($account_id . $row['keys_num']));
$random = Rand(0, $weight_sum);
$weight = 0;
for ($i = 0; $i < count($weight_array); $i++) {
@ -144,6 +209,7 @@ class ShareController{
$item_num = $item_num_array[$keys][0];
$addreward = new classes\AddReward();
$addreward->addReward($item_id, $item_num, $account_id);
$addreward->updateReward($item_id, $item_num, $account_id);
$item_list = array();
array_push($item_list, array(
'item_id' => $item_id,
@ -156,70 +222,6 @@ class ShareController{
'errcode' => 0,
'errmsg' => '',
'item_list' => $item_list,
'keys_num' => $row['keys_num'] - 1
));
}
public function keyBoxReward()
{
$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 + 2, '没有这个玩家');
return;
}
$row = $conn->execQueryOne('SELECT keys_num FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
//随机奖励
$free = $_REQUEST['free'];
$drop_id = 0;
if ($free != 0) {
$drop_id = 24002;
} else {
$drop_id = 24001;
}
$d = $this->getDrop($drop_id);
if (!$d) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
return;
}
$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++) {
$weight_sum += $weight_array[$i][0];
}
srand(crc32($account_id . $row['keys_num']));
$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];
$addreward = new classes\AddReward();
$addreward->addReward($item_id, $item_num, $account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
));
}

View File

@ -70,13 +70,13 @@ class SignController{
));
$nowTime = phpcommon\getdayseconds(time());
if (!$row) {
$ret = $conn->execScript('INSERT INTO sign(accountid, sign_days, sign_time, create_time, modify_time) ' .
' VALUES(:accountid, :sign_days, :sign_time, :create_time, :modify_time) ' .
' ON DUPLICATE KEY UPDATE accountid=:accountid, sign_days=:sign_days, sign_time=:sign_time, modify_time=:modify_time;',
$ret = $conn->execScript('INSERT INTO sign(accountid, sign_days, sign_time, item_id, item_num, create_time, modify_time) ' .
' VALUES(:accountid, :sign_days, :sign_time, 0, 0, :create_time, :modify_time) ' .
' ON DUPLICATE KEY UPDATE accountid=:accountid, sign_days=:sign_days, sign_time=:sign_time, item_id=0, item_num=0, modify_time=:modify_time;',
array(
':accountid' => $account_id,
':sign_days' => 0,
':sign_time' => 0,
':sign_days' => 1,
':sign_time' => time(),
':create_time' => time(),
':modify_time' => time()
));
@ -100,6 +100,7 @@ class SignController{
$num = $s['num'];
$addreward = new classes\AddReward();
$addreward->addReward($item_id, $num, $account_id);
$addreward->updateReward($item_id, $num, $account_id);
} else {
if ($nowTime - phpcommon\getdayseconds($row['sign_time']) > 0) {
$sign_days = $row['sign_days'] + 1;
@ -128,6 +129,7 @@ class SignController{
$num = $s['num'];
$addreward = new classes\AddReward();
$addreward->addReward($item_id, $num, $account_id);
$addreward->updateReward($item_id, $num, $account_id);
//刷新每日任务和活动任务
$rowCount = $conn->execQueryRowCount('SELECT * FROM quest WHERE accountid=:accountid;',
array(
@ -153,8 +155,8 @@ class SignController{
$quest = new classes\Quest();
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
//刷新战斗结算奖励次数,商店刷新次数,客服
$battle_ret = $conn->execScript('UPDATE user SET battle_re_times=0, shop_flush_times=0, kefu_status=0, modify_time=:modify_time ' .
//刷新战斗结算奖励次数,商店刷新次数,客服,免费宝箱
$battle_ret = $conn->execScript('UPDATE user SET battle_re_times=0, shop_flush_times=0, kefu_status=0, free_getbox=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,