vali 6 years ago
parent
commit
9d18f8498d

+ 34 - 2
app/Http/Model/StZqResult.php

@@ -3,8 +3,8 @@ namespace App\Http\Model;
 
 use Illuminate\Database\Eloquent\Model;
 use App\Http\Response\Response;
-//use Illuminate\Support\Facades\DB;
-use Illuminate\Database\Capsule\Manager as DB;
+use Fideloper\Proxy\TrustedProxyServiceProvider;
+use Illuminate\Support\Facades\DB;
 
 
 /**
@@ -337,6 +337,7 @@ class StZqResult extends Model
      * $match_id 本地赛事id 为0时 则用于后台手动刷新赛果 
      */
     public static function ZQresult_v2($model,$match_id = 0){
+
         //如果有赛事id 则只更新当前赛事结果
         if($match_id > 0){
             $match_ids_str = $match_id;
@@ -508,4 +509,35 @@ class StZqResult extends Model
             if ($ret_id < 1) throw new \Exception(Response::generate($opt['gameName'] . '赛事-match_id:' . $opt['match_id'] . ';', Response::SET_MATCH_ERR));
         }
     }
+
+    /**
+     * 更新赛事 危险球 数据
+     */
+    public static function set_result_warn($match_id = 0,$warn_data=[]){
+        //获取当前赛事已有危险球数据 json
+        $warn_json = self::where(['match_id' => $match_id])->SELECT('warn_more')->first()->warn_more;
+        //转数组
+        $warn_arr = json_decode($warn_json,true);
+
+        if($match_id > 0 and !empty($warn_data)){
+            $data = [];
+            foreach($warn_data as $k=>$v){
+                $data[$k]['timei'] = $v['find_time'];
+                $data[$k]['rtype'] = $v['warn_name'];
+                $data[$k]['timep'] = 90;
+
+            }
+            //合并危险球数据
+            $warn_data_new = array_merge($warn_arr,$data);
+
+            //转json
+            $warn_data = json_encode($warn_data_new);
+
+            //更新
+            $ret = self::where(['match_id' => $match_id])
+                    ->update(['warn_more'=>$warn_data,'update_time'=>date('Y-m-d H:i:s')]);
+        }
+
+        return $ret;
+    }
 }

+ 39 - 1
app/Http/Response/Response.php

@@ -62,6 +62,24 @@ class Response
     //===写赛果失败===
     const SET_MATCH_R_ERR = 10043;
 
+    //===写入危险球失败===
+    const SET_WARN_ERR = 10044;
+
+    //===滚球投注自动审核不通过处理失败===
+    const HANDLE_ORDER_N_ERR = 10045;
+
+     //===滚球投注自动审核不通过处理失败===
+     const HANDLE_ORDER_Y_ERR = 10046;
+     //===用户信息更新失败===
+     const UP_USER_ERR =10047;
+
+     //===用户资金更新失败===
+     const UP_MONEY_ERR = 10048;
+     //===订单数据更新失败===
+     const UP_ORDER_ERR = 10049;
+     //===赛事结束写入结算通知表失败===
+     const ADD_NOTICE_ERR = 10050;
+
 
 
     private static $errorMsgs = [
@@ -112,11 +130,31 @@ class Response
         self::DEL_ODDS_ERR =>'删除无效赔率失败',
 
         //===写预植赛果失败===
-        self::SET_MATCH_ERR =>'写预赛果失败',
+        self::SET_MATCH_ERR =>'写预赛果失败',
 
         //===写赛果失败===
         self::SET_MATCH_R_ERR =>'写赛果失败',
 
+        //===写危险球失败===
+        self::SET_WARN_ERR =>'写危险球失败',
+
+        //===滚球投注自动审核不通过处理失败===
+        self::HANDLE_ORDER_N_ERR =>'滚球投注自动审核不通过处理失败',
+
+         //===滚球投注自动审核通过处理失败===
+         self::HANDLE_ORDER_Y_ERR =>'滚球投注自动审核通过处理失败',
+         //===用户信息更新失败===
+         self::UP_USER_ERR =>'用户信息更新失败',
+
+         //===用户资金更新失败===
+         self::UP_MONEY_ERR =>'用户资金更新失败',
+
+         //===订单数据更新失败===
+         self::UP_ORDER_ERR =>'订单数据更新失败',
+
+         //===赛事结束写入结算通知表失败===
+         self::ADD_NOTICE_ERR=>'赛事结束写入结算通知表失败',
+
     ];
 
     public static function getMsg($code)

+ 109 - 58
app/Logic/DataLogic.php

@@ -29,6 +29,7 @@ use App\Http\Model\StZqResult as ZqResultModel;
 use App\Http\Model\St_area_country as StAreaCountryModel;
 use App\Http\Model\St_set_sports_record as St_set_sports_recordModel;
 use App\Http\Model\St_team as StTeamModel;
+use App\Models\SportsNoteList as SportsNoteListModel;
 
 class DataLogic
 {
@@ -943,15 +944,17 @@ class DataLogic
             if ($data['title'] != 'match_status') throw new \Exception(Response::generate('不是更新赛事状态数据', Response::ABNORMAL));
 
             /*
-           //写请求数据 日志记录
-           if($this->isRecord){
-               $setSportsRecord = St_set_sports_recordModel::setSportsRecord($getData['title'],$obt,$getData);
-               if($setSportsRecord < 1) throw new \Exception(Response::generate('',Response::SPORTS_RECORD_ERR));
-           }
-           */
+            //写请求数据 日志记录
+            if($this->isRecord){
+                $setSportsRecord = St_set_sports_recordModel::setSportsRecord($getData['title'],$obt,$getData);
+                if($setSportsRecord < 1) throw new \Exception(Response::generate('',Response::SPORTS_RECORD_ERR));
+            }
+            */
 
             //获取 球类代码
             $game_code = $data['game_code'];
+            //获取球类 名称
+            $gameName = gameModel::getGameName($game_code);
             //获取 数据源
             $source = $data['source'];
 
@@ -968,60 +971,46 @@ class DataLogic
                 ->whereIn('others_match_id', $others_match_ids)
                 ->get()->toArray();
             if (empty($local_match)) throw new \Exception(Response::generate('', Response::MATCHID_NULL));
-            //更新状态字段
-            if ($game_code == 'zq') {
-                foreach ($local_match as $k => $v) {
-                    foreach ($data['data'] as $kk => $vv) {
-                        if ($v['others_match_id'] == $vv['match_id']) {
-                            $set_status = [
-                                'status' => $vv['status'],
-                                'is_rollball' => $vv['is_rollball'],
-                                'is_today' => $vv['is_today'],
-                                'is_morningplate' => $vv['is_morningplate'],
-                                'is_stringscene' => $vv['is_stringscene'],
-                                'is_horn' => $vv['is_horn'],
-                                'utime' => date('Y-m-d H:i:s'),
-                            ];
-                            $ret = $model['model_match']::where(['id' => $v['match_id']])
-                                ->update($set_status);
-                            if ($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code) . '赛事-match_id:' . $v['others_match_id'], Response::UPSTATUS_ERROR));
-
-                            //===如果赛事已结束 新增 更新 赛事结果===
-                            if($vv['status'] == 2){
-                                $this->match_result($game_code, $v['match_id']);
-                            }
-                            //===end===
 
+            //取值 更新字段
+            foreach ($local_match as $k => $v) {
+                foreach ($data['data'] as $kk => $vv) {
+                    if ($v['others_match_id'] == $vv['match_id']) {
+
+                        $set_status = [
+                            'status' => $vv['status'],
+                            'is_rollball' => $vv['is_rollball'],
+                            'is_today' => $vv['is_today'],
+                            'is_morningplate' => $vv['is_morningplate'],
+                            'is_stringscene' => $vv['is_stringscene'],
+                            'utime' => date('Y-m-d H:i:s'),
+                        ];
+
+                        //如果是足球 追加角球状态
+                        if ($game_code == 'zq') {
+                            $set_status['is_horn'] = $vv['is_horn'];
                         }
-                    }
-                }
-            } else {
-                foreach ($local_match as $k => $v) {
-                    foreach ($data['data'] as $kk => $vv) {
-                        if ($v['others_match_id'] == $vv['match_id']) {
-                            $set_status = [
-                                'status' => $vv['status'],
-                                'is_rollball' => $vv['is_rollball'],
-                                'is_today' => $vv['is_today'],
-                                'is_morningplate' => $vv['is_morningplate'],
-                                'is_stringscene' => $vv['is_stringscene'],
-                                'utime' => date('Y-m-d H:i:s'),
-                            ];
-                            $ret = $model['model_match']::where(['id' => $v['match_id']])
-                                ->update($set_status);
-                            if ($ret < 1) throw new \Exception(Response::generate(gameModel::getGameName($game_code) . '赛事-match_id:' . $v['others_match_id'], Response::UPSTATUS_ERROR));
-
-                            //===如果赛事已结束 新增 更新 赛事结果===
-                            if($vv['status'] == 2){
-                                $this->match_result($game_code, $v['match_id']);
-                            }
-                            //===end===
-
+                        $ret = $model['model_match']::where(['id' => $v['match_id']])
+                            ->update($set_status);
+                        if ($ret < 1) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $v['others_match_id'], Response::UPSTATUS_ERROR));
+
+                        //===如果赛事已结束===
+                        if ($vv['status'] == 2) {
+                            // 新增 更新 赛事结果
+                            $this->match_result($game_code, $v['match_id']);
+                            //获取赛事开始时间
+                            $game_start_time = $model['model_result']::where(['match_id' => $v['match_id']])->first()->start_time;
+                            // 写入结算通知表 用于自动结算
+                            $Comendnotice = new \App\Models\Comendnotice();
+                            $ret_add = $Comendnotice->addcomendnotice($v['match_id'], $game_code, 0, $game_start_time);
+                            if ($ret_add != 1) throw new \Exception(Response::generate($gameName . '赛事-match_id:' . $v['others_match_id'], Response::ADD_NOTICE_ERR));
                         }
+                        //===end===
                     }
                 }
             }
 
+
             $this->writeLog($sdata, Response::success());
             //提交事务
             DB::commit();
@@ -1403,6 +1392,68 @@ class DataLogic
         }
     }
 
+    /**
+     * 写赛事危险球数据
+     */
+    public function setMatchWarn($data)
+    {
+
+        try {
+            //开启事务
+            DB::beginTransaction();
+            $obt = $data['data'];
+
+
+            //请求 数据 为空
+            if (empty($obt)) throw new \Exception(Response::generate('请求数据为空,', Response::ABNORMAL));
+            $getData = $this->getAddData($obt);
+
+            //不是 赛事 危险球 数据
+            if ($getData['title'] != 'match_warn') throw new \Exception(Response::generate('不是危险球数据,', Response::ABNORMAL));
+
+            //获取球类代码
+            $game_code = $getData['game_code'];
+            //获取数据源
+            $source = $getData['source'];
+            //获取数据源赛事id
+            $others_match_id = $getData['match_id'];
+            //获取球类名称
+            $gameName = gameModel::getGameName($game_code);
+            //获取 model
+            $models = commonFunction::getModels($game_code, 1);
+            //获取 赛事 数据
+            $warn_data = $getData['data'];
+
+            //获取赛事 match_id
+            $match_id = $models['model_local_match']::SELECT('others_match_id', 'match_id')
+                ->where(['source' => $source, 'others_match_id' => $others_match_id])
+                ->first()->match_id;
+
+            if (!empty($match_id)) {
+                //更新 危险球
+                $ret = ZqResultModel::set_result_warn($match_id, $warn_data);
+                if ($ret < 1) throw new \Exception(Response::generate('', Response::SET_WARN_ERR));
+
+                //追加 滚球投注 危险球审核
+                SportsNoteListModel::WarnHandle($match_id, $warn_data);
+
+            }
+
+            //提交事务
+            DB::commit();
+            //写请求数据 日志记录
+            $this->writeLog($data, Response::success());
+            return Response::success();
+        } catch (\Exception $e) {
+            //回滚事务
+            DB::rollBack();
+            //写请求数据 日志记录
+            if ($this->isRecord) commonFunction::SET_SPORTS_RECORD($game_code, $getData, $getData['title'], $e->getMessage());
+            return $e->getMessage();
+        }
+    }
+
+
     /*
      * 验证所属 联赛 是否存在
      */
@@ -1455,13 +1506,13 @@ class DataLogic
     /*
      * 写入 赛事 初始 结果
      */
-    public function match_result($game_code = '',$match_id = 0)
+    public function match_result($game_code = '', $match_id = 0)
     {
         $model = commonFunction::getModels($game_code, 1);
-        if ($game_code == 'zq') ZqResultModel::ZQresult_v2($model,$match_id);
-        if ($game_code == 'lq') LqResultModel::LQresult_v2($model,$match_id);
-        if ($game_code == 'wq') WqResultModel::WQresult_v2($model,$match_id);
-        if ($game_code == 'bq') BqResultModel::BQresult_v2($model,$match_id);
+        if ($game_code == 'zq') ZqResultModel::ZQresult_v2($model, $match_id);
+        if ($game_code == 'lq') LqResultModel::LQresult_v2($model, $match_id);
+        if ($game_code == 'wq') WqResultModel::WQresult_v2($model, $match_id);
+        if ($game_code == 'bq') BqResultModel::BQresult_v2($model, $match_id);
     }
 
     /*

+ 129 - 0
app/Models/Account_detailed.php

@@ -0,0 +1,129 @@
+<?php
+
+namespace App\Models;
+use Illuminate\Support\Facades\DB;
+
+/**
+ *
+ * @property mixed account_identity
+ */
+class Account_detailed extends BaseModel {
+	protected $table = "account_detailed";
+	public $timestamps = false;
+	//由identity获取用户信息
+	function getInfoBy($u_id) {
+		$data = $this->where('account_identity', $u_id)->first();
+		if (!$data) {
+			return -5040012022;
+		}
+		return $data->toArray();
+	}
+	protected function getInfoBys($u_id){
+	    return $this->getInfoBy($u_id);
+    }
+	
+	function getUinfo(){
+		DB::connection()->enableQueryLog();
+		$data = $this->select('account_identity')->whereNull('register_url')->limit(1000)->offset(0)->get();
+		// $queries = DB::getQueryLog();
+		// print_r($queries);
+		if (!$data) {
+			return -5040012022;
+		}
+		return $data->toArray();
+	}
+	
+	function updateInfo($data, $uid) {
+		$res = $this->where('account_identity', $uid)->update($data);
+		if (!$res) {
+			return -5040012022;
+		}
+		return 1;
+	}
+	function updateInfos($data, $id) {
+		$res = $this->where('id', $id)->update($data);
+		if (!$res) {
+			return -7010101202; //更新失败
+		}
+		return 1;
+	}
+	function addMoney($account_id,$money){
+	    $res1=$this->where('account_identity',$account_id)->increment('available_cash',$money);
+	    if(!$res1){
+            return -5040022022;//增加约失败
+        }
+	    $res2=$this->where('account_identity',$account_id)->increment('cash',$money);
+	    if(!$res2){
+            return -5040022022;//增加约失败
+        }
+        return 1;
+    }
+    function costMoney($account_id,$money){
+        $res1=$this->where('account_identity',$account_id)->decrement('available_cash',$money);
+        if(!$res1){
+            return -5040022022;//增加约失败
+        }
+        $res2=$this->where('account_identity',$account_id)->decrement('cash',$money);
+        if(!$res2){
+            return -5040022022;//增加约失败
+        }
+        return 1;
+    }
+
+    //统计在线用户
+    function getOnlineUser(){
+        $time=time();
+        $timeZone=[date('Y-m-d H:i:s',$time-300),date('Y-m-d H:i:s')];
+        $data=$this->select(DB::Raw('count(id) as value,last_url as name'))
+            ->where('statuss',1)->whereNotNull('last_url')
+            //->whereBetween('last_time',$timeZone)
+            ->groupBy('last_url')
+            ->get();
+        if(!$data){
+            return -2020032103;
+        }
+        return $data->toArray();
+    }
+    function getCashArray($id_array){
+        $data=$this->whereIn('account_identity',$id_array)->get();
+        if(!$data){
+            return -5040012522;
+        }
+        $data=$data->toArray();
+        $account_cash_array=array();
+        foreach ($data as $k=>$v){
+            $account_cash_array[$v['account_identity']]=$v['cash'];
+        }
+        return $account_cash_array;
+    }
+
+    //在线
+    function Accountas($where){
+        if (!empty($where)){
+            $data=$this->rightJoin('account','account.identity',$this->table.'.account_identity')
+                ->where('account_detailed'.'.'.'statuss',$where);
+            $data=$data ->paginate();
+        }else{
+            $data=$this->rightJoin('account','account.identity',$this->table.'.account_identity');
+            $data=$data ->paginate();
+        }
+
+        if (!$data){
+            return -502030154202;
+        }
+        return $data->toArray();
+    }
+    //改变会员标签至1
+    protected function changeToleve($group_codes,$data){
+//        DB::connection()->enableQueryLog();
+        $res=$this->where('group_code','like',"%{$group_codes}%")->update($data);
+//         $queries = DB::getQueryLog();
+//         print_r($queries);exit;
+
+        return 1;
+    }
+
+
+}
+
+?>

+ 96 - 0
app/Models/MoneyBuyMatch.php

@@ -0,0 +1,96 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: scstf
+ * Date: 2018/9/28
+ * Time: 20:05
+ */
+
+namespace App\Models;
+
+use Illuminate\Support\Facades\DB;
+use Illuminate\Database\Eloquent\Model;
+
+class MoneyBuyMatch extends Model
+{
+    protected $table = 'money_buy_match';
+    public $timestamps = false;
+
+    public function getByAttrs($where, $orderArray = [])
+    {
+        if (empty($order)) {
+            $datas = $this->where($where)->get();
+        } else {
+            $datas = $this->where($where)->orderby($orderArray['orderby'], $orderArray['order'])->get();
+        }
+        return $datas;
+    }
+
+    //赛事下所有下注单式下单
+    function allsimplexorder($ssid, $code)
+    {
+        //单式下单
+        $where = array();
+        $where[] = array('money_buy_match.match_id', '=', $ssid);
+        $where[] = array('money_buy_match.bet_type', '=', 1);
+        $where[] = array('money_buy_match.game_code', '=', $code);
+        $data = $this->join('money_buy_simplex', 'money_buy_match.batch_id', '=', 'money_buy_simplex.batch_id')->select('money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.account_identity', 'money_buy_simplex.info_identity', 'money_buy_simplex.match_id')->where($where)->get()->toArray();
+        return $data;
+    }
+
+    //赛事下所有下注串式下单
+    function allstrorder($ssid)
+    {
+        //串式下单
+        $where = array();
+        $where[] = array('money_buy_match.match_id', '=', $ssid);
+        $where[] = array('money_buy_match.bet_type', '=', 2);
+        $data = $this->join('money_buy_str', 'money_buy_match.batch_id', '=', 'money_buy_str.batch_id')->select('money_buy_str.order_id')->where($where)->distinct('money_buy_match.batch_id')->get()->toArray();
+        return $data;
+    }
+
+    //修改串式下注状态
+    function updatast($match_id)
+    {
+        $the = array(
+            'updated_at' => date('Y-m-d H:i:s'),
+            'result' => 2,
+        );
+        $where = array(
+            'match_id' => $match_id,
+            'bet_type' => 2,
+        );
+
+        $res = $this->where($where)->update($the);
+
+        if (!$res) {
+            return -4010000102; //更新失败
+        }
+        return $res;
+    }
+
+    //某个赛事的单式和串式条数统计
+    public function countByMatch($matchID)
+    {
+        $matchID = intval($matchID);
+
+        $sqla = "select count(id) as mcount from  money_buy_match where match_id=$matchID and  bet_type=1 and   order_id in( select order_id from  money_buy_simplex where match_id=$matchID and is_manual=0 )";
+        $sqlb = "select count(id) as mcount from  money_buy_match where match_id=$matchID and  bet_type=2 ";
+
+        $reta = DB::select($sqla);
+        $retb = DB::select($sqlb);
+
+        $ret1 = $ret2 = 0;
+        if ($reta && isset($reta['0']->mcount)) {
+            $ret1 = intval($reta['0']->mcount);
+        }
+
+        if ($retb && isset($retb['0']->mcount)) {
+            $ret2 = intval($retb['0']->mcount);
+        }
+
+        return ['bet1' => $ret1, 'bet2' => $ret2, 'count' => $ret1 + $ret2];
+    }
+
+
+}

+ 322 - 0
app/Models/MoneyBuyStr.php

@@ -0,0 +1,322 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jonlin
+ * Date: 2019/4/9
+ * Time: 9:18
+ */
+namespace App\Models;
+use Illuminate\Support\Facades\DB;
+class MoneyBuyStr extends BaseModel {
+    protected $table = "money_buy_str";
+    public $timestamps = false;
+
+    function getinfo($list = 10, $page = 1, $where = [],$ids=[])
+    {
+      
+        /*
+        if (is_array ($where) && count ($where) > 0) {
+            $data = $this
+                ->join('money_details','money_details.info_identity','=','money_buy_str.info_identity')
+                ->select('money_buy_str.id','money_buy_str.account_name','money_buy_str.account_identity','money_buy_str.order_id','money_buy_str.str_type','money_buy_str.money','money_buy_str.prize_money','money_buy_str.status','money_buy_str.money_time','money_buy_str.settle_status','money_buy_str.game_status','money_buy_str.gain_money','money_details.money_cash','money_buy_str.batch_id')
+                ->where($where)
+                ->wherein('money_buy_str.order_id',$ids)
+                ->orderby('money_buy_str.money_time','desc')
+                ->paginate ($list);
+        } else {
+            $data = $this
+                ->join('money_details','money_details.info_identity','=','money_buy_str.info_identity')
+                ->select('money_buy_str.id','money_buy_str.account_name','money_buy_str.account_identity','money_buy_str.order_id','money_buy_str.str_type','money_buy_str.money','money_buy_str.prize_money','money_buy_str.status','money_buy_str.money_time','money_buy_str.settle_status','money_buy_str.game_status','money_buy_str.gain_money','money_details.money_cash','money_buy_str.batch_id')
+                ->wherein('money_buy_str.order_id',$ids)
+                ->orderby('money_buy_str.money_time','desc')
+                ->paginate ($list);
+        }
+        */
+
+        //如果$ids 有值,则为查询指定赛事注单
+        if(!empty($ids)){
+            $data = $this
+                ->join('money_details','money_details.info_identity','=','money_buy_str.info_identity')
+                ->select('money_buy_str.id','money_buy_str.account_name','money_buy_str.account_identity','money_buy_str.order_id','money_buy_str.str_type','money_buy_str.money','money_buy_str.prize_money','money_buy_str.status','money_buy_str.money_time','money_buy_str.settle_status','money_buy_str.game_status','money_buy_str.gain_money','money_details.money_cash','money_buy_str.batch_id')
+                ->where($where)
+                ->wherein('money_buy_str.order_id',$ids)
+                ->orderby('money_buy_str.money_time','desc')
+                ->paginate ($list);
+        }else{
+            $data = $this
+                ->join('money_details','money_details.info_identity','=','money_buy_str.info_identity')
+                ->select('money_buy_str.id','money_buy_str.account_name','money_buy_str.account_identity','money_buy_str.order_id','money_buy_str.str_type','money_buy_str.money','money_buy_str.prize_money','money_buy_str.status','money_buy_str.money_time','money_buy_str.settle_status','money_buy_str.game_status','money_buy_str.gain_money','money_details.money_cash','money_buy_str.batch_id')
+                ->where($where)
+                ->orderby('money_buy_str.money_time','desc')
+                ->paginate ($list);
+        }
+
+
+
+        if (!$data < 0) {
+            return -2021052003; //
+        }
+
+        //足球赛事
+        $zqmatch =  \App\Models\SportsSoccer::where('status','<>','4')->where('status','<>','6')->get();
+        //篮球赛事
+        $lqmatch =  \App\Models\SportsBasket::where('status','<>','4')->where('status','<>','6')->get();
+        //网球赛事
+        $wqmatch =  \App\Models\SportsTennis::where('status','<>','4')->where('status','<>','6')->get();
+        //棒球赛事
+        $bqmatch =  \App\Models\SportsBase::where('status','<>','4')->where('status','<>','6')->get();
+
+        //反水
+        $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','2')->get();
+        for($c=0;$c<count($content);$c++){
+            if($content[$c]->game_code == 'zq'){
+                for($d=0;$d<count($zqmatch);$d++){
+                    if($content[$c]->match_id == $zqmatch[$d]->id){
+                        $content[$c]->match_status = $zqmatch[$d]->status;
+                    }
+                }
+            }
+            if($content[$c]->game_code == 'lq'){
+                for($d=0;$d<count($lqmatch);$d++){
+                    if($content[$c]->match_id == $zqmatch[$d]->id){
+                        $content[$c]->match_status = $zqmatch[$d]->status;
+                    }
+                }
+            }
+            if($content[$c]->game_code == 'wq'){
+                for($d=0;$d<count($wqmatch);$d++){
+                    if($content[$c]->match_id == $zqmatch[$d]->id){
+                        $content[$c]->match_status = $zqmatch[$d]->status;
+                    }
+                }
+            }
+            if($content[$c]->game_code == 'bq'){
+                for($d=0;$d<count($bqmatch);$d++){
+                    if($content[$c]->match_id == $zqmatch[$d]->id){
+                        $content[$c]->match_status = $zqmatch[$d]->status;
+                    }
+                }
+            }
+        }
+
+        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/SoccerStringNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerStringNoteList/invalid/?id='.$data[$i]->id.'\',\''.$data[$i]->order_id.'\');"> 作废 </a>';
+            }else if($data[$i]->status==1 && $data[$i]->settle_status==2){
+                $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 if($data[$i]->game_status==1){
+                $data[$i]->game_status = '中奖';
+            }else if($data[$i]->game_status==2){
+                $data[$i]->game_status = '未中奖';
+            }
+
+            //$str_type = str_replace('*', '串', $data[$i]->str_type);
+            $mun = explode('串',$data[$i]->str_type);
+            $data[$i]->detail_content = $data[$i]->settle_status.':'.$mun[0].' [<a class="detail" lay-event="detail" pid="id" uri="/admin/SoccerStringNoteList/detail/?id=" href="/admin/SoccerStringNoteList/detail/?id='.$data[$i]->id.'"> 详情 </a>]';
+            $data[$i]->str_type = $data[$i]->str_type.'<br>(<span>'.$data[$i]->account_name.'</span>)';
+
+            //反水
+            $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]->money_time = '下注:'.$data[$i]->money_time;
+            //用户投注前账户金额
+            $data[$i]->available_cash = $data[$i]->money_cash+$data[$i]->money;
+            $data[$i]->account_money = $data[$i]->available_cash.' <span>'.$data[$i]->money.' </span> '.$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]->settle_status = $data[$i]->settle_status;
+
+            // if($data[$i]->status == 1){
+            //     if($data[$i]->settle_status == '未结算'){
+            //         $match_status = array();
+            //         for($j=0;$j<count($content);$j++){
+            //             if($data[$i]->batch_id == $content[$j]->batch_id){
+            //                 $match_status[] = $content[$j]->match_status;
+            //             }
+            //         }
+            //         if(in_array(0,$match_status) || in_array(1,$match_status)){
+            //             $data[$i]->settle_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm resettlement settlement" lay-event="detail" pid="id" lay-filter = "resettlement" uri="" href="javascript:void(0)" style="background-color: grey;"> 结算 </a>';
+            //         }else{
+            //             $data[$i]->settle_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm settlement" lay-event="detail" pid="id" lay-filter = "resettlement" uri="/admin/SoccerStringNoteList/settlement/?id=" href="javascript:settlement(\'/admin/SoccerStringNoteList/settlement/?id='.$data[$i]->id.'\');"> 结算 </a>';
+            //         }
+
+            //     }else if($data[$i]->settle_status == '已结算'){
+            //         $data[$i]->settle_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm settlement" lay-event="detail" pid="id" lay-filter = "resettlement" uri="/admin/SoccerStringNoteList/resettlement/?id=" href="javascript:resettlement(\'/admin/SoccerStringNoteList/resettlement/?id='.$data[$i]->id.'\');">重新结算 </a>';
+            //     }
+            // }else{
+            //     $data[$i]->settle_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm resettlement settlement" lay-event="detail" pid="id" lay-filter = "resettlement" uri="" href="javascript:void(0)" style="background-color: grey;"> 结算 </a>';
+            // }
+        }
+        return $data->toArray();
+
+    }
+
+    //投注金额汇总统计
+    function MoneyCount($where = '') {
+        $data = array();
+        $data['all_money'] = $this->where('status','1')->sum('money');
+        $data['all_prize_money'] = $this->where('status','1')->sum('prize_money');
+        $data['alraedy_prize_money'] = $this->where('settle_status','2')->where('status','1')->sum('gain_money');
+        if (!empty($where) && is_array($where)) {
+            $data['all_money'] = $this->where($where)->where('status','1')->sum('money');
+            $data['all_prize_money'] = $this->where($where)->where('status','1')->sum('prize_money');
+            $data['alraedy_prize_money'] = $this->where($where)->where('settle_status','2')->where('status','1')->sum('gain_money');
+        }
+
+        return $data;
+    }
+
+    //获取串关注单详情信息
+    function getdetailinfo($id) {
+        $res = $this->where('id',$id)->first();
+        $data = \App\Models\MoneyBuyMatch::where('batch_id',$res->batch_id)->where('bet_type','2')->get();
+        $game_type = \App\Models\StGameType::get();
+        $odds_code = \App\Models\Matchcode::get();
+        for($i=0;$i<count($data);$i++){
+
+            //当父级玩法代码为first_last_ball/half_full/capot/two_sides时,不显示赔率条件
+            if($data[$i]->p_code == 'first_last_ball' || $data[$i]->p_code == 'half_full' || $data[$i]->p_code == 'capot' || $data[$i]->p_code == 'two_sides' || $data[$i]->p_code == 'total_goal'){
+                $data[$i]->condition = '';
+            }
+            
+            $league = DB::table('st_'.$data[$i]->game_code.'_league')->join('st_'.$data[$i]->game_code.'_competition','st_'.$data[$i]->game_code.'_competition.lg_id','=','st_'.$data[$i]->game_code.'_league.id')->where('st_'.$data[$i]->game_code.'_league.id',$data[$i]->lg_id)->where('st_'.$data[$i]->game_code.'_competition.id',$data[$i]->match_id)->first();
+            if(!empty($league)){
+                //联赛名称
+                $data[$i]->league = $league->name_chinese;
+                //赛事开赛时间
+                $data[$i]->time = $league->match_date.' '.$league->match_time;
+            }
+
+            if(!empty(strstr($data[$i]->odds_code,'home',true))){
+                $data[$i]->team = $data[$i]->home_team;
+            }
+            if(!empty(strstr($data[$i]->odds_code,'guest',true))){
+                $data[$i]->team = $data[$i]->guest_team;
+            }
+
+            if($data[$i]->p_code == 'half_full'){
+                $string = str_replace('home',$data[$i]->home_team,$data[$i]->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'];
+            }
+
+            for($j=0;$j<count($odds_code);$j++){
+                if($data[$i]->game_code == $odds_code[$j]->game_code && $data[$i]->odds_code == $odds_code[$j]->odds_code){
+                    $data[$i]->odds_code = $odds_code[$j]->odds_name;
+                }
+                if($data[$i]->game_code == $odds_code[$j]->game_code && $data[$i]->p_code == $odds_code[$j]->odds_code){
+                    $data[$i]->p_code = $odds_code[$j]->odds_name;
+                }
+            }
+
+            $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
+            $data[$i]->content = $data[$i]->p_code.'<br><span>'.$data[$i]->odds_code.$data[$i]->condition.'<br>'.$data[$i]->team.' @'.$data[$i]->odds.'</span>';
+
+            for($j=0;$j<count($game_type);$j++){
+                if($data[$i]->game_code == $game_type[$j]->game_code){
+                    $data[$i]->game_type = $game_type[$j]->game_name;
+                }
+            }
+
+            if($league->status == 0){
+                $data[$i]->status = '未开始';
+            }else if($league->status == 1){
+                $data[$i]->status = '正在进行';
+            }else if($league->status == 2){
+                $data[$i]->status = '已结束';
+            }else if($league->status == 3){
+                $data[$i]->status = '已结算';
+            }else if($league->status == 4){
+                $data[$i]->status = '已作废';
+            }else if($league->status == 5){
+                $data[$i]->status = '未结算';
+            }else if($league->status == 6){
+                $data[$i]->status = '已取消';
+            }
+
+            if($data[$i]->result == -1){
+                $data[$i]->result = '输';
+            }else if($data[$i]->result == 0){
+                $data[$i]->result = '未处理';
+            }else if($data[$i]->result == 1){
+                $data[$i]->result = '赢';
+            }else if($data[$i]->result == 2){
+                $data[$i]->result = '平';
+            }else if($data[$i]->result == 3){
+                $data[$i]->result = '赢半平半';
+            }else if($data[$i]->result == 4){
+                $data[$i]->result = '输半平半';
+            }
+
+            if($data[$i]->result != '未处理'){
+                $data[$i]->result = $data[$i]->result.'<br>('.$data[$i]->matchresult.')';
+            }
+        }
+        return $data->toArray();
+    }
+
+    //串式撤单修改状态
+    function updatestatus($data){
+        if($data){
+            for ($i=0; $i < count($data); $i++) { 
+                $the = array(
+                    'status' => 2,
+                );
+                $res = $this->where('order_id',$data[$i])->update($the);
+            }
+            if (!$res) {
+                return -4010000102; //更新失败
+            }
+            return $res;
+        }
+    }
+
+
+}

+ 462 - 0
app/Models/Money_details.php

@@ -0,0 +1,462 @@
+<?php
+namespace App\Models;
+use Illuminate\Support\Facades\DB;
+
+class Money_details extends BaseModel {
+	protected $table = "money_details";
+	public $timestamps = false;
+
+	//获取存取反水列表
+	function getPartlist($value = '', $type = 1, $page = 10, $sort = 1, $ads = 'desc') {
+//       DB::connection()->enableQueryLog();
+		$key = $this->getFeild($type);
+		$sort = is_integer($sort) ? $this->getFeild($sort) : $sort;
+
+		$data = $this->select('money_details.id', 'money_details.trade_id', 'money_details.account_name', 'money_details.account_identity', 'money_details.money', 'money_details.money_time', 'money_details.money_type', 'money_details.money_cash', 'money_details.trade_type', 'money_details.trade_desc', 'money_details.reason', 'money_details.sysetem_user','money_details.status','money_recharge.remark')->leftJoin('money_recharge', 'money_recharge.order_id', '=', 'money_details.trade_id')->whereIn('trade_type', [5, 6, 7, 8, 9, 11, 12, 13, 14, 15,16,19,22]);
+		if (is_array($value)) {
+			$data = $data->where($value);
+		} else {
+			$data = $data->where($key, $value);
+		}
+
+		$data = $data->orderby($sort, $ads)->paginate($page);
+//        $queries = DB::getQueryLog();
+
+//        print_r($queries);
+		if (!$data) {
+			return -3021000102; //没有列表数据
+		}
+		return $data->toArray();
+	}
+
+	//获取资金流水列表
+	function getMoneylist($value = '', $type = 1, $page = 10, $sort = 6, $ads = 'desc') {
+		$key = $this->getFeild($type);
+		$sort = is_integer($sort) ? $this->getFeild($sort) : $sort;
+		//DB::connection()->enableQueryLog();
+		if (is_array($value)) {
+			$data = $this->where($value);
+		} else {
+			$data = $this->where($key, $value);
+		}
+		$data = $data->select('money_details.id', 'money_details.trade_id', 'money_details.account_name', 'money_details.account_identity', 'money_details.money', 'money_details.money_time', 'money_details.money_type', 'money_details.money_cash', 'money_details.trade_type', 'money_details.trade_desc', 'money_details.reason', 'money_details.sysetem_user','money_details.status','money_recharge.remark')->leftJoin('money_recharge', 'money_recharge.order_id', '=', 'money_details.trade_id')->orderby($sort, $ads)->orderby('money_details.id',$ads)->paginate($page);
+		//$queries = DB::getQueryLog();
+		//print_r($queries);
+		if (!$data) {
+			return -3021000102; //没有列表数据
+		}
+		return $data->toArray();
+	}
+
+	//用户提现笔数区间筛选
+	function getTakenumArea($where = '', $type = 1, $list = 10, $sort = 6, $ads = 'desc', $page = 1, $having = '', $whereIn = '') {
+		//DB::connection()->enableQueryLog();
+		$data = $this->select(DB::raw('max(account.id) as id, max(account.identity) as identity, max(account) as account, max(grade) as grade, max(cash) as cash, max(name) as name, max(register_time) as register_time, max(register_ip) as register_ip, max(last_ip) as last_ip, max(phone) as phone, max(email) as email, max(statuss) as statuss,max(last_time) as last_time,count("trade_id") as betnum'))->join('account_detailed', 'money_details.account_identity', '=', 'account_detailed.account_identity')->join('account', 'money_details.account_identity', 'account.identity')->groupBy('money_details.account_identity')->whereIn('trade_type', $whereIn)->where('money_details.status', 1);
+
+		if (!empty($where) && is_array($where) && !empty($having) && is_array($having)) {
+			$data = $data->where($where);
+			foreach ($having as $v) {
+				$data = $data->havingRaw($v);
+			}
+		} elseif (!empty($having) && is_array($having)) {
+			foreach ($having as $v) {
+				$data = $data->havingRaw($v);
+			}
+		} elseif (!empty($where) && is_array($where)) {
+			$data = $data->where($where);
+		}
+
+		$data = $data->paginate($list);
+		//$queries = DB::getQueryLog();
+		//print_r($queries);
+		if (!$data) {
+			return -3020100402; //没有订单统计信息
+		}
+		$data = $data->toArray();
+
+		return $data;
+	}
+
+	//统计会员财务日志
+	function getFundlog($value = '', $type = 1, $limit = 10, $sort = 6, $ads = 'desc',$page=1) {
+		$key = $this->getFeild($type);
+		$sort = is_integer($sort) ? $this->getFeild($sort) : $sort;
+		//DB::connection()->enableQueryLog();
+		$value .= empty($value)?' where ':' and ';
+		$value .= 'status=1 ';
+		$offset = ($page-1)*$limit;
+		$sql = 'SELECT main.account_name,SUM(CASE WHEN trade_type=14 THEN money ELSE 0 END) as sendmoney,
+		SUM(CASE WHEN trade_type=6 OR trade_type=11 THEN money ELSE 0 END) as savemoney,
+		SUM(CASE WHEN trade_type=5 OR trade_type=9 THEN money ELSE 0 END) as getmoney,
+		SUM(CASE WHEN trade_type=12 AND money_type=1 THEN money ELSE 0 END) as adminadd,
+		SUM(CASE WHEN trade_type=12 AND trade_type=2 THEN money ELSE 0 END) as adminpull,
+		SUM(CASE WHEN trade_type=13 THEN money ELSE 0 END) as recharge_send,
+		SUM(CASE WHEN trade_type=7 OR trade_type=8 THEN money ELSE 0 END) as back_return,
+		(SUM(CASE WHEN trade_type=14 OR trade_type=6 OR trade_type=11 THEN money ELSE 0 END)-
+		SUM(CASE WHEN trade_type=5 OR trade_type=9 THEN money ELSE 0 END)) as winmoney 
+		from money_details as main '.$value.' GROUP BY main.account_name LIMIT '.$limit.' OFFSET '.$offset;
+		$countsql = 'SELECT COUNT(account_name) from (SELECT account_name from money_details '.$value.'  GROUP BY account_name) as a';
+		$data = DB::select($sql);
+		$count = DB::select($countsql);
+		//$queries = DB::getQueryLog();
+		//print_r($queries);
+		if (!$data) {
+			return -3021000502; //没有列表数据
+		}
+		$data = json_encode($data);
+		$data = json_decode($data,1);
+		$resdata['data'] = $data;
+		$resdata['total'] = $count[0]->count;
+		return $resdata;
+
+		/*$data = $this->select(DB::raw('account_name,MAX("account_identity") as account_identity'))->groupBy('account_name');
+
+		if (is_array($value)) {
+			$data = $data->where($value);
+		} else if (!empty($value)) {
+			$data = $data->where($key, $value);
+		}
+		if (!empty($whereIn) && is_array($whereIn)) {
+			foreach ($whereIn as $k => $v) {
+				$data = $data->whereIn($v[0], $v[1]);
+			}
+		}
+		if (!empty($whereNotin) && is_array($whereNotin)) {
+			foreach ($whereNotin as $k => $v) {
+				$data = $data->whereNotIn($v[0], $v[1]);
+			}
+		}
+		$data = $data->paginate($page);
+		//$queries = DB::getQueryLog();
+		//print_r($queries);
+		if (!$data) {
+			return -3021000102; //没有列表数据
+		}
+		return $data->toArray();*/
+	}
+
+	//分类统计会员财务
+	function getPartlog($value = '', $type = 1) {
+		$key = $this->getFeild($type);
+		$data = $this->select(DB::raw('trade_type,SUM("money") as summoney,money_type'))->groupBy('trade_type')->groupBy('money_type');
+
+		if (is_array($value)) {
+			$data = $data->where($value);
+		} else if (!empty($value)) {
+			$data = $data->where($key, $value);
+		}
+
+		$data = $data->get();
+		//$queries = DB::getQueryLog();
+		//print_r($queries);
+		if (!$data) {
+			return -3021000102; //没有列表数据
+		}
+		return $data->toArray();
+	}
+    //分类统计会员财务改
+	function getPatlog($where){
+        $data = $this->select(DB::raw('trade_type,sum("money") as summoney,money_type,account_name'))
+            ->where($where)
+            ->groupBy('trade_type')
+            ->groupBy('money_type')
+            ->groupBy('account_name')
+            ->get();
+        if (!$data) {
+            return -3021000102; //没有列表数据
+        }
+        return $data->toArray();
+    }
+
+	//获取账务订单详情
+	function getOrderDetails($value, $type = 1, $jointable = '', $columnn = '', $columnw = '') {
+		$key = $this->getFeild($type);
+		if (empty($jointable)) {
+			$data = $this->where($key, $value)->first();
+		} elseif ($jointable == 'account_bank') {
+			$data = $this->select('money_details.account_name as account', 'trade_id', 'bank_name', 'account_bank.account_name', 'bank_number', 'bank_address', 'money_time', 'money', 'money_details.status', 'trade_type', 'reason')->where($key, $value)->join($jointable, $this->table . '.' . $columnn, $jointable . '.' . $columnw)->first();
+		} else {
+			$data = $this->where($key, $value)->join($jointable, $this->table . '.' . $columnn, $jointable . '.' . $columnw)->first();
+		}
+
+		if (!$data) {
+			return -3021000402; //没有订单信息
+		}
+		return $data->toArray();
+	}
+	//获取游戏倍率
+	function getOddsBy($game_code) {
+		$data = $this->select('odds')->where('game_code', $game_code)->where('type', 2)->where('isparent_node', 1)->get();
+		$data = $data->toArray();
+		if (!$data) {
+			return -8010011001; //没有倍率
+		}
+		$redata = array();
+		//组合游戏项的倍率
+		foreach ($data as $k => $v) {
+			$redata = array_merge($redata, json_decode($v['odds'], 1));
+		}
+		return $redata;
+	}
+
+	//获取号码信息
+	function getInfoByCode($code) {
+		$data = $this->where('parent', $code)->get();
+		if (!$data) {
+			return -8020000501; //没有游戏玩法的号码
+		}
+		return $data->toArray();
+	}
+	//字段对应值
+	private function getFeild($num) {
+		$data = array(
+			'1' => 'id',
+			'2' => 'info_identity',
+			'3' => 'trade_id',
+			'4' => 'account_name',
+			'5' => 'account_identity',
+			'6' => 'money_time',
+			'7' => 'money_type',
+			'8' => 'trade_type',
+			'9' => 'sysetem_user',
+			'10' => 'status',
+		);
+		return $data[$num];
+	}
+
+	function updateInfo($data,$value,$field=1){
+		$key = $this->getFeild($field);
+		$res = $this->where($key,$value)->update($data);
+		if($res<0){
+			return -3021010102;	//更新失败
+		}
+		return 1;
+	}
+
+	function money($page, $identity, $status) {
+		$data = $this->select('account_identity', 'money_type', 'money_time', 'trade_id', 'trade_type', 'money', 'money_cash', 'trade_desc', 'status')
+			->orderBy('money_time', 'desc')
+			->where('account_identity', $identity)
+			->limit($page)
+			->get();
+		foreach ($data as $k => $v) {
+			if ($v['money_type'] == 1 && $v['status'] == $status) {
+				$data[$k]['old_money'] = sprintf("%.1f", $v['money_cash'] - $v['money']);
+			} elseif ($v->money_type == 2 && $v['status'] == $status) {
+				$data[$k]['old_money'] = sprintf("%.1f", $v['money_cash'] + $v['money']);
+			}
+		}
+		if (!$data) {
+			return -2020062003; //用户没有数据
+		}
+		return $data->toArray();
+	}
+	//插入数据
+	function insertData($data) {
+		if ($this->checkTrade_id($data['trade_id'])) {
+			return -3010026022; //订单号已存在。
+		}
+		$data['info_identity'] = UUID();
+		$res = $this->insert($data);
+		if (!$res) {
+			return -2020072022; //插入资金详情失败
+		}
+		return 1;
+
+	}
+	//获取用户的流水记录
+	function getUserWater($account_id, $list = 10, $where = '') {
+		$data = $this->where('account_identity', $account_id);
+		if (!empty($where) && is_array($where)) {
+			$data = $data->where($where);
+		}
+		$data = $data->orderBy('money_time', 'desc')->paginate($list);
+		if (!$data) {
+			return -8020010522; //没有数据
+		}
+		$datas = $data->toArray();
+		if (is_array($datas['data']) && count($datas['data'])) {
+			foreach ($datas['data'] as $k => $v) {
+				if ($v['money_type'] == 1) {
+					$datas['data'][$k]['old_money'] = $v['money_cash'] - $v['money'];
+				} else {
+					$datas['data'][$k]['old_money'] = $v['money_cash'] + $v['money'];
+				}
+			}
+		}
+		return $datas;
+	}
+	//检测交易订单号
+	function checkTrade_id($order_id) {
+		$res = $this->where('trade_id', $order_id)->first();
+		if ($res) {
+			return true;
+		}
+		return false;
+	}
+	//统计总金额
+	function sumMoney($where) {
+		$res = $this->where($where)->sum('money');
+		return $res;
+	}
+	//获取存取反水总金额含活动赠送
+	function getTotal($time) {
+		$array = array(5, 6, 7, 8, 9, 11, 12, 13, 14);
+		$res = $this->where($time)->whereIn('trade_type', $array)->sum('money');
+		return $res;
+	}
+	//入款总额汇总
+	function getIntoTotal($where) {
+		$array = array(6, 11, 14);
+		$res = $this->where($where)->whereIn('trade_type', $array)->sum('money');
+		return $res;
+	}
+	//统计各项入款金额
+	function sumIntoMoney($where) {
+		$res = $this->where($where)->sum('money');
+		return $res;
+	}
+	//测试统计
+	function totalTypeMoney($where){
+	    $type=array(5,6,7,8,9,12,11,13,14,16,19,10,22);
+	    $data=$this->select(DB::raw('sum(money) as money,trade_type,money_type'))
+            ->whereIn('trade_type',$type)
+            ->where($where)
+            ->groupBy('trade_type')
+            ->groupBy('money_type')
+            ->get();
+	    return $data->toArray();
+    }
+
+	function getActiveMoney($where, $type) {
+		$res = $this->where('money_type', $type)->where($where)->where('trade_type', 12)->sum('money');
+		return $res;
+	}
+
+	//汇款金额汇总统计
+	function sendMoneyCount($where = '') {
+		$data = array();
+		$data['all_money'] = $this->whereIn('trade_type', [13, 14])->sum('money');
+		$data['success_money'] = $this->whereIn('trade_type', [13])->sum('money');
+		$data['give_money'] = $this->whereIn('trade_type', [13, 14])->where('status', 1)->sum('money');
+		$data['fail_money'] = $this->whereIn('trade_type', [13, 14])->where('status', 2)->sum('money');
+		if (!empty($where) && is_array($where)) {
+			$data['all_money'] = $this->where($where)->whereIn('trade_type', [13, 14])->sum('money');
+			$data['success_money'] = $this->where($where)->whereIn('trade_type', [13])->sum('money');
+			$data['give_money'] = $this->where($where)->whereIn('trade_type', [13, 14])->where('status', 1)->sum('money');
+			$data['fail_money'] = $this->where($where)->whereIn('trade_type', [13, 14])->where('status', 2)->sum('money');
+		}
+
+		return $data;
+	}
+	//反水插入
+	function returnData($data) {
+		$res = $this->insert($data);
+		if (!$res) {
+			return -5020034002; //反水失败
+		}
+		return 1;
+	}
+
+	function getBet() {
+		$time2 = date("Y-m-d H:i:s", time() - 60 * 60 * 24 * 7);
+		$type=array(5,6,11,14);
+		//提现
+		$rech_data= $this->select(DB::Raw('date(money_time)'), DB::Raw('sum(money) as value'),'trade_type')->where('money_time', '>=', $time2)
+            ->where('status',1)
+            ->whereIn('trade_type',$type)
+            ->orderBy(DB::Raw('date(money_time)'), 'asc')->groupBy(DB::Raw('date(money_time)'))->groupBy('trade_type')->get();
+		if (!$rech_data) {
+			return -3021010102; //没有列表数据
+		}
+		return $rech_data->toArray();
+		//判断数据是否存在
+		/*$rech_data['money_with'] = $rech_data['money_with']->toArray();
+		$rech_data['money_recharge'] = $this->join('account', 'account.identity', '=', 'money_details.account_identity')->select(DB::Raw('date(money_time)'), DB::Raw('sum(money) as value'))->whereBetween('money_time', $timearea)->orderBy(DB::Raw('date(money_time)'), 'asc')->groupBy(DB::Raw('date(money_time)'))->where('trade_type', 6)->get();
+
+		$rech_data['money_recharge'] = $rech_data['money_recharge']->toArray();
+		$rech_data['money_remittance'] = $this->join('account', 'account.identity', '=', 'money_details.account_identity')->select(DB::Raw('date(money_time)'), DB::Raw('sum(money) as value'))->whereBetween('money_time', $timearea)->orderBy(DB::Raw('date(money_time)'), 'asc')->groupBy(DB::Raw('date(money_time)'))->where('trade_type', 11)->get();
+		$rech_data['money_remittance'] = $rech_data['money_remittance']->toArray();
+		$rech_data['money_trans'] = $this->join('account', 'account.identity', '=', 'money_details.account_identity')->select(DB::Raw('date(money_time)'), DB::Raw('sum(money) as value'))->whereBetween('money_time', $timearea)->orderBy(DB::Raw('date(money_time)'), 'asc')->groupBy(DB::Raw('date(money_time)'))->where('trade_type', 14)->get();
+		$rech_data['money_trans'] = $rech_data['money_trans']->toArray();
+		return $rech_data;*/
+	}
+	function countUser($timearea, $array) {
+		$data = $this->select('account_name')->whereBetween('money_time', $timearea)->whereIn('trade_type', $array)->groupBy('account_name')->get();
+		if (!$data) {
+			return 0;
+		}
+		$data = $data->toArray();
+		return count($data);
+	}
+    //下级会员资金列表
+	function getChildMoneyList($childs,$list){
+        $data=$this->whereIn('account_name',$childs)->orderBy('money_time','desc')->paginate($list);
+        if (!$data) {
+            return -3021000102; //没有列表数据
+        }
+
+        return $data->toArray();
+    }
+
+	//获取用户存取款笔数
+	function getUserMoneynum($aid){
+        $rechargenum=$this->whereIn('trade_type',array(6,12,11,14))->where('account_identity',$aid)->count();
+		$takenum=$this->whereIn('trade_type',array(5))->where('account_identity',$aid)->count();
+        $data = array(
+			'recharge_num' => !$rechargenum?0:$rechargenum,
+			'take_num' => !$takenum?0:$takenum,
+		);
+        return $data;
+    }
+
+    //批量插入数据
+    function insertAllData($data) {
+        $res = $this->insert($data);
+        if (!$res) {
+            return -2020072022; //插入资金详情失败
+        }
+        return 1;
+
+    }
+    //根据用户名统计该用户提款,充值成功次数
+    function countUserNum($account_name){
+	    $data=$this->select(DB::raw('count(id) as num,trade_type'))->where('status',1)->where('account_name',$account_name)->whereIn('trade_type',array(5,6,11,14))->groupBy('trade_type')->get();
+	    if(!$data){
+	        return array();
+	    }
+	    return $data->toArray();
+    }
+    //获取用户充值总金额
+    function sumRecharge($account_name){
+       return $this->where('account_name',$account_name)->where('status',1)->whereIn('trade_type',array(6,11,14))->sum('money');
+    }
+
+    protected function getBetMoney($time,$id) {
+        // DB::connection()->enableQueryLog();
+        $sum = $this->where('money_time', '>', $time)->whereIn('status',['1','2'])->where('account_identity',$id)->sum('money');
+        // $queries = DB::getQueryLog();
+        // print_r($queries);
+        return $sum;
+    }
+
+    /** 获取一种类型得数据
+     * @param $type 交易类型
+     * @param $limit 条数
+     * @param $otherWhere 其他条件
+     */
+    protected function getTypeData($type,$limit,$otherwhere=array()){
+        $data=$this->where('trade_type',$type);
+        if(is_array($otherwhere)&&count($otherwhere)>0){
+            $data=$data->where($otherwhere);
+        }
+        $data=$data->orderBy('id','asc');
+        $data=$data->paginate($limit);
+        return $data->toArray();
+    }
+
+    protected function getTypesData($typearray=array(),$limit){
+        $data=$this->whereIn('trade_type',$typearray)->paginate($limit);
+        return $data->toArray();
+    }
+}

+ 206 - 0
app/Models/Setinfo.php

@@ -0,0 +1,206 @@
+<?php
+namespace App\Models;
+class Setinfo extends BaseModel {
+//	const CREATED_AT = 'createTime';
+	protected $table = "setinfo";
+//	const UPDATED_AT = 'updateTime';
+	public $timestamps = false;
+//	protected $primaryKey = "id";
+    //获得公告内容
+    function getNotice(){
+        $data=$this->where('id',19)->where('infotype',8)->first();
+        if(!$data){
+            return -6010000122;
+        }
+        return $data->toArray();
+    }
+    //获得弹框内容
+    function getBoxOut(){
+        $data=$this->where('infotype',6)->first();
+        if(!$data){
+            return -6010000222;//没有弹框信息
+        }
+        return $data->toArray();
+    }
+    function fsnum(){
+        $data=$this->where('id',1001)->first();
+        if(!$data){
+            return -6010000222;//没有弹框信息
+        }
+        return $data->toArray();
+    }
+    //获取客服qq信息
+    function getQQnumber(){
+        $data=$this->where('infotype',16)->first();
+        if(!$data){
+            return -6010000322;//没有qq信息
+        }
+        return $data->toArray();
+    }
+    //获取代理模式开关信息
+    function getAgentSet(){
+        $data=$this->where('infotype',13)->first();
+        if(!$data){
+            return -6010000422;//获取设置信息失败
+        }
+        return $data->toArray();
+    }
+    //获取平台维护开关设置
+    function getPlatSet(){
+        $data=$this->where('infotype',17)->first();
+        if(!$data){
+            return -6010000622;//获取失败
+        }
+        return $data->toArray();
+    }
+    //虚拟游戏设置信息
+    function getPrizeSet(){
+        $data=$this->where('infotype',15)->first();
+        if(!$data){
+            return -6010000622;//获取失败
+        }
+        return $data->toArray();
+    }
+    //获取转账银行信息
+    function getBankInfo(){
+        $data=$this->where('infotype',10)->first();
+        if(!$data){
+            return -6010000722;//获取失败
+        }
+        return $data->toArray();
+    }
+    //跑马灯内容
+    function getRunNotice(){
+        $data=$this->where('infotype',9)->first();
+        if(!$data){
+            return -6010000822;//获取失败
+        }
+        return $data->toArray();
+    }
+    function getAllSet($where=''){
+        $data=array(6,9,13,15,16,17,18,19);
+		if(!empty($where)&&is_array($where)){
+			$data=$this->where($where)->whereIn('infotype',$data)->get();
+		}else{
+			$data=$this->whereIn('infotype',$data)->get();
+		}
+        if(!$data){
+            return -6010000822;//获取失败
+        }
+        return $data->toArray();
+    }
+    protected function getsInfo($info_type){
+        $info= $this->getInfo($info_type);
+        if($info<0){
+            return $info;
+        }
+        return $info['infocontent'];
+    }
+    //获取msg
+    function getInfo($info_type){
+
+        $data=$this->where('infotype',$info_type)->first();
+        if(!$data){
+            return -6010000122;
+        }
+        return $data->toArray();
+    }
+
+     function getInfos($info_type){
+        $data=$this->where('infotype',$info_type)->get();
+        if(!$data){
+            return -6010000122;
+        }
+        return $data->toArray();
+    }
+
+    //更新设置
+    function updateInfo($data,$type){
+        $data_arr=$this->where('infotype',$type)->first();
+        if(!$data_arr){
+            if(!isset($data['infoname'])){
+                $data['infoname']='新增';
+            }
+            $data['identity']=UUID();
+            $data['infotype']=$type;
+            $res=$this->insert($data);
+        }else{
+            $res=$this->where('infotype',$type)->update($data);
+        }
+        if(!$res){
+            return -7020050022;//更新失败
+        }
+        return $res;
+    }
+
+
+    //添加设置
+    function addInfo($data){
+        $data['identity']=UUID();
+        $res=$this->insert($data);
+        if(!$res){
+            return -7020050022;//更新失败
+        }
+        return $res;
+    }
+
+    //更新设置
+    function updateInfos($data,$id){
+        $res=$this->where('id',$id)->update($data);
+        if(!$res){
+            return -7020050022;//更新失败
+        }
+        return 1;
+    }
+
+    function checkdata($data,$id){
+        if(empty($id)){
+            $arr = $this->where('infoname',$data['infoname'])->where('remarks',$data['remarks'])->first();
+            if($arr && isset($arr->id)){
+                $id = $arr->id;
+                return $this->updateInfos($data,$id);
+            }
+           return $this->addInfo($data);
+        }else{
+             $arr = $this->where('id',$id)->first();
+            if (!$arr) {
+               return -7020050022;//没有数据
+            }
+            return $this->updateInfos($data,$id);
+        }
+    }
+
+    protected function getIPlimit(){
+        $data=$this->where('infotype',23)->where('status',1)->first();
+        if(!$data){
+            return -7022250022;//ip设置关闭
+        }
+        return 1;
+    }
+
+    protected function getWebSet(){
+        $data=$this->where('remarks','recedata')->first();
+        if(!$data){
+            return array('infocontent'=>'开游');
+        }
+        return $data->toArray();
+    }
+
+    protected function getPath(){
+        $data=$this->where('infotype',18)->first();
+        if(!$data){
+            return -1234;
+        }
+        return $data->infocontent;
+    }
+
+    //域名检测 2019-01-16 anton liu
+    protected function checkDom($dmo)
+    {
+        return $this
+            ->where('infotype','=',1018)
+            ->where('infocontent','like','%'.$dmo.'%')
+            ->first();
+    }
+
+}

+ 1170 - 0
app/Models/SportsNoteList.php

@@ -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;
+
+    }
+
+
+}

+ 2 - 0
datainf/logic/HttpServerDataInf.php

@@ -149,6 +149,8 @@ class HttpServerDataInf
                 break;
             case 'setResultExpress':
                 $ret = DataLogic::getInstance()->setResultExpress($data);
+            case 'setMatchWarn':
+                $ret = DataLogic::getInstance()->setMatchWarn($data);
             default:
                 $ret = 'false';
                 break;