| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?php
- namespace App\Sports\Controller;
- use BaseController\Controller;
- use Biz\Account\AccountManager;
- /**
- * 赛事数据验证
- * Tank.peng
- * 2019/11/6
- */
- class MatchVer extends Controller
- {
- public function init() {
- $this->time = date('Y-m-d H:i:s',time());
- $this->accountManager = new AccountManager();
- $this->commonFunction = C()->get('commonFunction');
- }
- /**
- * 验证 赛事赔率/比分 是否发生变更
- */
- public function VerOddsScore(){
- /*
- //拼装请求数据
- $data = [
- [
- 'game_code'=>'zq',//球类代码
- 'match_id'=>123,//赛事id
- 'home_score'=>1,//主队得分/进球 如果是滚球让球
- 'guest_score'=>2,//客队得分/进球 如果是滚球让球
- 'odds_only'=>'34f8e550779c6446c05d2dd2bb969631'//赔率uuid
- ],
- [
- 'game_code'=>'lq',
- 'match_id'=>123,
- 'home_score'=>1,
- 'guest_score'=>2,
- 'odds_only'=>'5c890c276384c40648760233194067b9'
- ]
- ];
- */
- //获取 查询数据
- $data_json = $_REQUEST['data'];
- $token = $_REQUEST['token'];
- if(empty($data_json)||empty($token)){
- Render('', '51029',lang('Errors','Api')->get('error-51029'));
- }
- //验证用户token
- $this->getAgent($token);
- //数据转arr
- $data_arr = json_decode($data_json,true);
- if(empty($data_arr)) Render('', '1', lang('Tips','Sports')->get('success'));
- //循环处理 根据球类分组
- //足球 赛事数据
- $zq_data = [];
- //篮球 赛事数据
- $lq_data = [];
- //网球 赛事数据
- $wq_data = [];
- //棒球 赛事数据
- $bq_data = [];
- foreach($data_arr as $k=>$v){
- //序号 赋值
- $v['sort'] = $k;
- //足球
- if($v['game_code'] == 'zq'){
- $zq_data[] = $v;
- }
- //篮球
- if($v['game_code'] == 'lq'){
- $lq_data[] = $v;
- }
- //网球
- if($v['game_code'] == 'wq'){
- $wq_data[] = $v;
- }
- //棒球
- if($v['game_code'] == 'bq'){
- $bq_data[] = $v;
- }
- }
- //处理 足球
- if(!empty($zq_data)){
- //获取model
- $getModels = $this->commonFunction->getModels('zq');
- //获取赛事id
- $zq_match_ids = array_column($zq_data,'match_id');
- //根据赛事id 获取赛事状态
- $zq_match_status = $this->getMatchStatus($zq_match_ids,$getModels);
- //根据赛事id 获取赛事比分
- $zq_match_score = $this->getMatchScore($zq_match_ids,$getModels);
- //根据赔率uuid 验证是否存在
-
- dd($zq_match_score);exit;
- }
- dd($zq_data);
- //验证比分是否发生变化
- //
- dd(123);
- Render('', '1', lang('Tips','Sports')->get('success'));
- }
- /**
- * 获取各球类 指定赛事 状态
- */
- public function getMatchStatus($match_ids,$getModels){
-
- $match_model = $getModels['model_match'];
- $match_status = lm($match_model, 'Sports')
- ->select('id as match_id','status')
- ->whereIn('id',$match_ids)
- ->get()
- ->toArray();
- return $match_status;
- }
- /**
- * 获取各球类 指定赛事 比分
- */
- public function getMatchScore($match_ids,$getModels){
- $model_result = $getModels['model_result'];
- $match_result = lm($model_result, 'Sports')
- ->select('home_score','guest_score')
- ->whereIn('id',$match_ids)
- ->get()
- ->toArray();
- return $match_result;
- }
- /**
- * token获取用户详情
- */
- public function getAgent($token = '') {
- $checkToken = $this->accountManager->checkEffectiveTime($token);
- if ($checkToken['status'] != 1) {
- Render($checkToken['data'], $checkToken['status'], lang('commons')->get('user does login'));
- };
- // $result = $this->accountManager->refreshToken($token);
- // return $result['data'];
- }
- }
|