This commit is contained in:
wangwei01 2019-08-21 14:36:30 +08:00
parent 699eb277eb
commit ad15d40c27
6 changed files with 252 additions and 66 deletions

View File

@ -65,6 +65,9 @@ CREATE TABLE `user` (
`kefu_status` int(11) NOT NULL DEFAULT '0' COMMENT '客服奖励状态(0:未领取,1:已领取)',
`sign_sum` int(11) NOT NULL DEFAULT '0' COMMENT '签到总天数',
`box_num` int(11) NOT NULL DEFAULT '0' COMMENT '空投宝箱数量',
`diamond_num` bigint NOT NULL DEFAULT '0' COMMENT '钻石数量',
`diamond_shop_flush_times` int(11) NOT NULL DEFAULT '0' COMMENT '每日钻石商店刷新次数',
`sum_coin` double NOT NULL DEFAULT '0' COMMENT '累计充值金额',
PRIMARY KEY (`idx`),
UNIQUE KEY `accountid` (`accountid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
@ -280,6 +283,75 @@ CREATE TABLE `activity` (
UNIQUE KEY `accountid` (`accountid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `buy_his`;
/*!40101 SET @saved_cs_client = @@character_set_client*/;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `buy_his` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`itemid` int(11) NOT NULL DEFAULT '0' COMMENT 'itemid',
`sum_times` int(11) NOT NULL DEFAULT '0' COMMENT '累计充值次数',
`today_times` int(11) NOT NULL DEFAULT '0' COMMENT '今日充值次数',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
KEY `accountid` (`accountid`),
UNIQUE KEY `accountid_itemid` (`accountid`, `itemid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `orderinfo`;
/*!40101 SET @saved_cs_client = @@character_set_client*/;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `orderinfo` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`orderid` varchar(60) DEFAULT '' COMMENT '订单id',
`itemid` int(11) NOT NULL DEFAULT '0' COMMENT 'itemid',
`coin` double NOT NULL DEFAULT '0' COMMENT '充值金额',
`status` int(11) NOT NULL DEFAULT '0' COMMENT '0: 新添加订单 1:已经完成订单',
`confirmtime` int(11) NOT NULL DEFAULT '0' COMMENT 'GameServer订单确认时间',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
KEY `accountid` (`accountid`),
UNIQUE KEY `orderid` (`orderid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `vipinfo`;
/*!40101 SET @saved_cs_client = @@character_set_client*/;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `vipinfo` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`vipid` int(11) NOT NULL DEFAULT '0' COMMENT 'vipid',
`reward_id` int(11) NOT NULL DEFAULT '0' COMMENT '奖励id',
`reward_status` int(11) NOT NULL DEFAULT '0' COMMENT '奖励状态',
`today_reward_id` int(11) NOT NULL DEFAULT '0' COMMENT '今日奖励id',
`today_reward_status` int(11) NOT NULL DEFAULT '0' COMMENT '今日奖励状态',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
KEY `accountid` (`accountid`),
UNIQUE KEY `accountid_vipid` (`accountid`, `vipid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `passinfo`;
/*!40101 SET @saved_cs_client = @@character_set_client*/;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `passinfo` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`passid` int(11) NOT NULL DEFAULT '0' COMMENT 'passid',
`active_status` int(11) NOT NULL DEFAULT '0' COMMENT '普通奖励状态',
`honor_status` int(11) NOT NULL DEFAULT '0' COMMENT '荣耀奖励状态',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
KEY `accountid` (`accountid`),
UNIQUE KEY `accountid_passid` (`accountid`, `passid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

View File

@ -158,5 +158,35 @@ function getRobotConfig($robot_table, $robot_id)
$robot_id = (int)$robot_id;
return array_key_exists($robot_id, $robot_table) ? $robot_table[$robot_id] : null;
}
function getDiamondShopConfig($diamond_table, $diamond_id)
{
$diamond_id = (int)$diamond_id;
return array_key_exists($diamond_id, $diamond_table) ? $diamond_table[$diamond_id] : null;
}
function getVipConfig($vip_table, $vip_id)
{
$vip_id = (int)$vip_id;
return array_key_exists($vip_id, $vip_table) ? $vip_table[$vip_id] : null;
}
function getSeasonConfig($Season_table, $Season_id)
{
$Season_id = (int)$Season_id;
return array_key_exists($Season_id, $Season_table) ? $Season_table[$Season_id] : null;
}
function getSeasonRewardConfig($SeaReward_table, $SeaReward_id)
{
$SeaReward_id = (int)$SeaReward_id;
return array_key_exists($SeaReward_id, $SeaReward_table) ? $SeaReward_table[$SeaReward_id] : null;
}
function getSeasonPointConfig($SeaPoint_table, $SeaPoint_id)
{
$SeaPoint_id = (int)$SeaPoint_id;
return array_key_exists($SeaPoint_id, $SeaPoint_table) ? $SeaPoint_table[$SeaPoint_id] : null;
}
checkMysqlConfig();
checkRedisConfig();

View File

@ -276,14 +276,14 @@ class ActivityController{
return;
}
$ret = $conn->execScript('UPDATE activity SET free_times=:free_times, item_id=:item_id, item_num=:item_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':free_times' => $row['free_times'] + 1,
':item_id' => $item_id,
':item_num' => $item_num,
':modify_time' => time()
));
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':free_times' => $row['free_times'] + 1,
':item_id' => $item_id,
':item_num' => $item_num,
':modify_time' => time()
));
if (!$ret) {
die();
return;
@ -439,7 +439,6 @@ class ActivityController{
$user_db = json_decode($user_db_str, true);
foreach ($user_db['randreward_list'] as $randreward) {
//增加奖励
error_log($randreward['item_num']);
$addreward = new classes\AddReward();
$addreward->addReward($randreward['item_id'], $randreward['item_num'], $account_id);
}

View File

@ -100,9 +100,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) ' .
' 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) ' .
' 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;',
$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) ' .
' 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) ' .
' 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=0, sum_coin=0;',
array(
':accountid' => $account_id,
':user_name' => $user_name,
@ -130,7 +130,9 @@ class RoleController{
'collect_status' => 0,
'keys_num' => 0,
'kefu_status' => 0,
'box_num' => 0
'box_num' => 0,
'diamond_num' => 0,
'sum_coin' => 0
));
} else {
echo json_encode(array(
@ -149,7 +151,9 @@ class RoleController{
'collect_status' => $row['collect_status'],
'keys_num' => $row['keys_num'],
'kefu_status' => $row['kefu_status'],
'box_num' => $row['box_num']
'box_num' => $row['box_num'],
'diamond_num' => $row['diamond_num'],
'sum_coin' => $row['sum_coin']
));
}
}

View File

@ -52,6 +52,7 @@ class ShopController{
'discount' => $shop_conf['discount'],
'discount_weight' => $shop_conf['discount_weight'],
'tip' => $shop_conf['tip'],
'type' => $shop_conf['shop_type']
);
return $s;
}
@ -81,25 +82,17 @@ class ShopController{
return $arr;
}
public function shopInfo()
protected function getShopInfo($shop_uuid, $type)
{
$account_id = $_REQUEST['account_id'];
//登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$shop_uuid = 'game2001api_shop_uuid: ' . md5($_REQUEST['account_id']);
$shop_list = array();
$r = $this->getRedis($shop_uuid);
if (!$r) {
die();
return;
}
$shop_list = array();
$user_db_str = $r->get($shop_uuid);
if (empty($user_db_str)) {
$shop_list = $this->randomShop();
$shop_list = $this->randomShop($type);
$shop_db = array(
'shop_uuid' => $shop_uuid,
'shop_list' => $shop_list,
@ -124,15 +117,32 @@ class ShopController{
));
}
}
return $shop_list;
}
public function shopInfo()
{
$account_id = $_REQUEST['account_id'];
//登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$shop_uuid = 'game2001api_shop_uuid: ' . md5($_REQUEST['account_id']);
$diamond_shop_uuid = 'game2001api_diamond_shop_uuid:' . md5($_REQUEST['account_id']);
//钻石商店信息
$diamond_shop_list = $this->getShopInfo($diamond_shop_uuid, 2);
//商店信息
$shop_list = $this->getShopInfo($shop_uuid, 1);
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
$row = $conn->execQueryOne('SELECT shop_flush_times FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
$row = $conn->execQueryOne('SELECT shop_flush_times, diamond_shop_flush_times FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
@ -143,6 +153,9 @@ class ShopController{
'shop_uuid' => $shop_uuid,
'shop_list' => $shop_list,
'shop_flush_times' => $row['shop_flush_times'],
'diamond_shop_uuid' => $diamond_shop_uuid,
'diamond_shop_list' => $diamond_shop_list,
'diamond_shop_flush_times' => $row['diamond_shop_flush_times'],
));
}
@ -162,6 +175,7 @@ class ShopController{
$price = 0;
$status = 0;
$flag = 0;
$tip = 0;
$r = $this->getRedis($shop_uuid);
$user_db_str = $r->get($shop_uuid);
if (empty($user_db_str)) {
@ -179,6 +193,7 @@ class ShopController{
$item_num = $shop['item_num'];
$price = $shop['price'];
$status = $shop['status'];
$tip = $shop['tip'];
$flag = 1;
break;
}
@ -192,7 +207,7 @@ class ShopController{
return;
}
//扣除货币
$this->SubCoin($price, $account_id);
$this->SubCoin($price, $account_id, $tip);
//修改购买状态
foreach ($user_db['shop_list'] as &$shop) {
if ($shop['shop_id'] == $shop_id) {
@ -276,13 +291,15 @@ class ShopController{
return;
}
$shop_uuid = $_REQUEST['shop_uuid'];
$shop_type = $_REQUEST['shop_type'];
$shop_list = array();
$flush_times = 0;
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
$row = $conn->execQueryOne('SELECT shop_flush_times FROM user WHERE accountid=:accountid;',
$row = $conn->execQueryOne('SELECT shop_flush_times, diamond_shop_flush_times FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
@ -290,21 +307,43 @@ class ShopController{
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
$p_flush = $this->getParameter(MAX_SHOP_REFRESH);
if ($p_flush['param_value'] <= $row['shop_flush_times']) {
phpcommon\sendError(ERR_USER_BASE + 3, '今日刷新次数已满');
return;
if ($shop_type == 1) {
$p_flush = $this->getParameter(MAX_SHOP_REFRESH);
if ($p_flush['param_value'] <= $row['shop_flush_times']) {
phpcommon\sendError(ERR_USER_BASE + 3, '今日刷新次数已满');
return;
}
$ret = $conn->execScript('UPDATE user SET shop_flush_times=:shop_flush_times, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':shop_flush_times' => $row['shop_flush_times'] + 1,
':modify_time' => time()
));
if (!$ret) {
die();
return;
}
$flush_times = $row['shop_flush_times'] + 1;
}
$ret = $conn->execScript('UPDATE user SET shop_flush_times=:shop_flush_times, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':shop_flush_times' => $row['shop_flush_times'] + 1,
':modify_time' => time()
));
if (!$ret) {
die();
return;
if ($shop_type == 2) {
$p_flush = $this->getParameter(MAX_SHOP_REFRESH);
if ($p_flush['param_value'] <= $row['diamond_shop_flush_times']) {
phpcommon\sendError(ERR_USER_BASE + 3, '今日刷新次数已满');
return;
}
$ret = $conn->execScript('UPDATE user SET diamond_shop_flush_times=:diamond_shop_flush_times, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':diamond_shop_flush_times' => $row['diamond_shop_flush_times'] + 1,
':modify_time' => time()
));
if (!$ret) {
die();
return;
}
$flush_times = $row['diamond_shop_flush_times'] + 1;
}
$r = $this->getRedis($shop_uuid);
$user_db_str = $r->get($shop_uuid);
@ -319,10 +358,10 @@ class ShopController{
}
if ($_REQUEST['type'] == 3) {
$p = $this->getParameter(RAND_SHOP_GOLD);
$this->SubCoin($p['param_value'], $account_id);
$this->SubCoin($p['param_value'], $account_id, $_REQUEST['type']);
}
unset($user_db['shop_list']);
$shop_list = $this->randomShop();
$shop_list = $this->randomShop($shop_type);
$user_db['shop_list'] = $shop_list;
$r -> set($shop_uuid, json_encode($user_db));
$r -> pexpire($shop_uuid, 1000 * 3600 * 24);
@ -331,15 +370,37 @@ class ShopController{
'errmsg'=> '',
'shop_uuid' => $shop_uuid,
'shop_list' => $shop_list,
'shop_flush_times' => $row['shop_flush_times'] + 1
'flush_times' => $flush_times
));
}
protected function randomShop()
protected function randomShop($type)
{
$shop_list = array();
$g_conf_shop_cluster = require('../res/shop@shop.php');
$coin_len = 0;
$diamond_len = 0;
$len = 0;
$id = 0;
for ($i = 1; $i <= count($g_conf_shop_cluster); $i++)
{
$s = $this->getShop($i);
if ($s['type'] == 1) {
$coin_len++;
}
if ($s['type'] == 2) {
$diamond_len++;
}
}
if ($type == 1) {
$id = 1;
$len = $coin_len;
}
if ($type == 2) {
$id = $coin_len + 1;
$len = $diamond_len + $coin_len;
}
for ($i = $id; $i <= $len; $i++)
{
$item_id = 0;
$item_num = 0;
@ -368,7 +429,7 @@ class ShopController{
$item_num = $num_array[$key][0];
//确定折扣和价格
$it = $this->getItem($item_id);
if ($s['tip'] != 3) {
if ($s['tip'] == 1) {
$discount = 0;
$price = 0;
} else {
@ -404,31 +465,51 @@ class ShopController{
return $shop_list;
}
protected function subCoin($coin_num, $account_id)
protected function subCoin($coin_num, $account_id, $tips)
{
error_log($tips);
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
//扣除货币
$rowCoin = $conn->execQueryOne('SELECT coin_num FROM user WHERE accountid=:accountid;',
$rowCoin = $conn->execQueryOne('SELECT coin_num, diamond_num FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if ($rowCoin['coin_num'] < $coin_num) {
phpcommon\sendError(ERR_USER_BASE + 5, '金币不足');
die();
if ($tips == 3) {
//扣除货币
if ($rowCoin['coin_num'] < $coin_num) {
phpcommon\sendError(ERR_USER_BASE + 5, '金币不足');
die();
}
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':coin_num' => $rowCoin['coin_num'] - $coin_num,
':modify_time' => time()
));
if (!$ret) {
die();
}
}
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':coin_num' => $rowCoin['coin_num'] - $coin_num,
':modify_time' => time()
));
if (!$ret) {
die();
if ($tips == 4) {
//扣除货币
if ($rowCoin['diamond_num'] < $coin_num) {
phpcommon\sendError(ERR_USER_BASE + 5, '钻石不足');
die();
}
$ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':diamond_num' => $rowCoin['diamond_num'] - $coin_num,
':modify_time' => time()
));
if (!$ret) {
die();
}
}
}
}

View File

@ -322,7 +322,7 @@ class SignController{
}
}
//刷新战斗结算奖励次数,商店刷新次数,客服
$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, diamond_shop_flush_times=0, shop_flush_times=0, kefu_status=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,