|
@@ -30,12 +30,12 @@ class WriteSports extends Controller{
|
|
|
// if(in_array('', $v)) Render([], '10001', lang('Tips','Sports')->get('PARAM_ERROR'));
|
|
// if(in_array('', $v)) Render([], '10001', lang('Tips','Sports')->get('PARAM_ERROR'));
|
|
|
// }
|
|
// }
|
|
|
switch ($data['title']){
|
|
switch ($data['title']){
|
|
|
- case 'area'://地区
|
|
|
|
|
- $ret = $this->area($data['data']);
|
|
|
|
|
- break;
|
|
|
|
|
- case 'country'://国家
|
|
|
|
|
- $ret = $this->country($data['data']);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+// case 'area'://地区
|
|
|
|
|
+// $ret = $this->area($data['data']);
|
|
|
|
|
+// break;
|
|
|
|
|
+// case 'country'://国家
|
|
|
|
|
+// $ret = $this->country($data['data']);
|
|
|
|
|
+// break;
|
|
|
case 'league'://联赛
|
|
case 'league'://联赛
|
|
|
$ret = $this->league($data);
|
|
$ret = $this->league($data);
|
|
|
break;
|
|
break;
|
|
@@ -48,10 +48,10 @@ class WriteSports extends Controller{
|
|
|
case 'league_result'://联赛结果
|
|
case 'league_result'://联赛结果
|
|
|
$ret = $this->league_result($data);
|
|
$ret = $this->league_result($data);
|
|
|
break;
|
|
break;
|
|
|
- case 'competition_result'://赛事结果
|
|
|
|
|
|
|
+ case 'match_result'://赛事结果
|
|
|
$ret = $this->com_result($data);
|
|
$ret = $this->com_result($data);
|
|
|
break;
|
|
break;
|
|
|
- case 'competition_result_record'://赛事结果记录
|
|
|
|
|
|
|
+ case 'match_result_record'://赛事结果记录
|
|
|
$ret = $this->com_result_record($data);
|
|
$ret = $this->com_result_record($data);
|
|
|
break;
|
|
break;
|
|
|
case 'odds_record'://赔率记录
|
|
case 'odds_record'://赔率记录
|
|
@@ -67,14 +67,14 @@ class WriteSports extends Controller{
|
|
|
Render([], '10010', lang('Tips','Sports')->get('HANDLE_ERRORS'));
|
|
Render([], '10010', lang('Tips','Sports')->get('HANDLE_ERRORS'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //写入地区数据
|
|
|
|
|
- public function area($opt = []){
|
|
|
|
|
|
|
+ //写入地区数据 弃用
|
|
|
|
|
+ public function __area($opt = []){
|
|
|
$ret = lm('st_area','Sports')->insert($opt);
|
|
$ret = lm('st_area','Sports')->insert($opt);
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //写入国家数据
|
|
|
|
|
- public function country($opt = []){
|
|
|
|
|
|
|
+ //写入国家数据 弃用
|
|
|
|
|
+ public function __country($opt = []){
|
|
|
$ret = lm('st_country','Sports')->insert($opt);
|
|
$ret = lm('st_country','Sports')->insert($opt);
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
@@ -92,13 +92,13 @@ class WriteSports extends Controller{
|
|
|
$set_lg['country_id'] = $belong['country_id'];
|
|
$set_lg['country_id'] = $belong['country_id'];
|
|
|
|
|
|
|
|
//查询中间表 是否已记录
|
|
//查询中间表 是否已记录
|
|
|
- $m_lg_id = lm($model['model_local_league'],'Sports')
|
|
|
|
|
- ->select('m_lg_id')
|
|
|
|
|
- ->where(['lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
|
|
- ->first()->m_lg_id;
|
|
|
|
|
|
|
+ $g_id = lm($model['model_local_league'],'Sports')
|
|
|
|
|
+ ->select('lg_id')
|
|
|
|
|
+ ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first()->lg_id;
|
|
|
|
|
|
|
|
//如果没有记录
|
|
//如果没有记录
|
|
|
- if(empty($m_lg_id)){
|
|
|
|
|
|
|
+ if(empty($lg_id)){
|
|
|
//查询联赛是否已存在
|
|
//查询联赛是否已存在
|
|
|
$id = lm($model['model_league'],'Sports')
|
|
$id = lm($model['model_league'],'Sports')
|
|
|
->select('id')
|
|
->select('id')
|
|
@@ -117,8 +117,8 @@ class WriteSports extends Controller{
|
|
|
if($m_lg_id < 1) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
if($m_lg_id < 1) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
|
}
|
|
}
|
|
|
$set_local = [
|
|
$set_local = [
|
|
|
- 'm_lg_id'=>$id,
|
|
|
|
|
- 'lg_id'=>$data['lg_id'],
|
|
|
|
|
|
|
+ 'lg_id'=>$id,
|
|
|
|
|
+ 'others_lg_id'=>$data['lg_id'],
|
|
|
'source'=>$data['source'],
|
|
'source'=>$data['source'],
|
|
|
];
|
|
];
|
|
|
$ret = lm($model['model_local_league'],'Sports')-> insertGetId($set_local);
|
|
$ret = lm($model['model_local_league'],'Sports')-> insertGetId($set_local);
|
|
@@ -175,20 +175,18 @@ class WriteSports extends Controller{
|
|
|
|
|
|
|
|
if(empty($data['lg_id'])) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
if(empty($data['lg_id'])) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
|
|
|
- //验证赛事所属联赛
|
|
|
|
|
- if(!empty($data['lg_id'])){
|
|
|
|
|
- $lg = lm($model['model_local_league'],'Sports')
|
|
|
|
|
- ->select('m_lg_id')
|
|
|
|
|
- ->where(['lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
|
|
- ->first()->m_lg_id;
|
|
|
|
|
- if(empty($lg)) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //根据源联赛ID 获取本地关联id
|
|
|
|
|
+ $lg_id = lm($model['model_local_league'],'Sports')
|
|
|
|
|
+ ->select('lg_id')
|
|
|
|
|
+ ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first()->lg_id;
|
|
|
|
|
+ if(empty($lg_id)) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
|
|
|
//查询关联记录是否存在
|
|
//查询关联记录是否存在
|
|
|
$match_id = lm($model['model_local_match'],'Sports')
|
|
$match_id = lm($model['model_local_match'],'Sports')
|
|
|
- ->select('m_match_id')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id'],'source'=>$data['source']])
|
|
|
|
|
- ->first()->m_match_id;
|
|
|
|
|
|
|
+ ->select('match_id')
|
|
|
|
|
+ ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first()->match_id;
|
|
|
if(empty($match_id)){
|
|
if(empty($match_id)){
|
|
|
//查询赛事是否存在
|
|
//查询赛事是否存在
|
|
|
$id = lm($model['model_match'],'Sports')
|
|
$id = lm($model['model_match'],'Sports')
|
|
@@ -198,16 +196,30 @@ class WriteSports extends Controller{
|
|
|
|
|
|
|
|
//写入赛事
|
|
//写入赛事
|
|
|
if(empty($id)){
|
|
if(empty($id)){
|
|
|
- $data['ctime'] = $this->newTime;
|
|
|
|
|
- $data['utime'] = $this->newTime;
|
|
|
|
|
- $data['expire_time'] = date('Y-m-d H:m:i',(time()+60));
|
|
|
|
|
|
|
+ $set_match = [
|
|
|
|
|
+ 'ctime'=>$this->newTime,
|
|
|
|
|
+ 'utime'=>$this->newTime,
|
|
|
|
|
+ 'expire_time'=>date('Y-m-d H:m:i',time()+60),
|
|
|
|
|
+ 'home_team'=>$data['home_team'],
|
|
|
|
|
+ 'guest_team'=>$data['guest_team'],
|
|
|
|
|
+ 'lg_id'=>$lg_id,
|
|
|
|
|
+ 'status'=>$data['status'],
|
|
|
|
|
+ 'match_date'=>$data['match_date'],
|
|
|
|
|
+ 'match_time'=>$data['match_time'],
|
|
|
|
|
+ 'tag'=>$data['tag'],
|
|
|
|
|
+ 'is_rollball'=>$data['is_rollball'],
|
|
|
|
|
+ 'is_today'=>$data['is_today'],
|
|
|
|
|
+ 'is_morningplate'=>$data['is_morningplate'],
|
|
|
|
|
+ 'is_stringscene'=>$data['is_stringscene'],
|
|
|
|
|
+ 'us_time'=>$data['us_time'],
|
|
|
|
|
+ ];
|
|
|
|
|
|
|
|
- $id = lm($model['model_match'],'Sports')->insertGetId($data);
|
|
|
|
|
|
|
+ $id = lm($model['model_match'],'Sports')->insertGetId($set_match);
|
|
|
if($id < 1) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
if($id < 1) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
|
}
|
|
}
|
|
|
$set_local = [
|
|
$set_local = [
|
|
|
- 'm_match_id'=>$id,
|
|
|
|
|
- 'match_id'=>$data['match_id'],
|
|
|
|
|
|
|
+ 'match_id'=>$id,
|
|
|
|
|
+ 'others_match_id'=>$data['match_id'],
|
|
|
'source'=>$data['source'],
|
|
'source'=>$data['source'],
|
|
|
];
|
|
];
|
|
|
$ret = lm($model['model_local_match'],'Sports')-> insertGetId($set_local);
|
|
$ret = lm($model['model_local_match'],'Sports')-> insertGetId($set_local);
|
|
@@ -254,36 +266,61 @@ class WriteSports extends Controller{
|
|
|
//根据球类代码获取相关model
|
|
//根据球类代码获取相关model
|
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
|
$data = $opt['data'];
|
|
$data = $opt['data'];
|
|
|
-// foreach ($opt['data'] as $k => $v){
|
|
|
|
|
- //验证赔率所属赛事
|
|
|
|
|
- if(!empty($data['match_id'])){
|
|
|
|
|
- $match = lm($model['model_match'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- if($match < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
|
|
- }
|
|
|
|
|
- //验证赔率所属联赛 冠军盘口
|
|
|
|
|
- if(!empty($data['lg_id'])){
|
|
|
|
|
- $lg = lm($model['model_league'],'Sports')
|
|
|
|
|
- ->where(['lg_id'=>$data['lg_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- if($lg < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
- }
|
|
|
|
|
- $post = lm($model['model_odds'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id'],'odds_code'=>$data['odds_code'],'sort'=>$data['sort']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- //更新操作
|
|
|
|
|
- if($post > 0){
|
|
|
|
|
- $ret = lm($model['model_odds'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id'],'odds_code'=>$data['odds_code'],'sort'=>$data['sort']])
|
|
|
|
|
- -> update($data);
|
|
|
|
|
- if($ret < 1) Render([], '10011', lang('Tips','Sports')->get('update_error'));
|
|
|
|
|
- }else{
|
|
|
|
|
- //写入操作
|
|
|
|
|
- $ret = lm($model['model_odds'],'Sports')->insert($data);
|
|
|
|
|
- if($ret != true) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
|
|
|
- }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $match = lm($model['model_local_match'],'Sports')
|
|
|
|
|
+ ->select('match_id','others_match_id')
|
|
|
|
|
+ ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(count($match) < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
|
|
+
|
|
|
|
|
+ //获取赛事 本地/源ID
|
|
|
|
|
+ $others_match_id = $match->others_match_id;
|
|
|
|
|
+ $match_id = $match->match_id;
|
|
|
|
|
+
|
|
|
|
|
+ $lg = lm($model['model_local_league'],'Sports')
|
|
|
|
|
+ ->select('lg_id','others_lg_id')
|
|
|
|
|
+ ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(count($lg) < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
+
|
|
|
|
|
+ //获取联赛 本地/源ID
|
|
|
|
|
+ $others_lg_id = $lg->others_lg_id;
|
|
|
|
|
+ $lg_id = $lg->lg_id;
|
|
|
|
|
+ //查询 赔率数据是否存在
|
|
|
|
|
+ $oddsID = lm($model['model_odds'],'Sports')
|
|
|
|
|
+ ->where(['lg_id'=>$lg_id,'others_lg_id'=>$others_lg_id,'match_id'=>$match_id,'others_match_id'=>$others_match_id,'odds_code'=>$data['odds_code'],'sort'=>$data['sort']])
|
|
|
|
|
+ ->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'],
|
|
|
|
|
+ 'sole'=> $data['sole'],
|
|
|
|
|
+ 'source'=> $data['source'],
|
|
|
|
|
+ 'type'=> $data['type'],
|
|
|
|
|
+ 'team'=> $data['team'],
|
|
|
|
|
+ 'lg_id'=> $lg_id,
|
|
|
|
|
+ 'others_lg_id'=> $others_lg_id,
|
|
|
|
|
+ 'ctime'=> $this->newTime,
|
|
|
|
|
+ 'utime'=> $this->newTime,
|
|
|
|
|
+ 'expire_time'=>date('Y-m-d H:m:i',time()+60),
|
|
|
|
|
+ ];
|
|
|
|
|
+ //更新或写入赔率数据
|
|
|
|
|
+ if(!empty($oddsID)){
|
|
|
|
|
+ $ret = lm($model['model_odds'],'Sports')
|
|
|
|
|
+ ->where(['id'=>$oddsID])
|
|
|
|
|
+ -> update($set_odds);
|
|
|
|
|
+ if($ret < 1) Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $ret = lm($model['model_odds'],'Sports')->insert($set_odds);
|
|
|
|
|
+ if($ret != true) Render([], '10019', lang('Tips','Sports')->get('add_odds_error'));
|
|
|
|
|
+ }
|
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -293,29 +330,35 @@ class WriteSports extends Controller{
|
|
|
//根据球类代码获取相关model
|
|
//根据球类代码获取相关model
|
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
|
$data = $opt['data'];
|
|
$data = $opt['data'];
|
|
|
-// foreach ($opt['data'] as $k => $v){
|
|
|
|
|
- //验证结果所属联赛
|
|
|
|
|
- if(!empty($data['lg_id'])){
|
|
|
|
|
- $lg = lm($model['model_league'],'Sports')
|
|
|
|
|
- ->where(['lg_id'=>$data['lg_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- if($lg < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
- }
|
|
|
|
|
- $post = lm($model['model_league_result'],'Sports')
|
|
|
|
|
- ->where(['lg_id'=>$data['lg_id'],'game_name'=>$data['game_name']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- //更新操作
|
|
|
|
|
- if($post > 0){
|
|
|
|
|
- $ret = lm($model['model_league_result'],'Sports')
|
|
|
|
|
- ->where(['lg_id'=>$data['lg_id'],'game_name'=>$data['game_name']])
|
|
|
|
|
- -> update($data);
|
|
|
|
|
- if($ret < 1) Render([], '10011', lang('Tips','Sports')->get('update_error'));
|
|
|
|
|
- }else{
|
|
|
|
|
- //写入操作
|
|
|
|
|
- $ret = lm($model['model_league_result'],'Sports')->insert($data);
|
|
|
|
|
- if($ret != true) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
|
|
|
- }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //验证结果所属联赛
|
|
|
|
|
+ $lg_id = lm($model['model_local_league'],'Sports')
|
|
|
|
|
+ ->select('lg_id')
|
|
|
|
|
+ ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first()->lg_id;
|
|
|
|
|
+ if($lg_id < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
+
|
|
|
|
|
+ $lg_result_id = lm($model['model_league_result'],'Sports')
|
|
|
|
|
+ ->where(['lg_id'=>$lg_id,'game_name'=>$data['game_name']])
|
|
|
|
|
+ ->value('id');
|
|
|
|
|
+ $set_lg_result = [
|
|
|
|
|
+ 'lg_id'=>$lg_id,
|
|
|
|
|
+ 'game_name'=>$data['game_name'],
|
|
|
|
|
+ 'result'=>json_encode($data['result'],JSON_UNESCAPED_UNICODE),
|
|
|
|
|
+ 'status'=>$data['status'],
|
|
|
|
|
+ 'ctime'=> $this->newTime,
|
|
|
|
|
+ 'utime'=> $this->newTime,
|
|
|
|
|
+ ];
|
|
|
|
|
+ //联赛结果数据处理
|
|
|
|
|
+ if(!empty($lg_result_id)){
|
|
|
|
|
+ $ret = lm($model['model_league_result'],'Sports')
|
|
|
|
|
+ ->where(['id'=>$lg_result_id])
|
|
|
|
|
+ -> update($set_lg_result);
|
|
|
|
|
+ if($ret < 1) Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $ret = lm($model['model_league_result'],'Sports')->insert($set_lg_result);
|
|
|
|
|
+ if($ret != true) Render([], '10021', lang('Tips','Sports')->get('add_lg_r_error'));
|
|
|
|
|
+ }
|
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -325,36 +368,56 @@ class WriteSports extends Controller{
|
|
|
//根据球类代码获取相关model
|
|
//根据球类代码获取相关model
|
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
|
$data = $opt['data'];
|
|
$data = $opt['data'];
|
|
|
-// foreach ($opt['data'] as $k => $v){
|
|
|
|
|
- //验证结果所属联赛
|
|
|
|
|
- if(!empty($data['lg_id'])){
|
|
|
|
|
- $lg = lm($model['model_league'],'Sports')
|
|
|
|
|
- ->where(['lg_id'=>$data['lg_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- if($lg < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
- }
|
|
|
|
|
- //验证结果所属赛事
|
|
|
|
|
- if(!empty($data['match_id'])){
|
|
|
|
|
- $lg = lm($model['model_match'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- if($lg < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
|
|
- }
|
|
|
|
|
- $post = lm($model['model_result'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- //更新操作
|
|
|
|
|
- if($post > 0){
|
|
|
|
|
- $ret = lm($model['model_result'],'Sports')
|
|
|
|
|
- -> where(['match_id'=>$data['match_id']])
|
|
|
|
|
- -> update($data);
|
|
|
|
|
- if($ret < 1) Render([], '10011', lang('Tips','Sports')->get('update_error'));
|
|
|
|
|
- }else{
|
|
|
|
|
- //写入操作
|
|
|
|
|
- $ret = lm($model['model_result'],'Sports')->insert($data);
|
|
|
|
|
- if($ret != true) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
|
|
|
- }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ //验证结果所属联赛
|
|
|
|
|
+ $lg_id = lm($model['model_local_league'],'Sports')
|
|
|
|
|
+ ->select('lg_id')
|
|
|
|
|
+ ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first()->lg_id;
|
|
|
|
|
+ if($lg_id < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
+ //验证结果所属赛事
|
|
|
|
|
+ $match_id = lm($model['model_local_match'],'Sports')
|
|
|
|
|
+ ->select('match_id')
|
|
|
|
|
+ ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->value('match_id');
|
|
|
|
|
+ if($match_id < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
|
|
+ //查询结果是否存在
|
|
|
|
|
+ $match_r_id = lm($model['model_result'],'Sports')
|
|
|
|
|
+ ->where(['match_id'=>$match_id])
|
|
|
|
|
+ ->value('id');
|
|
|
|
|
+
|
|
|
|
|
+ $set_match_r = [
|
|
|
|
|
+ "home_team"=>$data['home_team'],
|
|
|
|
|
+ "guest_team"=>$data['guest_team'],
|
|
|
|
|
+ "lg_id"=>$lg_id,
|
|
|
|
|
+ "home_rate"=> $data['home_rate'],
|
|
|
|
|
+ "guest_rate"=> $data['guest_rate'],
|
|
|
|
|
+ "home_score"=> $data['home_score'],
|
|
|
|
|
+ "guest_score"=> $data['guest_score'],
|
|
|
|
|
+ "all_goal"=> $data['all_goal'],
|
|
|
|
|
+ "status"=>$data['status'],
|
|
|
|
|
+ "first_score"=>$data['first_score'],
|
|
|
|
|
+ "last_score"=> $data['last_score'],
|
|
|
|
|
+ "match_score"=> $data['match_score'],
|
|
|
|
|
+ "match_winer"=> $data['match_winer'],
|
|
|
|
|
+ "match_time"=> $data['match_time'],
|
|
|
|
|
+ "match_process"=> $data['match_process'],
|
|
|
|
|
+ "tag"=> $data['tag'],
|
|
|
|
|
+ "match_id"=> $match_id,
|
|
|
|
|
+ "u_home_score"=> $data['u_home_score'],
|
|
|
|
|
+ "u_guest_score"=> $data['u_guest_score'],
|
|
|
|
|
+ "p_code"=> $data['p_code'],
|
|
|
|
|
+ "update_time"=>$this->newTime
|
|
|
|
|
+ ];
|
|
|
|
|
+ //赛事结果数据处理
|
|
|
|
|
+ if(!empty($match_r_id)){
|
|
|
|
|
+ $ret = lm($model['model_result'],'Sports')
|
|
|
|
|
+ -> where(['id'=>$match_r_id])
|
|
|
|
|
+ -> update($set_match_r);
|
|
|
|
|
+ if($ret < 1) Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $ret = lm($model['model_result'],'Sports')->insert($set_match_r);
|
|
|
|
|
+ if($ret != true) Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
|
|
|
|
|
+ }
|
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -364,36 +427,56 @@ class WriteSports extends Controller{
|
|
|
//根据球类代码获取相关model
|
|
//根据球类代码获取相关model
|
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
|
$data = $opt['data'];
|
|
$data = $opt['data'];
|
|
|
-// foreach ($opt['data'] as $k => $v){
|
|
|
|
|
- //验证结果所属联赛
|
|
|
|
|
- if(!empty($data['lg_id'])){
|
|
|
|
|
- $lg = lm($model['model_league'],'Sports')
|
|
|
|
|
- ->where(['lg_id'=>$data['lg_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- if($lg < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
- }
|
|
|
|
|
- //验证结果所属赛事
|
|
|
|
|
- if(!empty($data['match_id'])){
|
|
|
|
|
- $lg = lm($model['model_match'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- if($lg < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
|
|
- }
|
|
|
|
|
- $post = lm($model['model_result_record'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id'],'match_time'=>$data['match_time']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- //更新操作
|
|
|
|
|
- if($post > 0){
|
|
|
|
|
- $ret = lm($model['model_result_record'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id'],'match_time'=>$data['match_time']])
|
|
|
|
|
- -> update($data);
|
|
|
|
|
- if($ret < 1) Render([], '10011', lang('Tips','Sports')->get('update_error'));
|
|
|
|
|
- }else{
|
|
|
|
|
- //写入操作
|
|
|
|
|
- $ret = lm($model['model_result_record'],'Sports')->insert($data);
|
|
|
|
|
- if($ret != true) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
|
|
|
- }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ //验证结果所属联赛
|
|
|
|
|
+ $lg_id = lm($model['model_local_league'],'Sports')
|
|
|
|
|
+ ->select('lg_id')
|
|
|
|
|
+ ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first()->lg_id;
|
|
|
|
|
+ if($lg_id < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
+ //验证结果所属赛事
|
|
|
|
|
+ $match_id = lm($model['model_local_match'],'Sports')
|
|
|
|
|
+ ->select('match_id')
|
|
|
|
|
+ ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->value('match_id');
|
|
|
|
|
+ if($match_id < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
|
|
+
|
|
|
|
|
+ $match_r_id = lm($model['model_result_record'],'Sports')
|
|
|
|
|
+ ->where(['match_id'=>$match_id,'match_time'=>$data['match_time']])
|
|
|
|
|
+ ->value('id');
|
|
|
|
|
+ $set_match_r = [
|
|
|
|
|
+ "home_team"=>$data['home_team'],
|
|
|
|
|
+ "guest_team"=>$data['guest_team'],
|
|
|
|
|
+ "lg_id"=>$lg_id,
|
|
|
|
|
+ "home_rate"=> $data['home_rate'],
|
|
|
|
|
+ "guest_rate"=> $data['guest_rate'],
|
|
|
|
|
+ "home_score"=> $data['home_score'],
|
|
|
|
|
+ "guest_score"=> $data['guest_score'],
|
|
|
|
|
+ "all_goal"=> $data['all_goal'],
|
|
|
|
|
+ "status"=>$data['status'],
|
|
|
|
|
+ "first_score"=>$data['first_score'],
|
|
|
|
|
+ "last_score"=> $data['last_score'],
|
|
|
|
|
+ "match_score"=> $data['match_score'],
|
|
|
|
|
+ "match_winer"=> $data['match_winer'],
|
|
|
|
|
+ "match_time"=> $data['match_time'],
|
|
|
|
|
+ "match_process"=> $data['match_process'],
|
|
|
|
|
+ "tag"=> $data['tag'],
|
|
|
|
|
+ "match_id"=> $match_id,
|
|
|
|
|
+ "p_code"=> $data['p_code'],
|
|
|
|
|
+ "update_time"=>$this->newTime
|
|
|
|
|
+ ];
|
|
|
|
|
+ //更新操作
|
|
|
|
|
+ if($match_r_id > 0){
|
|
|
|
|
+ $ret = lm($model['model_result_record'],'Sports')
|
|
|
|
|
+ ->where(['id'=>$match_r_id])
|
|
|
|
|
+ ->update($set_match_r);
|
|
|
|
|
+
|
|
|
|
|
+ dd($ret);
|
|
|
|
|
+ if($ret < 1) Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //写入操作
|
|
|
|
|
+ $ret = lm($model['model_result_record'],'Sports')->insert($set_match_r);
|
|
|
|
|
+ if($ret != true) Render([], '10022', lang('Tips','Sports')->get('add_match_r_error'));
|
|
|
|
|
+ }
|
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -403,36 +486,59 @@ class WriteSports extends Controller{
|
|
|
//根据球类代码获取相关model
|
|
//根据球类代码获取相关model
|
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
$model = $this->commonFunction->getModels($game_code,1);
|
|
|
$data = $opt['data'];
|
|
$data = $opt['data'];
|
|
|
-// foreach ($opt['data'] as $k => $v){
|
|
|
|
|
- //验证赔率所属赛事
|
|
|
|
|
- if(!empty($data['match_id'])){
|
|
|
|
|
- $match = lm($model['model_match'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- if($match < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
|
|
- }
|
|
|
|
|
- //验证赔率所属联赛 冠军盘口
|
|
|
|
|
- if(!empty($data['lg_id'])){
|
|
|
|
|
- $lg = lm($model['model_league'],'Sports')
|
|
|
|
|
- ->where(['lg_id'=>$data['lg_id']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- if($lg < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
- }
|
|
|
|
|
- $post = lm($model['model_odds_record'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id'],'odds_code'=>$data['odds_code'],'sort'=>$data['sort']])
|
|
|
|
|
- ->count();
|
|
|
|
|
- //更新操作
|
|
|
|
|
- if($post > 0){
|
|
|
|
|
- $ret = lm($model['model_odds_record'],'Sports')
|
|
|
|
|
- ->where(['match_id'=>$data['match_id'],'odds_code'=>$data['odds_code'],'sort'=>$data['sort']])
|
|
|
|
|
- ->update($data);
|
|
|
|
|
- if($ret < 1) Render([], '10011', lang('Tips','Sports')->get('update_error'));
|
|
|
|
|
- }else{
|
|
|
|
|
- //写入操作
|
|
|
|
|
- $ret = lm($model['model_odds_record'],'Sports')->insert($data);
|
|
|
|
|
- if($ret != true) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
|
|
|
- }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $match = lm($model['model_local_match'],'Sports')
|
|
|
|
|
+ ->select('match_id','others_match_id')
|
|
|
|
|
+ ->where(['others_match_id'=>$data['match_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(count($match) < 1) Render([], '10016', lang('Tips','Sports')->get('match_error'));
|
|
|
|
|
+
|
|
|
|
|
+ //获取赛事 本地/源ID
|
|
|
|
|
+ $others_match_id = $match->others_match_id;
|
|
|
|
|
+ $match_id = $match->match_id;
|
|
|
|
|
+
|
|
|
|
|
+ $lg = lm($model['model_local_league'],'Sports')
|
|
|
|
|
+ ->select('lg_id','others_lg_id')
|
|
|
|
|
+ ->where(['others_lg_id'=>$data['lg_id'],'source'=>$data['source']])
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(count($lg) < 1) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
|
|
+
|
|
|
|
|
+ //获取联赛 本地/源ID
|
|
|
|
|
+ $others_lg_id = $lg->others_lg_id;
|
|
|
|
|
+ $lg_id = $lg->lg_id;
|
|
|
|
|
+ //查询 赔率数据是否存在
|
|
|
|
|
+ $oddsID = lm($model['model_odds_record'],'Sports')
|
|
|
|
|
+ ->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'=> $this->newTime,
|
|
|
|
|
+ 'utime'=> $this->newTime,
|
|
|
|
|
+ ];
|
|
|
|
|
+ //更新或写入赔率记录
|
|
|
|
|
+ if(!empty($oddsID)){
|
|
|
|
|
+ $ret = lm($model['model_odds_record'],'Sports')
|
|
|
|
|
+ ->where(['id'=>$oddsID])
|
|
|
|
|
+ -> update($set_odds);
|
|
|
|
|
+ if($ret < 1) Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $ret = lm($model['model_odds_record'],'Sports')->insert($set_odds);
|
|
|
|
|
+ if($ret != true) Render([], '10020', lang('Tips','Sports')->get('add_odds_r_error'));
|
|
|
|
|
+ }
|
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -442,7 +548,9 @@ class WriteSports extends Controller{
|
|
|
* json转数组
|
|
* json转数组
|
|
|
*/
|
|
*/
|
|
|
public function getAddData($data){
|
|
public function getAddData($data){
|
|
|
|
|
+
|
|
|
$data = json_decode($data,true);
|
|
$data = json_decode($data,true);
|
|
|
|
|
+
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|