136 lines
4.0 KiB
PHP
Executable File
136 lines
4.0 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Customer;
|
|
|
|
use App\Model\Lq\JclqOdds;
|
|
use App\Model\Lq\JclqResult;
|
|
use App\Model\Zq\JczqOdds;
|
|
use App\Model\Zq\JczqResult;
|
|
use App\Utils\Helps;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class MatchController extends BaseController
|
|
{
|
|
/**
|
|
* @api {POST} /api/customer/match/jczq 比分-竞彩足球
|
|
* @apiVersion 0.1.0
|
|
* @apiGroup 客户端
|
|
*
|
|
* @apiParam {String} [date] 日期
|
|
*
|
|
* @apiSuccessExample {json} 返回结果
|
|
* {
|
|
* "code": 200,
|
|
* "message": "",
|
|
* "data": {
|
|
* "dates": [{ // 用户信息
|
|
* "date": 2,
|
|
* "date_str": 1,
|
|
* "week_str": "13511111111"
|
|
* }],
|
|
* "result" :[{ // 比赛信息
|
|
* }],
|
|
* }
|
|
* }
|
|
*/
|
|
public function jczq(Request $request)
|
|
{
|
|
$date = $request->input('date');
|
|
|
|
$startDate = date('Ymd', strtotime('-30 day'));
|
|
$endDate = date('Ymd', strtotime('+7 day'));
|
|
|
|
$dates = [];
|
|
for ($d = $startDate; $d <$endDate; $d = date('Ymd', strtotime('+1 day', strtotime($d)))) {
|
|
$dates[] = [
|
|
'date' => date('Y-m-d', strtotime($d)),
|
|
'date_str' => date('m-d', strtotime($d)),
|
|
'week_str' => Helps::getWeek($d),
|
|
];
|
|
}
|
|
if (!$date) {
|
|
$date = date('Y-m-d');
|
|
}
|
|
|
|
$jczq = JczqOdds::with([ 'score', 'match'])
|
|
->select([
|
|
DB::raw('jczq_odds.*'),
|
|
DB::raw('zq_match.status as match_status')
|
|
])
|
|
->leftJoin('zq_match', 'zq_match.match_id', 'jczq_odds.match_id')
|
|
->whereLike('issue_num', $date)
|
|
->orderBy('zq_match.start_time', 'asc')
|
|
->get();
|
|
|
|
$doing = collect($jczq)->where('match_status', 1)->collect();
|
|
$will = collect($jczq)->where('match_status', 0)->collect();
|
|
$done = collect($jczq)->whereNotIn('match_status', [1,0])->collect();
|
|
|
|
return $this->jsonSuccess([
|
|
'dates' => $dates,
|
|
'result' => $doing->merge($will)->merge($done)
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @api {POST} /api/customer/match/lq 比分-竞彩篮球
|
|
* @apiVersion 0.1.0
|
|
* @apiGroup 客户端
|
|
*
|
|
* @apiParam {String} [date] 日期
|
|
*
|
|
* @apiSuccessExample {json} 返回结果
|
|
* {
|
|
* "code": 200,
|
|
* "message": "",
|
|
* "data": {
|
|
* "dates": [{ // 用户信息
|
|
* "date": 2,
|
|
* "date_str": 1,
|
|
* "week_str": "13511111111"
|
|
* }],
|
|
* "result" :[{ // 比赛信息
|
|
* }],
|
|
* }
|
|
* }
|
|
*/
|
|
public function lq(Request $request)
|
|
{
|
|
$date = $request->input('date');
|
|
$startDate = date('Ymd', strtotime('-30 day'));
|
|
$endDate = date('Ymd', strtotime('+7 day'));
|
|
|
|
$dates = [];
|
|
for ($d = $startDate; $d <$endDate; $d = date('Ymd', strtotime('+1 day', strtotime($d)))) {
|
|
$dates[] = [
|
|
'date' => date('Y-m-d', strtotime($d)),
|
|
'date_str' => date('m-d', strtotime($d)),
|
|
'week_str' => Helps::getWeek($d),
|
|
];
|
|
}
|
|
if (!$date) {
|
|
$date = date('Y-m-d');
|
|
}
|
|
|
|
$odds = JclqOdds::with( ['score', 'match'])
|
|
->select([
|
|
DB::raw('jclq_odds.*'),
|
|
DB::raw('jclq_match.status as match_status')
|
|
])
|
|
->leftJoin('jclq_match', 'jclq_match.match_id', 'jclq_odds.match_id')
|
|
->whereLike('issue_num', $date)
|
|
->orderBy('jclq_match.start_time', 'asc')
|
|
->get();
|
|
|
|
$doing = collect($odds)->where('match_status', 1)->collect();
|
|
$will = collect($odds)->where('match_status', 0)->collect();
|
|
$done = collect($odds)->whereNotIn('match_status', [1,0])->collect();
|
|
|
|
return $this->jsonSuccess([
|
|
'dates' => $dates,
|
|
'result' => $doing->merge($will)->merge($done)
|
|
]);
|
|
}
|
|
}
|