|
|
@@ -45,10 +45,10 @@ class DataLogic
|
|
|
$obt = $data['data'];
|
|
|
|
|
|
//请求 数据 为空
|
|
|
- if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
|
|
|
+ if (empty($obt)) throw new \Exception(Response::generate('请求数据为空,', Response::ABNORMAL));
|
|
|
$getData = $this->getAddData($obt);
|
|
|
//不是 联赛 数据
|
|
|
- if($getData['title'] != 'league') throw new \Exception(Response::generate('不是联赛数据,',Response::ABNORMAL));
|
|
|
+ if ($getData['title'] != 'league') throw new \Exception(Response::generate('不是联赛数据,', Response::ABNORMAL));
|
|
|
|
|
|
/*
|
|
|
//写请求数据 日志记录
|
|
|
@@ -75,45 +75,45 @@ class DataLogic
|
|
|
|
|
|
//获取 当前请求 所有 联赛 uuid
|
|
|
$identity = [];
|
|
|
- foreach($leagueData as $k=>$v){
|
|
|
+ foreach ($leagueData as $k => $v) {
|
|
|
$identity[] = $v['uuid'];
|
|
|
}
|
|
|
$identity = array_unique($identity);
|
|
|
sort($identity);
|
|
|
|
|
|
//获取 本地 已存在 联赛
|
|
|
- $l_lg_data = $models['model_local_league']::whereIn('identity',$identity)->select('identity','lg_id')->get()->toArray();
|
|
|
+ $l_lg_data = $models['model_local_league']::whereIn('identity', $identity)->select('identity', 'lg_id')->get()->toArray();
|
|
|
//二维数组去重
|
|
|
- $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
|
|
|
+ $l_lg_data = commonFunction::uniquArrV2($l_lg_data, 'identity');
|
|
|
//循环对比 请求identity->本地identity
|
|
|
- foreach($l_lg_data as $k=>$v){
|
|
|
- foreach($identity as $kk=> $uuid){
|
|
|
- if($v['identity'] == $uuid){
|
|
|
+ foreach ($l_lg_data as $k => $v) {
|
|
|
+ foreach ($identity as $kk => $uuid) {
|
|
|
+ if ($v['identity'] == $uuid) {
|
|
|
unset($identity[$kk]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//去除本地和请求里都存在的联赛,如果还有剩余联赛uuid,则将其写入
|
|
|
- if(!empty($identity)) {
|
|
|
+ if (!empty($identity)) {
|
|
|
//没有 决赛时间 默认获取本年最后一天
|
|
|
$last_time = date('Y-12-31 23:59:59');
|
|
|
- foreach($leagueData as $k=>$v){
|
|
|
- foreach($identity as $kk=> $uuid){
|
|
|
- if($v['uuid'] == $uuid){
|
|
|
+ foreach ($leagueData as $k => $v) {
|
|
|
+ foreach ($identity as $kk => $uuid) {
|
|
|
+ if ($v['uuid'] == $uuid) {
|
|
|
//如有 决赛时间
|
|
|
- if($v['last_time']){
|
|
|
+ if ($v['last_time']) {
|
|
|
$last_time = $v['last_time'];
|
|
|
}
|
|
|
//获取联赛所属国家或地区
|
|
|
$getArea = $this->getArea($v['name_chinese']);
|
|
|
- if($getArea['pid'] == 0){
|
|
|
+ if ($getArea['pid'] == 0) {
|
|
|
$area_id = $getArea['id'];
|
|
|
$country_id = 0;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$area_id = $getArea['pid'];
|
|
|
$country_id = $getArea['id'];
|
|
|
}
|
|
|
- if(empty($v['uuid'])) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$v['lg_id'].';',Response::LG__UUID_NULL));
|
|
|
+ if (empty($v['uuid'])) throw new \Exception(Response::generate($gameName . '联赛-lg_id:' . $v['lg_id'] . ';', Response::LG__UUID_NULL));
|
|
|
$set_lg['name_chinese'] = $v['name_chinese'];
|
|
|
$set_lg['kind'] = $v['kind'];
|
|
|
$set_lg['match_mode'] = $v['match_mode'];
|
|
|
@@ -126,18 +126,18 @@ class DataLogic
|
|
|
//写入联赛
|
|
|
$id = $models['model_league']::insertGetId($set_lg);
|
|
|
$m_lg_id = $id;
|
|
|
- if($m_lg_id < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$v['lg_id'].';',Response::INSERT_ERROR));
|
|
|
+ if ($m_lg_id < 1) throw new \Exception(Response::generate($gameName . '联赛-lg_id:' . $v['lg_id'] . ';', Response::INSERT_ERROR));
|
|
|
|
|
|
//写入 本地 联赛记录
|
|
|
$set_local = [
|
|
|
- 'lg_id'=>$id,
|
|
|
- 'others_lg_id'=>$v['lg_id'],
|
|
|
- 'source'=>$source,
|
|
|
- 'ctime'=>date('Y-m-d H:i:s'),
|
|
|
- 'identity'=>$v['uuid'],
|
|
|
+ 'lg_id' => $id,
|
|
|
+ 'others_lg_id' => $v['lg_id'],
|
|
|
+ 'source' => $source,
|
|
|
+ 'ctime' => date('Y-m-d H:i:s'),
|
|
|
+ 'identity' => $v['uuid'],
|
|
|
];
|
|
|
$ret = $models['model_local_league']::insertGetId($set_local);
|
|
|
- if($ret < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LOCAL_LEAGUE_ERROR)) ;//Render([], '10017', lang('Tips','Sports')->get('local_league_error'));
|
|
|
+ if ($ret < 1) throw new \Exception(Response::generate($gameName . '联赛-lg_id:' . $data['lg_id'] . ';', Response::LOCAL_LEAGUE_ERROR));//Render([], '10017', lang('Tips','Sports')->get('local_league_error'));
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -151,7 +151,7 @@ class DataLogic
|
|
|
} catch (\Exception $e) {
|
|
|
//回滚事务
|
|
|
DB::rollBack();
|
|
|
- $this->writeLog($data, ['file'=>$e->getFile(),'line'=>$e->getLine(),'msg'=>$e->getMessage()]);
|
|
|
+ $this->writeLog($data, ['file' => $e->getFile(), 'line' => $e->getLine(), 'msg' => $e->getMessage()]);
|
|
|
return $e->getMessage();
|
|
|
}
|
|
|
}
|
|
|
@@ -168,10 +168,10 @@ class DataLogic
|
|
|
$obt = $data['data'];
|
|
|
|
|
|
//请求 数据 为空
|
|
|
- if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
|
|
|
+ if (empty($obt)) throw new \Exception(Response::generate('请求数据为空,', Response::ABNORMAL));
|
|
|
$getData = $this->getAddData($obt);
|
|
|
//不是 赛事 数据
|
|
|
- if($getData['title'] != 'match') throw new \Exception(Response::generate('不是赛事数据,',Response::ABNORMAL));
|
|
|
+ if ($getData['title'] != 'match') throw new \Exception(Response::generate('不是赛事数据,', Response::ABNORMAL));
|
|
|
|
|
|
/*
|
|
|
//写请求数据 日志记录
|
|
|
@@ -194,7 +194,7 @@ class DataLogic
|
|
|
$identity = [];
|
|
|
$s_match_ids = [];
|
|
|
$match_uuids = [];
|
|
|
- foreach($matchData as $k=>$v){
|
|
|
+ foreach ($matchData as $k => $v) {
|
|
|
$identity[] = $v['uuid'];
|
|
|
$s_match_ids[] = $v['match_id'];
|
|
|
}
|
|
|
@@ -204,25 +204,25 @@ class DataLogic
|
|
|
sort($identity);
|
|
|
|
|
|
//获取 本地 已存在 联赛
|
|
|
- $l_lg_data = $models['model_local_league']::whereIn('identity',$identity)->select('identity','lg_id','others_lg_id')->get()->toArray();
|
|
|
+ $l_lg_data = $models['model_local_league']::whereIn('identity', $identity)->select('identity', 'lg_id', 'others_lg_id')->get()->toArray();
|
|
|
//二维数组去重
|
|
|
- $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
|
|
|
+ $l_lg_data = commonFunction::uniquArrV2($l_lg_data, 'identity');
|
|
|
//如果获取不到本地联赛数据,则返回联赛不存在
|
|
|
- if(empty($l_lg_data)) throw new \Exception(Response::generate($gameName.'本次请求的所有赛事都没有联赛数据;',Response::LEAGUE_ERROR));
|
|
|
+ if (empty($l_lg_data)) throw new \Exception(Response::generate($gameName . '本次请求的所有赛事都没有联赛数据;', Response::LEAGUE_ERROR));
|
|
|
|
|
|
//获取到本次请求,所有本地有联赛的赛事
|
|
|
$mathData_before = $matchData;//接收原赛事
|
|
|
$matchData = [];//获取新赛事
|
|
|
- foreach($l_lg_data as $k=>$v){
|
|
|
- foreach($mathData_before as $kk=>$vv){
|
|
|
- if($v['identity'] == $vv['uuid']){
|
|
|
+ foreach ($l_lg_data as $k => $v) {
|
|
|
+ foreach ($mathData_before as $kk => $vv) {
|
|
|
+ if ($v['identity'] == $vv['uuid']) {
|
|
|
$matchData[] = $vv;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//获取当前请求有关联联赛的赛事 match_id
|
|
|
$s_match_ids = [];
|
|
|
- foreach($matchData as $k=>$v){
|
|
|
+ foreach ($matchData as $k => $v) {
|
|
|
$s_match_ids[] = $v['match_id'];
|
|
|
//追加获取赛事uuid
|
|
|
$match_uuids[] = $v['match_identity'];
|
|
|
@@ -231,19 +231,19 @@ class DataLogic
|
|
|
$match_uuids = array_unique($match_uuids);
|
|
|
sort($match_uuids);
|
|
|
|
|
|
- $l_match_data = $models['model_local_match']::whereIn('identity',$match_uuids)->where('source',$source)->select('match_id','identity')->get()->toArray();
|
|
|
+ $l_match_data = $models['model_local_match']::whereIn('identity', $match_uuids)->where('source', $source)->select('match_id', 'identity')->get()->toArray();
|
|
|
|
|
|
//二维数组去重
|
|
|
- $l_match_data = commonFunction::uniquArrV2($l_match_data,'identity');
|
|
|
+ $l_match_data = commonFunction::uniquArrV2($l_match_data, 'identity');
|
|
|
|
|
|
//循环对比 请求match_id->本地others_match_id
|
|
|
//如果本地有 赛事,则分别获取本地已存在/不存在赛事
|
|
|
- if(!empty($l_match_data)){
|
|
|
+ if (!empty($l_match_data)) {
|
|
|
//本地已存在赛事,用于更新
|
|
|
$matchData_y = [];
|
|
|
- foreach($l_match_data as $k=>$v){
|
|
|
- foreach($match_uuids as $kk=> $match_identity){
|
|
|
- if($v['identity'] == $match_identity){
|
|
|
+ foreach ($l_match_data as $k => $v) {
|
|
|
+ foreach ($match_uuids as $kk => $match_identity) {
|
|
|
+ if ($v['identity'] == $match_identity) {
|
|
|
$matchData_y[$k]['match_identity'] = $match_identity;
|
|
|
$matchData_y[$k]['match_id'] = $v['match_id'];
|
|
|
unset($match_uuids[$kk]);
|
|
|
@@ -253,25 +253,25 @@ class DataLogic
|
|
|
sort($match_uuids);
|
|
|
}
|
|
|
//如果 请求中 有本地赛事,则执行更新
|
|
|
- if(!empty($matchData_y)){
|
|
|
- foreach($matchData as $k=>$v){
|
|
|
- foreach($matchData_y as $kk=> $vv){
|
|
|
- if($v['match_identity'] == $vv['match_identity']){
|
|
|
+ if (!empty($matchData_y)) {
|
|
|
+ foreach ($matchData as $k => $v) {
|
|
|
+ foreach ($matchData_y as $kk => $vv) {
|
|
|
+ if ($v['match_identity'] == $vv['match_identity']) {
|
|
|
$data = $v;
|
|
|
- $up_match=[];
|
|
|
+ $up_match = [];
|
|
|
$up_match['utime'] = date('Y-m-d H:i:s');
|
|
|
$up_match['status'] = $data['status'];
|
|
|
//获取需更新字段
|
|
|
- if($data['is_rollball'] == 1){
|
|
|
+ if ($data['is_rollball'] == 1) {
|
|
|
$up_match['is_rollball'] = $data['is_rollball'];
|
|
|
}
|
|
|
- if($data['is_today'] == 1){
|
|
|
+ if ($data['is_today'] == 1) {
|
|
|
$up_match['is_today'] = $data['is_today'];
|
|
|
}
|
|
|
- if($data['is_morningplate'] == 1){
|
|
|
+ if ($data['is_morningplate'] == 1) {
|
|
|
$up_match['is_morningplate'] = $data['is_morningplate'];
|
|
|
}
|
|
|
- if($data['is_stringscene'] == 1){
|
|
|
+ if ($data['is_stringscene'] == 1) {
|
|
|
$up_match['is_stringscene'] = $data['is_stringscene'];
|
|
|
}
|
|
|
|
|
|
@@ -281,80 +281,80 @@ class DataLogic
|
|
|
$up_match['us_time'] = $data['us_time'];
|
|
|
|
|
|
//如果是网球 追加rule 字段
|
|
|
- if($game_code == 'wq' and !empty($data['rule'])){
|
|
|
+ if ($game_code == 'wq' and !empty($data['rule'])) {
|
|
|
$up_match['rule'] = $data['rule'];
|
|
|
}
|
|
|
//更新赛事 返回成功数量
|
|
|
- $set = $models['model_match']::where(['id'=>$vv['match_id']])
|
|
|
+ $set = $models['model_match']::where(['id' => $vv['match_id']])
|
|
|
->update($up_match);
|
|
|
- if($set < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::UPSTATUS_ERROR)) ;
|
|
|
+ if ($set < 1) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $data['match_id'] . ';', Response::UPSTATUS_ERROR));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//剩余 赛事 数据 写入
|
|
|
- if(!empty($match_uuids)){
|
|
|
- foreach($matchData as $k=>$v){
|
|
|
- foreach($match_uuids as $kk=> $match_identity){
|
|
|
- if($v['match_identity'] == $match_identity){
|
|
|
+ if (!empty($match_uuids)) {
|
|
|
+ foreach ($matchData as $k => $v) {
|
|
|
+ foreach ($match_uuids as $kk => $match_identity) {
|
|
|
+ if ($v['match_identity'] == $match_identity) {
|
|
|
$data = $v;
|
|
|
$half_match_id = $v['half_match_id'];
|
|
|
//获取 本地 联赛 ID
|
|
|
//验证本赛事是否有数据源lg_id
|
|
|
- if(empty($data['lg_id'])) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::S_LG_ID_NULL));
|
|
|
- $lg_id = commonFunction::searcharray($data['uuid'],'identity',$l_lg_data,'lg_id');
|
|
|
+ if (empty($data['lg_id'])) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $data['match_id'] . ';', Response::S_LG_ID_NULL));
|
|
|
+ $lg_id = commonFunction::searcharray($data['uuid'], 'identity', $l_lg_data, 'lg_id');
|
|
|
//验证 本赛事是否获取到本地lg_id
|
|
|
- if(empty($lg_id)) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::L_LG_ID_NULL));
|
|
|
+ if (empty($lg_id)) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $data['match_id'] . ';', Response::L_LG_ID_NULL));
|
|
|
//如果赛事没有开始日期,则为冠军盘口赛事
|
|
|
- if(empty($data['match_date'])){
|
|
|
+ if (empty($data['match_date'])) {
|
|
|
//冠军盘口赛事获取所属联赛结束时间
|
|
|
- $last_time = $models['model_league']::where(['id'=>$lg_id])
|
|
|
+ $last_time = $models['model_league']::where(['id' => $lg_id])
|
|
|
->value('last_time');
|
|
|
|
|
|
- if(empty($last_time)) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LG_LASTTIME_ERROR));//Render([], '10023', lang('Tips','Sports')->get('lg_lastTime_error'));
|
|
|
+ if (empty($last_time)) throw new \Exception(Response::generate($gameName . '联赛-lg_id:' . $data['lg_id'] . ';', Response::LG_LASTTIME_ERROR));//Render([], '10023', lang('Tips','Sports')->get('lg_lastTime_error'));
|
|
|
//给冠军盘口赛事 赋值时间
|
|
|
$time = strtotime($last_time);
|
|
|
- $data['match_date'] = date('Y-m-d',$time);
|
|
|
- $data['match_time'] = date('H:i:s',$time);
|
|
|
+ $data['match_date'] = date('Y-m-d', $time);
|
|
|
+ $data['match_time'] = date('H:i:s', $time);
|
|
|
}
|
|
|
$set_match = [
|
|
|
- 'ctime'=>date('Y-m-d H:i:s'),
|
|
|
- 'utime'=>date('Y-m-d H:i:s'),
|
|
|
- 'expire_time'=>date('Y-m-d H:i:s',time()+60),
|
|
|
- 'home_team'=>$data['home_team']?:'',
|
|
|
- 'guest_team'=>$data['guest_team']?:'no_team',
|
|
|
- 'lg_id'=>$lg_id,
|
|
|
- 'status'=>$data['status'],
|
|
|
- 'match_date'=>$data['match_date']?:date('Y-m-d'),
|
|
|
- 'match_time'=>$data['match_time']?:date('H:i:s'),
|
|
|
- 'is_rollball'=>$data['is_rollball']?:0,
|
|
|
- 'is_today'=>$data['is_today']?:0,
|
|
|
- 'is_morningplate'=>$data['is_morningplate']?:0,
|
|
|
- 'is_stringscene'=>$data['is_stringscene']?:0,
|
|
|
- 'us_time'=>$data['us_time']?:commonFunction::qgmdate('Y-m-d H:i:s', '', -4),
|
|
|
- 'half_match_id'=>$half_match_id?:0,
|
|
|
+ 'ctime' => date('Y-m-d H:i:s'),
|
|
|
+ 'utime' => date('Y-m-d H:i:s'),
|
|
|
+ 'expire_time' => date('Y-m-d H:i:s', time() + 60),
|
|
|
+ 'home_team' => $data['home_team'] ?: '',
|
|
|
+ 'guest_team' => $data['guest_team'] ?: 'no_team',
|
|
|
+ 'lg_id' => $lg_id,
|
|
|
+ 'status' => $data['status'],
|
|
|
+ 'match_date' => $data['match_date'] ?: date('Y-m-d'),
|
|
|
+ 'match_time' => $data['match_time'] ?: date('H:i:s'),
|
|
|
+ 'is_rollball' => $data['is_rollball'] ?: 0,
|
|
|
+ 'is_today' => $data['is_today'] ?: 0,
|
|
|
+ 'is_morningplate' => $data['is_morningplate'] ?: 0,
|
|
|
+ 'is_stringscene' => $data['is_stringscene'] ?: 0,
|
|
|
+ 'us_time' => $data['us_time'] ?: commonFunction::qgmdate('Y-m-d H:i:s', '', -4),
|
|
|
+ 'half_match_id' => $half_match_id ?: 0,
|
|
|
'identity' => $data['uuid'],
|
|
|
'match_identity' => $data['match_identity'],
|
|
|
];
|
|
|
|
|
|
//如果是网球 追加rule 字段
|
|
|
- if($game_code == 'wq'){
|
|
|
+ if ($game_code == 'wq') {
|
|
|
$set_match['rule'] = $data['rule'];
|
|
|
}
|
|
|
//写入赛事 返回id
|
|
|
$id = $models['model_match']::insertGetId($set_match);
|
|
|
- if($id < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::INSERT_ERROR)) ;
|
|
|
+ if ($id < 1) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $data['match_id'] . ';', Response::INSERT_ERROR));
|
|
|
|
|
|
//写关联记录
|
|
|
$set_local = [
|
|
|
- 'match_id'=>$id,
|
|
|
- 'others_match_id'=>$data['match_id'],
|
|
|
- 'source'=>$source,
|
|
|
+ 'match_id' => $id,
|
|
|
+ 'others_match_id' => $data['match_id'],
|
|
|
+ 'source' => $source,
|
|
|
'identity' => $data['match_identity'],
|
|
|
- 'ctime'=>date('Y-m-d H:i:s')
|
|
|
+ 'ctime' => date('Y-m-d H:i:s')
|
|
|
];
|
|
|
$ret = $models['model_local_match']::insertGetId($set_local);
|
|
|
- if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::LOCAL_MATCH_ERROR)) ;
|
|
|
+ if ($ret < 1) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $data['match_id'] . ';', Response::LOCAL_MATCH_ERROR));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -368,7 +368,7 @@ class DataLogic
|
|
|
} catch (\Exception $e) {
|
|
|
//回滚事务
|
|
|
DB::rollBack();
|
|
|
- $this->writeLog($data, ['file'=>$e->getFile(),'line'=>$e->getLine(),'msg'=>$e->getMessage()]);
|
|
|
+ $this->writeLog($data, ['file' => $e->getFile(), 'line' => $e->getLine(), 'msg' => $e->getMessage()]);
|
|
|
return $e->getMessage();
|
|
|
}
|
|
|
|
|
|
@@ -385,11 +385,11 @@ class DataLogic
|
|
|
DB::beginTransaction();
|
|
|
$obt = $data['data'];
|
|
|
|
|
|
- if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
|
|
|
+ if (empty($obt)) throw new \Exception(Response::generate('请求数据为空,', Response::ABNORMAL));
|
|
|
$getData = $this->getAddData($obt);
|
|
|
|
|
|
//不是 赛事 结果 记录 数据
|
|
|
- if($getData['title'] != 'match_result_r') throw new \Exception(Response::generate('不是赛事结果记录数据,',Response::ABNORMAL));
|
|
|
+ if ($getData['title'] != 'match_result_r') throw new \Exception(Response::generate('不是赛事结果记录数据,', Response::ABNORMAL));
|
|
|
|
|
|
/*
|
|
|
//写请求数据 日志记录
|
|
|
@@ -414,7 +414,7 @@ class DataLogic
|
|
|
$identity = [];
|
|
|
$s_match_ids = [];
|
|
|
$match_uuids = [];
|
|
|
- foreach($match_r_data as $k=>$v){
|
|
|
+ foreach ($match_r_data as $k => $v) {
|
|
|
$identity[] = $v['uuid'];
|
|
|
$s_match_ids[] = $v['match_id'];
|
|
|
//追加获取赛事uuid
|
|
|
@@ -426,20 +426,20 @@ class DataLogic
|
|
|
sort($identity);
|
|
|
|
|
|
//获取 本地 已存在 联赛
|
|
|
- $l_lg_data = $models['model_local_league']::whereIn('identity',$identity)->select('identity','lg_id')->get()->toArray();
|
|
|
+ $l_lg_data = $models['model_local_league']::whereIn('identity', $identity)->select('identity', 'lg_id')->get()->toArray();
|
|
|
//二维数组去重
|
|
|
- $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
|
|
|
+ $l_lg_data = commonFunction::uniquArrV2($l_lg_data, 'identity');
|
|
|
//循环对比 请求uuid->本地identity
|
|
|
- foreach($l_lg_data as $k=>$v){
|
|
|
- foreach($identity as $kk=> $uuid){
|
|
|
- if($v['identity'] == $uuid){
|
|
|
+ foreach ($l_lg_data as $k => $v) {
|
|
|
+ foreach ($identity as $kk => $uuid) {
|
|
|
+ if ($v['identity'] == $uuid) {
|
|
|
unset($identity[$kk]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
sort($identity);
|
|
|
//去除本地和请求里都存在的联赛,如果还有剩余联赛id,则返回异常
|
|
|
- if(!empty($identity)) throw new \Exception(Response::generate($gameName.'联赛:uuid-'.$identity[0].';',Response::LEAGUE_ERROR));
|
|
|
+ if (!empty($identity)) throw new \Exception(Response::generate($gameName . '联赛:uuid-' . $identity[0] . ';', Response::LEAGUE_ERROR));
|
|
|
//====end====
|
|
|
|
|
|
//====验证 赛事结果记录 所属赛事 是否存在====
|
|
|
@@ -447,38 +447,38 @@ class DataLogic
|
|
|
sort($match_uuids);
|
|
|
|
|
|
//获取 本地 已存在 赛事
|
|
|
- $l_match_data = $models['model_local_match']::whereIn('identity',$match_uuids)->where('source',$source)->select('identity','match_id')->get()->toArray();
|
|
|
+ $l_match_data = $models['model_local_match']::whereIn('identity', $match_uuids)->where('source', $source)->select('identity', 'match_id')->get()->toArray();
|
|
|
//二维数组去重
|
|
|
- $l_match_data = commonFunction::uniquArrV2($l_match_data,'identity');
|
|
|
+ $l_match_data = commonFunction::uniquArrV2($l_match_data, 'identity');
|
|
|
|
|
|
//循环对比 请求identity->本地identity
|
|
|
- foreach($l_match_data as $k=>$v){
|
|
|
- foreach($match_uuids as $kk=> $match_identity){
|
|
|
- if($v['identity'] == $match_identity){
|
|
|
+ foreach ($l_match_data as $k => $v) {
|
|
|
+ foreach ($match_uuids as $kk => $match_identity) {
|
|
|
+ if ($v['identity'] == $match_identity) {
|
|
|
unset($match_uuids[$kk]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
sort($s_match_ids);
|
|
|
//去除本地和请求里都存在的赛事,如果还有剩余赛事id,则返回异常
|
|
|
- if(!empty($s_match_ids)) throw new \Exception(Response::generate($gameName.'赛事-match_id'.$s_match_ids[0].';',Response::MATCH_ERROR));
|
|
|
+ if (!empty($s_match_ids)) throw new \Exception(Response::generate($gameName . '赛事-match_id' . $s_match_ids[0] . ';', Response::MATCH_ERROR));
|
|
|
//====end====
|
|
|
|
|
|
//处理 赛事 结果记录 数据
|
|
|
- foreach($match_r_data as $k=>$v){
|
|
|
+ foreach ($match_r_data as $k => $v) {
|
|
|
$data = $v;
|
|
|
//获取 本地 联赛 ID
|
|
|
- $lg_id = commonFunction::searcharray($data['uuid'],'identity',$l_lg_data,'lg_id');
|
|
|
+ $lg_id = commonFunction::searcharray($data['uuid'], 'identity', $l_lg_data, 'lg_id');
|
|
|
//获取 本地 赛事 ID
|
|
|
- $match_id = commonFunction::searcharray($data['match_id'],'identity',$l_match_data,'match_id');
|
|
|
+ $match_id = commonFunction::searcharray($data['match_id'], 'identity', $l_match_data, 'match_id');
|
|
|
|
|
|
//根据球类 获取 赛事结果记录字段
|
|
|
- $set_match_r = $this->get_match_r($game_code,$lg_id,$match_id,$data);
|
|
|
+ $set_match_r = $this->get_match_r($game_code, $lg_id, $match_id, $data);
|
|
|
|
|
|
//写 赛事 结果 记录
|
|
|
$ret = $models['model_result_record']::insert($set_match_r);
|
|
|
|
|
|
- if($ret != true) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_R_ERROR));
|
|
|
+ if ($ret != true) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $data['match_id'] . ';', Response::ADD_MATCH_R_R_ERROR));
|
|
|
}
|
|
|
|
|
|
$this->writeLog($data, Response::success());
|
|
|
@@ -488,7 +488,7 @@ class DataLogic
|
|
|
} catch (\Exception $e) {
|
|
|
//回滚事务
|
|
|
DB::rollBack();
|
|
|
- $this->writeLog($data, ['file'=>$e->getFile(),'line'=>$e->getLine(),'msg'=>$e->getMessage()]);
|
|
|
+ $this->writeLog($data, ['file' => $e->getFile(), 'line' => $e->getLine(), 'msg' => $e->getMessage()]);
|
|
|
return $e->getMessage();
|
|
|
}
|
|
|
|
|
|
@@ -506,16 +506,16 @@ class DataLogic
|
|
|
$obt = $data['data'];
|
|
|
|
|
|
//请求 数据 为空
|
|
|
- if(empty($obt)) throw new \Exception(Response::generate('请求数据为空,',Response::ABNORMAL));
|
|
|
+ if (empty($obt)) throw new \Exception(Response::generate('请求数据为空,', Response::ABNORMAL));
|
|
|
$getData = $this->getAddData($obt);
|
|
|
|
|
|
//不是 赔率 数据
|
|
|
- if($getData['title'] != 'odds') throw new \Exception(Response::generate('不是赔率数据,',Response::ABNORMAL));
|
|
|
+ if ($getData['title'] != 'odds') throw new \Exception(Response::generate('不是赔率数据,', Response::ABNORMAL));
|
|
|
|
|
|
//写请求数据 日志记录
|
|
|
- if($this->isRecord){
|
|
|
- $setSportsRecord = St_set_sports_recordModel::setSportsRecord($getData['title'],$obt,$getData);
|
|
|
- if($setSportsRecord < 1) throw new \Exception(Response::generate('',Response::SPORTS_RECORD_ERR));
|
|
|
+ if ($this->isRecord) {
|
|
|
+ $setSportsRecord = St_set_sports_recordModel::setSportsRecord($getData['title'], $obt, $getData);
|
|
|
+ if ($setSportsRecord < 1) throw new \Exception(Response::generate('', Response::SPORTS_RECORD_ERR));
|
|
|
}
|
|
|
|
|
|
//获取球类代码
|
|
|
@@ -527,7 +527,7 @@ class DataLogic
|
|
|
//获取源数据赛事ID
|
|
|
$s_match_id = $getData['match_id'];
|
|
|
//获取赔率所属赛事 tag 值 玩法数量
|
|
|
- $tag = $getData['tag']?:99;
|
|
|
+ $tag = $getData['tag'] ?: 99;
|
|
|
//获取赔率是否是串场
|
|
|
$is_stringscene = $getData['is_stringscene'];
|
|
|
|
|
|
@@ -535,36 +535,36 @@ class DataLogic
|
|
|
$gameName = gameModel::getGameName($game_code);
|
|
|
//验证本次请求所属联赛/赛事是否存在 返回本地联赛/赛事ID
|
|
|
$models = commonFunction::getModels($game_code, 1);
|
|
|
- $lg_id = $this->leagueVerify($models,$uuid,$source,$gameName);
|
|
|
- $match_id = $this->matchVerify($models,$s_match_id,$source,$gameName);
|
|
|
+ $lg_id = $this->leagueVerify($models, $uuid, $source, $gameName);
|
|
|
+ $match_id = $this->matchVerify($models, $s_match_id, $source, $gameName);
|
|
|
|
|
|
//更新赛事 tag 值
|
|
|
//如果未获取到本地赛事id,则返回异常
|
|
|
- if(empty($match_id)) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::L_MATCH_ID_ERR)) ;
|
|
|
+ if (empty($match_id)) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $s_match_id . ';', Response::L_MATCH_ID_ERR));
|
|
|
|
|
|
- $upMatch = $models['model_match']::where(['id'=>$match_id])
|
|
|
- ->update(['tag'=>$tag,'utime'=>date('Y-m-d H:i:s')]);
|
|
|
- if($upMatch < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$s_match_id.';',Response::UPMATCHTAG_ERROR)) ;
|
|
|
+ $upMatch = $models['model_match']::where(['id' => $match_id])
|
|
|
+ ->update(['tag' => $tag, 'utime' => date('Y-m-d H:i:s')]);
|
|
|
+ if ($upMatch < 1) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $s_match_id . ';', Response::UPMATCHTAG_ERROR));
|
|
|
|
|
|
//获取 赔率数据
|
|
|
$oddsData = $getData['data'];
|
|
|
//获取 当前 所有 可用 赔率 sole
|
|
|
$odds_only = $getData['odds_only'];
|
|
|
//更新赛事下所有 不在本次请求的赔率 状态
|
|
|
- $ret= OddsModel::upOddsStatus($models,$s_match_id,'',$source,$odds_only,$is_stringscene);
|
|
|
- if($ret != true) throw new \Exception(Response::generate($gameName,Response::ODDS_SOLE_ERR));
|
|
|
+ $ret = OddsModel::upOddsStatus($models, $s_match_id, '', $source, $odds_only, $is_stringscene);
|
|
|
+ if ($ret != true) throw new \Exception(Response::generate($gameName, Response::ODDS_SOLE_ERR));
|
|
|
|
|
|
//获取当前赛事 在本地的所有赔率
|
|
|
- $l_odds_data = $models['model_odds']::select('odds_only')->where(['match_id'=>$match_id])->get()->toArray();
|
|
|
+ $l_odds_data = $models['model_odds']::select('odds_only')->where(['match_id' => $match_id])->get()->toArray();
|
|
|
|
|
|
$set_odds_r = [];
|
|
|
$set_odds = [];
|
|
|
- if(!empty($oddsData)){
|
|
|
+ if (!empty($oddsData)) {
|
|
|
//去除本地已有的赔率
|
|
|
- if(!empty($l_odds_data)){
|
|
|
- foreach($oddsData as $k=>$v){
|
|
|
- foreach($l_odds_data as $kk=>$vv){
|
|
|
- if($v['odds_only'] == $vv['odds_only']){
|
|
|
+ if (!empty($l_odds_data)) {
|
|
|
+ foreach ($oddsData as $k => $v) {
|
|
|
+ foreach ($l_odds_data as $kk => $vv) {
|
|
|
+ if ($v['odds_only'] == $vv['odds_only']) {
|
|
|
unset($oddsData[$k]);
|
|
|
}
|
|
|
}
|
|
|
@@ -572,61 +572,61 @@ class DataLogic
|
|
|
sort($oddsData);
|
|
|
}
|
|
|
//处理待写入 赔率记录数据
|
|
|
- foreach($oddsData as $k=>$v){
|
|
|
+ foreach ($oddsData as $k => $v) {
|
|
|
//组装数据
|
|
|
$set_odds_r[] = [
|
|
|
- 'match_id'=> $match_id?:0,
|
|
|
- 'others_match_id'=> $v['match_id']?:0,
|
|
|
- 'odds_code'=> $v['odds_code']?:'',
|
|
|
- 'status'=> $v['status']?:0,
|
|
|
- 'sort'=> $v['sort']?:0,
|
|
|
- 'p_code'=> $v['p_code']?:'',
|
|
|
- 'odds'=> $v['odds']?:0,
|
|
|
- 'condition'=> $v['condition'],
|
|
|
- 'odds_only'=> $v['odds_only']?:'',
|
|
|
- 'source'=> $v['source']?:'',
|
|
|
- 'type'=> $v['type']?:0,
|
|
|
- 'team'=> $v['team']?:'',
|
|
|
- 'lg_id'=> $lg_id,
|
|
|
- 'is_stringscene'=>$is_stringscene,
|
|
|
- 'others_lg_id'=> $v['lg_id'],
|
|
|
- 'ctime'=> date('Y-m-d H:i:s'),
|
|
|
- 'utime'=> date('Y-m-d H:i:s'),
|
|
|
+ 'match_id' => $match_id ?: 0,
|
|
|
+ 'others_match_id' => $v['match_id'] ?: 0,
|
|
|
+ 'odds_code' => $v['odds_code'] ?: '',
|
|
|
+ 'status' => $v['status'] ?: 0,
|
|
|
+ 'sort' => $v['sort'] ?: 0,
|
|
|
+ 'p_code' => $v['p_code'] ?: '',
|
|
|
+ 'odds' => $v['odds'] ?: 0,
|
|
|
+ 'condition' => $v['condition'],
|
|
|
+ 'odds_only' => $v['odds_only'] ?: '',
|
|
|
+ 'source' => $v['source'] ?: '',
|
|
|
+ 'type' => $v['type'] ?: 0,
|
|
|
+ 'team' => $v['team'] ?: '',
|
|
|
+ 'lg_id' => $lg_id,
|
|
|
+ 'is_stringscene' => $is_stringscene,
|
|
|
+ 'others_lg_id' => $v['lg_id'],
|
|
|
+ 'ctime' => date('Y-m-d H:i:s'),
|
|
|
+ 'utime' => date('Y-m-d H:i:s'),
|
|
|
];
|
|
|
}
|
|
|
|
|
|
//处理待写入 赔率数据
|
|
|
- foreach($oddsData as $k=>$v){
|
|
|
+ foreach ($oddsData as $k => $v) {
|
|
|
//组装数据
|
|
|
$set_odds[] = [
|
|
|
- 'match_id'=> $match_id?:0,
|
|
|
- 'others_match_id'=> $v['match_id']?:0,
|
|
|
- 'odds_code'=> $v['odds_code']?:'',
|
|
|
- 'status'=> $v['status']?:0,
|
|
|
- 'sort'=> $v['sort']?:0,
|
|
|
- 'p_code'=> $v['p_code']?:'',
|
|
|
- 'odds'=> $v['odds']?:0,
|
|
|
- 'condition'=> $v['condition'],
|
|
|
- 'odds_only'=> $v['odds_only']?:'',
|
|
|
- 'source'=> $v['source']?:'',
|
|
|
- 'type'=> $v['type']?:0,
|
|
|
- 'team'=> $v['team']?:'',
|
|
|
- 'lg_id'=> $lg_id,
|
|
|
- 'is_stringscene'=>$is_stringscene,
|
|
|
- 'others_lg_id'=> $v['lg_id'],
|
|
|
- 'ctime'=> date('Y-m-d H:i:s'),
|
|
|
- 'utime'=> date('Y-m-d H:i:s'),
|
|
|
+ 'match_id' => $match_id ?: 0,
|
|
|
+ 'others_match_id' => $v['match_id'] ?: 0,
|
|
|
+ 'odds_code' => $v['odds_code'] ?: '',
|
|
|
+ 'status' => $v['status'] ?: 0,
|
|
|
+ 'sort' => $v['sort'] ?: 0,
|
|
|
+ 'p_code' => $v['p_code'] ?: '',
|
|
|
+ 'odds' => $v['odds'] ?: 0,
|
|
|
+ 'condition' => $v['condition'],
|
|
|
+ 'odds_only' => $v['odds_only'] ?: '',
|
|
|
+ 'source' => $v['source'] ?: '',
|
|
|
+ 'type' => $v['type'] ?: 0,
|
|
|
+ 'team' => $v['team'] ?: '',
|
|
|
+ 'lg_id' => $lg_id,
|
|
|
+ 'is_stringscene' => $is_stringscene,
|
|
|
+ 'others_lg_id' => $v['lg_id'],
|
|
|
+ 'ctime' => date('Y-m-d H:i:s'),
|
|
|
+ 'utime' => date('Y-m-d H:i:s'),
|
|
|
'sole' => $v['sole'],
|
|
|
- 'expire_time' => date('Y-m-d H:i:s',time()+60)
|
|
|
+ 'expire_time' => date('Y-m-d H:i:s', time() + 60)
|
|
|
];
|
|
|
}
|
|
|
|
|
|
//写赔率记录数据
|
|
|
$ret = $models['model_odds_record']::insert($set_odds_r);
|
|
|
- if($ret != true) throw new \Exception(Response::generate($gameName.'赔率记录;',Response::ADD_ODDS_R_ERROR));
|
|
|
+ if ($ret != true) throw new \Exception(Response::generate($gameName . '赔率记录;', Response::ADD_ODDS_R_ERROR));
|
|
|
//写赔率 数据
|
|
|
$ret = $models['model_odds']::insert($set_odds);
|
|
|
- if($ret != true) throw new \Exception(Response::generate($gameName.'赔率;',Response::ADD_ODDS_ERROR));
|
|
|
+ if ($ret != true) throw new \Exception(Response::generate($gameName . '赔率;', Response::ADD_ODDS_ERROR));
|
|
|
}
|
|
|
|
|
|
$this->writeLog($data, Response::success());
|
|
|
@@ -636,7 +636,7 @@ class DataLogic
|
|
|
} catch (\Exception $e) {
|
|
|
//回滚事务
|
|
|
DB::rollBack();
|
|
|
- $this->writeLog($data, ['file'=>$e->getFile(),'line'=>$e->getLine(),'msg'=>$e->getMessage()]);
|
|
|
+ $this->writeLog($data, ['file' => $e->getFile(), 'line' => $e->getLine(), 'msg' => $e->getMessage()]);
|
|
|
return $e->getMessage();
|
|
|
}
|
|
|
}
|
|
|
@@ -708,7 +708,7 @@ class DataLogic
|
|
|
} catch (\Exception $e) {
|
|
|
//回滚事务
|
|
|
DB::rollBack();
|
|
|
- $this->writeLog($data, ['file'=>$e->getFile(),'line'=>$e->getLine(),'msg'=>$e->getMessage()]);
|
|
|
+ $this->writeLog($data, ['file' => $e->getFile(), 'line' => $e->getLine(), 'msg' => $e->getMessage()]);
|
|
|
return $e->getMessage();
|
|
|
}
|
|
|
}
|
|
|
@@ -857,7 +857,7 @@ class DataLogic
|
|
|
} catch (\Exception $e) {
|
|
|
//回滚事务
|
|
|
DB::rollBack();
|
|
|
- $this->writeLog($data, ['file'=>$e->getFile(),'line'=>$e->getLine(),'msg'=>$e->getMessage()]);
|
|
|
+ $this->writeLog($data, ['file' => $e->getFile(), 'line' => $e->getLine(), 'msg' => $e->getMessage()]);
|
|
|
return $e->getMessage();
|
|
|
}
|
|
|
}
|
|
|
@@ -918,7 +918,7 @@ class DataLogic
|
|
|
} catch (\Exception $e) {
|
|
|
//回滚事务
|
|
|
DB::rollBack();
|
|
|
- $this->writeLog($data, ['file'=>$e->getFile(),'line'=>$e->getLine(),'msg'=>$e->getMessage()]);
|
|
|
+ $this->writeLog($data, ['file' => $e->getFile(), 'line' => $e->getLine(), 'msg' => $e->getMessage()]);
|
|
|
return $e->getMessage();
|
|
|
}
|
|
|
}
|
|
|
@@ -1379,7 +1379,7 @@ class DataLogic
|
|
|
//"tag" => $data['tag'] ?: 0,
|
|
|
"match_id" => $match_id,
|
|
|
"update_time" => date('Y-m-d H:i:s'),
|
|
|
- "result_mark" =>json_encode($data['result_mark'])?:'',
|
|
|
+ "result_mark" => json_encode($data['result_mark']) ?: '',
|
|
|
];
|
|
|
}
|
|
|
if ($game_code == 'wq') {
|
|
|
@@ -1478,6 +1478,9 @@ class DataLogic
|
|
|
if (!is_string($body)) {
|
|
|
$body = json_encode([$body], 256);
|
|
|
}
|
|
|
+ if (!is_string($ret)) {
|
|
|
+ $ret = json_encode([$ret], 256);
|
|
|
+ }
|
|
|
$data = ['ctime' => date("Y-m-d H:i:s"), 'body' => $body, 'ret' => $ret];
|
|
|
$return = DB::table('datainf_log')->insert($data);
|
|
|
return $return;
|