|
|
@@ -186,11 +186,11 @@ class WriteSportsController extends BaseController{
|
|
|
$this->odds($vv,$gameName,$l_lg_id,$l_match_id,$ret_odds,$ret_odds_record);
|
|
|
break;
|
|
|
case 'league_result'://联赛结果
|
|
|
- $this->league_result($vv);
|
|
|
+ $this->league_result($vv,$gameName);
|
|
|
break;
|
|
|
case 'match_result'://赛事结果
|
|
|
throw new \Exception(Response::generate('赛事结果数据-match_result:',Response::AUTH_ERROR));
|
|
|
- $this->match_result($vv);
|
|
|
+ $this->match_result($vv,$gameName);
|
|
|
break;
|
|
|
case 'match_result_record'://赛事结果记录
|
|
|
$s_lg_id = $vv['data']['lg_id'];
|
|
|
@@ -221,10 +221,6 @@ class WriteSportsController extends BaseController{
|
|
|
//处理 赛事结果 记录
|
|
|
$this->com_result_record($vv,$gameName,$l_lg_id,$l_match_id);
|
|
|
break;
|
|
|
- case 'odds_record'://赔率记录
|
|
|
- throw new \Exception(Response::generate('赔率记录数据-odds_record:',Response::AUTH_ERROR));
|
|
|
- $this->odds_record($vv);
|
|
|
- break;
|
|
|
case 'broadcast'://直播数据
|
|
|
$this->broadcast($vv,$game_code);
|
|
|
break;
|
|
|
@@ -291,7 +287,9 @@ class WriteSportsController extends BaseController{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //写入直播 数据
|
|
|
+ /*
|
|
|
+ * 写入直播 数据
|
|
|
+ */
|
|
|
public function broadcast($opt = [],$game_code=''){
|
|
|
$data = $opt['data'];
|
|
|
$set_broadcast = [
|
|
|
@@ -311,7 +309,9 @@ class WriteSportsController extends BaseController{
|
|
|
if($ret == false) throw new \Exception(Response::generate('',Response::BROADCAST_ERROR));
|
|
|
}
|
|
|
|
|
|
- //将进行中赛事写入 赛事结果
|
|
|
+ /*
|
|
|
+ * 写入 赛事 初始 结果
|
|
|
+ */
|
|
|
public function match_result($game_code = ''){
|
|
|
$model =commonFunction::getModels($game_code,1);
|
|
|
if($game_code == 'zq') ZqResultModel::ZQresult($model);
|
|
|
@@ -319,29 +319,17 @@ class WriteSportsController extends BaseController{
|
|
|
if($game_code == 'wq') WqResultModel::WQresult($model);
|
|
|
if($game_code == 'bq') BqResultModel::BQresult($model);
|
|
|
}
|
|
|
- //写入地区数据 弃用
|
|
|
- public function area($opt = []){
|
|
|
- $ret = lm('st_area','Sports')->insert($opt);
|
|
|
- return $ret;
|
|
|
- }
|
|
|
-
|
|
|
- //写入国家数据 弃用
|
|
|
- public function country($opt = []){
|
|
|
- $ret = lm('st_country','Sports')->insert($opt);
|
|
|
- return $ret;
|
|
|
- }
|
|
|
|
|
|
- //写入联赛数据
|
|
|
+ /*
|
|
|
+ * 写入联赛数据
|
|
|
+ */
|
|
|
public function league($opt = [],$gameName=''){
|
|
|
$game_code = $opt['game_code'];
|
|
|
//根据球类代码获取相关model
|
|
|
$model =commonFunction::getModels($game_code,1);
|
|
|
$data = $opt['data'];
|
|
|
-// if(empty($data['belong'])) throw new \Exception(Response::generate(Response::COUNTRY_ERROR)) ;//Render([], '10013', lang('Tips','Sports')->get('country_error'));
|
|
|
-// //获取联赛所属 国家/地区id
|
|
|
-// $belong = St_area_countryModel::getID($data['belong']);
|
|
|
- $set_lg['area_id'] = 0;//$belong['area_id'];
|
|
|
- $set_lg['country_id'] = 0;// $belong['country_id'];
|
|
|
+ $set_lg['area_id'] = 0;
|
|
|
+ $set_lg['country_id'] = 0;
|
|
|
|
|
|
//查询联赛是否已存在
|
|
|
$id = $model['model_league']::where('name_chinese','=',$data['name_chinese'])
|
|
|
@@ -385,7 +373,9 @@ class WriteSportsController extends BaseController{
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- //写入赛事数据
|
|
|
+ /*
|
|
|
+ * 写入赛事数据
|
|
|
+ */
|
|
|
public function competition($opt = [],$gameName='',$lg_id=''){
|
|
|
$game_code = $opt['game_code'];
|
|
|
//根据球类代码获取相关model
|
|
|
@@ -461,7 +451,9 @@ class WriteSportsController extends BaseController{
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- //写入赔率数据
|
|
|
+ /*
|
|
|
+ * 写入赔率/赔率记录数据
|
|
|
+ */
|
|
|
public function odds($opt=[],$gameName='',$lg_id=0,$match_id=0,$oddsID='',$oddsRecordID=''){
|
|
|
$game_code = $opt['game_code'];
|
|
|
//根据球类代码获取相关model
|
|
|
@@ -534,8 +526,10 @@ class WriteSportsController extends BaseController{
|
|
|
//===end===
|
|
|
}
|
|
|
|
|
|
- //写入联赛结果
|
|
|
- public function league_result($opt){
|
|
|
+ /*
|
|
|
+ * 写入联赛结果
|
|
|
+ */
|
|
|
+ public function league_result($opt,$gameName){
|
|
|
$game_code = $opt['game_code'];
|
|
|
//根据球类代码获取相关model
|
|
|
$model = commonFunction::getModels($game_code,1);
|
|
|
@@ -544,7 +538,7 @@ class WriteSportsController extends BaseController{
|
|
|
//验证结果所属联赛
|
|
|
$lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
->value('lg_id');
|
|
|
- if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR));//Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
+ if($lg_id < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR));//Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
|
$lg_result_id = $model['model_league_result']::where(['lg_id'=>$lg_id,'game_name'=>$data['game_name']])
|
|
|
->value('id');
|
|
|
@@ -560,28 +554,21 @@ class WriteSportsController extends BaseController{
|
|
|
if(!empty($lg_result_id)){
|
|
|
$ret = $model['model_league_result']::where(['id'=>$lg_result_id])
|
|
|
-> update($set_lg_result);
|
|
|
- if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR)) ;//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
|
|
|
+ if($ret < 1) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR)) ;//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
|
|
|
}else{
|
|
|
$ret = $model['model_league_result']::insert($set_lg_result);
|
|
|
- if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR));//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
|
|
|
+ if($ret != true) throw new \Exception(Response::generate($gameName.'联赛-lg_id:'.$data['lg_id'].';',Response::ADD_LG_R_ERROR));//Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
|
|
|
}
|
|
|
-// return Response::success();
|
|
|
}
|
|
|
|
|
|
- //写入赛事结果
|
|
|
+ /*
|
|
|
+ * 写入赛事结果
|
|
|
+ */
|
|
|
public function com_result($opt=[],$gameName='',$lg_id='',$match_id=''){
|
|
|
$game_code = $opt['game_code'];
|
|
|
//根据球类代码获取相关model
|
|
|
$model = commonFunction::getModels($game_code,1);
|
|
|
$data = $opt['data'];
|
|
|
-// //验证结果所属联赛
|
|
|
-// $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
-// ->value('lg_id');
|
|
|
-// if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
-// //验证结果所属赛事
|
|
|
-// $match_id = $model['model_local_match']::where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
|
|
|
-// ->value('match_id');
|
|
|
-// if($match_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR));//Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
//查询结果是否存在
|
|
|
$match_r_id = $model['model_result']::where(['match_id'=>$match_id])
|
|
|
->value('id');
|
|
|
@@ -613,10 +600,10 @@ class WriteSportsController extends BaseController{
|
|
|
if(!empty($match_r_id)){
|
|
|
$ret = $model['model_result']::where(['id'=>$match_r_id])
|
|
|
-> update($set_match_r);
|
|
|
- if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
|
|
|
+ if($ret < 1) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
|
|
|
}else{
|
|
|
$ret = $model['model_result']::insert($set_match_r);
|
|
|
- if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
|
|
|
+ if($ret != true) throw new \Exception(Response::generate($gameName.'赛事-match_id:'.$data['match_id'].';',Response::ADD_MATCH_R_ERROR)) ;//Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
|
|
|
}
|
|
|
// return Response::success();
|
|
|
}
|
|
|
@@ -628,15 +615,6 @@ class WriteSportsController extends BaseController{
|
|
|
$model = commonFunction::getModels($game_code,1);
|
|
|
$data = $opt['data'];
|
|
|
|
|
|
- //验证结果所属联赛
|
|
|
-// $lg_id = $model['model_local_league']::where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
-// ->value('lg_id');
|
|
|
-// if($lg_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
-// //验证结果所属赛事
|
|
|
-// $match_id = $model['model_local_match']::where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
|
|
|
-// ->value('match_id');
|
|
|
-// if($match_id < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR));//Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
-
|
|
|
$match_r_id = $model['model_result_record']::where(['match_id'=>$match_id,'match_time'=>$data['match_time']])
|
|
|
->value('id');
|
|
|
//根据球类 获取 赛事结果记录字段
|
|
|
@@ -653,64 +631,6 @@ class WriteSportsController extends BaseController{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //写入赔率记录
|
|
|
- public function odds_record($opt){
|
|
|
- $game_code = $opt['game_code'];
|
|
|
- //根据球类代码获取相关model
|
|
|
- $model = commonFunction::getModels($game_code,1);
|
|
|
- $data = $opt['data'];
|
|
|
-
|
|
|
- $match = $model['model_local_match']::select('match_id','others_match_id')
|
|
|
- ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
|
|
|
- ->first();
|
|
|
- if(count($match) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赛事-match_id:'.$data['match_id'].';',Response::MATCH_ERROR)) ;//Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
-
|
|
|
- //获取赛事 本地/源ID
|
|
|
- $others_match_id = $match->others_match_id;
|
|
|
- $match_id = $match->match_id;
|
|
|
-
|
|
|
- $lg = $model['model_local_league']::select('lg_id','others_lg_id')
|
|
|
- ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
- ->first();
|
|
|
- if(count($lg) < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'联赛-lg_id:'.$data['lg_id'].';',Response::LEAGUE_ERROR)) ;//Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
-
|
|
|
- //获取联赛 本地/源ID
|
|
|
- $others_lg_id = $lg->others_lg_id;
|
|
|
- $lg_id = $lg->lg_id;
|
|
|
- //查询 赔率数据是否存在
|
|
|
- $oddsID = $model['model_odds_record']::where(['odds_only'=>$data['odds_only']])
|
|
|
- ->value('id');
|
|
|
-
|
|
|
- $set_odds = [
|
|
|
- 'match_id'=> $match_id,
|
|
|
- 'others_match_id'=> $others_match_id,
|
|
|
- 'odds_code'=> $data['odds_code'],
|
|
|
- 'status'=> $data['status'],
|
|
|
- 'sort'=> $data['sort'],
|
|
|
- 'p_code'=> $data['p_code'],
|
|
|
- 'odds'=> $data['odds'],
|
|
|
- 'condition'=> $data['condition'],
|
|
|
- 'odds_only'=> $data['odds_only'],
|
|
|
- 'source'=> $data['source'],
|
|
|
- 'type'=> $data['type'],
|
|
|
- 'team'=> $data['team'],
|
|
|
- 'lg_id'=> $lg_id,
|
|
|
- 'others_lg_id'=> $others_lg_id,
|
|
|
- 'ctime'=> date('Y-m-d H:i:s'),
|
|
|
- 'utime'=> date('Y-m-d H:i:s'),
|
|
|
- ];
|
|
|
- //更新或写入赔率记录
|
|
|
- if(!empty($oddsID)){
|
|
|
- $ret = $model['model_odds_record']::where(['id'=>$oddsID])
|
|
|
- -> update($set_odds);
|
|
|
- if($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR)) ;//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
|
|
|
- }else{
|
|
|
- $ret = $model['model_odds_record']::insert($set_odds);
|
|
|
- if($ret != true) throw new \Exception(Response::generate(gameModel::getGameName($game_code).'赔率记录-odds_only:'.$data['odds_only'].';',Response::ADD_ODDS_R_ERROR));//Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
|
|
|
- }
|
|
|
-// return Response::success();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @param $data
|
|
|
* @return mixed
|
|
|
@@ -723,7 +643,9 @@ class WriteSportsController extends BaseController{
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- //根据球类获取 赛事结果记录字段
|
|
|
+ /*
|
|
|
+ * 根据球类获取 赛事结果记录字段
|
|
|
+ */
|
|
|
public function get_match_r($game_code,$lg_id,$match_id,$data){
|
|
|
$set_match_r = [];
|
|
|
if($game_code == 'zq'){
|