|
|
@@ -184,20 +184,34 @@ class WriteSports extends Controller{
|
|
|
if(empty($lg)) Render([], '10015', lang('Tips','Sports')->get('league_error'));
|
|
|
}
|
|
|
|
|
|
+ //查询关联记录是否存在
|
|
|
$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;
|
|
|
- //更新操作
|
|
|
if(empty($match_id)){
|
|
|
- $ret = lm($model['model_match'],'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_match'],'Sports')->insert($data);
|
|
|
- if($ret != true) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
|
+ //查询赛事是否存在
|
|
|
+ $id = lm($model['model_match'],'Sports')
|
|
|
+ ->select('id')
|
|
|
+ ->where(['home_team'=>$data['home_team'],'guest_team'=>$data['guest_team'],'match_date'=>$data['match_date'],'match_time'=>$data['match_time']])
|
|
|
+ ->first()->id;
|
|
|
+
|
|
|
+ //写入赛事
|
|
|
+ if(empty($id)){
|
|
|
+ $data['ctime'] = $this->newTime;
|
|
|
+ $data['utime'] = $this->newTime;
|
|
|
+ $data['expire_time'] = date('Y-m-d H:m:i',(time()+60));
|
|
|
+
|
|
|
+ $id = lm($model['model_match'],'Sports')->insertGetId($data);
|
|
|
+ if($id < 1) Render([], '10012', lang('Tips','Sports')->get('insert_error'));
|
|
|
+ }
|
|
|
+ $set_local = [
|
|
|
+ 'm_match_id'=>$id,
|
|
|
+ 'match_id'=>$data['match_id'],
|
|
|
+ 'source'=>$data['source'],
|
|
|
+ ];
|
|
|
+ $ret = lm($model['model_local_match'],'Sports')-> insertGetId($set_local);
|
|
|
+ if($ret < 1) Render([], '10018', lang('Tips','Sports')->get('local_match_error'));
|
|
|
}
|
|
|
Render([], '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|