|
|
@@ -166,11 +166,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'] != 'match') throw new \Exception(Response::generate('不是赛事数据,', Response::ABNORMAL));
|
|
|
+ if($getData['title'] != 'match') 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));
|
|
|
+ }
|
|
|
//获取球类代码
|
|
|
$game_code = $getData['game_code'];
|
|
|
//获取数据源
|
|
|
@@ -181,10 +186,10 @@ class DataLogic
|
|
|
$models = commonFunction::getModels($game_code, 1);
|
|
|
//获取 赛事 数据
|
|
|
$matchData = $getData['data'];
|
|
|
- //获取 当前请求 所有 uuid /match_id
|
|
|
+ //获取 当前请求 所有 uuid
|
|
|
$identity = [];
|
|
|
$s_match_ids = [];
|
|
|
- foreach ($matchData as $k => $v) {
|
|
|
+ foreach($matchData as $k=>$v){
|
|
|
$identity[] = $v['uuid'];
|
|
|
$s_match_ids[] = $v['match_id'];
|
|
|
}
|
|
|
@@ -194,112 +199,163 @@ 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');
|
|
|
- //循环对比 请求uuid->本地identity
|
|
|
- foreach ($l_lg_data as $k => $v) {
|
|
|
- foreach ($identity as $kk => $uuid) {
|
|
|
- if ($v['identity'] == $uuid) {
|
|
|
- unset($identity[$kk]);
|
|
|
+ $l_lg_data = commonFunction::uniquArrV2($l_lg_data,'identity');
|
|
|
+ //如果获取不到本地联赛数据,则返回联赛不存在
|
|
|
+ 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']){
|
|
|
+ $matchData[] = $vv;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- sort($identity);
|
|
|
- //去除本地和请求里都存在的联赛,如果还有剩余联赛id,则返回异常
|
|
|
- if (!empty($identity)) throw new \Exception(Response::generate($gameName . '联赛:uuid-' . $identity[0] . ';', Response::LEAGUE_ERROR));
|
|
|
- //====end====
|
|
|
+ //获取当前请求有关联联赛的赛事 match_id
|
|
|
+ $s_match_ids = [];
|
|
|
+ foreach($matchData as $k=>$v){
|
|
|
+ $s_match_ids[] = $v['match_id'];
|
|
|
+ }
|
|
|
|
|
|
//====获取 本地 已存在 赛事====
|
|
|
$s_match_ids = array_unique($s_match_ids);
|
|
|
sort($s_match_ids);
|
|
|
|
|
|
- $l_match_data = $models['model_local_match']::whereIn('others_match_id', $s_match_ids)->where('source', $source)->select('others_match_id', 'match_id')->get()->toArray();
|
|
|
+ $l_match_data = $models['model_local_match']::whereIn('others_match_id',$s_match_ids)->where('source',$source)->select('others_match_id','match_id')->get()->toArray();
|
|
|
//二维数组去重
|
|
|
- $l_match_data = commonFunction::uniquArrV2($l_match_data, 'others_match_id');
|
|
|
+ $l_match_data = commonFunction::uniquArrV2($l_match_data,'others_match_id');
|
|
|
|
|
|
//循环对比 请求match_id->本地others_match_id
|
|
|
- //如果本地有 赛事,则取出本地不存在赛事
|
|
|
- if (!empty($l_match_data)) {
|
|
|
- foreach ($l_match_data as $k => $v) {
|
|
|
- foreach ($s_match_ids as $kk => $s_match_id) {
|
|
|
- if ($v['others_match_id'] == $s_match_id) {
|
|
|
+ //如果本地有 赛事,则分别获取本地已存在/不存在赛事
|
|
|
+ if(!empty($l_match_data)){
|
|
|
+ //本地已存在赛事,用于更新
|
|
|
+ $matchData_y = [];
|
|
|
+ foreach($l_match_data as $k=>$v){
|
|
|
+ foreach($s_match_ids as $kk=> $s_match_id){
|
|
|
+ if($v['others_match_id'] == $s_match_id){
|
|
|
+ $matchData_y[$k]['others_match_id'] = $s_match_id;
|
|
|
+ $matchData_y[$k]['match_id'] = $v['match_id'];
|
|
|
unset($s_match_ids[$kk]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
sort($s_match_ids);
|
|
|
}
|
|
|
+ //如果 请求中 有本地赛事,则执行更新
|
|
|
+ if(!empty($matchData_y)){
|
|
|
+ foreach($matchData as $k=>$v){
|
|
|
+ foreach($matchData_y as $kk=> $vv){
|
|
|
+ if($v['match_id'] == $vv['others_match_id']){
|
|
|
+ $data = $v;
|
|
|
+ $up_match=[];
|
|
|
+ $up_match['utime'] = date('Y-m-d H:i:s');
|
|
|
+ $up_match['status'] = $data['status'];
|
|
|
+ //获取需更新字段
|
|
|
+ if($data['is_rollball'] == 1){
|
|
|
+ $up_match['is_rollball'] = $data['is_rollball'];
|
|
|
+ }
|
|
|
+ if($data['is_today'] == 1){
|
|
|
+ $up_match['is_today'] = $data['is_today'];
|
|
|
+ }
|
|
|
+ if($data['is_morningplate'] == 1){
|
|
|
+ $up_match['is_morningplate'] = $data['is_morningplate'];
|
|
|
+ }
|
|
|
+ if($data['is_stringscene'] == 1){
|
|
|
+ $up_match['is_stringscene'] = $data['is_stringscene'];
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果是网球,追加更新开赛日期/时间
|
|
|
+ if($game_code == 'wq'){
|
|
|
+ $up_match['match_date'] = $data['match_date'];
|
|
|
+ $up_match['match_time'] = $data['match_time'];
|
|
|
+ $up_match['us_time'] = $data['us_time'];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果是网球 追加rule 字段
|
|
|
+ if($game_code == 'wq' and !empty($data['rule'])){
|
|
|
+ $up_match['rule'] = $data['rule'];
|
|
|
+ }
|
|
|
+ //更新赛事 返回成功数量
|
|
|
+ $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 (!empty($s_match_ids)) {
|
|
|
- foreach ($matchData as $k => $v) {
|
|
|
- foreach ($s_match_ids as $kk => $s_match_id) {
|
|
|
- if ($v['match_id'] == $s_match_id) {
|
|
|
+ if(!empty($s_match_ids)){
|
|
|
+ foreach($matchData as $k=>$v){
|
|
|
+ foreach($s_match_ids as $kk=> $s_match_id){
|
|
|
+ if($v['match_id'] == $s_match_id){
|
|
|
$data = $v;
|
|
|
- $half_match_id = 0;
|
|
|
+ $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['lg_id'], 'others_lg_id', $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));
|
|
|
- //如果有上半场赛事id 获取上半场赛事是否存在
|
|
|
- if (!empty($l_match_data) and $data['half_match_id'] > 0) {
|
|
|
- $half_match_id = -1;
|
|
|
- // $half_match_id = $models['model_local_match']::where(['others_match_id'=>$data['half_match_id'],'source'=>$source])
|
|
|
- // ->value('match_id');
|
|
|
- // if(empty($half_match_id)) throw new \Exception(Response::generate($gameName.'上半场赛事-match_id:'.$data['match_id'].';',Response::HALF_MATCH_ERROR)) ;//Render([], '10024', lang('Tips','Sports')->get('half_match_error'));
|
|
|
- }
|
|
|
+ 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'),
|
|
|
- // 'tag'=>$data['tag']?:0,
|
|
|
- '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'],
|
|
|
];
|
|
|
+
|
|
|
+ //如果是网球 追加rule 字段
|
|
|
+ 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,
|
|
|
- 'ctime' => date('Y-m-d H:i:s')
|
|
|
+ 'match_id'=>$id,
|
|
|
+ 'others_match_id'=>$data['match_id'],
|
|
|
+ 'source'=>$source,
|
|
|
+ '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));//Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
|
|
|
+ if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::LOCAL_MATCH_ERROR)) ;//Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
$this->writeLog($data, Response::success());
|
|
|
//提交事务
|
|
|
DB::commit();
|
|
|
@@ -325,16 +381,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'] != 'match_result_r') throw new \Exception(Response::generate('不是赛事结果记录数据,', Response::ABNORMAL));
|
|
|
+ if($getData['title'] != 'match_result_r') 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));
|
|
|
}
|
|
|
|
|
|
//获取球类代码
|
|
|
@@ -351,7 +407,7 @@ class DataLogic
|
|
|
//获取 当前请求 所有 uuid /match_id
|
|
|
$identity = [];
|
|
|
$s_match_ids = [];
|
|
|
- foreach ($match_r_data as $k => $v) {
|
|
|
+ foreach($match_r_data as $k=>$v){
|
|
|
$identity[] = $v['uuid'];
|
|
|
$s_match_ids[] = $v['match_id'];
|
|
|
}
|
|
|
@@ -361,20 +417,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====
|
|
|
|
|
|
//====验证 赛事结果记录 所属赛事 是否存在====
|
|
|
@@ -382,38 +438,38 @@ class DataLogic
|
|
|
sort($s_match_ids);
|
|
|
|
|
|
//获取 本地 已存在 赛事
|
|
|
- $l_match_data = $models['model_local_match']::whereIn('others_match_id', $s_match_ids)->where('source', $source)->select('others_match_id', 'match_id')->get()->toArray();
|
|
|
+ $l_match_data = $models['model_local_match']::whereIn('others_match_id',$s_match_ids)->where('source',$source)->select('others_match_id','match_id')->get()->toArray();
|
|
|
//二维数组去重
|
|
|
- $l_match_data = commonFunction::uniquArrV2($l_match_data, 'others_match_id');
|
|
|
+ $l_match_data = commonFunction::uniquArrV2($l_match_data,'others_match_id');
|
|
|
|
|
|
//循环对比 请求match_id->本地others_match_id
|
|
|
- foreach ($l_match_data as $k => $v) {
|
|
|
- foreach ($s_match_ids as $kk => $s_match_id) {
|
|
|
- if ($v['others_match_id'] == $s_match_id) {
|
|
|
+ foreach($l_match_data as $k=>$v){
|
|
|
+ foreach($s_match_ids as $kk=> $s_match_id){
|
|
|
+ if($v['others_match_id'] == $s_match_id){
|
|
|
unset($s_match_ids[$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'], 'others_match_id', $l_match_data, 'match_id');
|
|
|
+ $match_id = commonFunction::searcharray($data['match_id'],'others_match_id',$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());
|
|
|
@@ -440,16 +496,17 @@ 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'] != '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));
|
|
|
}
|
|
|
|
|
|
//获取球类代码
|
|
|
@@ -461,42 +518,44 @@ class DataLogic
|
|
|
//获取源数据赛事ID
|
|
|
$s_match_id = $getData['match_id'];
|
|
|
//获取赔率所属赛事 tag 值 玩法数量
|
|
|
- $tag = $getData['tag'] ?: 99;
|
|
|
+ $tag = $getData['tag']?:99;
|
|
|
+ //获取赔率是否是串场
|
|
|
+ $is_stringscene = $getData['is_stringscene'];
|
|
|
|
|
|
//获取球类名称
|
|
|
$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);
|
|
|
- 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]);
|
|
|
}
|
|
|
}
|
|
|
@@ -504,59 +563,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,
|
|
|
- '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,
|
|
|
- '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());
|