77 lines
2.0 KiB
PHP
77 lines
2.0 KiB
PHP
<?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 0; //$this->getPrivilegePlus($account_id, 'battleplus');
|
|
}
|
|
|
|
public function getOfflineLimitPlus($account_id) {
|
|
return $this->getPrivilegePlus($account_id, 'offline_times');
|
|
}
|
|
|
|
public function getMedalLimitPlus($account_id) {
|
|
return $this->getPrivilegePlus($account_id, 'medal_limit_up');
|
|
}
|
|
|
|
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,
|
|
)
|
|
);
|
|
|
|
if (!$row || is_null($row['vip_info']) || empty($row['vip_info'])) {
|
|
return 0;
|
|
}
|
|
|
|
$plus = 0;
|
|
$nowtime = time();
|
|
$vip_info = json_decode($row['vip_info'], true);
|
|
foreach ($vip_info as $carditem) {
|
|
if ($carditem['expire'] == 0 || $carditem['expire'] > $nowtime) {
|
|
$privilegecard_conf = metatable\getPrivilegeCardById($carditem['id']);
|
|
if ($privilegecard_conf) {
|
|
$plus += $privilegecard_conf[$name];
|
|
}
|
|
}
|
|
}
|
|
|
|
return $plus;
|
|
}
|
|
}
|