SportbetRecordLogic.php 5.9 KB

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