first(); } /** * @description: 查询所有数据 * @param array $search * @return Collection */ public static function findAll(array $search = []): Collection { return self::$MODEL::where(self::getWhere($search))->get(); } /** * @description: 分页查询 * @param array $search * @return array */ public static function paginate(array $search = []): array { $limit = $search['limit'] ?? 15; // 当天(纽约时间)的记录也展示实时统计,但要到次日才能发放,见 RewardGrantService::grant $today = Carbon::now('America/New_York')->format('Y-m-d'); $paginator = static::$MODEL::where(self::getWhere($search)) ->where('date', '<=', $today) ->tap(fn($query) => MemberAccount::filter($query, $search['account'] ?? null)) ->with(['member']) ->orderByDesc('date') ->orderBy('status') ->orderByDesc('betting_amount') ->paginate($limit); $list = $paginator->items(); foreach ($list as $item) { $item['account'] = (string)($item->member->account ?? ''); $item['can_grant'] = (int)$item->status === RebateModel::STATUS_WEI_FAN_YONG && (string)$item->date < $today; } return ['total' => $paginator->total(), 'data' => $list]; } //笔笔返 根据某天的有效投注额,和反水比例,进行笔笔返 public static function BibiReturn(Rebate $rebate, $amount): bool { // Read the current effective amount under lock rather than paying the supplied stale snapshot. return RewardGrantService::grant('rebate', (int) $rebate->id, (string) (request()->user->username ?? 'system')); } }