|
@@ -7,6 +7,12 @@ use Dever;
|
|
|
class Ranking
|
|
|
{
|
|
|
|
|
|
+ # 积分回调,增加积分榜单
|
|
|
+ public function score($log)
|
|
|
+ {
|
|
|
+ $this->up($log['uid'], $log['type_id'], 4, $log['num']);
|
|
|
+ }
|
|
|
+
|
|
|
# 获取最新的总榜
|
|
|
public function getInfo($info_id, $type = 1)
|
|
|
{
|
|
@@ -52,7 +58,12 @@ class Ranking
|
|
|
$update['ranking_id'] = $periods['ranking_id'];
|
|
|
if ($data) {
|
|
|
$update['where_id'] = $data['id'];
|
|
|
- $update['num'] = $data['num'] + $num;
|
|
|
+ if ($num < 0) {
|
|
|
+ $update['num'] = $data['num'] - $num;
|
|
|
+ } else {
|
|
|
+ $update['num'] = $data['num'] + $num;
|
|
|
+ }
|
|
|
+
|
|
|
Dever::db('collection/ranking_data')->update($update);
|
|
|
} else {
|
|
|
$update['num'] = $num;
|
|
@@ -76,7 +87,7 @@ class Ranking
|
|
|
$this->createPeriods(1, $cur, $v);
|
|
|
} else {
|
|
|
# 如果有,检查结束时间到没到期,如果到了,就把这一期置为已结束,重新建立新的期数
|
|
|
- if ($cur > $info['end']) {
|
|
|
+ if ($info['end'] > 0 && $cur > $info['end']) {
|
|
|
Dever::db('collection/ranking_periods')->update(array('where_id' => $info['id'], 'status' => 2));
|
|
|
$this->createPeriods($info['periods'] + 1, $cur, $v);
|
|
|
}
|
|
@@ -100,17 +111,29 @@ class Ranking
|
|
|
$data['users'] = 0;
|
|
|
$data['status'] = 1;
|
|
|
$data['start'] = $cur;
|
|
|
- if ($info['periods'] == 2) {
|
|
|
+ $day = 86400;
|
|
|
+ if ($info['periods'] == 1) {
|
|
|
+ # 天
|
|
|
+ $time = $day;
|
|
|
+ } elseif ($info['periods'] == 2) {
|
|
|
# 周
|
|
|
- $time = 3600*24*7;
|
|
|
+ $time = $day * 7;
|
|
|
} elseif ($info['periods'] == 3) {
|
|
|
# 月
|
|
|
- $time = 3600*24*30;
|
|
|
+ $time = $day * 30;
|
|
|
} elseif ($info['periods'] == 4) {
|
|
|
# 年
|
|
|
- $time = 3600*24*365;
|
|
|
- }
|
|
|
- $data['end'] = $data['start'] + $time;
|
|
|
+ $time = $day * 365;
|
|
|
+ } elseif ($info['periods'] == 5) {
|
|
|
+ # 永久
|
|
|
+ $time = 0;
|
|
|
+ }
|
|
|
+ if ($time > 0) {
|
|
|
+ $data['end'] = $data['start'] + $time;
|
|
|
+ } else {
|
|
|
+ $data['end'] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
Dever::db('collection/ranking_periods')->insert($data);
|
|
|
}
|
|
|
}
|