privilege
This commit is contained in:
parent
2105b305b0
commit
9a149a1950
@ -344,6 +344,7 @@ CREATE TABLE `recharge` (
|
||||
`accountid` varchar(60) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`first_data` mediumblob COMMENT '首充数据',
|
||||
`daily_purchase` mediumblob COMMENT '每日特惠礼包',
|
||||
`vip_info` mediumblob COMMENT '月卡信息',
|
||||
`recharge_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '累计充值钻石',
|
||||
`present_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '充值赠送钻石总量',
|
||||
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
@ -364,8 +365,8 @@ CREATE TABLE `orderinfo` (
|
||||
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `idx_orderid` (`orderid`),
|
||||
KEY `idx_accountid` (`accountid`),
|
||||
KEY `idx_orderid` (`orderid`),
|
||||
KEY `idx_goodsid` (`goodsid`),
|
||||
KEY `idx_time` (`create_time`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
64
webapp/classes/Privilege.php
Normal file
64
webapp/classes/Privilege.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace classes;
|
||||
|
||||
use phpcommon;
|
||||
use metatable;
|
||||
require_once 'metatable/privilegecard.php';
|
||||
|
||||
class Privilege
|
||||
{
|
||||
|
||||
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' => DBNAME_PREFIX . $mysql_conf['instance_id']
|
||||
));
|
||||
return $conn;
|
||||
}
|
||||
|
||||
public function getBattlePlus($account_id)
|
||||
{
|
||||
return $this->getPrivilegePlus($account_id, 'battleplus');
|
||||
}
|
||||
|
||||
public function getCoinTimesPlus($account_id)
|
||||
{
|
||||
return $this->getPrivilegePlus($account_id, 'dailycoin_times');
|
||||
}
|
||||
|
||||
protected function getPrivilegePlus($account_id, $name)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$row = $conn->execQueryOne(
|
||||
'SELECT * FROM recharge WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
)
|
||||
);
|
||||
$plus = 0;
|
||||
if ($row) {
|
||||
$nowtime = time();
|
||||
$vip_info = json_decode($row['vip_info']);
|
||||
foreach ($vip_info as $key => $carditem) {
|
||||
if ($vip_info[$key]['expire'] == 0 || $vip_info[$key]['expire'] > $nowtime) {
|
||||
$privilegecard_conf = metatable\getPrivilegeCardById($key);
|
||||
if (!$privilegecard_conf) {
|
||||
$plus += $privilegecard_conf[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $plus;
|
||||
}
|
||||
}
|
@ -3,7 +3,8 @@
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
class GameOverController{
|
||||
class GameOverController
|
||||
{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
@ -164,10 +165,12 @@ class GameOverController{
|
||||
}
|
||||
//道具物品
|
||||
$first_list = array();
|
||||
if (phpcommon\extractChannel($account_id) == 6001 ||
|
||||
if (
|
||||
phpcommon\extractChannel($account_id) == 6001 ||
|
||||
phpcommon\extractChannel($account_id) == 6007 ||
|
||||
phpcommon\extractChannel($account_id) == 6008 ||
|
||||
phpcommon\extractChannel($account_id) == 6000) {
|
||||
phpcommon\extractChannel($account_id) == 6000
|
||||
) {
|
||||
array_push($first_list, array(
|
||||
'item_id' => 18006,
|
||||
'item_num' => $num,
|
||||
@ -214,6 +217,15 @@ class GameOverController{
|
||||
$all_item_list = array();
|
||||
if ($type == 0) {
|
||||
$item_list = $this->fixReward($item_list, 5);
|
||||
$privilege = new classes\Privilege();
|
||||
$coinplus = $privilege->getBattlePlus($account_id);
|
||||
if ($coinplus > 0) {
|
||||
foreach ($item_list as $key => $val) {
|
||||
if ($val['item_id'] == 10001) {
|
||||
$item_list[$key]['item_num'] = $val['item_num'] * (100 + $coinplus) / 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$r = $this->getRedis($first_uuid);
|
||||
$user_db_str = $r->get($first_uuid);
|
||||
@ -288,7 +300,8 @@ class GameOverController{
|
||||
return $item_list;
|
||||
}
|
||||
|
||||
protected function randomBox($item_list, $type) {
|
||||
protected function randomBox($item_list, $type)
|
||||
{
|
||||
$b1 = $this->getbox($type);
|
||||
if (!$b1) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||
@ -319,7 +332,6 @@ class GameOverController{
|
||||
'item_num' => $fixed_num[$j][0],
|
||||
'time' => $fixed_time[$j][0]
|
||||
));
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -514,10 +526,12 @@ class GameOverController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$rowUser = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;',
|
||||
$rowUser = $conn->execQueryOne(
|
||||
'SELECT diamond_num FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
)
|
||||
);
|
||||
if (!$rowUser) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
return;
|
||||
|
@ -3,6 +3,7 @@
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
require_once 'metatable/shopGoods.php';
|
||||
require_once 'metatable/privilegecard.php';
|
||||
|
||||
class RechargeController
|
||||
{
|
||||
@ -255,23 +256,24 @@ class RechargeController
|
||||
die();
|
||||
}
|
||||
|
||||
$privilegecard_conf = null;
|
||||
if ($shopgoods['type'] == 3) {
|
||||
$privilegecard_conf = metatable\getPrivilegeCardById($_REQUEST['goodsid']);
|
||||
if (!$privilegecard_conf) {
|
||||
error_log('game2004api payNotify privilege card goods config error:' + json_encode($_REQUEST));
|
||||
echo json_encode(array(
|
||||
'errcode' => 4,
|
||||
'errmsg' => 'privilege card error'
|
||||
));
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$nowtime = time();
|
||||
$conn = $this->getMysql($_REQUEST['account_id']);
|
||||
$this->insertNewOrder($conn, $nowtime);
|
||||
$addreward = new classes\AddReward();
|
||||
$item_list = $addreward->addReward($shopgoods['item_id'], 1, $_REQUEST['account_id'], 0, 0);
|
||||
foreach ($item_list as &$value) {
|
||||
$value['itemnum'] = (float)$value['itemnum'];
|
||||
}
|
||||
error_log(json_encode($item_list));
|
||||
|
||||
$this->updateUserTable($conn);
|
||||
$this->addToBuyHis($conn, $nowtime);
|
||||
|
||||
//update daily purchase
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$rechargerow = $conn->execQueryOne(
|
||||
'SELECT * FROM recharge WHERE accountid=:accountid;',
|
||||
@ -280,6 +282,84 @@ class RechargeController
|
||||
)
|
||||
);
|
||||
|
||||
$addreward = new classes\AddReward();
|
||||
if ($shopgoods['first_present'] > 0) {
|
||||
$addreward->addReward(10003, $shopgoods['first_present'], $account_id, 0, 0);
|
||||
}
|
||||
|
||||
if ($shopgoods['type'] == 3) {
|
||||
$nowtime = time();
|
||||
// update vip_info
|
||||
if (!$rechargerow) {
|
||||
$vip_info = array();
|
||||
$expire = 0;
|
||||
if ($privilegecard_conf['time'] > 0) {
|
||||
$expire = phpcommon\getdayseconds($nowtime) + $privilegecard_conf['time'] * 3600 * 24 + 3600 * 24 - 1;
|
||||
}
|
||||
array_push($vip_info, array(
|
||||
'id' => $_REQUEST['goodsid'],
|
||||
'expire' => $expire,
|
||||
'daily_time' => 0,
|
||||
));
|
||||
|
||||
$ret = $conn->execScript(
|
||||
'INSERT INTO recharge(accountid, vip_info, create_time, modify_time) ' .
|
||||
' VALUES(:account_id, :vip_info, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, vip_info=:vip_info, modify_time=:modify_time;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':vip_info' => json_encode($vip_info),
|
||||
':create_time' => $nowtime,
|
||||
':modify_time' => $nowtime,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$vip_info = json_decode($rechargerow['vip_info']);
|
||||
$found = false;
|
||||
foreach ($vip_info as $key => $carditem) {
|
||||
if ($carditem['id'] == $_REQUEST['goodsid']) {
|
||||
$found = true;
|
||||
if ($vip_info[$key]['expire'] > $nowtime) {
|
||||
$vip_info[$key]['expire'] += $privilegecard_conf['time'] * 3600 * 24;
|
||||
} else {
|
||||
if ($privilegecard_conf['time'] > 0) {
|
||||
$vip_info[$key]['expire'] = phpcommon\getdayseconds($nowtime) + $privilegecard_conf['time'] * 3600 * 24 + 3600 * 24 - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$expire = 0;
|
||||
if ($privilegecard_conf['time'] > 0) {
|
||||
$expire = phpcommon\getdayseconds($nowtime) + $privilegecard_conf['time'] * 3600 * 24 + 3600 * 24 - 1;
|
||||
}
|
||||
array_push($vip_info, array(
|
||||
'id' => $_REQUEST['goodsid'],
|
||||
'expire' => $expire,
|
||||
'daily_time' => 0,
|
||||
));
|
||||
}
|
||||
|
||||
$ret = $conn->execScript(
|
||||
'UPDATE recharge SET daily_purchase=:daily_purchase, modify_time=:modify_time' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':vip_info' => json_encode($vip_info),
|
||||
':modify_time' => time(),
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$item_list = $addreward->addReward($shopgoods['item_id'], 1, $_REQUEST['account_id'], 0, 0);
|
||||
|
||||
foreach ($item_list as &$value) {
|
||||
$value['itemnum'] = (float)$value['itemnum'];
|
||||
}
|
||||
error_log(json_encode($item_list));
|
||||
|
||||
//update daily purchase
|
||||
if (!$rechargerow) {
|
||||
$daily_purchase = array();
|
||||
array_push($daily_purchase, array(
|
||||
@ -299,11 +379,11 @@ class RechargeController
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$daily_purchase = json_decode($rechargerow['first_data']);
|
||||
$daily_purchase = json_decode($rechargerow['daily_purchase']);
|
||||
$found = false;
|
||||
foreach ($daily_purchase as $key => $dailyitem) {
|
||||
if ($dailyitem['id'] == $_REQUEST['goodsid']) {
|
||||
$firstrecharge = true;
|
||||
$found = true;
|
||||
$daily_purchase[$key]['time'] = $_REQUEST['timestamp'];
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
require 'classes/Privilege.php';
|
||||
require_once 'metatable/parameter.php';
|
||||
class RoleController
|
||||
{
|
||||
@ -1614,7 +1615,8 @@ class RoleController
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$privilege = new classes\Privilege();
|
||||
$plustimes = $privilege->getCoinTimesPlus($account_id);
|
||||
$coin_times = $rowUser['coin_times'];
|
||||
$p1 = $this->getParameter(DAILYCOIN_TIMES);
|
||||
$max_times = $p1['param_value'];
|
||||
@ -1636,7 +1638,7 @@ class RoleController
|
||||
$coin_arr = $this->getExplode($eg['promote_gold']);
|
||||
$coin_num = $coin_list[$rowEquip['lv']][0] * $coin_arr[$rowEquip['lv']][0];
|
||||
}
|
||||
if ($coin_times >= $max_times) {
|
||||
if ($coin_times >= $max_times + $plustimes) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '今日次数达到上限');
|
||||
return;
|
||||
}
|
||||
|
36
webapp/metatable/privilegecard.php
Normal file
36
webapp/metatable/privilegecard.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace metatable;
|
||||
|
||||
/*
|
||||
配置表规范
|
||||
getXXXConf:获取表所有数据
|
||||
getXxxById():通过id获取单个数据
|
||||
_internalGetXXXConf:获取表所有数据内部实现不对外开放
|
||||
|
||||
使用方式
|
||||
require_once 'metatable/XXXX.php';
|
||||
|
||||
!!!注意必须使用require_once
|
||||
*/
|
||||
|
||||
function getPrivilegeCardConf()
|
||||
{
|
||||
return _internalGetPrivilegeCardConf();
|
||||
}
|
||||
|
||||
function getPrivilegeCardById($shop_id)
|
||||
{
|
||||
$conf = getPrivilegeCardConf();
|
||||
$shop_id = (int)$shop_id;
|
||||
return array_key_exists($shop_id, $conf) ? $conf[$shop_id] : null;
|
||||
}
|
||||
|
||||
function _internalGetPrivilegeCardConf()
|
||||
{
|
||||
global $g_privilegeCard_table;
|
||||
if (!$g_privilegeCard_table) {
|
||||
$g_privilegeCard_table = require(getConfigBaseDir() . 'privilegecard@privilegecard.php');
|
||||
}
|
||||
return $g_privilegeCard_table;
|
||||
}
|
@ -32,7 +32,7 @@ function _internalGetShopGoodsConf()
|
||||
{
|
||||
global $g_shopGoods_table;
|
||||
if (!$g_shopGoods_table) {
|
||||
$g_shopG_table = require(getConfigBaseDir() . 'shopGoods@shopGoods.php');
|
||||
$g_shopGoods_table = require(getConfigBaseDir() . 'shopGoods@shopGoods.php');
|
||||
}
|
||||
return $g_shopG_table;
|
||||
return $g_shopGoods_table;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user