|
|
@@ -85,6 +85,12 @@ class WriteSportsController extends BaseController
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
+ //写危险球数据
|
|
|
+ public function setMatchWarn(Req $data){
|
|
|
+ $ret = $this->setMatchWarn_v1($data);
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+
|
|
|
//写赛果接口
|
|
|
public function setResultExpress(Req $data)
|
|
|
{
|
|
|
@@ -2694,6 +2700,65 @@ class WriteSportsController extends BaseController
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 写赛事危险球数据
|
|
|
+ */
|
|
|
+ public function setMatchWarn_v1($data){
|
|
|
+ //验证token
|
|
|
+ $user = new \App\Models\System_user;
|
|
|
+ if (empty($data->token)) return Response::generate('未获取到token', Response::TOKEN_ERR);
|
|
|
+ $token = $user::where(['token' => $data->token])->value('token');
|
|
|
+ if (empty($token)) return Response::generate('token验证不通过', Response::TOKEN_ERR);
|
|
|
+
|
|
|
+ try {
|
|
|
+ //开启事务
|
|
|
+ DB::beginTransaction();
|
|
|
+ $obt = $data->data;
|
|
|
+ //请求 数据 为空
|
|
|
+ if (empty($obt)) throw new \Exception(Response::generate('请求数据为空,', Response::ABNORMAL));
|
|
|
+ $getData = $this->getAddData($obt);
|
|
|
+
|
|
|
+ //不是 赛事 危险球 数据
|
|
|
+ if ($getData['title'] != 'match_warn') throw new \Exception(Response::generate('不是危险球数据,', Response::ABNORMAL));
|
|
|
+
|
|
|
+ //获取球类代码
|
|
|
+ $game_code = $getData['game_code'];
|
|
|
+ //获取数据源
|
|
|
+ $source = $getData['source'];
|
|
|
+ //获取数据源赛事id
|
|
|
+ $others_match_id = $getData['match_id'];
|
|
|
+ //获取球类名称
|
|
|
+ $gameName = gameModel::getGameName($game_code);
|
|
|
+ //获取 model
|
|
|
+ $models = commonFunction::getModels($game_code, 1);
|
|
|
+ //获取 赛事 数据
|
|
|
+ $warn_data = $getData['data'];
|
|
|
+
|
|
|
+ //获取赛事 match_id
|
|
|
+ $match_id = $models['model_local_match']::SELECT('others_match_id', 'match_id')
|
|
|
+ ->where(['source' => $source,'others_match_id'=>$others_match_id])
|
|
|
+ ->first()->match_id;
|
|
|
+
|
|
|
+ if(!empty($match_id)){
|
|
|
+ //更新 危险球
|
|
|
+ $ret = ZqResultModel::set_result_warn($match_id,$warn_data);
|
|
|
+ if($ret < 1) throw new \Exception( Response::generate('',Response::SET_WARN_ERR));
|
|
|
+ }
|
|
|
+
|
|
|
+ //提交事务
|
|
|
+ DB::commit();
|
|
|
+ //写请求数据 日志记录
|
|
|
+ if ($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code, $getData, $getData['title'], Response::success());
|
|
|
+ return Response::success();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ //回滚事务
|
|
|
+ DB::rollBack();
|
|
|
+ //写请求数据 日志记录
|
|
|
+ if ($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code, $getData, $getData['title'], $e->getMessage());
|
|
|
+ return $e->getMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param $data
|
|
|
* @return mixed
|