请选择 进入手机版 | 继续访问电脑版
开启辅助访问
 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

点击进入授权页面

只需一步,快速开始

[Discuz教程] discuzx回帖奖励功能分析

回复:0 | 查看:1815 | hefangxuan 发表于 2018-1-17 00:01:07 |阅读模式 |复制链接
进入sourceincludepostpost_newreply.php文件,在438行附近找到如下代码:

  • if($thread['replycredit'] > 0 && $thread['authorid'] != $_G['uid'] && $_G['uid']) {

复制代码
如果$thread['replycredit']大于0,同时帖子作者不是当前登录用户,则进入下面的处理流程。
$thread['replycredit']为当前帖子的回帖奖励总积分。

  • $replycredit_rule = DB::fetch_first("SELECT * FROM ".DB::table('forum_replycredit')." WHERE tid = '$_G[tid]' LIMIT 1");
  • $have_replycredit = DB::result_first("SELECT COUNT(*) FROM".DB::table('common_credit_log')." WHERE relatedid = '{$_G[tid]}' ANDuid = '{$_G[uid]}' AND operation = 'RCA' LIMIT{$replycredit_rule['times']} ");

复制代码
$replycredit_rule为从forum_replycredit表中查询该帖的回帖奖励设置数组,具体格式为

  • array(
  • 'tid' => '帖子tid',
  • 'extcredits' => '每次回帖的奖励积分',
  • 'times' => '奖励次数',
  • 'membertimes' => '每个人最多奖励的次数',
  • 'random' => '中奖率',
  • 'extcreditstype' => '奖励的积分类型',
  • )

复制代码
$have_replycredit为从common_credit_log表中查询该帖中当前登录用户的已奖励次数。

  • if($replycredit_rule['membertimes'] - $have_replycredit > 0 && $thread['replycredit'] -$replycredit_rule['extcredits'] >= 0) {

复制代码
如果该帖的每个人最多奖励次数$replycredit_rule['membertimes']大于该帖中当前登录用户的已奖励次数$have_replycredit,同时该帖的回帖奖励总积分$thread['replycredit']大于或等于该帖每次回帖的奖励积分$replycredit_rule['extcredits']。

  • $replycredit_rule['extcreditstype'] = $replycredit_rule['extcreditstype'] ?$replycredit_rule['extcreditstype'] :$_G['setting']['creditstransextra'][10];

复制代码
$replycredit_rule['extcreditstype']为该帖奖励积分的积分类型,如果存在$replycredit_rule['extcreditstype']的话就为$replycredit_rule['extcreditstype'],否则为$_G['setting']['creditstransextra'][10]。
$_G['setting']['creditstransextra'][10]为后台->全局->积分设置下设置的回帖奖励使用的积分。

  • if($replycredit_rule['random'] > 0) {
  • $rand = rand(1, 100);
  • $rand_replycredit = $rand $replycredit_rule['extcredits']), 1, 'RCA', $_G[tid]);
  • DB::update($posttable, array('replycredit' => $replycredit_rule['extcredits']), array('pid' => $pid));
  • DB::update("forum_thread", array('replycredit'=> $thread['replycredit'] - $replycredit_rule['extcredits']),array('tid' => $_G[tid]));
  • }

复制代码
如果存在$rand_replycredit:

  • if(!$posttable) {
  • $posttable = getposttablebytid($_G['tid']);
  • }

复制代码
如果不存在回帖表$posttable,则通过tid获取$posttable。

  • updatemembercount($_G['uid'], array($replycredit_rule['extcreditstype'] =>$replycredit_rule['extcredits']), 1, 'RCA', $_G[tid]);

复制代码
根据回帖奖励的规则,更新当前登录用户的积分:在原有积分基础上+$replycredit_rule['extcredits']。$replycredit_rule['extcreditstype']为积分类型,$replycredit_rule['extcredits']为奖励积分数。

  • DB::update($posttable, array('replycredit' => $replycredit_rule['extcredits']), array('pid' => $pid));

复制代码
更新回帖表$posttable中当前用户回复的积分奖励。

  • DB::update("forum_thread", array('replycredit' => $thread['replycredit'] -$replycredit_rule['extcredits']), array('tid' => $_G[tid]));

复制代码
$thread['replycredit'] - $replycredit_rule['extcredits']为计算回帖奖励的剩余总积分。
更新主题表forum_thread中当前帖子的回帖奖励总积分replycredit。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册  

本版积分规则

快速回复 返回列表 客服中心





企业站定制,我们更专业!

联系我们
快速回复 返回顶部 返回列表