|
|
@@ -16,48 +16,49 @@ class Bet extends Controller
|
|
|
function index()
|
|
|
{
|
|
|
// try {
|
|
|
- $params = request()->validate([
|
|
|
- 'page' => ['nullable', 'integer', 'min:1'],
|
|
|
- 'limit' => ['nullable', 'integer', 'min:1'],
|
|
|
- 'member_id' => ['nullable', 'string'],
|
|
|
- 'keywords' => ['nullable', 'string', 'min:1'],
|
|
|
- 'issue_no' => ['nullable', 'string'],
|
|
|
- 'id' => ['nullable', 'string'],
|
|
|
- 'status' => ['nullable', 'integer', 'in:1,2'],
|
|
|
- 'username' => ['nullable', 'string', 'min:1'],
|
|
|
- 'start_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:end_time'],
|
|
|
- 'end_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:start_time'],
|
|
|
- 'is_winner' => ['nullable', 'integer', 'in:0,1'],
|
|
|
- ]);
|
|
|
+ $params = request()->validate([
|
|
|
+ 'page' => ['nullable', 'integer', 'min:1'],
|
|
|
+ 'limit' => ['nullable', 'integer', 'min:1'],
|
|
|
+ 'member_id' => ['nullable', 'string'],
|
|
|
+ 'keywords' => ['nullable', 'string', 'min:1'],
|
|
|
+ 'issue_no' => ['nullable', 'string'],
|
|
|
+ 'id' => ['nullable', 'string'],
|
|
|
+ 'status' => ['nullable', 'integer', 'in:1,2'],
|
|
|
+ 'username' => ['nullable', 'string', 'min:1'],
|
|
|
+ 'start_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:end_time'],
|
|
|
+ 'end_time' => ['nullable', 'date', 'date_format:Y-m-d', 'required_with:start_time'],
|
|
|
+ 'is_winner' => ['nullable', 'integer', 'in:0,1'],
|
|
|
+ ]);
|
|
|
|
|
|
- $page = request()->input('page', 1);
|
|
|
- $limit = request()->input('limit', 10);
|
|
|
+ $page = request()->input('page', 1);
|
|
|
+ $limit = request()->input('limit', 10);
|
|
|
|
|
|
- $query = BetModel::where(BetService::getWhere($params))
|
|
|
- ->with(['user', 'issue','pcIssue']);
|
|
|
+ $query = BetModel::where(BetService::getWhere($params))
|
|
|
+ ->with(['user', 'issue', 'pcIssue']);
|
|
|
|
|
|
|
|
|
- if (isset($params['username']) && !empty($params['username'])) {
|
|
|
- $username = $params['username'];
|
|
|
- $query = $query->whereHas('user', function ($query) use ($username) {
|
|
|
- $query->where('username', $username);
|
|
|
- });
|
|
|
- }
|
|
|
+ if (isset($params['username']) && !empty($params['username'])) {
|
|
|
+ $username = $params['username'];
|
|
|
+ $query = $query->whereHas('user', function ($query) use ($username) {
|
|
|
+ $query->where('username', $username);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- $count = $query->count();
|
|
|
- $query->orderBy('id', 'desc');
|
|
|
- $list = $query->forPage($page, $limit)->get();
|
|
|
+ $count = $query->count();
|
|
|
+ $query->orderBy('id', 'desc');
|
|
|
+ $list = $query->forPage($page, $limit)->get();
|
|
|
|
|
|
|
|
|
- $result = ['total' => $count, 'data' => $list];
|
|
|
- foreach ($result['data'] as &$item) {
|
|
|
- $item['is_winner'] = null;
|
|
|
-// $item['winning_array'] = $item['issue']['winning_array'];
|
|
|
-// unset($item['issue']);
|
|
|
- if ($item['status'] == 2) {
|
|
|
- $item['is_winner'] = $item['profit'] > 0;
|
|
|
- }
|
|
|
+ $result = ['total' => $count, 'data' => $list];
|
|
|
+ foreach ($result['data'] as &$item) {
|
|
|
+ $item['is_winner'] = null;
|
|
|
+ $issue = $item['issue'] ?: $item['pc_issue'];
|
|
|
+ $item['winning_array'] = $issue['winning_array'];
|
|
|
+ unset($item['issue'],$item['pc_issue']);
|
|
|
+ if ($item['status'] == 2) {
|
|
|
+ $item['is_winner'] = $item['profit'] > 0;
|
|
|
}
|
|
|
+ }
|
|
|
// } catch (ValidationException $e) {
|
|
|
// return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first());
|
|
|
// } catch (Exception $e) {
|