|
@@ -1691,6 +1691,87 @@ class WriteSportsController extends BaseController
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param Req $data
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ * @throws \App\Lib\Biz\Sport\Exception
|
|
|
|
|
+ * 更新赛事状态
|
|
|
|
|
+ */
|
|
|
|
|
+ public function upMatch(Req $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_status') 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 = $data['game_code'];
|
|
|
|
|
+ //获取 数据源
|
|
|
|
|
+ $source = $data['source'];
|
|
|
|
|
+
|
|
|
|
|
+ //获取所有数据源赛事 match_id
|
|
|
|
|
+ $others_match_ids = [];
|
|
|
|
|
+ foreach ($data['data'] as $k => $v) {
|
|
|
|
|
+ $others_match_ids[] = $v['match_id'];
|
|
|
|
|
+ }
|
|
|
|
|
+ //根据球类代码 获取model
|
|
|
|
|
+ $model = commonFunction::getModels($game_code, 1);
|
|
|
|
|
+ //获取所有赛事 match_id
|
|
|
|
|
+ $local_match = $model['model_local_match']::SELECT('others_match_id', 'match_id')
|
|
|
|
|
+ ->where(['source' => $source])
|
|
|
|
|
+ ->whereIn('others_match_id', $others_match_ids)
|
|
|
|
|
+ ->get()->toArray();
|
|
|
|
|
+ if (empty($local_match)) throw new \Exception(Response::generate('', Response::MATCHID_NULL));
|
|
|
|
|
+ //更新状态字段
|
|
|
|
|
+ foreach ($local_match as $k => $v) {
|
|
|
|
|
+ $set_status = [
|
|
|
|
|
+ 'status' => $v['status'],
|
|
|
|
|
+ 'is_rollball' => $v['is_rollball'],
|
|
|
|
|
+ 'is_today' => $v['is_today'],
|
|
|
|
|
+ 'is_morningplate' => $v['is_morningplate'],
|
|
|
|
|
+ 'is_stringscene' => $v['is_stringscene'],
|
|
|
|
|
+ 'is_horn' => $v['is_horn'],
|
|
|
|
|
+ 'utime' => date('Y-m-d H:i:s'),
|
|
|
|
|
+ ];
|
|
|
|
|
+ $ret = $model['model_match']::where(['id' => $v['match_id']])
|
|
|
|
|
+ ->update($set_status);
|
|
|
|
|
+ if ($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code) . '赛事-match_id:' . $v['others_match_id'], Response::UPSTATUS_ERROR));
|
|
|
|
|
+ }
|
|
|
|
|
+ //提交事务
|
|
|
|
|
+ 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();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
* 验证所属 联赛 是否存在
|
|
* 验证所属 联赛 是否存在
|
|
|
*/
|
|
*/
|
|
@@ -1952,85 +2033,6 @@ class WriteSportsController extends BaseController
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @param Req $data
|
|
|
|
|
- * @return string
|
|
|
|
|
- * @throws \App\Lib\Biz\Sport\Exception
|
|
|
|
|
- * 更新赛事状态
|
|
|
|
|
- */
|
|
|
|
|
- public function upMatch(Req $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_status') 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 = $data['game_code'];
|
|
|
|
|
- //获取 数据源
|
|
|
|
|
- $source = $data['source'];
|
|
|
|
|
-
|
|
|
|
|
- //获取所有数据源赛事 match_id
|
|
|
|
|
- $others_match_ids = [];
|
|
|
|
|
- foreach ($data['data'] as $k => $v) {
|
|
|
|
|
- $others_match_ids[] = $v['match_id'];
|
|
|
|
|
- }
|
|
|
|
|
- //根据球类代码 获取model
|
|
|
|
|
- $model = commonFunction::getModels($game_code, 1);
|
|
|
|
|
- //获取所有赛事 match_id
|
|
|
|
|
- $local_match = $model['model_local_match']::SELECT('others_match_id', 'match_id')
|
|
|
|
|
- ->where(['source' => $source])
|
|
|
|
|
- ->whereIn('others_match_id', $others_match_ids)
|
|
|
|
|
- ->get()->toArray();
|
|
|
|
|
- if (empty($local_match)) throw new \Exception(Response::generate('', Response::MATCHID_NULL));
|
|
|
|
|
- //更新状态字段
|
|
|
|
|
- foreach ($local_match as $k => $v) {
|
|
|
|
|
- $set_status = [
|
|
|
|
|
- 'status' => $v['status'],
|
|
|
|
|
- 'is_rollball' => $v['is_rollball'],
|
|
|
|
|
- 'stais_todaytus' => $v['is_today'],
|
|
|
|
|
- 'is_morningplate' => $v['is_morningplate'],
|
|
|
|
|
- 'is_stringscene' => $v['is_stringscene'],
|
|
|
|
|
- 'is_horn' => $v['is_horn'],
|
|
|
|
|
- ];
|
|
|
|
|
- $ret = $model['model_match']::where(['id' => $v['match_id']])
|
|
|
|
|
- ->update($set_status);
|
|
|
|
|
- if ($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code) . '赛事-match_id:' . $v['others_match_id'], Response::UPSTATUS_ERROR));
|
|
|
|
|
- }
|
|
|
|
|
- //提交事务
|
|
|
|
|
- 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();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
* 写入直播 数据
|
|
* 写入直播 数据
|