hasMany(MoneyBuyMatch::class, 'order_id', 'order_id'); } function getinfo($list = 10, $page, $where = '', $type) { $data = $this ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity') ->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id') //->join('money_buy_match','money_buy_match.order_id','=','money_buy_simplex.order_id') ->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id') ->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time') ->whereIn('money_buy_simplex.roll_ratify',array(0,1)) ->where($where) //->distinct('money_buy_match.order_id') ->orderby('money_buy_simplex.money_time', 'desc') ->paginate($list); if (!$data < 0) { return -2021052003; // } //反水 $water_return_money = \App\Models\Money_details::where('trade_type', '7')->get(); //注单作废 $invalid_money = \App\Models\Money_details::where('trade_type', '3')->get(); //订单投注的玩法 $content = \App\Models\MoneyBuyMatch::where('bet_type', '1')->get(); for ($d = 0; $d < count($content); $d++) { if ($content[$d]->result == 0) { $content[$d]->result = '未处理'; } if ($content[$d]->result == 1) { $content[$d]->result = '赢'; } if ($content[$d]->result == -1) { $content[$d]->result = '输'; } if ($content[$d]->result == 2) { $content[$d]->result = '平'; } if ($content[$d]->result == 3) { $content[$d]->result = '赢半平半'; } if ($content[$d]->result == 4) { $content[$d]->result = '输半平半'; } } //玩法 $result = \App\Models\Matchcode::where('game_code', $type)->get(); //$result = \App\Model\Matchcode::get(); for ($i = 0; $i < count($data); $i++) { if($data[$i]->status==1 && $data[$i]->settle_status == 1){ $data[$i]->order_status = '投注'.'
作废 '; } else if ($data[$i]->status == 1 && $data[$i]->settle_status != 1) { $data[$i]->order_status = '投注'; } else if ($data[$i]->status == 2) { $data[$i]->order_status = '作废';//.'
已作废 '; } else if ($data[$i]->status == 3) { $data[$i]->order_status = '撤单';//.'
已撤单 '; } if ($data[$i]->settle_status == 1) { $data[$i]->settle_status = '未结算'; } else{ $data[$i]->settle_status = '已结算'; } if ($data[$i]->game_status == 0) { $data[$i]->game_status = '未处理'; } else { $data[$i]->game_status = '已处理'; } $data[$i]->league = $data[$i]->name_chinese; if ($data[$i]->is_champion == 0) { if ($data[$i]->game_code == 'zq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } if ($data[$i]->game_code == 'lq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } if ($data[$i]->game_code == 'wq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } if ($data[$i]->game_code == 'bq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } $data[$i]->home_guest = $data[$i]->home_team . ' VS ' . $data[$i]->guest_team; $data[$i]->time = '开赛:' . $data[$i]->match_date . ' ' . $data[$i]->match_time; } else { $data[$i]->lg_id_order = $data[$i]->match_id . '(' . $data[$i]->account_name . ')
' . $data[$i]->order_id; $data[$i]->home_guest = '冠军联赛投注'; $data[$i]->time = '结束:' . $data[$i]->last_time; } $data[$i]->money_match_time = '下注:' . $data[$i]->money_time . $data[$i]->time; //反水 $data[$i]->water_return = -1; for ($a = 0; $a < count($water_return_money); $a++) { if ($data[$i]->order_id == $water_return_money[$a]->trade_id) { if ($data[$i]->status == 2 || $data[$i]->status == 3) { $data[$i]->water_return = 0; } else { $data[$i]->water_return = $water_return_money[$a]->money; } //用户投注后账户金额 $data[$i]->frozen_cash = $water_return_money[$a]->money_cash; } } if ($data[$i]->water_return == -1) { $data[$i]->water_return = 0; //用户投注后账户金额 $data[$i]->frozen_cash = $data[$i]->money_cash; } //此时结果金额 $data[$i]->result = $data[$i]->water_return + $data[$i]->gain_money; //用户投注前账户金额 $data[$i]->available_cash = $data[$i]->money_cash + $data[$i]->money; //投注前后账户金额 $data[$i]->account_money = $data[$i]->available_cash . '
' . $data[$i]->money . '
' . $data[$i]->frozen_cash; if ($data[$i]->status == 2 || $data[$i]->status == 3) { // for ($b = 0; $b < count($invalid_money); $b++) { // if ($data[$i]->order_id == $invalid_money[$b]->trade_id) { // $data[$i]->available_cash = $invalid_money[$b]->money_cash; // $data[$i]->account_money = $data[$i]->available_cash; // } // } $data[$i]->account_money = $data[$i]->available_cash; } $data[$i]->str = 0; for ($b = 0; $b < count($content); $b++) { $data[$i]->str1 = 0; $data[$i]->team = ''; if (!empty($content[$b]->odds_code)) { if (!empty(stristr($content[$b]->odds_code, 'home'))) { $data[$i]->team = $data[$i]->home_team; } if (!empty(stristr($content[$b]->odds_code, 'guest'))) { $data[$i]->team = $data[$i]->guest_team; } if ($content[$b]->p_code == 'half_full') { $string = str_replace('home', $data[$i]->home_team, $content[$b]->odds_code); $string = str_replace('guest', $data[$i]->guest_team, $string); $string = str_replace('dogfall', '和局', $string); $string = explode('_', $string); $data[$i]->team = $string['2'] . '/' . $string['3']; } } //处理普通赛事玩法详情 if ($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 0) { if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') { $content[$b]->condition = ''; } $data[$i]->game_status = $data[$i]->game_status; //投注详情 if (!empty($data[$i]->match_time)) { $data[$i]->content1 = '[' . $data[$i]->match_time . ']'; //$data[$i]->match_time = $data[$i]->match_time; } else { if (!empty($data[$i]->last_time)) { $datetime = explode(' ', $data[$i]->last_time); //$data[$i]->match_time = $datetime[1]; $data[$i]->content1 = '[' . $datetime[1] . ']'; } } for ($c = 0; $c < count($result); $c++) { if ($content[$b]->odds_code == $result[$c]->odds_code) { $data[$i]->str1 = 1; if ($content[$b]->result == '未处理') { $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
'; } else { $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
' . $content[$b]->result . '(' . $content[$b]->matchresult . ')
'; } } } if ($data[$i]->str1 == 0) { if ($content[$b]->result == '未处理') { $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
'; } else { $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
' . $content[$b]->result . '(' . $content[$b]->matchresult . ')
'; } } } //处理冠军联赛玩法详情 if ($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 1) { $content[$b]->condition = ''; if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') { $content[$b]->condition = ''; } $data[$i]->game_status = $data[$i]->game_status; /* //投注详情 if(!empty($data[$i]->match_time)){ $data[$i]->content1 = '['.$data[$i]->match_time.']'; //$data[$i]->match_time = $data[$i]->match_time; } else{ if(!empty($data[$i]->last_time)){ $datetime = explode(' ',$data[$i]->last_time); //$data[$i]->match_time = $datetime[1]; $data[$i]->content1 = '['.$datetime[1].']'; } } */ /* for($c=0;$codds_code == $result[$c]->odds_code){ $data[$i]->str1 = 1; if($content[$b]->result=='未处理'){ $data[$i]->content = $content[$b]->home_team.'
'.$data[$i]->content.$result[$c]->odds_name.'
'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'
'; }else{ $data[$i]->content = $content[$b]->home_team.'
'.$data[$i]->content.$result[$c]->odds_name.'
'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'
'.$content[$b]->result.'('.$content[$b]->matchresult.')
'; } } } */ if ($data[$i]->str1 == 0) { if ($content[$b]->result == '未处理') { $data[$i]->content = $content[$b]->home_team . '
' . $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
'; } else { $data[$i]->content = $content[$b]->home_team . '
' . $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
' . $content[$b]->result . '(' . $content[$b]->matchresult . ')
'; } } } } // if($data[$i]->status == 1){ // if($data[$i]->match_status == 0 || $data[$i]->match_status == 1){ // $data[$i]->game_status = $data[$i]->settle_status.'
结算 '; // } // if($data[$i]->match_status == 2 || $data[$i]->match_status == 3 || $data[$i]->match_status == 5){ // if($data[$i]->settle_status == '已结算'){ // $data[$i]->game_status = $data[$i]->settle_status.'
重新结算 '; // }else{ // $data[$i]->game_status = $data[$i]->settle_status.'
结算 '; // } // } // }else{ // $data[$i]->game_status = $data[$i]->settle_status.'
结2算 '; // } $data[$i]->content = $data[$i]->content1 . $data[$i]->content; } return $data->toArray(); } //投注金额汇总统计 function MoneyCount($where = '', $type) { $data = array(); // $data['all_money'] = $this->sum('money'); // $data['all_prize_money'] = $this->sum('prize_money'); // $data['alraedy_prize_money'] = $this->where('settle_status','2')->sum('gain_money'); $data['all_money'] = 0; $data['all_prize_money'] = 0; $data['alraedy_prize_money'] = 0; $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.status', '1')->get(); for ($a = 0; $a < count($all_money); $a++) { $data['all_money'] = $data['all_money'] + $all_money[$a]->money; } $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.status', '1')->get(); for ($a = 0; $a < count($all_prize_money); $a++) { $data['all_prize_money'] = $data['all_money'] + $all_prize_money[$a]->prize_money; } $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where('money_buy_simplex.settle_status', '2')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.status', '1')->get(); for ($a = 0; $a < count($alraedy_prize_money); $a++) { $data['alraedy_prize_money'] = $data['all_money'] + $alraedy_prize_money[$a]->gain_money; } if (!empty($where) && is_array($where)) { $data['all_money'] = 0; $data['all_prize_money'] = 0; $data['alraedy_prize_money'] = 0; //$data['all_money'] = $this->where($where)->sum('money'); // $data['all_prize_money'] = $this->where($where)->sum('prize_money'); // $data['alraedy_prize_money'] = $this->where($where)->where('settle_status','2')->sum('gain_money'); $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_zq_competition', 'st_zq_competition.id', '=', 'money_buy_simplex.match_id')->join('st_zq_league', 'st_zq_competition.lg_id', '=', 'st_zq_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where($where)->where('money_buy_simplex.status', '1')->get(); for ($a = 0; $a < count($all_money); $a++) { $data['all_money'] = $data['all_money'] + $all_money[$a]->money; } $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where($where)->where('money_buy_simplex.status', '1')->get(); for ($a = 0; $a < count($all_prize_money); $a++) { $data['all_prize_money'] = $data['all_prize_money'] + $all_prize_money[$a]->prize_money; } $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.settle_status', '2')->where($where)->where('money_buy_simplex.status', '1')->get(); for ($a = 0; $a < count($alraedy_prize_money); $a++) { $data['alraedy_prize_money'] = $data['alraedy_prize_money'] + $alraedy_prize_money[$a]->gain_money; } } return $data; } //修改赛事下的所有单式下注 3199308 function updatesimplex($ssid, $code) { $newapp = new \App\Models\MoneyBuyMatch(); $data = $newapp->allsimplexorder($ssid, $code); if ($data) { for ($i = 0; $i < count($data); $i++) { $the = array( 'status' => 2, 'game_status' => 3, 'game_code' => $code, ); $res = $this->where('order_id', $data[$i]['order_id'])->update($the); } if ($res < 0) { return -7012000302; //操作失败 } return $res; } else { return -111; } } function info($list = 10, $page, $where = '', $type) { $data = $this ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity') ->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id') // ->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id') ->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id') ->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time') ->whereIn('money_buy_simplex.roll_ratify',array(0,1)) ->where($where) ->orderby('money_buy_simplex.money_time', 'desc') ->paginate($list); if (!$data < 0) { return -2021052003; // } //反水 $water_return_money = \App\Models\Money_details::where('trade_type', '7')->get(); //注单作废 $invalid_money = \App\Models\Money_details::where('trade_type', '3')->get(); //订单投注的玩法 $content = \App\Models\MoneyBuyMatch::where('bet_type', '1')->get(); for ($d = 0; $d < count($content); $d++) { if ($content[$d]->result == 0) { $content[$d]->result = '未处理'; } if ($content[$d]->result == 1) { $content[$d]->result = '赢'; } if ($content[$d]->result == -1) { $content[$d]->result = '输'; } if ($content[$d]->result == 2) { $content[$d]->result = '平'; } if ($content[$d]->result == 3) { $content[$d]->result = '赢半平半'; } if ($content[$d]->result == 4) { $content[$d]->result = '输半平半'; } } //玩法 $result = \App\Models\Matchcode::where('game_code', $type)->get(); //$result = \App\Model\Matchcode::get(); for ($i = 0; $i < count($data); $i++) { if ($data[$i]->status == 1 && $data[$i]->settle_status == 1) { $data[$i]->order_status = '投注' . '
作废 '; } else if ($data[$i]->status == 1 && $data[$i]->settle_status != 1) { $data[$i]->order_status = '投注'; } else if ($data[$i]->status == 2) { $data[$i]->order_status = '作废'; } else if ($data[$i]->status == 3) { $data[$i]->order_status = '撤单'; } // if($data[$i]->settle_status==1){ // $data[$i]->settle_status = '未结算'; // }else if($data[$i]->settle_status==2){ // $data[$i]->settle_status = '已结算'; // } if ($data[$i]->game_status == 0) { $data[$i]->game_status = '未处理'; } else { $data[$i]->game_status = '已处理'; } $data[$i]->league = $data[$i]->name_chinese; if ($data[$i]->is_champion == 0) { if ($data[$i]->game_code == 'zq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } if ($data[$i]->game_code == 'lq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } if ($data[$i]->game_code == 'wq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } if ($data[$i]->game_code == 'bq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } $data[$i]->home_guest = $data[$i]->home_team . ' VS ' . $data[$i]->guest_team; $data[$i]->time = '开赛:' . $data[$i]->match_date . ' ' . $data[$i]->match_time; } else { $data[$i]->lg_id_order = $data[$i]->match_id . '(' . $data[$i]->account_name . ')
' . $data[$i]->order_id; $data[$i]->home_guest = '冠军联赛投注'; $data[$i]->time = '结束:' . $data[$i]->last_time; } $data[$i]->money_match_time = '下注:' . $data[$i]->money_time . $data[$i]->time; /* $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team; $data[$i]->time = '开赛:'.$data[$i]->match_date.' '.$data[$i]->match_time; $data[$i]->money_match_time = '下注:'.$data[$i]->money_time.'
'.$data[$i]->time; */ //反水 $data[$i]->water_return = -1; for ($a = 0; $a < count($water_return_money); $a++) { if ($data[$i]->order_id == $water_return_money[$a]->trade_id) { if ($data[$i]->status == 2 || $data[$i]->status == 3) { $data[$i]->water_return = 0; } else { $data[$i]->water_return = $water_return_money[$a]->money; } //用户投注后账户金额 $data[$i]->frozen_cash = $water_return_money[$a]->money_cash; } } if ($data[$i]->water_return == -1) { $data[$i]->water_return = 0; //用户投注后账户金额 $data[$i]->frozen_cash = $data[$i]->money_cash; } //此时结果金额 $data[$i]->result = $data[$i]->water_return + $data[$i]->gain_money; //用户投注前账户金额 $data[$i]->available_cash = $data[$i]->money_cash + $data[$i]->money; //投注前后账户金额 $data[$i]->account_money = $data[$i]->available_cash . '
' . $data[$i]->money . '
' . $data[$i]->frozen_cash; if ($data[$i]->status == 2 || $data[$i]->status == 3) { // for ($b = 0; $b < count($invalid_money); $b++) { // if ($data[$i]->order_id == $invalid_money[$b]->trade_id) { // $data[$i]->available_cash = $invalid_money[$b]->money_cash; // $data[$i]->account_money = $data[$i]->available_cash; // } // } $data[$i]->account_money = $data[$i]->available_cash; } $data[$i]->str = 0; for ($b = 0; $b < count($content); $b++) { $data[$i]->str1 = 0; $data[$i]->team = ''; if (!empty($content[$b]->odds_code)) { if (!empty(stristr($content[$b]->odds_code, 'home'))) { $data[$i]->team = $data[$i]->home_team; } if (!empty(stristr($content[$b]->odds_code, 'guest'))) { $data[$i]->team = $data[$i]->guest_team; } if ($content[$b]->p_code == 'half_full') { $string = str_replace('home', $data[$i]->home_team, $content[$b]->odds_code); $string = str_replace('guest', $data[$i]->guest_team, $string); $string = str_replace('dogfall', '和局', $string); $string = explode('_', $string); $data[$i]->team = $string['2'] . '/' . $string['3']; } } //处理普通赛事 if ($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 0) { if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') { $content[$b]->condition = ''; } $data[$i]->game_status = $data[$i]->game_status; //投注详情 if (!empty($data[$i]->match_time)) { $data[$i]->content1 = '[' . $data[$i]->match_time . ']'; //$data[$i]->match_time = $data[$i]->match_time; } else { if (!empty($data[$i]->last_time)) { $datetime = explode(' ', $data[$i]->last_time); //$data[$i]->match_time = $datetime[1]; $data[$i]->content1 = '[' . $datetime[1] . ']'; } } for ($c = 0; $c < count($result); $c++) { if ($content[$b]->odds_code == $result[$c]->odds_code) { $data[$i]->str1 = 1; if ($content[$b]->result == '未处理') { $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
'; } else { $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
' . $content[$b]->result . '(' . $content[$b]->matchresult . ')
'; } } } if ($data[$i]->str1 == 0) { if ($content[$b]->result == '未处理') { $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
'; } else { $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
' . $content[$b]->result . '(' . $content[$b]->matchresult . ')
'; } } } //处理冠军联赛玩法详情 if ($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 1) { $content[$b]->condition = ''; if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') { $content[$b]->condition = ''; } $data[$i]->game_status = $data[$i]->game_status; /* //投注详情 if(!empty($data[$i]->match_time)){ $data[$i]->content1 = '['.$data[$i]->match_time.']'; //$data[$i]->match_time = $data[$i]->match_time; } else{ if(!empty($data[$i]->last_time)){ $datetime = explode(' ',$data[$i]->last_time); //$data[$i]->match_time = $datetime[1]; $data[$i]->content1 = '['.$datetime[1].']'; } } */ /* for($c=0;$codds_code == $result[$c]->odds_code){ $data[$i]->str1 = 1; if($content[$b]->result=='未处理'){ $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.'
'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'
'; }else{ $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.'
'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'
'.$content[$b]->result.'('.$content[$b]->matchresult.')
'; } } } */ if ($data[$i]->str1 == 0) { if ($content[$b]->result == '未处理') { $data[$i]->content = $content[$b]->home_team . '
' . $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
'; } else { $data[$i]->content = $content[$b]->home_team . '
' . $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
' . $content[$b]->result . '(' . $content[$b]->matchresult . ')
'; } } } } $data[$i]->game_status = $data[$i]->settle_status; $data[$i]->content = $data[$i]->content1 . $data[$i]->content; } return $data->toArray(); } //查询单订单是否存在 function onlyorder($orderid) { $order = $this->where('order_id', $orderid)->count(); return $order; } //查询单订单是否存在 function getorder($orderid) { $order = $this->with("matchdatas")->where('order_id', $orderid)->first(); return $order; } function checkinfo($list = 10, $page, $where = '', $type) { $data = $this ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity') ->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id') //->join('money_buy_match','money_buy_match.order_id','=','money_buy_simplex.order_id') ->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id') ->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'money_buy_simplex.roll_ratify', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time') ->whereIn('money_buy_simplex.roll_ratify',array(-1,2)) ->where($where) //->distinct('money_buy_match.order_id') ->orderby('money_buy_simplex.money_time', 'desc') ->paginate($list); if (!$data < 0) { return -2021052003; // } //反水 $water_return_money = \App\Models\Money_details::where('trade_type', '7')->get(); //注单作废 $invalid_money = \App\Models\Money_details::where('trade_type', '3')->get(); //订单投注的玩法 $content = \App\Models\MoneyBuyMatch::where('bet_type', '1')->get(); for ($d = 0; $d < count($content); $d++) { if ($content[$d]->result == 0) { $content[$d]->result = '未处理'; } if ($content[$d]->result == 1) { $content[$d]->result = '赢'; } if ($content[$d]->result == -1) { $content[$d]->result = '输'; } if ($content[$d]->result == 2) { $content[$d]->result = '平'; } if ($content[$d]->result == 3) { $content[$d]->result = '赢半平半'; } if ($content[$d]->result == 4) { $content[$d]->result = '输半平半'; } } //玩法 $result = \App\Models\Matchcode::where('game_code', $type)->get(); //$result = \App\Model\Matchcode::get(); for ($i = 0; $i < count($data); $i++) { if($data[$i]->status==1 && $data[$i]->settle_status == 1){ $data[$i]->order_status = '投注'.'
作废 '; } if ($data[$i]->status == 1 && $data[$i]->settle_status != 1) { $data[$i]->order_status = '投注'; } else if ($data[$i]->status == 2) { $data[$i]->order_status = '作废';//.'
已作废 '; } else if ($data[$i]->status == 3) { $data[$i]->order_status = '撤单';//.'
已撤单 '; } if ($data[$i]->settle_status == 1) { $data[$i]->settle_status = '未结算'; } else if ($data[$i]->settle_status == 2) { $data[$i]->settle_status = '已结算'; } if ($data[$i]->game_status == 0) { $data[$i]->game_status = '未处理'; } else { $data[$i]->game_status = '已处理'; } if ($data[$i]->roll_ratify == 2) { $data[$i]->roll_ratify = ' 通过
拒绝 '; } if ($data[$i]->roll_ratify == -1) { $data[$i]->roll_ratify = '未通过审核'; } if ($data[$i]->game_code == 'zq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } if ($data[$i]->game_code == 'lq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } if ($data[$i]->game_code == 'wq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } if ($data[$i]->game_code == 'bq') { $data[$i]->match_id_order = '' . $data[$i]->match_id . ' (' . $data[$i]->account_name . ')
' . $data[$i]->order_id; } $data[$i]->league = $data[$i]->name_chinese; if ($data[$i]->is_champion == 0) { $data[$i]->home_guest = $data[$i]->home_team . ' VS ' . $data[$i]->guest_team; $data[$i]->time = '开赛:' . $data[$i]->match_date . ' ' . $data[$i]->match_time; } else { $data[$i]->home_guest = '冠军联赛投注'; $data[$i]->time = '结束:' . $data[$i]->last_time; } $data[$i]->money_match_time = '下注:' . $data[$i]->money_time . $data[$i]->time; //反水 $data[$i]->water_return = -1; for ($a = 0; $a < count($water_return_money); $a++) { if ($data[$i]->order_id == $water_return_money[$a]->trade_id) { if ($data[$i]->status == 2 || $data[$i]->status == 3) { $data[$i]->water_return = 0; } else { $data[$i]->water_return = $water_return_money[$a]->money; } //用户投注后账户金额 $data[$i]->frozen_cash = $water_return_money[$a]->money_cash; } } if ($data[$i]->water_return == -1) { $data[$i]->water_return = 0; //用户投注后账户金额 $data[$i]->frozen_cash = $data[$i]->money_cash; } //此时结果金额 $data[$i]->result = $data[$i]->water_return + $data[$i]->gain_money; //用户投注前账户金额 $data[$i]->available_cash = $data[$i]->money_cash + $data[$i]->money; //投注前后账户金额 $data[$i]->account_money = $data[$i]->available_cash . '
' . $data[$i]->money . '
' . $data[$i]->frozen_cash; if ($data[$i]->status == 2 || $data[$i]->status == 3) { // for ($b = 0; $b < count($invalid_money); $b++) { // if ($data[$i]->order_id == $invalid_money[$b]->trade_id) { // $data[$i]->available_cash = $invalid_money[$b]->money_cash; // $data[$i]->account_money = $data[$i]->available_cash; // } // } $data[$i]->account_money = $data[$i]->available_cash; } $data[$i]->str = 0; for ($b = 0; $b < count($content); $b++) { $data[$i]->str1 = 0; $data[$i]->team = ''; if (!empty($content[$b]->odds_code)) { if (!empty(stristr($content[$b]->odds_code, 'home'))) { $data[$i]->team = $data[$i]->home_team; } if (!empty(stristr($content[$b]->odds_code, 'guest'))) { $data[$i]->team = $data[$i]->guest_team; } if ($content[$b]->p_code == 'half_full') { $string = str_replace('home', $data[$i]->home_team, $content[$b]->odds_code); $string = str_replace('guest', $data[$i]->guest_team, $string); $string = str_replace('dogfall', '和局', $string); $string = explode('_', $string); $data[$i]->team = $string['2'] . '/' . $string['3']; } } //处理普通赛事玩法详情 if ($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 0) { if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') { $content[$b]->condition = ''; } $data[$i]->game_status = $data[$i]->game_status; //投注详情 if (!empty($data[$i]->match_time)) { $data[$i]->content1 = '[' . $data[$i]->match_time . ']'; //$data[$i]->match_time = $data[$i]->match_time; } else { if (!empty($data[$i]->last_time)) { $datetime = explode(' ', $data[$i]->last_time); //$data[$i]->match_time = $datetime[1]; $data[$i]->content1 = '[' . $datetime[1] . ']'; } } for ($c = 0; $c < count($result); $c++) { if ($content[$b]->odds_code == $result[$c]->odds_code) { $data[$i]->str1 = 1; if ($content[$b]->result == '未处理') { $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
'; } else { $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
' . $content[$b]->result . '(' . $content[$b]->matchresult . ')
'; } } } if ($data[$i]->str1 == 0) { if ($content[$b]->result == '未处理') { $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
'; } else { $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
' . $content[$b]->result . '(' . $content[$b]->matchresult . ')
'; } } } //处理冠军联赛玩法详情 if ($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 1) { $content[$b]->condition = ''; if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') { $content[$b]->condition = ''; } $data[$i]->game_status = $data[$i]->game_status; /* //投注详情 if(!empty($data[$i]->match_time)){ $data[$i]->content1 = '['.$data[$i]->match_time.']'; //$data[$i]->match_time = $data[$i]->match_time; } else{ if(!empty($data[$i]->last_time)){ $datetime = explode(' ',$data[$i]->last_time); //$data[$i]->match_time = $datetime[1]; $data[$i]->content1 = '['.$datetime[1].']'; } } */ /* for($c=0;$codds_code == $result[$c]->odds_code){ $data[$i]->str1 = 1; if($content[$b]->result=='未处理'){ $data[$i]->content = $content[$b]->home_team.'
'.$data[$i]->content.$result[$c]->odds_name.'
'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'
'; }else{ $data[$i]->content = $content[$b]->home_team.'
'.$data[$i]->content.$result[$c]->odds_name.'
'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'
'.$content[$b]->result.'('.$content[$b]->matchresult.')
'; } } } */ if ($data[$i]->str1 == 0) { if ($content[$b]->result == '未处理') { $data[$i]->content = $content[$b]->home_team . '
' . $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
'; } else { $data[$i]->content = $content[$b]->home_team . '
' . $data[$i]->content . $content[$b]->odds_code . '
' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '
' . $content[$b]->result . '(' . $content[$b]->matchresult . ')
'; } } } } // if($data[$i]->status == 1){ // if($data[$i]->match_status == 0 || $data[$i]->match_status == 1){ // $data[$i]->game_status = $data[$i]->settle_status.'
结算 '; // } // if($data[$i]->match_status == 2 || $data[$i]->match_status == 3 || $data[$i]->match_status == 5){ // if($data[$i]->settle_status == '已结算'){ // $data[$i]->game_status = $data[$i]->settle_status.'
重新结算 '; // }else{ // $data[$i]->game_status = $data[$i]->settle_status.'
结算 '; // } // } // }else{ // $data[$i]->game_status = $data[$i]->settle_status.'
结2算 '; // } $data[$i]->content = $data[$i]->content1 . $data[$i]->content; } return $data->toArray(); } //作废赛事下注单处理 function delorder($matchid,$type){ //该赛事的单式注单 $account_identitys = array(); $order_ids = array(); $orders = $this->where('match_id',$matchid)->get(); if(!empty($orders)){ for ($c=0; $c < count($orders); $c++){ $account_identitys[] = $orders[$c]['account_identitys']; $order_ids[] = $orders[$c]['order_id']; } //用戶账户金额 $account_money = \App\Models\Account_detailed::wherein('account_identity',$account_identitys)->get(); //反水 $water_return_money = \App\Models\Money_details::wherein('trade_id',$order_ids)->where('trade_type', '7')->get(); for($i=0;$imoney - $orders[$i]->gain_money - $water_return; $models = new \App\Models\Money_details(); $models->info_identity = UUID(); $models->trade_id = $orders[$i]->order_id; $models->account_name = $orders[$i]->account_name; $models->account_identity = $orders[$i]->account_identity; $models->money = abs($orders[$i]->money - $orders[$i]->gain_money - $water_return); $models->money_time = date("Y-m-d H:i:s", time()); if ($new_available_cash > $available_cash) { $models->money_type = '1'; } else { $models->money_type = '2'; } $models->money_cash = $new_available_cash; $models->trade_type = '3'; $models->trade_desc = '赛事作废单式注单回款'; $models->status = '1'; try { DB::beginTransaction();//开启事务 $this->where('id', $orders[$i]['id'])->update(['status' => '2']); \App\Models\Account_detailed::where('account_identity', $orders[$i]->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]); $models->save(); DB::commit();//提交 } catch (Exception $e) { DB::rollback();//回滚 } } } //该赛事相关的的串关注单做平局处理 \App\Models\MoneyBuyMatch::where('match_id',$matchid)->where('game_code',$type)->where('bet_type',2)->update(['result'=>2]); } }