Betorder.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <?php
  2. namespace App\Api\Controller;
  3. use Biz\Money\Moneycopy;
  4. use Biz\Money\Money;
  5. use Biz\Account\AccountManager;
  6. use App\Api\Model\St_odds_code as odds_codeModel;
  7. /*
  8. * Class Register
  9. * @package App\Api\Controller
  10. * User: junghwi
  11. * Date: 2019/3/21
  12. */
  13. class Betorder extends BaseController{
  14. private $simplex_money = 0; //单式投注总额
  15. public function init() {
  16. $this->time = date('Y-m-d H:i:s',time());
  17. $this->MC = new Moneycopy();
  18. $this->M = new Money();
  19. $this->accountManager = new AccountManager();
  20. $this->commonFunction = C()->get('commonFunction');
  21. }
  22. /**
  23. * 单式串式分类
  24. * @param [array] $res 投注数据
  25. * @return [array] $data
  26. *
  27. */
  28. public function Classify(array $res){
  29. if(empty($res)){
  30. Render($res, '7003',lang('Errors','Api')->get('error-7003'));
  31. }
  32. $data['single'] = [];//单式
  33. $data['bunch'] = [];//串式
  34. $last[] = $res[count($res)-1];
  35. unset($res[count($res)-1]);
  36. foreach ($last as $k =>$v){
  37. foreach ($v as $kk =>$vv){
  38. $num = $kk+1;
  39. //验证球类代码是否有效
  40. $this->verify_gameType($vv['ballId'],$num);
  41. //验证联赛是否存在
  42. $this->verify_league($vv['ballId'],(int)$vv['lg_id'],$num);
  43. //验证赛事/赔率代码是否存在,如果match_id = 0 则为冠军联赛赔率,无需验证
  44. if($vv['match_id'] > 0){
  45. $this->verify_match($vv['ballId'],$vv['match_id'],$num);
  46. //验证赛事下赔率玩法是否有效
  47. $this->verify_odds($vv['ballId'],$vv['odds_only'],$vv['odds'],$vv['condition'],$vv['odds_code'],$num);
  48. }
  49. }
  50. }
  51. foreach($res as $k => $v){
  52. //根据类型分组
  53. if($v['type'] == '1'){
  54. $data['single'][$k] = array_merge($last[0][$v['index']],$v);
  55. }else{
  56. $data['bunch'][$k] = $v;
  57. }
  58. }
  59. if(!empty($data['bunch'])){
  60. $data['bunch'] = array_merge_recursive($data['bunch'],$last);
  61. }
  62. return $data;
  63. }
  64. /**
  65. * 根据赛事ID分组
  66. * @param [array] $data 球类数据
  67. * @return [array] $data
  68. */
  69. public function Group_ball($data = []){
  70. if(empty($data)){
  71. return $data;
  72. }
  73. foreach($data as $k => $v){
  74. if(!isset($data[$v['match_id']])){
  75. $data[$v['match_id']][] = $v;
  76. unset($data[$k]);
  77. }else{
  78. $data[$v['match_id']][] = $v;
  79. unset($data[$k]);
  80. }
  81. }
  82. return $data;
  83. }
  84. /**
  85. * 单式投注数据处理
  86. * @param [array] $res 单式投注数据
  87. * @return [int] 1 成功 其他失败
  88. * @param [int] $batch_id 批量ID
  89. */
  90. public function Simplex_bet(array $res,array $userInfo,$batch_id){
  91. if(empty($res)||empty($userInfo)||empty($batch_id)){
  92. Render('', '7003',lang('Errors','Api')->get('error-7003'));
  93. }
  94. //验证与判断投注了几种
  95. foreach($res as $k => $v){
  96. $num = $k + 1;
  97. if(empty($v['bet_amount'])){
  98. $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5105');
  99. Render([], '5105',$msg);
  100. }
  101. //根据类型分组
  102. if(!isset($res[$v['ballId']])){
  103. $res[$v['ballId']][] = $v;
  104. unset($res[$k]);
  105. }else{
  106. $res[$v['ballId']][] = $v;
  107. unset($res[$k]);
  108. }
  109. }
  110. //球类联赛分类并且插入数据库
  111. foreach($res as $k => $v){
  112. dd($res[$k]);
  113. $gamedate = $this->Group_ball($res[$k]);
  114. $this->Simplex_bet_insert($gamedate,$userInfo,$k,$batch_id);
  115. }
  116. }
  117. /**
  118. * 单式投注单个球类数据插入
  119. * @param [array] $data 单式投注数据
  120. * @param [array] $userInfo 用户信息
  121. * @param [type] $game_code 球类代码
  122. * @param [int] $batch_id 批量ID
  123. * @return [int] 1 成功 其他失败
  124. */
  125. public function Simplex_bet_insert($data,$userInfo,$game_code,$batch_id){
  126. if(empty($data)||empty($userInfo)||empty($game_code)){
  127. Render('', '7003',lang('Errors','Api')->get('error-7003'));
  128. }
  129. foreach($data as $k => $v){
  130. $OrderID = OrderID();//生成订单ID
  131. $UUID = UUID(); //生成信息ID
  132. $bet_money = 0; //赛事总投注额
  133. $prize_money = 0; //可赢额
  134. foreach($v as $kk => $vv){
  135. $bet_money += $vv['bet_amount'];
  136. $prize_money += $vv['odds']* $vv['bet_amount'];
  137. $matchData =[
  138. 'odds_id' =>$vv['id'],
  139. 'home_team' => $vv['home_team'],
  140. 'guest_team' => $vv['guest_team'],
  141. 'condition' => $vv['condition'],
  142. 'odds' => $vv['odds'],
  143. 'odds_code' => $vv['odds_code'],
  144. 'p_code' => $vv['p_code'],
  145. 'odds_only' => $vv['odds_only'],
  146. 'match_id' => $vv['match_id'],
  147. 'game_code' => $game_code,
  148. 'lg_id' => $vv['lg_id'],
  149. 'batch_id' => $batch_id,
  150. 'bet_type' => 1,
  151. 'bet_money' => $vv['bet_amount'],
  152. 'ctime' => $this->time,
  153. 'utime' => $this->time
  154. ];
  155. //插入数据源
  156. $moneyBuyMatch = lm('MoneyBuyMatch','Api')->insert($matchData);
  157. if(!$moneyBuyMatch){
  158. Render('','3205',lang('errors','Api')->get('error-3205'));
  159. }
  160. }
  161. $order =[
  162. 'info_identity' => $UUID,
  163. 'account_name' => $userInfo['account'],
  164. 'account_identity' => $userInfo['account_identity'],
  165. 'order_id' => $OrderID,
  166. 'game_code' => $game_code,
  167. 'batch_id' => $batch_id,
  168. 'match_id' => $k,
  169. 'game_no' => "",
  170. 'prize_money'=> $prize_money,
  171. 'money' => $bet_money, //投注金额
  172. 'money_time' => $this->time
  173. ];
  174. $insert = lm("MoneyBuySimplex",'Api')->insert($order);
  175. if(!$insert){
  176. Render('','3205',lang('errors','Api')->get('error-3205'));
  177. }
  178. $insertMoney = $this->M->insertMoney($userInfo['account_identity'],$bet_money,$OrderID,1,"",$UUID,$userInfo);
  179. if($insertMoney!=1){
  180. Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
  181. }
  182. $this->M->fanshui($userInfo['account_identity'],$userInfo['account'],$bet_money,$OrderID);//反水
  183. }
  184. }
  185. public function Bet(){
  186. //如果获取不到data,则为游戏端提交,需转成数组
  187. if(!empty($_POST['game_data'])){
  188. //获取参数转成数组
  189. $get_data = json_decode($_POST['game_data'],true);
  190. $token = $get_data['token'];
  191. $bet_money = $get_data['bet_money'];
  192. $data = $get_data['data'];
  193. }else{
  194. $data = $_REQUEST['data'];
  195. $bet_money = $_REQUEST['bet_money'];
  196. $token = $_REQUEST['token'];
  197. }
  198. //验证用户token
  199. $userInfo = $this->getAgent($token);
  200. if(empty($data)||empty($bet_money)){
  201. Render('', '51029',lang('Errors','Api')->get('error-51029'));
  202. }
  203. //获取用户金额信息
  204. if(!$this->M->verifyMoney($bet_money,$userInfo['cash'])){
  205. Render('', '4204',lang('Errors','Api')->get('error-4204'));
  206. }
  207. $batch_id = strtotime(date('Y-m-d H:i:s',time())).mt_rand('1','99');//批量ID
  208. //执行数据插入
  209. try {
  210. _beginTransaction();//开启事务
  211. $data = $this->Classify($data);
  212. if(!empty($data['single'])){
  213. $this->Simplex_bet($data['single'],$userInfo,$batch_id);//单式数据处理
  214. }
  215. if(!empty($data['bunch'])){
  216. $data_all = $data['bunch'][count($data['bunch'])-1];//获取最后一个数组
  217. unset($data['bunch'][count($data['bunch'])-1]);//删除最后一个元素
  218. $this->stringBet($data['bunch'],$data_all,$userInfo,$batch_id);
  219. }
  220. _commit();//提交
  221. Render('', '1',lang('Errors','Api')->get('error-1'));
  222. } catch (Exception $e) {
  223. _rollBack();//回滚
  224. print $e->getMessage();
  225. }
  226. }
  227. /**
  228. * token获取用户详情
  229. */
  230. public function getAgent($token = '') {
  231. $checkToken = $this->accountManager->checkEffectiveTime($token);
  232. if ($checkToken['status'] != 1) {
  233. Render($checkToken['data'], $checkToken['status'], lang('commons')->get('user does login'));
  234. };
  235. $result = $this->accountManager->refreshToken($token);
  236. return $result['data'];
  237. }
  238. //验证联赛是否存在
  239. public function verify_league($game_code,$lg_id,$num = 1){
  240. if(empty($lg_id)){
  241. $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5112');
  242. Render([], '5112',$msg);
  243. }
  244. //根据球类代码 获取相关model
  245. $model = $this->commonFunction->getModels($game_code);
  246. $model_league = $model['model_league'];
  247. $info = lm($model_league,'Sports')
  248. ->select('id')
  249. ->where('id',$lg_id)
  250. ->first();
  251. if(empty($info)){
  252. $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5113');
  253. Render([], '5113',$msg);
  254. }
  255. }
  256. /**
  257. * 赛事是否存在或结束
  258. * @param [type] $game_code 球类代码
  259. * @param [type] $match_id 赔率ID
  260. * @param [type] $num 循环键值
  261. * $@param [type]type_str 串式
  262. *
  263. */
  264. public function verify_match($game_code,$match_id,$num = 1){
  265. if(empty($match_id)){
  266. $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5109');
  267. Render([], '5109',$msg);
  268. }
  269. //根据球类代码 获取相关model
  270. $models = $this->commonFunction->getModels($game_code);
  271. $model_match = $models['model_match'];
  272. $info = lm($model_match,'Sports')
  273. ->select('status')
  274. ->where('status', '<', '2')
  275. // ->where('us_time','>',qgmdate('Y-m-d H:i:s','', -4))
  276. // ->where('source','hg3535')
  277. ->where('id',$match_id)
  278. ->first();
  279. if(empty($info)){
  280. $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5103');
  281. Render([], '5103',$msg);
  282. }
  283. $info = $info->toarray();
  284. if($info['status'] == 2){
  285. $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5108');
  286. Render([], '5108',$msg);
  287. }
  288. return $info;
  289. }
  290. /**
  291. * 验证球类是否存在
  292. * @param [type] $game_code 球类代码
  293. * @param [type] $num 第几条
  294. */
  295. public function verify_gameType($game_code,$num){
  296. if(empty($game_code)){
  297. $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-5102');
  298. Render([], '5102', $msg);
  299. }
  300. $info = lm('GameType','Sports')->where('game_code',$game_code)->first();
  301. if(empty($info)){
  302. $msg = '第' . $num . '条数据' . lang('Errors', 'Api')->get('error-5102');
  303. Render([], '5102', $msg);
  304. }
  305. return $info;
  306. }
  307. /**
  308. * 验证赔率是否存在
  309. * @param [type] $game_code 球类代码
  310. * @param [type] $odds_id 赔率IDkk
  311. *
  312. */
  313. public function verify_odds($game_code,$odds_only,$odds,$condition,$odds_code,$num = 1){
  314. if (empty($odds_only)){
  315. $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-5111');
  316. Render([], '5111', $msg);
  317. }
  318. if(empty($odds_code)){
  319. $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7052');
  320. Render([], '7052', $msg);
  321. }
  322. if(empty($odds)){
  323. $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
  324. Render([], '7029', $msg);
  325. }
  326. $odds_codeNum = odds_codeModel::getOddsCode($odds_code,$game_code);
  327. if($odds_codeNum < 1){
  328. $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7053');
  329. Render([], '7053', $msg);
  330. }
  331. //根据球类代码 获取相关model
  332. $models = $this->commonFunction->getModels($game_code);
  333. $model_odds = $models['model_odds'];
  334. $model_odds_record = $models['model_odds_record'];
  335. //匹配赔率是否过期
  336. $odds_info = lm($model_odds,'Sports')
  337. ->join($model_odds_record,$model_odds_record.'.odds_only',$model_odds.'.odds_only')
  338. ->select($model_odds_record.'.odds',$model_odds_record.'.condition')
  339. ->where($model_odds.'.odds_only',$odds_only)
  340. ->first();
  341. if(empty($odds_info)){
  342. $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7051');
  343. Render([], '7051', $msg);
  344. }
  345. $odds_info = $odds_info->toarray();
  346. if($condition != $odds_info['condition']){
  347. $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7047');
  348. Render([], '7047', $msg);
  349. }
  350. if($odds != $odds_info['odds']){
  351. $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7049');
  352. Render([], '7049', $msg);
  353. }
  354. return $odds_info;
  355. }
  356. /**
  357. * 处理串式投注
  358. * $data_str 各串式 数据
  359. * $data_all 所有赛事 数据
  360. * $userInfo 用户数据
  361. * $batch_id 批次号
  362. */
  363. public function stringBet($data_str=[],$data_all=[],$userInfo=[],$batch_id=0){
  364. //验证串式投注是否合法
  365. $this->verify_stringType($data_all);
  366. //获取串式 总赛事数量
  367. $groupNum = count($data_all);//总数量
  368. $orderData = [];
  369. foreach ($data_str as $k=>$v){
  370. //字符串替换
  371. $str = str_ireplace("串","_",$v['type']);
  372. //获取type 3_12
  373. $after = substr($str,strpos($str,"_")+1);
  374. //当前串式 值
  375. $sonNum = substr($str,0,strrpos($str,"_"));
  376. //获取倍数
  377. if((int)$after == 1){
  378. $multiple = $this->getMultiple($groupNum,(int)$sonNum);
  379. }else{
  380. $multiple =(int)$after;
  381. }
  382. //获取当前串式投注金额及可赢金额
  383. if($after == 1){
  384. $money_all = $this->getmakeMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
  385. }else{
  386. $money_all = $this->getStrAllMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
  387. }
  388. //投注金额
  389. $moneyData = $money_all['moneyData'];
  390. //可赢金额
  391. $prize_money = $money_all['prize_money'];
  392. $uuid = UUID();
  393. $orderID = OrderID();
  394. $orderData[$k]['info_identity'] = $uuid;
  395. $orderData[$k]['account_name'] = $userInfo['account'];
  396. $orderData[$k]['account_identity'] = $userInfo['account_identity'];
  397. $orderData[$k]['order_id'] = $orderID;
  398. $orderData[$k]['game_no'] = "";
  399. $orderData[$k]['money'] = $moneyData;//$pay_money//总投注金额
  400. $orderData[$k]['money_time'] = $this->time;//下注时间
  401. $orderData[$k]['prize_money'] = $prize_money;//$expect_money ;//预期总可赢金额
  402. $orderData[$k]['str_type'] = $v['type'];//串式类型
  403. $orderData[$k]['batch_id'] = $batch_id;//批次号
  404. $orderData[$k]['wait_match_num'] = count($data_all);//批次号
  405. //写资金变动表
  406. $insertMoney = $this->M->insertMoney($userInfo['account_identity'],$moneyData,$orderID,1,"",$uuid,$userInfo);
  407. if($insertMoney!=1){
  408. Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
  409. }
  410. $this->M->fanshui($userInfo['account_identity'],$userInfo['account'],$moneyData,$orderID);//反水
  411. }
  412. //写注单 表
  413. $moneyBuy = lm('MoneyBuyStr','Api')->insert($orderData);
  414. if(!$moneyBuy){
  415. Render('','3205',lang('errors','Api')->get('error-3205'));
  416. }
  417. foreach ($data_all as $kk=>$vv){
  418. $getModels = $this->commonFunction->getModels($vv['ballId']);
  419. $model_match = $getModels['model_match'];
  420. $matchData[] = [
  421. 'batch_id'=>$batch_id,
  422. 'odds_id'=>$vv['id'],
  423. 'home_team'=>$vv['home_team'],
  424. 'guest_team'=>$vv['guest_team'],
  425. 'condition'=>$vv['condition'],
  426. 'odds'=>$vv['odds'],
  427. 'odds_code'=>$vv['odds_code'],
  428. 'p_code'=>$vv['p_code'],
  429. 'odds_only'=>$vv['odds_only'],
  430. 'status'=>0,
  431. 'match_id'=>$vv['match_id'],
  432. 'game_code'=>$vv['ballId'],
  433. 'lg_id'=> $vv['lg_id'],//lm($model_match,"Sports")->select('lg_id')->where('match_id',$vv['match_id'])->first()->lg_id,
  434. 'ctime'=>$this->time,//写入时间
  435. 'utime' => $this->time,
  436. 'bet_type'=>2
  437. ];
  438. }
  439. //写赔率数据表
  440. $moneyBuyMatch = lm('MoneyBuyMatch','Api')->insert($matchData);
  441. if(!$moneyBuyMatch){
  442. Render('','3205',lang('errors','Api')->get('error-3205'));
  443. }
  444. return true;
  445. }
  446. /**
  447. * 计算串式投注 倍率
  448. * $groupNum 总赛事 数量
  449. * $sonNum 当前串式 数量
  450. */
  451. public function getMultiple($groupNum = 0,$sonNum = 0){
  452. if($groupNum and $sonNum){
  453. $group =1;
  454. for($i = $groupNum ; $i >($groupNum - $sonNum);$i--) {
  455. $group = $group * $i;
  456. }
  457. $son =1;
  458. for($i = $sonNum ; $i >0;$i--) {
  459. $son = $son * $i;
  460. }
  461. }
  462. return $group/$son;
  463. }
  464. /**
  465. * @param int $sonNum 当前串式数量
  466. * @param int $bet_amount 当前串式投注额
  467. * @param int $multiple 当前串式倍数
  468. * @param array $data_all 当前注单 所有投注数据
  469. * @return mixed
  470. * 计算当前串式投注总额、可赢总额
  471. */
  472. public function getmakeMoney($sonNum=0,$bet_amount=0,$multiple=0,$data_all=[],$after = 0){
  473. $allNum = count($data_all);//所有数量
  474. $odds_all = [];//所有投注项数据
  475. foreach ($data_all as $k=>$v){
  476. $odds_all[] = $v['odds']+1;
  477. }
  478. //投注总额
  479. $data['moneyData'] = (double)$bet_amount*(double)$multiple;
  480. if($sonNum == $allNum and (int)$after ==1){//N场赛事 N串一
  481. //获取所有赛事赔率乘积
  482. $odds = array_product($odds_all) - 1;
  483. //获取可赢金额
  484. $data['prize_money'] = sprintf("%.2f",substr(sprintf("%.3f", $bet_amount*$odds), 0, -1));//floor($bet_amount*$odds*100)/100;//保留两位小数
  485. }
  486. if($sonNum < $allNum and (int)$after ==1){//例:N场赛事 <N串一
  487. $group = $this->commonFunction->combination($odds_all, $sonNum);
  488. foreach ($group as $k=>$v){
  489. $odds[] = array_product($v);
  490. }
  491. $odds = (array_sum($odds))-(count($odds));
  492. //获取可赢金额
  493. $data['prize_money'] = sprintf("%.2f",substr(sprintf("%.3f", $bet_amount*$odds), 0, -1));//floor($bet_amount*$odds*100)/100;
  494. }
  495. return $data;
  496. }
  497. /**
  498. * 获取所有可用串式 N场赛事 2串1,3串1...N串1,N<11
  499. * 并计算 其投注可赢金额
  500. */
  501. public function getStrAllMoney($sonNum=0,$bet_amount=0,$multiple=0,$data_all=[],$after = 0){
  502. $d = [];
  503. for ($i=2;$i<($sonNum+1);$i++){
  504. $d[] = $i;
  505. }
  506. foreach ($d as $k=>$v){
  507. $multiple = $this->getMultiple($sonNum,$v);
  508. $money[] = $this->getmakeMoney($v,$bet_amount,$multiple,$data_all,1);
  509. }
  510. $data=array();
  511. foreach($money as $k=>$v){
  512. $data['moneyData']+=$v['moneyData'];
  513. $data['prize_money']+=$v['prize_money'];
  514. }
  515. return $data;
  516. }
  517. /**
  518. * 验证串式投注 是否合法
  519. * $data 串式 所有赛事
  520. */
  521. public function verify_stringType($data=[]){
  522. if($data){
  523. foreach($data as $k=>$v){
  524. if($v['match_id']==$v['match_id']){
  525. $r[$v['match_id']][] = $v;
  526. }
  527. }
  528. }
  529. if($r){
  530. foreach ($r as $k=>$v){
  531. if(count($v) > 1){
  532. $msg = lang('Errors','Api')->get('error-50038');
  533. Render([], '50038',$msg);
  534. }
  535. }
  536. }
  537. }
  538. /**
  539. * 更新投注项相关数据
  540. */
  541. public function getBetData(){
  542. $data = $_REQUEST;
  543. // $data = [['game_code'=>'zq','match_id'=>3095448,'odds_id'=>623078],['game_code'=>'zq','match_id'=>3095448,'odds_id'=>623078]];
  544. foreach ($data as $k=>$v){
  545. $getModels = $this->commonFunction->getModels($v['game_code']);
  546. $model_match = $getModels['model_match'];
  547. $model_odds = $getModels['model_odds'];
  548. $oddsData = lm($model_match,"Sports")
  549. ->join($model_odds,$model_odds.'.match_id',$model_match.'.id')
  550. ->select($model_match.'.id as match_id',$model_match.'.match_date',$model_match.'.home_team',$model_match.'.guest_team',$model_odds.'.id as odds_id',$model_odds.'.p_code',$model_odds.'.odds_code',$model_odds.'.condition',$model_odds.'.odds',$model_odds.'.odds_only',$model_odds.'.status',$model_odds.'.sort')
  551. // ->where($model_match.'.source',$this->source)
  552. ->where($model_match.'.id',$v['match_id'])
  553. ->where($model_odds.'.id',$v['odds_id'])
  554. //->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
  555. ->first();
  556. $oddsData->game_code = $v['game_code'];
  557. $betData[] = $oddsData;
  558. }
  559. Render($betData, '1', lang('Tips','Sports')->get('success'));
  560. }
  561. }