硬汉工作室

 找回密码
 立即注册

QQ登录

只需一步,快速开始

+
搜索
热搜: 活动 交友 discuz

[开发技术] 群组积分排行规则修改

[复制链接]
发表于 2020-1-3 17:45:38 | 显示全部楼层 |阅读模式
默认情况下,群组积分排行是所有时间内的积分排行,但是有时候站长更需要最近时间的排行,比如说30天内排行,90天内排行。
直接上代码吧。

$topgrouplist = array();
$olddate = date('Ymd', TIMESTAMP - 90*86400); // 获取90天内排名
$rs = DB::fetch_all('select count(1) as credit, fid from %t forum_groupcreditslog where logdate >= %s group by fid order by credit desc limit 12', array('forum_groupcreditslog', $olddate));
foreach($rs as $v) {
    $_group = DB::fetch_first("SELECT * FROM ".DB::table('forum_forum')." f LEFT JOIN ".DB::table("forum_forumfield")." ff ON ff.fid=f.fid WHERE f.fid = {$v['fid']} and f.type='sub' AND f.status=3");
    $_group['commoncredits'] = $v['credit'];
    isset($_group['icon']) && $_group['icon'] = get_groupimg($_group['icon'], 'icon');
    $topgrouplist[] = $_group;
}

上面代码是获取90天内的积分排名,dz默认是通过forum_forum表里的commoncredits计算排名,我是通过forum_groupcreditlog表来计算排名,一个新帖会往这个表里插入一条数据。




有关PHP系统、Discuz或网站等各种问题,可以联系QQ1069971363寻求付费支持
Discuz插件商店:http://addon.dismall.com/?@56030.developer
回复

使用道具 举报

QQ|Archiver|手机版|小黑屋|硬汉工作室 ( 冀ICP备13021567号-9 )

GMT+8, 2025-2-5 22:48 , Processed in 0.051402 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表