1.3K Star 6.3K Fork 2.2K

GVPKarson / FastAdmin

 / 详情

签到送积分可能会导致获得双倍积分

已完成
创建于  
2022-07-21 11:16

文件位置: \library\Wechat.php 274行

$user->setInc('score', $score);
User::score($score, $user->id, "连续签到{$successions}天");

因为 \app\common\model\User::score 方法本身会增加用户积分,

/**
     * 变更会员积分
     * @param int    $score   积分
     * @param int    $user_id 会员ID
     * @param string $memo    备注
     */
    public static function score($score, $user_id, $memo)
    {
        Db::startTrans();
        try {
            $user = self::lock(true)->find($user_id);
            if ($user && $score != 0) {
                $before = $user->score;
                $after = $user->score + $score;
                $level = self::nextlevel($after);
                //更新会员信息
                $user->save(['score' => $after, 'level' => $level]);
                //写入日志
                ScoreLog::create(['user_id' => $user_id, 'score' => $score, 'before' => $before, 'after' => $after, 'memo' => $memo]);
            }
            Db::commit();
        } catch (\Exception $e) {
            Db::rollback();
        }
    }

评论 (1)

qyx520 创建了任务
Karson 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
10933 karson 1578914737 1186106 qyx520 1578945486
PHP
1
https://gitee.com/karson/fastadmin.git
git@gitee.com:karson/fastadmin.git
karson
fastadmin
FastAdmin

搜索帮助