Skip to content

Commit

Permalink
Fix : card expire time
Browse files Browse the repository at this point in the history
  • Loading branch information
sendya committed Jun 3, 2016
1 parent d492e92 commit 8104ad7
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 4 deletions.
40 changes: 40 additions & 0 deletions Library/Controller/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,44 @@ public function nodeStatus()
}
return $status;
}

/**
* @JSON
* @Authorization
*/
public function nodeQuery()
{
$API_BASE = "https://nodequery.com/api/";

$API_KEY = Option::get('SERVER_NODE_QUERY_API_KEY');
if (!$API_KEY) {
throw new Error('API_KEY is not available', 500);
}

$status = array();
$result = Http::doGet($API_BASE . 'servers?api_key=' . $API_KEY, array());
if($result) {
$result = json_decode($result, true);

foreach ($result['data'] as $node) {
$status[] = array('id' => $node['id'],
'status' => $node['status'],
'availability' => $node['availability'],
'update_time' => $node['update_time'],
'name' => $node['name'],
'load_percent' => $node['load_percent'],
'load_average' => $node['load_average'],
'ram_total' => $node['ram_total'],
'ram_usage' => $node['ram_usage'],
'disk_total' => $node['disk_total'],
'disk_usage' => $node['disk_usage_'],
'current_rx' => $node['current_rx'],
'current_tx' => $node['current_tx']
);
}


}
return $status;
}
}
32 changes: 28 additions & 4 deletions Library/Controller/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ public function activation()
$result['message'] = '您的流量套餐尚未使用完毕。无法转换到 ' . Utils::planAutoShow($card->info) . ' 套餐';
return $result;
}
$user->plan = $card->info;
/*
* 1. 判断账户卡号类型是否一致 一致则无视系统叠加开关进行 叠加时间
*
*/





$user->transfer = Utils::GB * intval($custom_transfer_level[$user->plan]);
$user->payTime = time();
if (($user->flow_up + $user->flow_down) < $user->transfer) {
Expand All @@ -61,11 +69,27 @@ public function activation()
if (is_numeric($card->expireTime)) {
$cardDay = intval($card->expireTime);
}
if ($user->expireTime < time() && !$custom_transfer_repeat) {
$user->expireTime = time() + (3600 * 24 * $cardDay); // 到期时间

$expireTime = 0;

if($user->plan == $card->info) {
if($user->expireTime > time()) {
$expireTime = $user->expireTime + (3600 * 24 * $cardDay);// 到期时间 = 当前账户到期时间+卡片时间
} else {
$expireTime = time() + (3600 * 24 * $cardDay); // 到期时间 = 当前系统续费时间+卡片时间
}
} else {
$user->expireTime = $user->expireTime + (3600 * 24 * $cardDay); // 到期时间

if ($user->expireTime < time() || !$custom_transfer_repeat) {
$expireTime = time() + (3600 * 24 * $cardDay); // 到期时间 = 不叠加原时间 (当前系统续费时间+卡片时间)
} else {
$expireTime = $user->expireTime + (3600 * 24 * $cardDay); // 到期时间 = 当前账户到期时间+卡片时间
}
}
$user->expireTime = $expireTime;

$user->plan = $card->info;

$result['message'] = '您的账户已升级到 ' . Utils::planAutoShow($user->plan) . ' ,共有流量 ' . Utils::flowAutoShow($user->transfer) . ', 已用 ' . Utils::flowAutoShow($user->flow_down + $user->flow_up) . ', 到期时间:' . date('Y-m-d H:i:s',
$user->expireTime);
} elseif ($card->type == 1) {
Expand Down

0 comments on commit 8104ad7

Please sign in to comment.