SportbetRecordLogic.php 6.0 KB

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