where('user_id', $user_id)->where('type', $type)->count() < $limit; } /** * 获取某种类型的积分 * @param int $user_id * @param string $type * @param null $changeModel * @param string $memo * @return int */ public static function getScore($user_id, string $type, $changeModel = null, string $memo = ''): int { switch (true) { // 未登录 case !$user_id: // 未设置得积分 case !$score = self::getScoreVal($type): // 非会员 case !UserModel::isMember($user_id): // 超过得分限制 case !self::checkLimit($user_id, $type): return 0; } // 递增用户积分并记录 UserScoreLogModel::increment($user_id, $score, $type, $changeModel, $memo); return $score; } }