SportbetRecordLogic.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/4/23
  6. * Time: 14:36
  7. */
  8. namespace Biz\Game;
  9. //获取某个代理下的体育项目订单相关的数据
  10. class SportbetRecordLogic
  11. {
  12. //代理Model
  13. private $wagentModel = '';
  14. //订单ID
  15. private $vendorid = null ;
  16. //是否结算
  17. private $isjs = 0 ;
  18. //返回数据
  19. private $retDataArray = [] ;
  20. //db obj ;
  21. private $db ;
  22. //
  23. private $buyModel = null ;
  24. public function __construct($wagModel,$vendorid,$isjs)
  25. {
  26. $this->wagentModel = $wagModel;
  27. $this->vendorid = $vendorid;
  28. $this->isjs = ($isjs==1) ? 2 : 1 ;
  29. $this->retDataArray = $this->getDefaultBackData();
  30. $this->db = $GLOBALS['DB'] ;
  31. }
  32. public function dorun(){
  33. $buyModel = lm("Money_buy",'Commons')->where(['order_id'=>$this->vendorid,'settle_status'=>$this->isjs])->first();
  34. if ( !$buyModel ) { return false; }
  35. $this->buyModel = $buyModel ;
  36. $this->Batchsetval();
  37. $ret = $this->retDataArray;
  38. return $ret;
  39. }
  40. //批量设置数据
  41. public function Batchsetval(){
  42. $buyModel = $this->buyModel ;
  43. if ($buyModel){
  44. $this->Setval('isjs',$buyModel->settle_status==2 ? 1 :0);
  45. $this->Setval('tzmoney',$buyModel->money);
  46. //$this->Setval('username',strlen($this->wagentModel->agent_pre)>0 ? (substr($buyModel->account_name,strlen($this->wagentModel->agent_pre))): substr($buyModel->account_name ) );
  47. $this->Setval('username',$buyModel->account_name );
  48. $this->Setval('win',($buyModel->settle_status==2) ? $buyModel->prize_money : 0 );
  49. $this->Setval('updatetime',$buyModel->money_time);
  50. $this->Setval('validamount',$buyModel->money);
  51. $this->Setval('tztype',$buyModel->game_name);
  52. $this->Setval('orderid',$buyModel->order_id);
  53. $this->Setval('iscancel',($buyModel->status==4) ? 1 : 0 );
  54. switch ( strtolower($buyModel->game_name) ){
  55. case 'zq':
  56. $this->Setval('sportid', 0);
  57. break;
  58. case 'lq':
  59. $this->Setval('sportid', 3);
  60. break;
  61. case 'wq':
  62. $this->Setval('sportid', 1);
  63. break;
  64. default;
  65. $this->Setval('sportid', 16);
  66. }
  67. if ($buyModel->settle_status==2 && intval($buyModel->prize_money)==0){ $this->Setval('lose', $buyModel->money ); }
  68. $tmpArray = json_decode($buyModel->codes,true);
  69. if ( is_array($tmpArray) && isset($tmpArray['0']) ){
  70. $tmpArray = $tmpArray['0'];
  71. if ( isset($tmpArray['bettingTime']) && $tmpArray['bettingTime']!='' && $buyModel->settle_status==2){
  72. $this->Setval('thisdate',$tmpArray['bettingTime']);
  73. $this->Setval('balltime',$tmpArray['bettingTime']);
  74. }
  75. if ( isset($tmpArray['odds']) && $tmpArray['odds']!='' ){ $this->Setval('odds',$tmpArray['curpl']); }
  76. if ( isset($tmpArray['match_id']) && $tmpArray['match_id']!='' ){ $this->Setval('matchid',$tmpArray['match_id']); }
  77. }
  78. }
  79. }
  80. //设置返回参数值
  81. private function Setval($key,$val=''){
  82. if (isset($this->retDataArray[$key])){
  83. $this->retDataArray[$key] = $val;
  84. }
  85. }
  86. //返回数据
  87. private function makeret($status=1,$msg='success',$datas=[]){
  88. return [
  89. 'status'=>$status,
  90. 'msg'=>$msg,
  91. 'datas'=>$datas
  92. ];
  93. }
  94. /*
  95. * ballid 场次id号
  96. balltime 结算时间
  97. curpl 赔率
  98. ds 单双
  99. dxc 大小个数
  100. isbk 无用
  101. iscancel 是否取消
  102. isdanger 是否危险球
  103. isjs 是否结算,1表示结算,0表示未结算
  104. lose 输的钱
  105. matchid 联赛id号
  106. moneyrate 会员使用的货币比率
  107. orderid 注单号
  108. redcard 红牌
  109. result 赛事结果
  110. rowguid 唯一性id号,自动生成,orderid为每个平台的id号,多平台可能不唯一
  111. rqc 让球个数
  112. rqteam 让球队伍,比如主队让球H,客对让球A
  113. sportid 下注球类id号
  114. tballtime 走地时间
  115. thisdate 结算日期
  116. truewin 0.5赢半,1全赢,-0.5输半,-1输,0和
  117. tzip 投注ip,IBC不提供,为空就行
  118. tzmoney 下注金额
  119. tzteam 下注队伍,比如主队H,客队A
  120. tztype 下注类别
  121. updatetime 下注时间
  122. username 会员名
  123. win 赢的钱
  124. zdbf 走地比分
  125. content 下注中文简体内容,需要用UrlDecode解码
  126. vendorid 注单更新顺序号
  127. validamount 有效投注额
  128. *
  129. * */
  130. private function getDefaultBackData(){
  131. $array = [
  132. "ballid"=>'',
  133. "balltime"=>'',
  134. "curpl"=>'',
  135. "ds"=>'',
  136. "dxc"=>'',
  137. "isbk"=>'',
  138. "iscancel"=>'',
  139. "isdanger"=>'',
  140. "isjs"=>'',
  141. "lose"=>'',
  142. "matchid"=>'',
  143. "moneyrate"=>'',
  144. "orderid"=>'',
  145. "redcard"=>'',
  146. "result"=>'',
  147. "rowguid"=>'',
  148. "rqc"=>'',
  149. "rqteam"=>'',
  150. "sportid"=>'',
  151. "tballtime"=>'',
  152. "thisdate"=>'',
  153. "truewin"=>'',
  154. "tzip"=>'',
  155. "tzmoney"=>'',
  156. "tzteam"=>'',
  157. "tztype"=>'',
  158. "updatetime"=>'',
  159. "username"=>'',
  160. "win"=>'',
  161. "zdbf"=>'',
  162. "content"=>'',
  163. "vendorid"=>'',
  164. "validamount"=>'',
  165. ];
  166. return $array ;
  167. }
  168. }