where(['course_id' => $course_id]) ->where(['user_id' => $user_id]) ->where(['classify' => 3]) ->limit(1) ->find(); } // 是否追剧 public static function isfollowthedrama($user_id, $course_id) { return DatabaseRoute::getDb('course_collect', $user_id) ->where(['course_id' => $course_id]) ->where(['classify' => 1]) ->limit(1) ->find(); } // 查询用户是否购买了整集 public static function selectCourseUser($user_id, $course_id) { return DatabaseRoute::getDb('course_user', $user_id) ->where(['course_id' => $course_id]) ->where(['classify' => 1]) ->find(); } /** * 校验用户是否达到免费播放购买次数 */ public static function checkFreeWatchPayCount($userId) { $isExpire = RedisUtils::getFreeWatchTimeIsExpire($userId); if (!$isExpire) { $count = DatabaseRoute::getDb('orders', $userId)->where([ 'status' => 1, 'pay_way' => 9, ['create_time', '>', date('Y-m-d 00:00:00')], ])->count(); $needCount = (new CommonInfo())->getByCode(916); $freeTime = (new CommonInfo())->getByCode(917); Db::connect()->close(); if (!$needCount || !$freeTime) { return false; } if ($count >= intval($needCount['value'])) { RedisUtils::setFreeWatchTime($userId, intval($freeTime['value']) * 60, false); RedisUtils::getFreeWatchTimeIsExpire($userId); $isExpire = false; }else{ $isExpire = true; } } return !$isExpire; } }