1
This commit is contained in:
parent
c0cfa83e86
commit
2b01108787
@ -68,6 +68,7 @@ CREATE TABLE `user` (
|
||||
`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 '累计充值金额',
|
||||
`pass_status` 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;
|
||||
@ -352,6 +353,21 @@ CREATE TABLE `passinfo` (
|
||||
UNIQUE KEY `accountid_passid` (`accountid`, `passid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `emoji`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client*/;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `emoji` (
|
||||
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`emojiid` int(11) NOT NULL DEFAULT '0' COMMENT 'emojiid',
|
||||
`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_emojiid` (`accountid`, `emojiid`)
|
||||
) 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 */;
|
||||
|
@ -1,7 +1,6 @@
|
||||
begin;
|
||||
|
||||
alter table supplybox drop column box_num;
|
||||
alter table supplybox add column `free_times` int(11) NOT NULL COMMENT '免费获得次数';
|
||||
DELETE FROM quest WHERE 1=1;
|
||||
|
||||
insert into version (version) values(2019061301);
|
||||
|
@ -188,5 +188,11 @@ function getSeasonPointConfig($SeaPoint_table, $SeaPoint_id)
|
||||
$SeaPoint_id = (int)$SeaPoint_id;
|
||||
return array_key_exists($SeaPoint_id, $SeaPoint_table) ? $SeaPoint_table[$SeaPoint_id] : null;
|
||||
}
|
||||
|
||||
function getEmojiConfig($Emoji_table, $Emoji_id)
|
||||
{
|
||||
$Emoji_id = (int)$Emoji_id;
|
||||
return array_key_exists($Emoji_id, $Emoji_table) ? $Emoji_table[$Emoji_id] : null;
|
||||
}
|
||||
checkMysqlConfig();
|
||||
checkRedisConfig();
|
||||
|
@ -72,6 +72,10 @@ define('MAX_SHOP_REFRESH', 41); //每日商店刷新次数
|
||||
define('FREELOTTERY_TIME', 45); //免费抽奖次数
|
||||
define('VIDEOLOTTERY_TIME', 46); //视频抽奖次数
|
||||
define('REWARD_TIMES', 54); //看视频奖励倍数
|
||||
define('RAND_DIAMONDSHOP_GOLD', 59); //钻石商店刷新价格
|
||||
define('RAND_DIAMONDSHOP_TIME', 60); //钻石商店刷新次数
|
||||
define('DIAMONDBOX', 61); //钻石宝箱花费钻石数
|
||||
define('DIAMONDBOX10', 62); //钻石视频宝箱花费钻石数
|
||||
require 'config_loader.php';
|
||||
|
||||
|
||||
|
@ -18,6 +18,50 @@ class AddReward {
|
||||
return $conn;
|
||||
}
|
||||
|
||||
protected function getItem($item_id)
|
||||
{
|
||||
$g_conf_item_cluster = require('../res/item@item.php');
|
||||
$item_conf = getItemConfig($g_conf_item_cluster, $item_id);
|
||||
$it = array(
|
||||
'id' => $item_conf['id'],
|
||||
'price' => $item_conf['price'],
|
||||
'dprice' => $item_conf['dprice'],
|
||||
'type' => $item_conf['fuction'],
|
||||
'index' => $item_conf['fuctionindex']
|
||||
);
|
||||
return $it;
|
||||
}
|
||||
|
||||
protected function getShop($shop_id)
|
||||
{
|
||||
$g_conf_shop_cluster = require('../res/shop@shop.php');
|
||||
$shop_conf = getShopConfig($g_conf_shop_cluster, $shop_id);
|
||||
$s = array(
|
||||
'shop_id' => $shop_conf['shop_id'],
|
||||
'item_id' => $shop_conf['item_id'],
|
||||
'num' => $shop_conf['num'],
|
||||
'item_weight' => $shop_conf['item_weight'],
|
||||
'discount' => $shop_conf['discount'],
|
||||
'discount_weight' => $shop_conf['discount_weight'],
|
||||
'tip' => $shop_conf['tip'],
|
||||
'type' => $shop_conf['shop_type']
|
||||
);
|
||||
return $s;
|
||||
}
|
||||
|
||||
protected function getExplode($string)
|
||||
{
|
||||
$delim = "|";
|
||||
$drop_multiply = explode($delim, $string);
|
||||
$delim1 = ":";
|
||||
$arr = array();
|
||||
for ($i = 0; $i < count($drop_multiply); $i++) {
|
||||
$mul = explode($delim1, $drop_multiply[$i]);
|
||||
array_push($arr, $mul);
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function addReward($item_id, $item_num, $account_id)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
@ -25,8 +69,153 @@ class AddReward {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
if ($item_id == 10001) {
|
||||
$row1 = $conn->execQueryOne('SELECT coin_num FROM user WHERE accountid=:accountid;',
|
||||
$it = $this->getItem($item_id);
|
||||
if (!$it) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
||||
die();
|
||||
}
|
||||
$item_list = array();
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
));
|
||||
if ($it['type'] == 5) {
|
||||
$item_list = $this->addGift($it['index'], $account_id);
|
||||
} else if ($it['type'] == 6) {
|
||||
$item_list = $this->addEmoji($it['index'], $account_id);
|
||||
} else if ($it['type'] == 4) {
|
||||
$item_list = $this->addSkin($it['index'], $item_num, $account_id);
|
||||
}
|
||||
foreach ($item_list as $item) {
|
||||
switch ($it['type'])
|
||||
{
|
||||
case 1:
|
||||
//添加金币
|
||||
$this->addCoin($it['index'], $item_num, $account_id);
|
||||
break;
|
||||
case 2:
|
||||
//添加钻石
|
||||
$this->addDiamond($it['index'], $item_num, $account_id);
|
||||
break;
|
||||
case 3:
|
||||
//添加角色碎片
|
||||
$this->addSkinFragment($it['index'], $item_num, $account_id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
//添加礼包
|
||||
protected function addGift($dropid, $accountid)
|
||||
{
|
||||
$conn = $this->getMysql($accountid);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
$d = $this->getDrop($dropid);
|
||||
if (!$d) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具');
|
||||
die();
|
||||
}
|
||||
$item_list = array();
|
||||
$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++) {
|
||||
$random = Rand(0, 10000);
|
||||
if ($weight_array[$i][0] > $random) {
|
||||
$item_id = $item_id_array[$i][0];
|
||||
$item_num = $item_num_array[$i][0];
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
));
|
||||
}
|
||||
}
|
||||
return $item_list;
|
||||
}
|
||||
//添加表情
|
||||
protected function addEmoji($itemid, $accountid, $dprice)
|
||||
{
|
||||
$item_list = array();
|
||||
$item_id = 0;
|
||||
$item_num = 0;
|
||||
$conn = $this->getMysql($accountid);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT status FROM emoji WHERE accountid=:accountid AND emojiid=:emojiid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':emojiid' => $itemid,
|
||||
));
|
||||
if (!$row) {
|
||||
$ret = $conn->execScript('INSERT INTO emoji(accountid, emojiid, status, create_time, modify_time) ' .
|
||||
' VALUES(:account_id, :emojiid, 1, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, emojiid=:emojiid, status=1, modify_time=:modify_time;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':emojiid' => $itemid,
|
||||
':create_time' => time(),
|
||||
':modify_time' => time()
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$item_id = $itemid;
|
||||
$item_num = 1;
|
||||
} else {
|
||||
$item_id = 10003;
|
||||
$item_num = $dprice;
|
||||
$this->addDirmond($item_num);
|
||||
}
|
||||
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
));
|
||||
return $item_list;
|
||||
}
|
||||
//添加钻石
|
||||
protected function addDiamond($item_id, $item_num, $accountid)
|
||||
{
|
||||
$conn = $this->getMysql($accountid);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
$row = $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 + $row['diamond_num'],
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
//添加金币
|
||||
protected function addCoin($item_id, $item_num, $accountid)
|
||||
{
|
||||
$conn = $this->getMysql($accountid);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT coin_num FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
@ -34,13 +223,21 @@ class AddReward {
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':coin_num' => $item_num + $row1['coin_num'],
|
||||
':coin_num' => $item_num + $row['coin_num'],
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
}
|
||||
} else if ($item_id > 13000 && $item_id < 14000) {
|
||||
}
|
||||
//添加角色碎片
|
||||
protected function addSkinFragment($item_id, $item_num, $accountid)
|
||||
{
|
||||
$conn = $this->getMysql($accountid);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
$rowSkin = $conn->execQueryOne('SELECT fragment_num FROM skin WHERE accountid=:accountid AND fragment_id=:fragment_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
@ -48,13 +245,14 @@ class AddReward {
|
||||
));
|
||||
if (!$rowSkin) {
|
||||
$ret = $conn->execScript('INSERT INTO skin(accountid, skin_id, skin_status, fragment_id, fragment_num, active_time, fragment_status, skin_type, skin_level, skin_experience_level, skin_experience_type, create_time, modify_time) ' .
|
||||
' VALUES(:account_id, :skin_id, :skin_status, :fragment_id, 0, 0, 0, :skin_type, 1, 0, 0, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, skin_id=:skin_id, skin_status=:skin_status, fragment_id=:fragment_id, fragment_num=0, active_time=0, fragment_status=0, skin_type=:skin_type, skin_level=1, skin_experience_level=0, skin_experience_type=0, modify_time=:modify_time;',
|
||||
' VALUES(:account_id, :skin_id, :skin_status, :fragment_id, :fragment_num, 0, 0, :skin_type, 1, 0, 0, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, skin_id=:skin_id, skin_status=:skin_status, fragment_id=:fragment_id, fragment_num=:fragment_num, active_time=0, fragment_status=0, skin_type=:skin_type, skin_level=1, skin_experience_level=0, skin_experience_type=0, modify_time=:modify_time;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $item_id + 1000,
|
||||
':skin_status' => 2,
|
||||
':fragment_id' => $item_id,
|
||||
':fragment_num' => $item_num,
|
||||
':skin_type' => 1,
|
||||
':create_time' => time(),
|
||||
':modify_time' => time()
|
||||
@ -75,22 +273,51 @@ class AddReward {
|
||||
die();
|
||||
}
|
||||
}
|
||||
} else if ($item_id == 10002) {
|
||||
$rowkey = $conn->execQueryOne('SELECT keys_num FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE user SET keys_num=:keys_num, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':keys_num' => $item_num + $rowkey['keys_num'],
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
}
|
||||
//添加角色
|
||||
protected function addSkin($item_id, $item_num, $accountid)
|
||||
{
|
||||
$item_list = array();
|
||||
$item_id = 0;
|
||||
$item_num = 0;
|
||||
$conn = $this->getMysql($accountid);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
$rowSkin = $conn->execQueryOne('SELECT fragment_num FROM skin WHERE accountid=:accountid AND fragment_id=:fragment_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':fragment_id' => $item_id
|
||||
));
|
||||
if (!$rowSkin) {
|
||||
$ret = $conn->execScript('INSERT INTO skin(accountid, skin_id, skin_status, fragment_id, fragment_num, active_time, fragment_status, skin_type, skin_level, skin_experience_level, skin_experience_type, create_time, modify_time) ' .
|
||||
' VALUES(:account_id, :skin_id, :skin_status, :fragment_id, 0, 0, 0, :skin_type, 1, 0, 0, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, skin_id=:skin_id, skin_status=:skin_status, fragment_id=:fragment_id, fragment_num=0, active_time=0, fragment_status=0, skin_type=:skin_type, skin_level=1, skin_experience_level=0, skin_experience_type=0, modify_time=:modify_time;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $item_id,
|
||||
':skin_status' => 1,
|
||||
':fragment_id' => $item_id - 1000,
|
||||
':skin_type' => 1,
|
||||
':create_time' => time(),
|
||||
':modify_time' => time()
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
}
|
||||
$item_id = $itemid;
|
||||
$item_num = 1;
|
||||
} else {
|
||||
$item_id = 10003;
|
||||
$item_num = $dprice;
|
||||
$this->addDirmond($item_num);
|
||||
}
|
||||
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
183
webapp/controller/EmojiController.class.php
Normal file
183
webapp/controller/EmojiController.class.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
class EmojiController{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig(crc32($account_id));
|
||||
$conn = new phpcommon\Mysql(array(
|
||||
'host' => $mysql_conf['host'],
|
||||
'port' => $mysql_conf['port'],
|
||||
'user' => $mysql_conf['user'],
|
||||
'passwd' => $mysql_conf['passwd'],
|
||||
'dbname' => 'gamedb2001_' . $mysql_conf['instance_id']
|
||||
));
|
||||
return $conn;
|
||||
}
|
||||
|
||||
protected function getEmoji($emoji_id)
|
||||
{
|
||||
$emoji_meta_table = require('../res/emoji@emoji.php');
|
||||
$emoji_meta = getEmojiConfig($emoji_meta_table, $emoji_id);
|
||||
$emoji = array(
|
||||
'id' => $emoji_meta['id'],
|
||||
'name' => $emoji_meta['emoji_name'],
|
||||
'title' => $emoji_meta['emoji_title'],
|
||||
'icon' => $emoji_meta['emoji_icon'],
|
||||
'type' => $emoji_meta['emoji_type'],
|
||||
'get_type' => $emoji_meta['get_type'],
|
||||
'number' => $emoji_meta['number'],
|
||||
'order_weight' => $emoji_meta['order_weight'],
|
||||
);
|
||||
return $emoji;
|
||||
}
|
||||
|
||||
|
||||
public function emojiInfo()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
$emoji_list = array();
|
||||
$emoji_meta_table = require('../res/emoji@emoji.php');
|
||||
foreach ($emoji_meta_table as $emoji_info) {
|
||||
$id = $emoji_info['id'];
|
||||
$emoji = $this->getEmoji($id);
|
||||
if (!$emoji) {
|
||||
continue;
|
||||
}
|
||||
$status = 2;
|
||||
$row = $conn->execQueryOne('SELECT status FROM emoji WHERE accountid=:accountid AND emojiid=:emojiid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
'emojiid' => $emoji['id']
|
||||
));
|
||||
if (!$row && $emoji['get_type'] == 1) {
|
||||
//插入默认上阵的表情
|
||||
$ret = $conn->execScript('INSERT INTO emoji(accountid, emojiid, status, create_time, modify_time) ' .
|
||||
' VALUES(:account_id, :emojiid, 0, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, emojiid=:emojiid, status=0, modify_time=:modify_time;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':emojiid' => $id,
|
||||
':create_time' => time(),
|
||||
':modify_time' => time()
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
}
|
||||
$status = 0;
|
||||
}
|
||||
if ($row) {
|
||||
$status = $row['status'];
|
||||
}
|
||||
array_push($emoji_list, array(
|
||||
'emoji_id' => $emoji['id'],
|
||||
'emoji_status' => $status,
|
||||
'emoji_icon' => $emoji['icon'],
|
||||
'title_icon' => $emoji['title'],
|
||||
'emoji_type' => $emoji['type'],
|
||||
'get_type' => $emoji['get_type'],
|
||||
'coin_num' => $emoji['number'],
|
||||
'order' => $emoji['order_weight'],
|
||||
));
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'emoji_list' => $emoji_list
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public function exchageEmoji()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$emoji_list = array();
|
||||
$usingemoji_id = $_REQUEST['usingemoji_id'];
|
||||
$exchangeemoji_id = $_REQUEST['exchangeemoji_id'];
|
||||
$row = $conn->execQueryOne('SELECT status FROM emoji WHERE accountid=:accountid AND emojiid=:emojiid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':emojiid' => $usingemoji_id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个表情');
|
||||
return;
|
||||
}
|
||||
if ($row['status'] != 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '该表情未上阵');
|
||||
return;
|
||||
}
|
||||
$using_ret = $conn->execScript('UPDATE emoji SET status=1, modify_time=:modify_time ' .
|
||||
' WHERE accountid = :account_id AND emojiid = :emojiid;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':emojiid' => $usingemoji_id,
|
||||
':modify_time' => time()
|
||||
));
|
||||
|
||||
if(!$using_ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
array_push($emoji_list, array(
|
||||
'emoji_id' => $usingemoji_id,
|
||||
'emoji_status' => 1
|
||||
));
|
||||
$row = $conn->execQueryOne('SELECT status FROM emoji WHERE accountid=:accountid AND emojiid=:emojiid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':emojiid' => $exchangeemoji_id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个表情');
|
||||
return;
|
||||
}
|
||||
$exchange_ret = $conn->execScript('UPDATE emoji SET status=0, modify_time=:modify_time ' .
|
||||
' WHERE accountid = :account_id AND emojiid = :emojiid;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':emojiid' => $exchangeemoji_id,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if(!$exchange_ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
array_push($emoji_list, array(
|
||||
'emoji_id' => $exchangeemoji_id,
|
||||
'emoji_status' => 0
|
||||
));
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'emoji_list' => $emoji_list
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
@ -3,7 +3,7 @@
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
class PayController{
|
||||
class PassController{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
@ -70,5 +70,257 @@ class PayController{
|
||||
return $seaPoint;
|
||||
}
|
||||
|
||||
public function getPassInfo()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
//判断当前赛季
|
||||
$number = 0;
|
||||
$open_time = 0;
|
||||
$end_time = 0;
|
||||
$season_meta_table = require('../res/season@season.php');
|
||||
for ($i = 1; $i <= count($season_meta_table); $i++) {
|
||||
$season = $this->getSeason($i);
|
||||
if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) {
|
||||
$open_time = strtotime($season['open_time']);
|
||||
$end_time = strtotime($season['end_time']);
|
||||
$number = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($number == 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '赛季未开启');
|
||||
return;
|
||||
}
|
||||
//当前段位及积分
|
||||
$rank = 0;
|
||||
$next_score = 0;
|
||||
$max_score = 0;
|
||||
$sum_score = 0;
|
||||
$score = 0;
|
||||
$row = $conn->execQueryOne('SELECT integral, pass_status FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||
$seaPoint = $this->getSeasonPoint($ii);
|
||||
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|
||||
|| $seaPoint['max'] == -1) {
|
||||
$rank = $ii;
|
||||
if ($ii == count($seaPoint_meta_table)) {
|
||||
$next_score = $seaPoint['max'];
|
||||
} else {
|
||||
$next_score = $seaPoint['max'] + 1 - $seaPoint['min'];
|
||||
}
|
||||
$score = $row['integral'] - $seaPoint['min'];
|
||||
}
|
||||
if ($ii == count($seaPoint_meta_table)) {
|
||||
$max_score = $seaPoint['min'];
|
||||
} else {
|
||||
$max_score = $seaPoint['max'];
|
||||
}
|
||||
}
|
||||
if ($rank == 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '未达到段位要求');
|
||||
return;
|
||||
}
|
||||
//奖励信息
|
||||
$item_list = array();
|
||||
$seaReward_meta_table = require('../res/seasonReward@seasonReward.php');
|
||||
for ($j = 1; $j <= count($season_meta_table); $j++) {
|
||||
$id = $j + $number * 100;
|
||||
if ($id >= ($number + 1) * 100 || $id <= ($number - 1) * 100) {
|
||||
continue;
|
||||
}
|
||||
$drop_multiply = array();
|
||||
$status = 0;
|
||||
$seaReward = $this->getSeasonReward($j + $number * 100);
|
||||
$rowPass = $conn->execQueryOne('SELECT active_status, honor_status ' .
|
||||
' FROM passinfo WHERE accountid=:accountid AND passid=:passid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':passid' => $seaReward['id']
|
||||
));
|
||||
for ($t = 1; $t <= 2; $t++) {
|
||||
$delim = ":";
|
||||
if ($t == 1) {
|
||||
$drop_multiply = explode($delim, $seaReward['active']);
|
||||
if ($rowPass) {
|
||||
$status = $rowPass['active_status'];
|
||||
}
|
||||
}
|
||||
if ($t == 2) {
|
||||
$drop_multiply = explode($delim, $seaReward['honor']);
|
||||
if ($rowPass) {
|
||||
$status = $rowPass['honor_status'];
|
||||
}
|
||||
}
|
||||
array_push($item_list, array(
|
||||
'id' => $id,
|
||||
'type' => $t,
|
||||
'point' => $seaReward['point'],
|
||||
'item_id' => $drop_multiply[0],
|
||||
'item_num' => $drop_multiply[1],
|
||||
'status' => $status,
|
||||
));
|
||||
}
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'pass_status' => $row['pass_status'],
|
||||
'season' => $number,
|
||||
'open_time' => $open_time,
|
||||
'end_time' => $end_time,
|
||||
'rank' => $rank,
|
||||
'sum_score' => $row['integral'],
|
||||
'score' => $score,
|
||||
'max_score' => $max_score,
|
||||
'next_score' => $next_score,
|
||||
'item_list' => $item_list
|
||||
));
|
||||
}
|
||||
|
||||
public function getPassReward()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$passid = $_REQUEST['id'];
|
||||
$type = $_REQUEST['type'];
|
||||
$status = 0;
|
||||
$seaReward = $this->getSeasonReward($passid);
|
||||
if (!$seaReward) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||
return;
|
||||
}
|
||||
$rowPass = $conn->execQueryOne('SELECT active_status, honor_status ' .
|
||||
' FROM passinfo WHERE accountid=:accountid AND passid=:passid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':passid' => $$passid
|
||||
));
|
||||
if ($rowPass) {
|
||||
if ($type == 1) {
|
||||
$status = $rowPass['active_status'];
|
||||
}
|
||||
if ($type == 2) {
|
||||
$status = $rowPass['honor_status'];
|
||||
}
|
||||
if ($status == 1) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '该奖励已领取');
|
||||
return;
|
||||
}
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT integral, pass_status FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($seaReward['point'] > $row['integral']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 4, '没有达到通行证要求');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($type == 2 && $row['pass_status'] == 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 4, '没有达到通行证要求');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$rowPass) {
|
||||
$ret = $conn->execScript('INSERT INTO passinfo(accountid, passid, active_status, honor_status, create_time, modify_time) ' .
|
||||
' VALUES(:accountid, :passid, 0, 0, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, passid=:passid, active_status=0, honor_status=0, modify_time=:modify_time;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':passid' => $passid,
|
||||
':create_time' => time(),
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->updateStatus($account_id, $passid, $type);
|
||||
//增加奖励
|
||||
$drop_multiply = array();
|
||||
if ($type == 1) {
|
||||
$drop_multiply = explode($delim, $seaReward['active']);
|
||||
}
|
||||
if ($type == 2) {
|
||||
$drop_multiply = explode($delim, $seaReward['honor']);
|
||||
}
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($drop_multiply[0], $drop_multiply[1], $account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'status' => 1,
|
||||
));
|
||||
}
|
||||
|
||||
protected function updateStatus($accountid, $passid, $type)
|
||||
{
|
||||
$conn = $this->getMysql($accountid);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
if ($type == 1) {
|
||||
$ret = $conn->execScript('UPDATE passinfo SET active_status=1, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid AND passid=:passid;',
|
||||
array(
|
||||
':accountid' => $accountid,
|
||||
':passid' => $passid,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($type == 2) {
|
||||
$ret = $conn->execScript('UPDATE passinfo SET honor_status=1, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid AND passid=:passid;',
|
||||
array(
|
||||
':accountid' => $accountid,
|
||||
':passid' => $passid,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -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, 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;',
|
||||
$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) ' .
|
||||
' 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) ' .
|
||||
' 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;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':user_name' => $user_name,
|
||||
@ -132,7 +132,8 @@ class RoleController{
|
||||
'kefu_status' => 0,
|
||||
'box_num' => 0,
|
||||
'diamond_num' => 0,
|
||||
'sum_coin' => 0
|
||||
'sum_coin' => 0,
|
||||
'pass_status' => 0,
|
||||
));
|
||||
} else {
|
||||
echo json_encode(array(
|
||||
@ -153,7 +154,8 @@ class RoleController{
|
||||
'kefu_status' => $row['kefu_status'],
|
||||
'box_num' => $row['box_num'],
|
||||
'diamond_num' => $row['diamond_num'],
|
||||
'sum_coin' => $row['sum_coin']
|
||||
'sum_coin' => $row['sum_coin'],
|
||||
'pass_status' => $row['pass_status'],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,38 @@ class ShareController{
|
||||
return $p;
|
||||
}
|
||||
|
||||
protected function subCoin($coin_num, $account_id)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
if ($row['diamond_num'] < $diamond_num) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足');
|
||||
die();
|
||||
}
|
||||
$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'] - $diamond_num,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function keyBoxInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
@ -96,39 +128,18 @@ class ShareController{
|
||||
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;
|
||||
}
|
||||
if ($row['keys_num'] < 1) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '钥匙不足');
|
||||
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'] - 1,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
//随机奖励
|
||||
$free = $_REQUEST['free'];
|
||||
$drop_id = 0;
|
||||
if ($free != 0) {
|
||||
$drop_id = 24002;
|
||||
} else {
|
||||
$drop_id = 24001;
|
||||
}
|
||||
//扣除钻石
|
||||
$p = $this->getParameter(DIAMONDBOX);
|
||||
$diamond_num = $p['param_value'];
|
||||
$this->subCoin($diamond_num, $account_id);
|
||||
//随机奖励
|
||||
$drop_id = 0;
|
||||
$d = $this->getDrop($drop_id);
|
||||
if (!$d) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||
|
@ -36,6 +36,7 @@ class ShopController{
|
||||
$it = array(
|
||||
'id' => $item_conf['id'],
|
||||
'price' => $item_conf['price'],
|
||||
'dprice' => $item_conf['dprice'],
|
||||
);
|
||||
return $it;
|
||||
}
|
||||
@ -327,7 +328,7 @@ class ShopController{
|
||||
$flush_times = $row['shop_flush_times'] + 1;
|
||||
}
|
||||
if ($shop_type == 2) {
|
||||
$p_flush = $this->getParameter(MAX_SHOP_REFRESH);
|
||||
$p_flush = $this->getParameter(RAND_DIAMONDSHOP_TIME);
|
||||
if ($p_flush['param_value'] <= $row['diamond_shop_flush_times']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '今日刷新次数已满');
|
||||
return;
|
||||
@ -358,6 +359,9 @@ class ShopController{
|
||||
}
|
||||
if ($_REQUEST['type'] == 3) {
|
||||
$p = $this->getParameter(RAND_SHOP_GOLD);
|
||||
if ($shop_type == 2) {
|
||||
$p = $this->getParameter(RAND_DIAMONDSHOP_GOLD);
|
||||
}
|
||||
$this->SubCoin($p['param_value'], $account_id, $_REQUEST['type']);
|
||||
}
|
||||
unset($user_db['shop_list']);
|
||||
@ -451,6 +455,9 @@ class ShopController{
|
||||
$discount_array = $this->getExplode($s['discount']);
|
||||
$discount = $discount_array[$keys][0];
|
||||
$price = round($it['price'] * $item_num * ($discount * 1.0 / 10));
|
||||
if ($s['tip'] == 4) {
|
||||
$price = round($it['dprice'] * $item_num * ($discount * 1.0 / 10));
|
||||
}
|
||||
}
|
||||
array_push($shop_list, array(
|
||||
'shop_id' => $s['shop_id'],
|
||||
@ -467,7 +474,6 @@ class ShopController{
|
||||
|
||||
protected function subCoin($coin_num, $account_id, $tips)
|
||||
{
|
||||
error_log($tips);
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
|
@ -1,356 +0,0 @@
|
||||
<?php
|
||||
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
class SignController{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig(crc32($account_id));
|
||||
$conn = new phpcommon\Mysql(array(
|
||||
'host' => $mysql_conf['host'],
|
||||
'port' => $mysql_conf['port'],
|
||||
'user' => $mysql_conf['user'],
|
||||
'passwd' => $mysql_conf['passwd'],
|
||||
'dbname' => 'gamedb2001_' . $mysql_conf['instance_id']
|
||||
));
|
||||
return $conn;
|
||||
}
|
||||
|
||||
protected function getSign($sign_id)
|
||||
{
|
||||
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
||||
$sign_conf = getSignConfig($g_conf_sign_cluster, $sign_id);
|
||||
$s = array(
|
||||
'sign_id' => $sign_conf['sign_id'],
|
||||
'condition' => $sign_conf['condition'],
|
||||
'item_id' => $sign_conf['item_id'],
|
||||
'num' => $sign_conf['num'],
|
||||
);
|
||||
return $s;
|
||||
}
|
||||
|
||||
protected function getExplode($string)
|
||||
{
|
||||
$delim = "|";
|
||||
$drop_multiply = explode($delim, $string);
|
||||
$delim1 = ":";
|
||||
$arr = array();
|
||||
for ($i = 0; $i < count($drop_multiply); $i++) {
|
||||
$mul = explode($delim1, $drop_multiply[$i]);
|
||||
array_push($arr, $mul);
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
protected function getParameter($para_id)
|
||||
{
|
||||
$g_conf_para_cluster = require('../res/parameter@parameter.php');
|
||||
$para_conf = getParameterConfig($g_conf_para_cluster, $para_id);
|
||||
$p = array(
|
||||
'id' => $para_conf['id'],
|
||||
'param_name' => $para_conf['param_name'],
|
||||
'param_value' => $para_conf['param_value'],
|
||||
);
|
||||
return $p;
|
||||
}
|
||||
|
||||
protected function insertSign($account_id, $sign_days)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
$ret = $conn->execScript('INSERT INTO sign(accountid, sign_id, signable, sign_time, create_time, modify_time) ' .
|
||||
' VALUES(:accountid, :sign_id, 0, :sign_time, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, sign_id=:sign_id, signable=0, sign_time=:sign_time, modify_time=:modify_time;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':sign_id' => $sign_days,
|
||||
':sign_time' => time(),
|
||||
':create_time' => time(),
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
public function signInfo()
|
||||
{
|
||||
$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);
|
||||
$last_sign_id = 0;
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = $conn->execQuery('SELECT sign_id, sign_time FROM sign WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$nowTime = phpcommon\getdayseconds(time());
|
||||
if (!$rows) {
|
||||
$last_sign_id = 1;
|
||||
//插入签到列表
|
||||
$this->insertSign($account_id, $last_sign_id);
|
||||
//更新签到总天数
|
||||
$this->updateSignSum($account_id, $last_sign_id);
|
||||
//完成签到任务
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
||||
$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
|
||||
} else {
|
||||
$last_sign_time = 0;
|
||||
foreach ($rows as $row) {
|
||||
if ($row['sign_id'] > $last_sign_id) {
|
||||
$last_sign_time = $row['sign_time'];
|
||||
$last_sign_id = $row['sign_id'];
|
||||
}
|
||||
}
|
||||
if ($nowTime - phpcommon\getdayseconds($last_sign_time) > 0) {
|
||||
//每日刷新
|
||||
$this->updateDaily($account_id);
|
||||
$passed_days = floor(($nowTime - phpcommon\getdayseconds($last_sign_time)) / (3600 * 24));
|
||||
if ($passed_days > 7 - $last_sign_id) {
|
||||
//跨周时删除老数据
|
||||
$ret = $conn->execScript('DELETE from sign WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$num = ($passed_days - 7 + $last_sign_id) % 7;
|
||||
for ($i = $last_sign_id + 1; $i < $num + $last_sign_id + 1; $i++) {
|
||||
//插入补签列表
|
||||
$this->insertSign($account_id, $i);
|
||||
}
|
||||
} else {
|
||||
for ($i = $last_sign_id + 1; $i < $passed_days + $last_sign_id + 1; $i++) {
|
||||
//插入补签列表
|
||||
$this->insertSign($account_id, $i);
|
||||
}
|
||||
}
|
||||
//更新签到总天数
|
||||
$this->updateSignSum($account_id, $passed_days);
|
||||
//完成签到任务
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
||||
$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
|
||||
}
|
||||
}
|
||||
$sign_list = array();
|
||||
$rows = $conn->execQuery('SELECT sign_id, signable FROM sign WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
foreach ($rows as $row) {
|
||||
array_push($sign_list, array(
|
||||
'sign_id' => $row['sign_id'],
|
||||
'signable' => $row['signable']
|
||||
));
|
||||
}
|
||||
$rowUser = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'sign_days' => $rowUser['sign_sum'],
|
||||
'sign_list' => $sign_list
|
||||
));
|
||||
}
|
||||
|
||||
public function signReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$double = $_REQUEST['double'];
|
||||
//登录校验
|
||||
$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 signable FROM sign WHERE accountid=:accountid AND sign_id=:sign_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':sign_id' => $_REQUEST['sign_id'],
|
||||
));
|
||||
if (!$row || $row['signable'] == 1) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '已签到');
|
||||
return;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE sign SET sign_time=:sign_time, signable=1, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid AND sign_id=:sign_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':sign_id' => $_REQUEST['sign_id'],
|
||||
':sign_time' => time(),
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$rowUser = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
//获得奖励
|
||||
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
||||
$day = ($rowUser['sign_sum'] / 7 + $_REQUEST['sign_id']) % count($g_conf_sign_cluster);
|
||||
if ($day == 0) {
|
||||
$day = count($g_conf_sign_cluster);
|
||||
}
|
||||
$s = $this->getSign($day + 90000);
|
||||
$item_id = $s['item_id'];
|
||||
$num = $s['num'];
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($item_id, $num, $account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
|
||||
public function signDoubleReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$double = $_REQUEST['double'];
|
||||
//登录校验
|
||||
$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;
|
||||
}
|
||||
$rowUser = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
//获得奖励
|
||||
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
|
||||
$day = ($rowUser['sign_sum'] / 7 + $_REQUEST['sign_id']) % count($g_conf_sign_cluster);
|
||||
if ($day == 0) {
|
||||
$day = count($g_conf_sign_cluster);
|
||||
}
|
||||
$s = $this->getSign($day + 90000);
|
||||
$item_id = $s['item_id'];
|
||||
$num = $s['num'];
|
||||
$p = $this->getParameter(REWARD_TIMES);
|
||||
$times = $p['param_value'] - 1;
|
||||
$num = $num * $times;
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($item_id, $num, $account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
protected function updateSignSum($account_id, $sign_num)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT sign_sum FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE user SET sign_sum=:sign_sum, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':sign_sum' => $row['sign_sum'] + $sign_num,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
protected function updateDaily($account_id)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
die();
|
||||
}
|
||||
//刷新每日任务和活动任务
|
||||
$rowCount = $conn->execQueryRowCount('SELECT * FROM quest WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
if ($rowCount != 0) {
|
||||
for ($i = 0; $i < $rowCount; $i++) {
|
||||
$ret = $conn->execScript('UPDATE quest SET quest_state=:quest_state, quest_num=:quest_num, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid AND quest_type=:quest_type1;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':quest_num' => 0,
|
||||
':quest_type1' => 1,
|
||||
':quest_state' => 0,
|
||||
':modify_time' => time()
|
||||
));
|
||||
}
|
||||
if (!$ret) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
//刷新战斗结算奖励次数,商店刷新次数,客服
|
||||
$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,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$battle_ret) {
|
||||
die();
|
||||
}
|
||||
//刷新抽奖活动奖励
|
||||
$lottery_ret = $conn->execScript('UPDATE activity SET free_times=0, video_times=0, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$lottery_ret) {
|
||||
die();
|
||||
}
|
||||
//刷新邀请好友奖励
|
||||
$share_ret = $conn->execScript('UPDATE share_achievement SET status=0, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$share_ret) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user