eloquentClass::where('user_id', $userId); if ($taskId) { $query->where('task_id', $taskId); } return $query->orderBy('rewarded_at', 'desc') ->limit($limit) ->get() ->toArray(); } /** * 获取特定时间段内的任务奖励发放日志 * * @param string $startDate 开始日期 * @param string $endDate 结束日期 * @return array 任务奖励发放日志列表 */ public function getRewardLogsByDateRange(string $startDate, string $endDate): array { return $this->eloquentClass::whereBetween('rewarded_at', [$startDate, $endDate]) ->orderBy('rewarded_at', 'desc') ->get() ->toArray(); } }