|
|
@@ -0,0 +1,1170 @@
|
|
|
+<?php
|
|
|
+/**
|
|
|
+ * Created by PhpStorm.
|
|
|
+ * User: Jonlin
|
|
|
+ * Date: 2019/4/9
|
|
|
+ * Time: 9:18
|
|
|
+ */
|
|
|
+
|
|
|
+namespace App\Models;
|
|
|
+
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
+use App\Models\MoneyBuyMatch;
|
|
|
+use App\Http\Response\Response;
|
|
|
+
|
|
|
+class SportsNoteList extends BaseModel
|
|
|
+{
|
|
|
+ protected $table = "money_buy_simplex";
|
|
|
+ public $timestamps = false;
|
|
|
+
|
|
|
+ public function matchdatas()
|
|
|
+ {
|
|
|
+ return $this->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 = '投注'.'<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\',\''.$data[$i]->order_id.'\',\''.$data[$i]->name_chinese.'\');"> 作废 </a>';
|
|
|
+ }
|
|
|
+ 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 = '作废';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已作废 </a>';
|
|
|
+ } else if ($data[$i]->status == 3) {
|
|
|
+ $data[$i]->order_status = '撤单';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已撤单 </a>';
|
|
|
+ }
|
|
|
+ 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 = '<a href="/admin/sportsfoot/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
|
|
|
+ }
|
|
|
+ if ($data[$i]->game_code == 'lq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
|
|
|
+ }
|
|
|
+ if ($data[$i]->game_code == 'wq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
|
|
|
+ }
|
|
|
+ if ($data[$i]->game_code == 'bq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $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 . '(<span>' . $data[$i]->account_name . '</span>)<br>' . $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 . '<br><span>' . $data[$i]->money . '</span><br>' . $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 . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
|
|
|
+ } else {
|
|
|
+ $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($data[$i]->str1 == 0) {
|
|
|
+ if ($content[$b]->result == '未处理') {
|
|
|
+ $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
|
|
|
+ } else {
|
|
|
+ $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理冠军联赛玩法详情
|
|
|
+ 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;$c<count($result);$c++){
|
|
|
+ if($content[$b]->odds_code == $result[$c]->odds_code){
|
|
|
+ $data[$i]->str1 = 1;
|
|
|
+ if($content[$b]->result=='未处理'){
|
|
|
+ $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
|
|
|
+ }else{
|
|
|
+ $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ */
|
|
|
+ if ($data[$i]->str1 == 0) {
|
|
|
+ if ($content[$b]->result == '未处理') {
|
|
|
+ $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
|
|
|
+ } else {
|
|
|
+ $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // if($data[$i]->status == 1){
|
|
|
+ // if($data[$i]->match_status == 0 || $data[$i]->match_status == 1){
|
|
|
+ // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结算 </a>';
|
|
|
+ // }
|
|
|
+ // 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.'<br><a class="layui-btn layui-btn-sm resettlement" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/resettlement/?id=" href="javascript:resettlement(\'/admin/SoccerNoteList/resettlement/?id='.$data[$i]->id.'\');"> 重新结算 </a>';
|
|
|
+ // }else{
|
|
|
+ // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm settlement" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/settlement/?id=" href="javascript:settlement(\'/admin/SoccerNoteList/settlement/?id='.$data[$i]->id.'\');"> 结算 </a>';
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }else{
|
|
|
+ // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结2算 </a>';
|
|
|
+ // }
|
|
|
+
|
|
|
+ $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 = '投注' . '<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\',\''.$data[$i]->order_id.'\',\''.$data[$i]->name_chinese.'\');"> 作废 </a>';
|
|
|
+ } 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 = '<a href="/admin/sportsfoot/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
|
|
|
+ }
|
|
|
+ if ($data[$i]->game_code == 'lq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
|
|
|
+ }
|
|
|
+ if ($data[$i]->game_code == 'wq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
|
|
|
+ }
|
|
|
+ if ($data[$i]->game_code == 'bq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $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 . '(<span>' . $data[$i]->account_name . '</span>)<br>' . $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.'<br>'.$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 . '<br><span>' . $data[$i]->money . '</span><br>' . $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 . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
|
|
|
+ } else {
|
|
|
+ $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($data[$i]->str1 == 0) {
|
|
|
+ if ($content[$b]->result == '未处理') {
|
|
|
+ $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
|
|
|
+ } else {
|
|
|
+ $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理冠军联赛玩法详情
|
|
|
+ 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;$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.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
|
|
|
+ }else{
|
|
|
+ $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ */
|
|
|
+ if ($data[$i]->str1 == 0) {
|
|
|
+ if ($content[$b]->result == '未处理') {
|
|
|
+ $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
|
|
|
+ } else {
|
|
|
+ $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $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 = '投注'.'<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\',\''.$data[$i]->order_id.'\',\''.$data[$i]->name_chinese.'\');"> 作废 </a>';
|
|
|
+ }
|
|
|
+ if ($data[$i]->status == 1 && $data[$i]->settle_status != 1) {
|
|
|
+ $data[$i]->order_status = '投注';
|
|
|
+ } else if ($data[$i]->status == 2) {
|
|
|
+ $data[$i]->order_status = '作废';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已作废 </a>';
|
|
|
+ } else if ($data[$i]->status == 3) {
|
|
|
+ $data[$i]->order_status = '撤单';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已撤单 </a>';
|
|
|
+ }
|
|
|
+ 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 = '<a class="layui-btn layui-btn-sm lay-btn-diy" lay-event="detail" pid="id" uri="/admin/CheckRolling/check/?id=" href="javascript:check(\'/admin/CheckRolling/check/?id=' . $data[$i]->id . '\');"> 通过 </a><br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" style="margin-top:5px;" uri="/admin/CheckRolling/nocheck/?id=" href="javascript:nocheck(\'/admin/CheckRolling/nocheck/?id=' . $data[$i]->id . '\');"> 拒绝 </a>';
|
|
|
+ }
|
|
|
+ if ($data[$i]->roll_ratify == -1) {
|
|
|
+ $data[$i]->roll_ratify = '未通过审核';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($data[$i]->game_code == 'zq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/sportsfoot/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
|
|
|
+ }
|
|
|
+ if ($data[$i]->game_code == 'lq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
|
|
|
+ }
|
|
|
+ if ($data[$i]->game_code == 'wq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
|
|
|
+ }
|
|
|
+ if ($data[$i]->game_code == 'bq') {
|
|
|
+ $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $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 . '<br><span>' . $data[$i]->money . '</span><br>' . $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 . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
|
|
|
+ } else {
|
|
|
+ $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($data[$i]->str1 == 0) {
|
|
|
+ if ($content[$b]->result == '未处理') {
|
|
|
+ $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
|
|
|
+ } else {
|
|
|
+ $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理冠军联赛玩法详情
|
|
|
+ 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;$c<count($result);$c++){
|
|
|
+ if($content[$b]->odds_code == $result[$c]->odds_code){
|
|
|
+ $data[$i]->str1 = 1;
|
|
|
+ if($content[$b]->result=='未处理'){
|
|
|
+ $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
|
|
|
+ }else{
|
|
|
+ $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ */
|
|
|
+ if ($data[$i]->str1 == 0) {
|
|
|
+ if ($content[$b]->result == '未处理') {
|
|
|
+ $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
|
|
|
+ } else {
|
|
|
+ $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // if($data[$i]->status == 1){
|
|
|
+ // if($data[$i]->match_status == 0 || $data[$i]->match_status == 1){
|
|
|
+ // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结算 </a>';
|
|
|
+ // }
|
|
|
+ // 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.'<br><a class="layui-btn layui-btn-sm resettlement" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/resettlement/?id=" href="javascript:resettlement(\'/admin/SoccerNoteList/resettlement/?id='.$data[$i]->id.'\');"> 重新结算 </a>';
|
|
|
+ // }else{
|
|
|
+ // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm settlement" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/settlement/?id=" href="javascript:settlement(\'/admin/SoccerNoteList/settlement/?id='.$data[$i]->id.'\');"> 结算 </a>';
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }else{
|
|
|
+ // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结2算 </a>';
|
|
|
+ // }
|
|
|
+
|
|
|
+ $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;$i<count($orders);$i++){
|
|
|
+ //用户余额 默认
|
|
|
+ $available_cash = '';
|
|
|
+ for($a=0;$a<count($account_money);$a++){
|
|
|
+ if($orders[$i]['account_identity'] == $account_money[$a]['account_identity']){
|
|
|
+ $available_cash = $account_money[$a]['available_cash'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $water_return = '';
|
|
|
+ for($b=0;$b<count($water_return_money);$b++){
|
|
|
+ if($orders[$i]['order_id'] == $water_return_money[$b]['trade_id']){
|
|
|
+ $water_return = $water_return_money[$b]['money'];
|
|
|
+ } else {
|
|
|
+ $water_return = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $new_available_cash = $available_cash + $orders[$i]->money - $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]);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 滚球投注 危险球自动审核
|
|
|
+ * $match_id int 赛事id
|
|
|
+ * $warn_data arr 危险球数据
|
|
|
+ */
|
|
|
+ public static function WarnHandle($match_id=0,$warn_data=[]){
|
|
|
+
|
|
|
+ if(!empty($match_id) and !empty($warn_data)){
|
|
|
+ $db = new \App\Models\Setinfo();
|
|
|
+ //获取设定需审核时间 秒
|
|
|
+ $handle_time = $db->getInfo(1003)['infocontent']?:90;
|
|
|
+ //获取赛事下 待审核 滚球投注
|
|
|
+ $where = [
|
|
|
+ ['match_id','=',$match_id],
|
|
|
+ ['roll_ratify','=',2]
|
|
|
+ ];
|
|
|
+ $order_data = self::where($where)->SELECT('id','account_name','account_identity','order_id','money_time','roll_ratify','money','gain_money')->get()->toArray();
|
|
|
+ if(!empty($order_data)){
|
|
|
+ //获取审核不通过订单 订单号
|
|
|
+ $order_ids_n = [];
|
|
|
+ //获取审核不通过订单
|
|
|
+ $order_data_n = [];
|
|
|
+ //获取审核通过订单 订单号
|
|
|
+ $order_ids_y = [];
|
|
|
+ //获取审核未通过订单 投注人
|
|
|
+ $account_identitys = [];
|
|
|
+ foreach($order_data as $k=>$v){
|
|
|
+ //投注时间 时间戳
|
|
|
+ $order_time = strtotime($v['money_time']);
|
|
|
+ foreach($warn_data as $kk=>$vv){
|
|
|
+ //危险球时间 时间戳
|
|
|
+ $warn_time = strtotime($vv['find_time']);
|
|
|
+ if($order_time < $warn_time and ($order_time+$handle_time) > $warn_time){
|
|
|
+ $order_ids_n[] = $v['order_id'];
|
|
|
+ $account_identitys[] = $v['account_identity'];
|
|
|
+ $order_data_n[] = $v;
|
|
|
+ unset($order_data[$k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($order_data)){
|
|
|
+ foreach($order_data as $k=>$v){
|
|
|
+ $order_ids_y[] = $v['order_id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($order_ids_n)){
|
|
|
+ //在审核时间内订单 审核不通过
|
|
|
+ self::HandleMoney_v2($account_identitys,$order_ids_n,$order_data_n);
|
|
|
+ }
|
|
|
+ if(!empty($order_ids_y)){
|
|
|
+ //在审核时间外订单 审核通过
|
|
|
+ $ret_y = self::whereIn('order_id', $order_ids_y)->update(['roll_ratify' => 1,'use_mark'=>'滚球投注自动审核(危险球)通过']);
|
|
|
+ //如果更新数量小于订单数量 则返回异常
|
|
|
+ if($ret_y < count($order_ids_y)) throw new \Exception( Response::generate('',Response::HANDLE_ORDER_Y_ERR));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 滚球自动审核 账户资金处理
|
|
|
+ * v1
|
|
|
+ * 当用户下同时只有一个订单退款时 可用
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public static function HandleMoney($account_identitys=[],$order_ids=[],$orders=[]){
|
|
|
+ //用戶账户金额
|
|
|
+ $account_money = \App\Models\Account_detailed::whereIn('account_identity',$account_identitys)->SELECT('account_identity','available_cash')->get()->toArray();
|
|
|
+ //反水
|
|
|
+ $water_return_money = \App\Models\Money_details::whereIn('trade_id',$order_ids)->where('trade_type', '7')->SELECT('trade_id','money')->get()->toArray();
|
|
|
+
|
|
|
+ if(!empty($orders)){
|
|
|
+ for($i=0;$i<count($orders);$i++){
|
|
|
+ for($a=0;$a<count($account_money);$a++){
|
|
|
+ if($orders[$i]['account_identity'] == $account_money[$a]['account_identity']){
|
|
|
+ $available_cash = $account_money[$a]['available_cash'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for($b=0;$b<count($water_return_money);$b++){
|
|
|
+ if($orders[$i]['order_id'] == $water_return_money[$b]['trade_id']){
|
|
|
+ $water_return = $water_return_money[$b]['money'];
|
|
|
+ } else {
|
|
|
+ $water_return = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //需退回金额 = 投注金额-反水金额
|
|
|
+ $money = abs($orders[$i]['money'] - $water_return);
|
|
|
+ //用户剩余金额
|
|
|
+ $new_available_cash = $available_cash + $money;
|
|
|
+
|
|
|
+ $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 = $money;
|
|
|
+ $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 = '25';
|
|
|
+ $models->trade_desc = '滚球投注自动审核(危险球)不通过,退回投注资金:¥'.$money.';订单号:'.$orders[$i]['order_id'].'';
|
|
|
+ $models->status = '1';
|
|
|
+
|
|
|
+ //更新订单数据
|
|
|
+ $ret_order = self::where('id', $orders[$i]['id'])->update(['roll_ratify' => '-1','status' => '2','use_mark'=>'滚球投注自动审核(危险球)不通过']);
|
|
|
+ if($ret_order < 1) throw new \Exception( Response::generate('',Response::UP_ORDER_ERR));
|
|
|
+
|
|
|
+ //更新用户数据
|
|
|
+ $ret_user = \App\Models\Account_detailed::where('account_identity', $orders[$i]['account_identity'])->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
|
|
|
+ if($ret_user < 1) throw new \Exception( Response::generate('',Response::UP_USER_ERR));
|
|
|
+
|
|
|
+ //更新用户资金数据
|
|
|
+ if(!$models->save()) throw new \Exception( Response::generate('',Response::UP_MONEY_ERR));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 滚球自动审核 账户资金处理
|
|
|
+ * v2
|
|
|
+ * 处理一个用户下 多个注单退款时的 余额计算
|
|
|
+ */
|
|
|
+ public static function HandleMoney_v2($account_identitys=[],$order_ids=[],$orders=[]){
|
|
|
+
|
|
|
+ //获取 用户 初始余额
|
|
|
+ $account_money = \App\Models\Account_detailed::whereIn('account_identity',$account_identitys)->SELECT('account_identity','available_cash')->get()->toArray();
|
|
|
+ //获取 指定注单 反水金额
|
|
|
+ $water_return_money = \App\Models\Money_details::whereIn('trade_id',$order_ids)->where('trade_type', '7')->SELECT('trade_id','money')->get()->toArray();
|
|
|
+
|
|
|
+ if(!empty($account_money) and !empty($orders) and !empty($water_return_money)){
|
|
|
+ //拼接每个注单 反水
|
|
|
+ foreach($orders as $k=>$v){
|
|
|
+ $v['fanshui'] = self::getFanshui($v['order_id'],$water_return_money);
|
|
|
+ $orders[$k] = $v;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach($account_money as $k=>$v){
|
|
|
+ //默认 余额 0
|
|
|
+ $account_identity = 0;
|
|
|
+ foreach($orders as $kk=>$vv){
|
|
|
+ //计算当前余额
|
|
|
+ if($v['account_identity'] == $vv['account_identity']){
|
|
|
+ //第一个注单 获取用户初始余额
|
|
|
+ if($account_identity == 0){
|
|
|
+ //当前注单余额
|
|
|
+ $vv['available_cash'] = $v['available_cash'];
|
|
|
+ //当前注单退款后的余额
|
|
|
+ $account_identity = $v['available_cash']+$vv['money']-$vv['fanshui'];
|
|
|
+ }else{//其他 获取 上个注单处理后的余额
|
|
|
+ $vv['available_cash'] = $account_identity;
|
|
|
+ $account_identity = $account_identity+$vv['money']-$vv['fanshui'];
|
|
|
+ }
|
|
|
+ $orders[$kk] = $vv;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach($orders as $k=>$v){
|
|
|
+ //需退回金额 = 投注金额-反水金额
|
|
|
+ $money = abs($v['money'] - $v['fanshui']);
|
|
|
+ //用户剩余金额
|
|
|
+ $new_available_cash = $v['available_cash'] + $money;
|
|
|
+ $models = new \App\Models\Money_details();
|
|
|
+ $models->info_identity = UUID();
|
|
|
+ $models->trade_id = $v['order_id'];
|
|
|
+ $models->account_name = $v['account_name'];
|
|
|
+ $models->account_identity = $v['account_identity'];
|
|
|
+ $models->money = $money;
|
|
|
+ $models->money_time = date("Y-m-d H:i:s", time());
|
|
|
+ $models->money_type = '1';
|
|
|
+
|
|
|
+ $models->money_cash = $new_available_cash;
|
|
|
+ $models->trade_type = '25';
|
|
|
+ $models->trade_desc = '滚球投注自动审核(危险球)不通过,退回投注资金:¥'.$money.';订单号:'.$v['order_id'].'';
|
|
|
+ $models->status = '1';
|
|
|
+
|
|
|
+ //更新订单数据
|
|
|
+ $ret_order = self::where('id', $v['id'])->update(['roll_ratify' => '-1','status' => '2','use_mark'=>'滚球投注自动审核(危险球)不通过']);
|
|
|
+ if($ret_order < 1) throw new \Exception( Response::generate('',Response::UP_ORDER_ERR));
|
|
|
+
|
|
|
+ //更新用户数据
|
|
|
+ $ret_user = \App\Models\Account_detailed::where('account_identity', $v['account_identity'])->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
|
|
|
+ if($ret_user < 1) throw new \Exception( Response::generate('',Response::UP_USER_ERR));
|
|
|
+
|
|
|
+ //更新用户资金数据
|
|
|
+ if(!$models->save()) throw new \Exception( Response::generate('',Response::UP_MONEY_ERR));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取注单 反水金额
|
|
|
+ * $order_id 订单id str
|
|
|
+ * $fanshuiData 反水数据 arr
|
|
|
+ */
|
|
|
+ public static function getFanshui($order_id='',$fanshuiData=[]){
|
|
|
+ foreach($fanshuiData as $k=>$v){
|
|
|
+ if($v['trade_id'] == $order_id){
|
|
|
+ $fanshui = $v['money'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $fanshui;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|