Betorder.php 23 KB

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