SportsNoteList.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/4/9
  6. * Time: 9:18
  7. */
  8. namespace App\Models;
  9. use Illuminate\Support\Facades\DB;
  10. class SportsNoteList extends BaseModel {
  11. protected $table = "st_zq_bet";
  12. public $timestamps = false;
  13. function getinfo($list = 10, $page, $where = '',$type)
  14. {
  15. if (is_array ($where) && count ($where) > 0) {
  16. $data = $this
  17. ->join('st_zq_competition','st_zq_competition.match_id','=','st_zq_bet.match_id')
  18. ->join('account_detailed','account_detailed.account_identity','=','st_zq_bet.account_identity')
  19. ->where($where)
  20. ->where('st_zq_bet.game_name', 'zq')
  21. ->where('st_zq_bet.type', $type)
  22. ->orderby('money_time','desc')
  23. ->paginate ($list);
  24. } else {
  25. $data = $this
  26. ->join('st_zq_competition','st_zq_competition.match_id','=','st_zq_bet.match_id')
  27. ->join('account_detailed','account_detailed.account_identity','=','st_zq_bet.account_identity')
  28. ->where('st_zq_bet.game_name', 'zq')
  29. ->where('st_zq_bet.type', $type)
  30. ->orderby('money_time','desc')
  31. ->paginate ($list);
  32. }
  33. if (!$data < 0) {
  34. return -2021052003; //
  35. }
  36. for($i=0;$i<count($data);$i++){
  37. if($data[$i]->status==1){
  38. $data[$i]->status = '投注';
  39. }else if($data[$i]->status==2){
  40. $data[$i]->status = '追号';
  41. }else if($data[$i]->status==4){
  42. $data[$i]->status = '撤单';
  43. }
  44. if($data[$i]->water_status==1){
  45. $data[$i]->water_status = '未回水';
  46. }else if($data[$i]->water_status==2){
  47. $data[$i]->water_status = '已回水';
  48. }
  49. if($data[$i]->settle_status==1){
  50. $data[$i]->settle_status = '未结算';
  51. }else if($data[$i]->settle_status==2){
  52. $data[$i]->settle_status = '已结算';
  53. }
  54. if($data[$i]->game_status==0){
  55. $data[$i]->game_status = '待开奖';
  56. }else if($data[$i]->game_status==1){
  57. $data[$i]->game_status = '中奖';
  58. }else if($data[$i]->game_status==2){
  59. $data[$i]->game_status = '未中奖';
  60. }
  61. if($data[$i]->member_type==1){
  62. $data[$i]->member_type = '普通会员';
  63. }else if($data[$i]->member_type==2){
  64. $data[$i]->member_type = '超级会员';
  65. }
  66. $data[$i]->match_id_order = '<span>'.$data[$i]->match_id.'</span><br>'.$data[$i]->order_id;
  67. $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
  68. $data[$i]->match_time = '开赛:'.$data[$i]->match_date.' '.$data[$i]->match_time;
  69. $data[$i]->money_match_time = '投注:'.$data[$i]->money_time.'<br>'.$data[$i]->match_time;
  70. $league = DB::table('st_zq_league')->where('lg_id',$data[$i]->lg_id)->first();
  71. if(!empty($league)){
  72. $data[$i]->league = $league->name_chinese;
  73. }else{
  74. $data[$i]->league = $data[$i]->lg_id;
  75. }
  76. $data[$i]->frozen_cash = $data[$i]->available_cash-$data[$i]->money.'.00';
  77. $data[$i]->account = $data[$i]->available_cash.'<br><span>'.$data[$i]->account_name.'</span><br>'.$data[$i]->frozen_cash;
  78. $codes = json_decode($data[$i]->codes, true);
  79. $data[$i]->content = '';
  80. for($j=0;$j<count($codes);$j++){
  81. $odds_code = $codes[$j]['odds_code'];
  82. $result = DB::table('st_odds_code')->where('odds_code',$odds_code)->first();
  83. if(!empty($result)){
  84. $odds_name = $result->odds_name;
  85. }else{
  86. $odds_name = $odds_code;
  87. }
  88. $game = DB::table('st_game_type')->where('game_code',$data[$i]->game_name)->first();
  89. $data[$i]->content = $data[$i]->content.$odds_name. '¥'.$codes[$j]['bet_amount'].'<br>';
  90. $data[$i]->game = $game->game_name;
  91. }
  92. }
  93. return $data->toArray();
  94. }
  95. //投注金额汇总统计
  96. function MoneyCount($where = '',$type) {
  97. $data = array();
  98. $data['all_money'] = $this->where('type',$type)->sum('money');
  99. $data['all_prize_money'] = $this->where('type',$type)->sum('prize_money');
  100. $data['alraedy_prize_money'] = $this->where('game_status','1')->where('type',$type)->sum('prize_money');
  101. if (!empty($where) && is_array($where)) {
  102. $data['all_money'] = $this->where($where)->where('type',$type)->sum('money');
  103. $data['all_prize_money'] = $this->where($where)->where('type',$type)->sum('prize_money');
  104. $data['alraedy_prize_money'] = $this->where($where)->where('game_status','1')->where('type',$type)->sum('prize_money');
  105. }
  106. return $data;
  107. }
  108. }