Browse Source

追加推送 5/6

彭俊 6 years ago
parent
commit
a2d531b08d

+ 147 - 0
app/Http/Controllers/Admin/GjmatchController.php

@@ -0,0 +1,147 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request as Req;
+use Illuminate\Support\Facades\DB;
+use App\Models;
+use Request;
+
+/**
+ * 冠军赛事
+ */
+class GjmatchController extends Controller {
+
+	//
+	public function index(Req $req){
+		$request=array();
+		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
+		$request['source'] = isset($req->source) ? $req->source : null;
+		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
+		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
+		$dt = \App\Lib\DataTable\DataTable::init();
+        $dt->setDataSource('/admin/gjmatch/info');
+        $dt->setLang('gjmatch');
+        $dt->addColsFields('id', array('templet' => '#home_team', 'sort' => false, 'width' => 60));
+        $dt->addColsFields('name_chinese', array('templet' => '#guest_team', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('game_name', array('templet' => '#home_rate', 'sort' => false, 'width' => 130));
+        $dt->addColsFields('ctime', array('templet' => '#home_rate', 'sort' => false, 'width' => 180));
+        $dt->addColsFields('utime', array('templet' => '#home_rate', 'sort' => false, 'width' => 180));
+        $dt->addColsFields('status', array('templet' => '#status', 'sort' => false, 'width' => 80));
+
+        if (checkRriv('/admin/gjmatch/edit')) {
+			$arr[] = 'edit';
+		}
+		$dt->setToolBar($arr, array('width' => 200));
+        $dt->enableCheckBox();
+
+		return view('admin/gjmatch/index',$dt->render($request));
+	}
+
+	//添加
+	public function add(Req $req) {
+		if (!$req->isMethod('post')) {
+            $lange = trans('menu');
+			$newapp = new \App\Models\SoccerLeague();
+			$league_data = $newapp->allleague();//联赛id
+
+            return view('admin.gjmatch/add',['data'=>$league_data]);
+        } else {
+            $model = new \App\Models\Stzqleagueresult();
+			$model->lg_id = trim($req->input('lg_id'));//联赛id
+			$model->game_name = trim($req->input('game_name'));
+			$model->result = json_encode(explode(',', trim($req->input('result'))),JSON_UNESCAPED_UNICODE);
+			$model->ctime = date("Y-m-d H:i:s");//创建时间
+			$model->status = trim($req->input('status'));
+			$model->save();
+			return responseToJson(1);
+        }
+	}
+
+	//编辑
+	public function edit(Req $req) {
+		$id = $req->id;
+		if (intval($id) < 1) {
+			return -1;
+		}
+		if (!$req->isMethod('post')) {
+
+			$data = \App\Models\Stzqleagueresult::where('id', $id)->first();
+			if (!$data) {
+				return -2;
+			}
+			$data = $data->toArray();
+
+			$newapp = new \App\Models\SoccerLeague();
+			$league_data = $newapp->allleague();//所有联赛
+
+			//已选择的联赛相信
+			$only = $newapp->onlyleague($data['lg_id']);
+
+			return view('admin.gjmatch/edit', ['data'=>$data,'ldata'=>$league_data,'only'=>$only]);
+		} else {
+			$model = \App\Models\Stzqleagueresult::where('id', $id)->first();
+			$model->game_name = $req->input('game_name');
+			$model->utime = date("Y-m-d H:i:s");//更新时间
+			$model->lg_id = $req->input('lg_id');//赛事id
+			$model->status = $req->input('status');
+
+			$model->save();
+			return responseToJson(1);
+		}
+
+	}
+
+	public function info(){
+		$page = Request::has('page') ? Request::get('page') : '';
+		$list = Request::has('limit') ? Request::get('limit') : 10;
+		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
+		$sureblurs = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
+		$status = Request::has('status') ? Request::get('status') : '';
+        $where = array();
+        if (!empty($home_team)) {
+			if (empty($sureblurs) || $sureblurs == 'off') {
+				$where[] = array('st_zq_league_result.game_name', 'like', '%' . $home_team . '%');
+			} else {
+				$where[] = array('st_zq_league_result.game_name', '=', $home_team);
+			}
+		}
+        if ($status != -1) {
+			$where[] = array('st_zq_league_result.status', '=', $status);
+		}
+		if (!empty($source)) {
+			$where[] = array('st_zq_league_result.source', '=', $source);
+		}
+		$newapp = new \App\Models\Stzqleagueresult();
+        $data = $newapp->resultlist($list, $page, $where);
+        
+        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
+	}
+
+	//删除
+	public function dele(Req $req) {
+		$id = $req->input('id');
+		if (empty($id)) {
+			return responseToJson(-2001); //
+		}
+		$ids = explode(',', $id);
+		if (!is_array($ids) && intval($ids) < 0) {
+			return responseToJson(-2002); //
+		}
+		if (is_array($ids) && count($ids) > 0) {
+			foreach ($ids as $k => $v) {
+				if (intval($v) < 1) {
+					unset($ids[$k]);
+				}
+			}
+		}
+		// echo '敬请期待';die;
+		$rows = \App\Models\Stzqleagueresult::whereIn('id', $ids)->delete();
+		if (!$rows) {
+			return responseToJson(-2003); 
+		}
+		return responseToJson(1);
+	}
+
+}

+ 55 - 2
app/Http/Controllers/Admin/SoccerNoteListController.php

@@ -10,6 +10,7 @@ namespace App\Http\Controllers\Admin;
 use App\Http\Controllers\Controller;
 use Illuminate\Http\Request as Req;
 use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementOrder;
 use App\Models;
 use Request;
 
@@ -28,6 +29,7 @@ class SoccerNoteListController extends Controller
         $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
         $request['order_id'] = isset($req->order_id) ? trim($req->order_id) :null ;
         $request['match_id'] = isset($req->match_id) ? trim($req->match_id) :null ;
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
         $request['type'] = isset($req->type) ? trim($req->type) : 'zq';
         $dt = \App\Lib\DataTable\DataTable::init();
         $dt->setDataSource('/admin/SoccerNoteList/info');
@@ -62,6 +64,7 @@ class SoccerNoteListController extends Controller
         $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
         $order_id = Request::get('order_id') ? Request::get('order_id') : '';
         $match_id = Request::get('match_id') ? Request::get('match_id') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
         $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
         $type = Request::has('type') ? Request::get('type') : 'zq';
         $where = array();
@@ -91,6 +94,9 @@ class SoccerNoteListController extends Controller
         if (!empty($match_id)){
             $where[] = array('money_buy_simplex.match_id', $match_id);
         }
+        if ($status != -1) {
+            $where[] = array('money_buy_simplex.settle_status', '=', $status);
+        }
         $where[] = array('money_buy_simplex.game_code', $type);
         $newapp = new \App\Models\SportsNoteList();
         $data = $newapp->getinfo($list, $page, $where,$type);
@@ -98,16 +104,41 @@ class SoccerNoteListController extends Controller
         return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total'], 0, $where);
     }
 
+    /**
+     *单式注单结算
+     */
+    public function settlement(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $order = DB::table('money_buy_simplex')->where('id', $id)->first();
+        $order_ids = array($order->order_id);
+        //return $order_ids;
+        $SettlementOrder = new SettlementOrder();
+        $bet_type = 1;//单式注单
+        $data = $SettlementOrder->reSettlement($order_ids, $bet_type);
+        return $data;
+    }
+
 
     /**
-     *单式注单重新审核
+     *单式注单重新结算
      */
-    public function reaudit(Req $req) {
+    public function resettlement(Req $req) {
         $id = $req->id;
         if (intval($id) < 1) {
             return -1;
         }
         $order = DB::table('money_buy_simplex')->where('id',$id)->first();
+        $order_ids = array($order->order_id);
+        //return $order_ids;
+        $SettlementOrder = new SettlementOrder();
+        $bet_type = 1;//单式注单
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
+        return $data;
+
         //获取此订单下包含的赛事玩法
         $matchs = DB::table('money_buy_match')->where('batch_id',$order->batch_id)->where('match_id',$order->match_id)->where('bet_type','1')->get()->toArray();
         $win_money = 0;
@@ -167,6 +198,28 @@ class SoccerNoteListController extends Controller
         return "<script>history.go(-1);</script>";
     }
 
+    /**
+     *单式注单批量结算
+     */
+    public function batchsettlement(){
+        $orders = DB::table('money_buy_simplex')->where('settle_status','1')->get();
+        $order_ids = array();
+        for($i=0;$i<count($orders);$i++){
+            $result = DB::table('money_buy_match')->where('batch_id',$orders[$i]->batch_id)->where('match_id',$orders[$i]->match_id)->get();
+            $res = array();
+            for($j=0;$j<count($result);$j++){
+                $res[] = $result[$j]->result;
+            }
+            if(!in_array(0,$res)){
+                $order_ids[] = $orders[$i]->order_id;
+            }
+        }
+        //return $order_ids;
+        $SettlementOrder = new SettlementOrder();
+        $bet_type = 1;//单式注单
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
+        return $data;
+    }
 
     /**
      *删除订单

+ 61 - 1
app/Http/Controllers/Admin/SoccerStringNoteListController.php

@@ -10,6 +10,7 @@ namespace App\Http\Controllers\Admin;
 use App\Http\Controllers\Controller;
 use Illuminate\Http\Request as Req;
 use Illuminate\Support\Facades\DB;
+Use App\Lib\Settlement\SettlementOrder;
 use App\Models;
 use Request;
 
@@ -27,6 +28,7 @@ class SoccerStringNoteListController extends Controller
         $request['star_time'] = isset($req->star_time) ? trim($req->star_time) :null ;
         $request['end_time'] = isset($req->end_time) ? trim($req->end_time) :null ;
         $request['order_id'] = isset($req->order_id) ? trim($req->order_id) :null ;
+        $request['status'] = isset($req->status) ? trim($req->status) : '-1';
         $dt = \App\Lib\DataTable\DataTable::init();
         $dt->setDataSource('/admin/SoccerStringNoteList/info');
         $dt->setLang('sportsnotelist');
@@ -58,6 +60,7 @@ class SoccerStringNoteListController extends Controller
         $star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
         $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
         $order_id = Request::get('order_id') ? Request::get('order_id') : '';
+        $status = Request::has('status') ? Request::get('status') : '';
         $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
         $where = array();
         if (!empty($account)) {
@@ -83,6 +86,9 @@ class SoccerStringNoteListController extends Controller
         if (!empty($order_id)){
             $where[] = array('money_buy_str.order_id', $order_id);
         }
+        if ($status != -1) {
+            $where[] = array('money_buy_str.settle_status', '=', $status);
+        }
         $newapp = new \App\Models\MoneyBuyStr();
         $data = $newapp->getinfo($list, $page, $where);
 
@@ -122,6 +128,25 @@ class SoccerStringNoteListController extends Controller
         return \App\Lib\DataTable\DataTable::init()->toJson($data);
     }
 
+    /**
+     *串关注单结算
+     */
+    public function settlement(Req $req)
+    {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
+        }
+        $order = DB::table('money_buy_str')->where('id', $id)->first();
+        $order_ids = array($order->order_id);
+        //return $order_ids;
+        $SettlementOrder = new SettlementOrder();
+        $bet_type = 2; //串关注单
+        $data = $SettlementOrder->reSettlement($order_ids, $bet_type);
+        //dd($SettlementOrder);
+        return $data;
+    }
+
     /**
      *串关注单重新结算
      */
@@ -131,6 +156,18 @@ class SoccerStringNoteListController extends Controller
             return -1;
         }
         $order = DB::table('money_buy_str')->where('id',$id)->first();
+        $order_ids = array($order->order_id);
+        //return $order_ids;
+        $SettlementOrder = new SettlementOrder();
+        $bet_type = 2; //串关注单
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
+        //dd($SettlementOrder);
+        return  $data;
+//        if($data['status'] == 1){
+//            return responseToJson(1, trans('menu.delete_success')); //id����
+//        }
+//        return "<script language=javascript>history.back();</script>";
+
         $m = explode('串',$order->str_type);
         //获取此订单下包含的赛事
         $matchs = DB::table('money_buy_match')->where('batch_id',$order->batch_id)->where('bet_type',2)->get()->toArray();
@@ -194,10 +231,33 @@ class SoccerStringNoteListController extends Controller
         return "<script>history.go(-1);</script>";
     }
 
+    /**
+     *串关注单批量结算
+     */
+    public function batchsettlement(){
+        $bet_type = 2; //串关注单
+        $orders = DB::table('money_buy_str')->where('settle_status','1')->get();
+        $order_ids = array();
+        for($i=0;$i<count($orders);$i++){
+            $result = DB::table('money_buy_match')->where('batch_id',$orders[$i]->batch_id)->get();
+            $res = array();
+            for($j=0;$j<count($result);$j++){
+                $res[] = $result[$j]->result;
+            }
+            if(!in_array(0,$res)){
+                $order_ids[] = $orders[$i]->order_id;
+            }
+        }
+        //return $order_id;
+        $SettlementOrder = new SettlementOrder();
+        $data = $SettlementOrder->reSettlement($order_ids,$bet_type);
+        return $data;
+    }
+
     /**
      *删除串关注单
      */
-    public function delete(Req $req) {
+    public function deletel(Req $req) {
         $id = $req->input('id');
         if (empty($id)) {
             return responseToJson(-2001); //id������

+ 5 - 2
app/Http/Controllers/Api/SettlementController.php

@@ -7,15 +7,18 @@ use App\Lib\Settlement\Adapter\LqRule;
 
 class SettlementController extends Controller{
     public function index(){
-        $dd = new LqRule();
+        $dd = new ZqRule();
 
-        dd($dd->capotRule(1,2,1));
+        dd($dd->bodan(1,2,1));
     }
     public function dd(){
         dd(1111);
     }
 
     public function  debug(){
+
+        echo intval(1.232);
+
         $obj = new SettlementSql();
         $ret = $obj->doRun();
         $sql = $obj->GetSQL();

+ 8 - 9
app/Lib/Settlement/Adapter/LqRule.php

@@ -776,16 +776,15 @@ class LqRule
         return $last_half_data;
     }
 
-
     //结果单/双 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球
     public function  lq_two_sides($model,$resultModel,$resultRecords){
         $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score) + intval($resultModel->guest_rate) + intval($resultModel->home_rate);
         if($resulttod%2==0){
-            $data = 2;
+            $data = '双';
         }else{
-            $data = 2;
+            $data = '单';
         }
-        if($data = intval($model->condition)){
+        if($data = $model->condition){
             return 1;
         }else{
             return -1;
@@ -795,10 +794,10 @@ class LqRule
 
     //最后进球球队 last_score 最后进球球队 model:money_buy_match  resultModel:st_lq_result
     public function lq_last_number($model,$resultModel,$resultRecords){
-    	if($resultModel->last_score == $model->condition){
-    		return 1;
-    	}else{
-    		return -1;
-    	}
+        if($resultModel->last_score == $model->condition){
+            return 1;
+        }else{
+            return -1;
+        }
     }
 }

+ 16 - 6
app/Lib/Settlement/Adapter/WqRule.php

@@ -70,17 +70,27 @@ class WqRule
     }
 
     /**
-     * 冠军
+     * 冠军 match_winer_player:获胜队员
      */
-    public function wq_kemp(){
-
+    public function wq_kemp($bet_match,$result_match,$result_match_r){
+        if($result_match->match_winer_player == $bet_match->condition){
+            return 1;
+        }else{
+            return -1;
+        }
     }
 
     /**
-     * 让盘
+     * 让盘 home_player_score:主队队员得分 guest_player_score:客队队员得分 home_player_let_plate:主队队员让盘 guest_player_let_plate:客队队员让盘
      */
-    public function wq_concede(){
-
+    public function wq_concede($bet_match,$result_match,$result_match_r){
+        $zdnum = $result_match->home_player_score + $result_match->home_player_let_plate;
+        $kdnum = $result_match->guest_player_score + $result_match->guest_player_let_plate;
+        if($bet_match->condition == $zdnum || $bet_match->condition == $kdnum){
+            return 1;
+        }else{
+            return -1;
+        }
     }
 
     /**

+ 114 - 21
app/Lib/Settlement/Adapter/ZqRule.php

@@ -7,6 +7,8 @@
  */
 
 namespace App\Lib\Settlement\Adapter;
+use Illuminate\Support\Facades\DB;
+
 
 class ZqRule
 {
@@ -18,7 +20,7 @@ class ZqRule
      * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
      */
     public function concede_home($model, $resultModel, $resultRecords) {
-        $this -> concedeFull($model, $resultModel, $resultRecords, 1);
+        return $this -> concedeFull($model, $resultModel, $resultRecords, 1);
     }
 
     /**
@@ -29,7 +31,7 @@ class ZqRule
      * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
      */
     public function concede_guest($model, $resultModel, $resultRecords) {
-        $this -> concedeFull($model, $resultModel, $resultRecords, 2);
+        return $this -> concedeFull($model, $resultModel, $resultRecords, 2);
     }
 
     /**
@@ -40,7 +42,7 @@ class ZqRule
      * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
      */
     public function half_concede_home($model, $resultModel, $resultRecords) {
-        $this -> concedeHalf($model, $resultModel, $resultRecords, 1, 1);
+        return $this -> concedeHalf($model, $resultModel, $resultRecords, 1, 1);
     }
 
     /**
@@ -51,7 +53,7 @@ class ZqRule
      * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
      */
     public function half_concede_guest($model, $resultModel, $resultRecords) {
-        $this -> concedeHalf($model, $resultModel, $resultRecords, 2, 1);
+        return $this -> concedeHalf($model, $resultModel, $resultRecords, 2, 1);
     }
 
     /**
@@ -62,7 +64,7 @@ class ZqRule
      * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
      */
     public function size_home($model, $resultModel, $resultRecords) {
-        $this -> sizeFull($model, $resultModel, $resultRecords, 0, 1);
+        return $this -> sizeFull($model, $resultModel, $resultRecords, 0, 1);
     }
 
     /**
@@ -73,7 +75,7 @@ class ZqRule
      * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
      */
     public function size_guest($model, $resultModel, $resultRecords) {
-        $this -> sizeFull($model, $resultModel, $resultRecords, 0, -1);
+        return $this -> sizeFull($model, $resultModel, $resultRecords, 0, -1);
     }
 
     /**
@@ -84,7 +86,7 @@ class ZqRule
      * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
      */
     public function half_size_home($model, $resultModel, $resultRecords) {
-        $this -> sizeHalf($model, $resultModel, $resultRecords, 0, 1, 1);
+        return $this -> sizeHalf($model, $resultModel, $resultRecords, 0, 1, 1);
     }
 
     /**
@@ -95,7 +97,7 @@ class ZqRule
      * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
      */
     public function half_size_guest($model, $resultModel, $resultRecords) {
-        $this -> sizeHalf($model, $resultModel, $resultRecords, 0, -1, 1);
+        return $this -> sizeHalf($model, $resultModel, $resultRecords, 0, -1, 1);
     }
 
     /**
@@ -106,7 +108,7 @@ class ZqRule
      * @return string 1:赢  -1:输
      */
     public function capot_home($model, $resultModel, $resultRecords) {
-        $this -> winFull($model, $resultModel, $resultRecords, 1);
+        return $this -> winFull($model, $resultModel, $resultRecords, 1);
     }
 
     /**
@@ -117,7 +119,7 @@ class ZqRule
      * @return string 1:赢  -1:输
      */
     public function capot_guest($model, $resultModel, $resultRecords) {
-        $this -> winFull($model, $resultModel, $resultRecords, 2);
+        return $this -> winFull($model, $resultModel, $resultRecords, 2);
     }
 
     /**
@@ -128,7 +130,7 @@ class ZqRule
      * @return string 1:赢  -1:输
      */
     public function capot_dogfall($model, $resultModel, $resultRecords) {
-        $this -> winFull($model, $resultModel, $resultRecords, 0);
+        return $this -> winFull($model, $resultModel, $resultRecords, 0);
     }
 
     /**
@@ -139,7 +141,7 @@ class ZqRule
      * @return string 1:赢  -1:输
      */
     public function half_capot_home($model, $resultModel, $resultRecords) {
-        $this -> winHalf($model, $resultModel, $resultRecords, 1, 1);
+        return $this -> winHalf($model, $resultModel, $resultRecords, 1, 1);
     }
 
     /**
@@ -150,7 +152,7 @@ class ZqRule
      * @return string 1:赢  -1:输
      */
     public function half_capot_guest($model, $resultModel, $resultRecords) {
-        $this -> winHalf($model, $resultModel, $resultRecords, 2, 1);
+        return $this -> winHalf($model, $resultModel, $resultRecords, 2, 1);
     }
 
     /**
@@ -161,7 +163,7 @@ class ZqRule
      * @return string 1:赢  -1:输
      */
     public function half_capot_dogfall($model, $resultModel, $resultRecords) {
-        $this -> winHalf($model, $resultModel, $resultRecords, 0, 1);
+        return $this -> winHalf($model, $resultModel, $resultRecords, 0, 1);
     }
 
     /**
@@ -593,9 +595,9 @@ class ZqRule
      * @param $result_match_r  结果记录
      */
     public function bodan($bet_match,$result_match,$result_match_r){
-//        $bet_match = DB::table('money_buy_match')->where('match_id', 3144414)->first();
-//        $result_match = DB::table('st_zq_result')->where('match_id', 3144414)->first();
-//        $result_match_r = DB::table('st_zq_result_record')->where('match_id', 3144414)->get()->toArray();
+//        $bet_match = DB::table('money_buy_match')->where('match_id', 3150765)->first();
+//        $result_match = DB::table('st_zq_result')->where('match_id', 3150765)->first();
+//        $result_match_r = DB::table('st_zq_result_record')->where('match_id', 3150765)->get()->toArray();
 
         //获取父/子级赔率代码
         $p_code = $bet_match->p_code;
@@ -613,10 +615,17 @@ class ZqRule
             //获取主客队上半场得分
             $home_score = $last_half_data->home_score;
             $guest_score = $last_half_data->guest_score;
+            if(strstr($bet_match->condition,"其他") ){
+                if(($home_score > 3) ||  ($guest_score > 3)) return 1;
+            }
         }else{//全场
             //获取主客队全场得分
             $home_score = $result_match->home_score;
             $guest_score = $result_match->guest_score;
+
+            if(strstr($bet_match->condition,"其他") ){
+                if(($home_score > 4) ||  ($guest_score > 4)) return 1;
+            }
         }
 
         //判断结果
@@ -629,17 +638,17 @@ class ZqRule
     public function  two_sides($model,$resultModel,$resultRecords){
         $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score) + intval($resultModel->guest_rate) + intval($resultModel->home_rate);
         if($resulttod%2==0){
-            $data = 2;
+            $data = '双';
         }else{
-            $data = 2;
+            $data = '单';
         }
-        if($data = intval($model->condition)){
+        if($data = $model->condition){
             return 1;
         }else{
             return -1;
         }
 
-    } 
+    }  
 
     //结果总数 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球 u_home_score 上半场-主队进球数 u_guest_score 上半场-客队进球数
     public function  total_goal($model,$resultModel,$resultRecords){
@@ -744,5 +753,89 @@ class ZqRule
         return $last_half_data;
     }
 
+    /**
+     * 冠军盘口投注
+     * $bet_match 投注赛事数据
+     * $result_match 联赛结果 数据 根据玩法代码查询一条
+     * $result_match_r 无用参数
+     */
+    public function gj($bet_match,$result_match,$result_match_r){
+
+//        $bet_match = DB::table('money_buy_match')->where('match_id', 127317)->first();
+//        $bet_match->odds_code = '巴西小组赛积分成绩';
+
+//        $result_match = DB::table('st_zq_league_result')->where(['lg_id'=>27317,'game_name'=>$bet_match->odds_code])->first();
+
+        if(empty($bet_match) || empty($result_match) ) return false;
+        if($bet_match->p_code != 'gj') return false;//冠军玩法
+        if($bet_match->odds_code == $result_match->game_name){
+            $condition = $bet_match->condition;
+
+            //进球数判断
+            if(strpos($bet_match->odds_code,'进球数') !== false){
+                //获取数值
+                $bet = $this->findNum($condition);
+                //以上/以下判断
+                if(strpos($condition,'上') !== false){
+                    if($bet < $result_match->result) return 1;
+                }
+                if(strpos($condition,'下') !== false){
+                    if($bet > $result_match->result) return 1;
+                }
+                //大/小判断
+                if(strpos($condition,'大') !== false){
+                    if($bet < $result_match->result) return 1;
+                }
+                if(strpos($condition,'小') !== false){
+                    if($bet > $result_match->result) return 1;
+                }
+            }
+            //积分成绩判断
+            if(strpos($bet_match->odds_code,'积分') !== false){
+                $condition = $bet_match->condition;
+                //获取数值
+                $bet = $this->findNum($condition);
+                if($bet == $result_match->result) return 1;
+            }
+
+            //如果条件中没有数字,则获取球队/球员结果
+            if((preg_match('/\d+/',$condition)) == 0){
+                $result = $this->teamJudge($condition,$result_match->result);
+
+                if($result) return 1;
+            };
+
+            return false;
+        }
+        return -1;
+    }
+
+    /**
+     * 冠军盘口 球队/球员结果判断
+     */
+    public function teamJudge($condition,$result){
+        //返回结果数组中是否包含该球队
+        $result = in_array($condition,json_decode($result,true));
+        return $result;
+    }
 
+    /**
+     * @param string $str
+     * @return string
+     * 处理字符串中的数字
+     */
+    public function findNum($str=''){
+        $str=trim($str);
+        if(empty($str)){return '';}
+        $result='';
+        for($i=0;$i<strlen($str);$i++){
+            if(is_numeric($str[$i]) || $str[$i] == '.' ){
+                $result.=$str[$i];
+            }
+        }
+        //如果有小数点,返回浮点数
+        if(strpos($result,'.')) return floatval($result);
+        //返回整数
+        return (int)$result;
+    }
 }

+ 122 - 239
app/Lib/Settlement/SettlementBase.php

@@ -11,282 +11,165 @@ set_time_limit(600);
 ini_set('memory_limit', '256M');
 
 
+use Illuminate\Support\Facades\DB;
+
 class SettlementBase
 {
      const  USER_WIN  = 1 ;   //用户赢钱
      const  USER_LOSE = -1;   //用户输钱
      const  USER_FLAT = 2 ;   //持平,用户钱原路返回
+     const  USER_HAFWIN = 3 ;  //半平半赢
+     const  USER_HALFLOSE = 4 ;  //半平半输
+
+     private  $RefClass = [] ;   //适配器缓存
+
+    //输赢判断
+    public function  winOrfalseInfo($gameType,$buyMatchModel,$resultModel,$resultRecordsArray){
+        if (!isset($this->RefClass[$gameType])){
+            $gameType = ucfirst($gameType);
+            $pathBase = dirname(__FILE__).DIRECTORY_SEPARATOR.'Adapter'.DIRECTORY_SEPARATOR ;
+            $file = $pathBase.$gameType.'Rule.php';
+            if (!file_exists($file)){  throw new \Exception('无胜负判断规则文件');}
+            include_once($file);
+            $tmpapater =  gameType.'Rule' ;
+            $this->RefClass[$gameType] = new $tmpapater();
+        }
 
-     public $match_id  = 0 ;     //比赛场次ID
-     public $matchModel = null ;  //比赛场次Model对像
-
-     public $lg_id = 0  ;    //联赛ID
-     public $lgModel = null ;  //联赛Model对像
-
-     public $resultId = 0 ; //比赛最终结果ID
-     public $resultModel = null ; //比赛最终结果对像MODEL
-     public $resultRecords = [] ; //比赛中间结果对像数组;
-
-     public $buyArrays = [] ;   //订单记录表
-
-     public $gameType = '' ;  //类型
-    //类型映射
-     public $gameAllMap = [
-         'zq'=>'ZqRule',
-         'lq'=>'LqRule',
-         'wq'=>'WqRule',
-         'bq'=>'BqRule',
-     ];
-    private  $AdapterObj = null ;
-
-
-    public  function __construct()
-    {
-        C()->set('BqRule','App\Lib\Settlement\Adapter\BqRule');
-        C()->set('LqRule','App\Lib\Settlement\Adapter\LqRule');
-        C()->set('WqRule','App\Lib\Settlement\Adapter\WqRule');
-        C()->set('ZqRule','App\Lib\Settlement\Adapter\ZqRule');
-
-        return true;
-    }
-
-    //返回数据
-    private function  makeData($status=1,$message='success',$data=''){
-        return [
-            'status' => $status ,
-            'message' =>$message,
-            'data' => $data ,
-        ] ;
-    }
-
-    //开始结算处理
-    public function  doSettlement(){
-            $model = $this->getNoticeData();
-            if ($model) {    return $this->makeData(1,'no data to process') ;  }
-
-            try{
-                _beginTransaction();
-                $ret1 = $this->doInit($model->type,$model->competionid);
-                if (!$ret1){   _rollBack(); return $this->makeData(0,'false_1') ;  }
-
-                $ret2 = $this->writeStatusBegin($model);
-                if (!$ret2){   _rollBack(); return $this->makeData(0,'false_2') ;  }
-
-                $ret3 = $this->getOrdersByMatchid($this->gameType,$this->match_id);
-                if (!$ret3){
-                    //没有下单数据,本场赛事结算处理完毕
-                    $this->writeStatusEndOk($model);
-                    _commit();
-                    return  $this->makeData();
-                }
-
-                $ret4 = $this->BatchModesResult($ret3);
-                if (!$ret4){
-                    _rollBack(); return $this->makeData(0,'false_4') ;
-                }
-
-
-
-
-
-
-
-                _commit();
-                return  $this->makeData();
-
-            }catch(\Exception $e){
-                _rollBack();
-                return $this->makeData(0,'false',['msg'=>$e->getMessage(),'code'=>$e->getCode()]) ;
-            }
-
-    }
-
-
-    //写处理状态
-    public function  writeStatusBegin($comendnticeModel){
-        $comendnticeModel->status = 1 ;
-        $comendnticeModel->pupdatetime = date("Y-m-d H:i:s");
-        $comendnticeModel->pcount ++ ;
-        $comendnticeModel->logs = 'begin|';
-        $ret = $comendnticeModel->save();
-        return  $ret;
-    }
-
-    //写处理状态结束
-    public function  writeStatusEndOk($comendnticeModel){
-        $comendnticeModel->status = 4 ;
-        $comendnticeModel->pret = 1 ;
-        $comendnticeModel->puodateendtime = date("Y-m-d H:i:s");
-        $comendnticeModel->logs = $comendnticeModel->logs.'end ok';
-        $ret = $comendnticeModel->save();
-        return  $ret;
-    }
-
+        $fun = $buyMatchModel->odds_code ;
+        $fun2 = $buyMatchModel->p_code ;
+        if ( $this->RefClass[$gameType]->hasMethod($fun) ){
+            $winorfalse = $this->RefClass[$gameType]->$fun($buyMatchModel,$resultModel,$resultRecordsArray);
+        }elseif ( $this->RefClass[$gameType]->hasMethod($fun2) ){
+            $winorfalse = $this->RefClass[$gameType]->$fun2($buyMatchModel,$resultModel,$resultRecordsArray);
+        }else{
+            throw new \Exception('没有找到玩法输赢判断规则',40010);
+        }
 
-    //查询是否有未处理的数据
-    public function  getNoticeData($where = ['status'=>0]){
-        $model = lm('Comendnotice','Commons')->where($where)->first();
-        if (!$model){
-            return false;
+        if (!in_array($winorfalse,[-1,1,2,3,4])){
+            throw new \Exception('胜负判断结果异常',40011);
         }
-        return $model ;
+        return $winorfalse ;
     }
 
-    //实现结算功能
-    public function   doInit($type,$match_id){
-            if ( isset($this->gameAllMap)){  throw  new \Exception('赛事类型错误',4002);   return false;  }
-
-            switch ($type){
-                case 'bq':
-                    $this->AdapterObj = C()->get('BqRule');
-                    break;
-                case  'lq':
-                    $this->AdapterObj = C()->get('LqRule');
+    /**
+     * 注单返现计算
+     * @param mixed $dataArray 结果表数据 [['odds'=>xx,'winOrLose'=>1],[...]];
+     * @return array 注单返现额
+     */
+    public function   winOddsCalculation($dataArray){
+        $returnMoney = 1;
+        // 循环计算每注返现赔率
+        foreach ($dataArray as $value) {
+            $odds = floatval($value['odds']);
+            // 因结果不同更改赔率
+            switch (intval($value['winOrLose'])) {
+                case 1:
+                    $oddsDiscount = $odds;
                     break;
-                case  'wq':
-                    $this->AdapterObj = C()->get('WqRule');
+                case 2:
+                    $oddsDiscount = 1;
                     break;
-                case  'zq':
-                    $this->AdapterObj = C()->get('ZqRule');
+                case 3:
+                    $oddsDiscount = $odds * 0.5;
                     break;
+                default:
+                    $oddsDiscount = 0.5;
             }
+            // 计算每注返现
+            $returnMoney = $returnMoney * $oddsDiscount;
+        }
+        // 计算赚钱
+        $earnMoney = $returnMoney - 1;
 
-            $this->gameType = $type ;
-            $this->match_id = $match_id ;
-
-            $this->getCompetitionData($type,$match_id);
-            $this->getCompResult($type,$match_id);
-
-            return true ;
+        return ['earnMoney' => $earnMoney, 'returnMoney' => $returnMoney];
     }
 
-    //获取比赛数据模型
-    public function  getCompetitionData($type,$match_id){
-
-        $model = null ;
-        switch ($type){
-            case 'bq':
-                $model = lm('St_bq_competition','Commons')->where('match_id',$match_id)->first();
-                break;
-            case  'lq':
-                $model = lm('St_lq_competition','Commons')->where('match_id',$match_id)->first();
-                break;
-            case  'wq':
-                $model = lm('St_wq_competition','Commons')->where('match_id',$match_id)->first();
-                break;
-            case  'zq':
-                $model = lm('St_zq_competition','Commons')->where('match_id',$match_id)->first();
-                break;
-        }
-        if (empty($model)){
-            throw  new   \Exception('无效match_id_'.$type.'-'.$match_id,4004);
-            return false;
+    /**
+     * 注单返现计算
+     * @param mixed $dataArray 结果表数据
+     * @return array 注单返现额
+     */
+    public function stringComputing($dataArray){
+        /*$dataArray = [
+            [
+                ['odds'=>3.02,'winOrLose'=>1],
+                ['odds'=>2.84,'winOrLose'=>1],
+                ['odds'=>3.01,'winOrLose'=>1],
+                ['odds'=>2.94,'winOrLose'=>1]
+            ], 2
+        ];*/
+        $data = $this->combination($dataArray[0],$dataArray[1]);
+        $dataCount = count($data);
+        $returnMoney = 0;
+        foreach ($data as $key => $value) {
+            $getReturnMoney = $this->winOddsCalculation($value);
+            $returnMoney += $getReturnMoney['returnMoney'];
         }
+        $returnMoney = $returnMoney / $dataCount;
 
-        $this->matchModel = $model;
-        return $model ;
+        return $returnMoney;
     }
 
+    // 组合
+    function combination($a, $m) {
+        $r = array();
 
-    //查询此比较有下单记录
-    public function  getOrdersByMatchid($type,$marchid){
-            $modes = lm('Money_buy_match','Commons')->getByTypeMatch($type,$marchid);
-            return $$modes;
-    }
-
-    //批量结算处理 [只处理状态]
-    public function  BatchModesResult($type,$models){
-             $pclass = $this->AdapterObj ;
-             $RefClass = new  \ReflectionClass($pclass) ;
-            foreach ($models as $model){
-                  $oddscode = $model->odds_code;
-                  if ( $RefClass->hasMethod($oddscode)){
-                      $model->result  = $pclass->$oddscode($model,$this->resultModel,$this->resultRecords);
-                      $model->utime = date("Y-m-d H:i:s");
-                      $ret  = $model->save();
-                      if (!$ret){
-                          throw  new  \Exception('更新记录buy_match失败!',4006);
-                      }
-                      $this->getBuyDatas($model->order_id);
+        $n = count($a);
+        if ($m <= 0 || $m > $n) {
+            return $r;
+        }
 
-                }else{
-                    throw  new  \Exception('找不到此玩法的胜负规则逻辑!',4005);
+        for ($i=0; $i<$n; $i++) {
+            $t = array($a[$i]);
+            if ($m == 1) {
+                $r[] = $t;
+            } else {
+                $b = array_slice($a, $i+1);
+                $c = $this->combination($b, $m-1);
+                foreach ($c as $v) {
+                    $r[] = array_merge($t, $v);
                 }
             }
-            return true;
-    }
-
-
-
-
-
-
-    //某个订单下面的所有比赛是否全部处理完成
-    public function   OrderIsPressFinish($orderId){
+        }
 
+        return $r;
+    }
 
+    /**
+     * UUID 生成
+     */
+    public  static  function UUID() {
+        $prefix = '';
+        $uuid = '';
+        $str = md5(uniqid(mt_rand(), true));
+        $uuid = substr($str, 0, 8) . '-';
+        $uuid .= substr($str, 8, 4) . '-';
+        $uuid .= substr($str, 12, 4) . '-';
+        $uuid .= substr($str, 16, 4) . '-';
+        $uuid .= substr($str, 20, 12);
+        return $prefix . $uuid;
     }
 
 
-    //得到比赛最终结果记录 和 中间结果记录
-    public function  getCompResult($type,$match_id){
-        $model = null ;
-        switch ($type){
-            case 'bq':
-                $model = lm('St_bq_result','Commons')->where('match_id',$match_id)->first();
-                $models = lm('St_bq_result_record','Commons')->where('match_id',$match_id)->find();
-                break;
-            case  'lq':
-                $model = lm('St_lq_resultn','Commons')->where('match_id',$match_id)->first();
-                $models = lm('St_lq_result_record','Commons')->where('match_id',$match_id)->find();
-                break;
-            case  'wq':
-                $model = lm('St_wq_result','Commons')->where('match_id',$match_id)->first();
-                $models = lm('St_wq_result_record','Commons')->where('match_id',$match_id)->find();
-                break;
-            case  'zq':
-                $model = lm('St_zq_result','Commons')->where('match_id',$match_id)->first();
-                $models = lm('St_zq_result_record','Commons')->where('match_id',$match_id)->find();
-                break;
-        }
-        if (empty($model)){
-            throw  new   \Exception('没找到比赛结果记录match_id_'.$type.'-'.$match_id,4007);
-            return false;
+    //获取到某个用户的account模型和detail模型,用于用户的余额计算等使用
+    public function  getUserInfo($account_name){
+
+        $accountModel = DB::table('account')->where('account',$account_name)->first();
+        if (!$accountModel){
+            throw  new   \Exception('查无此用户数据account='.$account_name,41002);
         }
 
-        $this->resultModel = $model;
-        $this->resultRecords = $models ;
+        $detailModel = DB::table('account_detailed')->where('account_identity',$accountModel->identity)->first();
 
+        if (!$detailModel){
+            throw  new   \Exception('查无此用户数据account_detail='.$accountModel->identity,41002);
+        }
         $ret = [
-            'result' => $model,
-            'records' => $models ,
+            'account'=>$detailModel,
+            'detail' => $detailModel ,
         ];
-        return $ret;
-
-    }
-
-    //得到订单信息
-    public function  getBuyDatas($orderId){
-         if ( isset($this->buyArrays[$orderId]) ){
-             return $this->buyArrays[$orderId];
-         }
-
-         $model = lm("Money_buy")->where(['order_id',$orderId])->first();
-         if (!$model){
-             throw new  \Exception('没有订单基本信息_'.$orderId, 4008);
-         }
-
-         $details = lm("Money_buy_detail")->where(['order_id',$orderId])->find();
-         if (!$details){
-             throw new  \Exception('没有订单detail信息_'.$orderId, 4009);
-         }
 
-         $ret = [
-             'buy' =>$model ,
-             'details' => $details ,
-         ];
 
-        $this->buyArrays[$orderId] = $ret  ;
         return $ret;
     }
 

+ 262 - 0
app/Lib/Settlement/SettlementOrder.php

@@ -0,0 +1,262 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/4/25
+ * Time: 14:10
+ */
+
+namespace App\Lib\Settlement;
+set_time_limit(600);
+ini_set('memory_limit', '256M');
+
+use Illuminate\Support\Facades\DB;
+use App\Lib\Settlement\SettlementBase ;
+
+
+/**
+   按订单结算或重结算
+ */
+class SettlementOrder extends SettlementBase
+{
+    private  $orderId = '' ;   //订单ID
+    private  $orderType =  1 ; //订单类型  1单式  2串式;
+    private  $BuyDatasMainModel = [] ;  //订单豪华版  单式一条   串式可能多条
+    private  $BuyDatas = [] ;  //订单豪华版  单式一条   串式可能多条
+
+
+    //返回数据
+    public static function  makeData($status=1,$message='success',$data=''){
+        return [
+            'status' => $status ,
+            'message' =>$message,
+            'data' => $data ,
+        ] ;
+    }
+
+
+    public function  reSettlement($order_ids,$bettype=2){
+          try{
+              DB::beginTransaction ();
+              foreach ($order_ids as $order_id){
+                  $this->BuyDatasMainModel = $this->orderTypeGet($order_id,$bettype);
+                  if (empty($this->BuyDatasMainModel)){  return   self::makeData(2,'查无此订单数据'); }
+                  if ($this->orderType==1){
+                      $this->SingOrder($order_id);
+                  }else{
+                      $this->ChuanOrder($order_id);
+                  }
+              }
+
+              DB::commit();
+          }catch (\Exception $e){
+              DB::rollBack();
+              return    self::makeData(-2,$e->getMessage());  ;
+          }
+
+            return self::makeData();
+    }
+
+    public function  orderTypeGet($order_id,$bettype){
+        if ($bettype==1){
+            $datas = DB::table('money_buy_simplex')->where('order_id',$order_id)->first();
+            $this->orderType = 1 ;
+        }else{
+            $datas = DB::table('money_buy_str')->where('order_id',$order_id)->first();
+            $this->orderType = 2 ;
+        }
+
+        if (!$datas){
+               throw  new  \Exception('没有主订单信息');
+        }
+
+        return $datas ;
+    }
+
+    /**
+     * 单式注单结算
+     * @param mixed $order_id 注单ID
+     */
+    public function singOrder($order_id) {
+        // 查询订单下所有的单式注单
+        $simplexData = DB :: table('money_buy_simplex')
+            -> select('batch_id', 'account_identity', 'order_id', 'money', 'game_code', 'info_identity')
+            -> where(['order_id' => $order_id])
+            -> first();
+        // 查询单式注单下的所有玩法
+        $matchData = DB :: table('money_buy_match') -> select('odds', 'result', 'batch_id') -> where(['bet_type' => 1, 'batch_id' => $simplexData -> batch_id]);
+        $matchData = $matchData -> where(function($query) {
+            $query = $query -> where(['result' => 1])
+                -> orWhere(['result' => 2])
+                -> orWhere(['result' => 3])
+                -> orWhere(['result' => 4]);
+        });
+        $matchData = $matchData -> get() -> toArray();
+        // 计算总回款
+        $settlementBase = new \App\Lib\Settlement\SettlementBase;
+        $returnMoney = 0;
+        $earnMoney = 0;
+        foreach ($matchData as $k => $v) {
+            $oddsResult[0]['winOrLose'] = $v -> result;
+            $oddsResult[0]['odds'] = $v -> odds;
+            $getReturnMoney = $settlementBase -> winOddsCalculation($oddsResult);
+            $returnMoney += $getReturnMoney['returnMoney'];
+            $earnMoney += $getReturnMoney['earnMoney'];
+        }
+        // 判断盈亏  1 赢  2 输  3 平
+        $game_status = $returnMoney > $simplexData -> money ? 1 : ($returnMoney == $simplexData -> money ? 3 : 2);
+        // 修改投注表状态及盈亏
+        DB :: table('money_buy_simplex')
+            -> where(['order_id' => $order_id])
+            -> update(['settle_status' => 2, 'game_status' => $game_status, 'gain_money' => $earnMoney]);
+        $this -> insertData(
+            $order_id,
+            $returnMoney,
+            $simplexData -> account_identity,
+            1,
+            $simplexData -> game_code,
+            $simplexData -> info_identity,
+            $simplexData -> money
+        );
+    }
+
+    /**
+     * 结算数据填入
+     * @param mixed $order_id 注单ID
+     * @param mixed $returnMoney 返现金额
+     * @param mixed $account_identity 用户ID
+     * @param mixed $type 1单式 2串式
+     * @param mixed $game_name 游戏名(zq,lq)
+     * @param mixed $buy_identity 游戏投注id
+     * @param mixed $money 投注金额
+     */
+    public function insertData($order_id, $returnMoney, $account_identity, $type, $game_name, $buy_identity, $money) {
+        // 查询用户当前剩余金额
+        $accountInfo = DB :: table('account_detailed')
+            -> join('account', 'account_detailed.account_identity', 'account.identity')
+            -> select(['available_cash', 'cash', 'account', 'account_identity'])
+            -> where(['account_identity' => $account_identity])
+            -> first();
+        // 计算用户回账后余额
+        $available_cash = $accountInfo -> available_cash + $returnMoney;
+        $cash = $accountInfo -> cash + $returnMoney;
+        // 添加流水记录
+        $info_identity = UUID();
+        $money_time = date('Y-m-d H:i:s', time());
+        $trade_desc = $type == 1 ? '单式投注订单回款' : '串式投注订单回款';
+        $reason = $type == 1 ? '单式投注订单回款' : '串式投注订单回款';
+        DB :: table('money_details') -> insert([
+            'info_identity' => $info_identity,
+            'trade_id' => $order_id,
+            'account_name' => $accountInfo -> account,
+            'account_identity' => $accountInfo -> account_identity,
+            'money' => $returnMoney,
+            'money_time' => $money_time,
+            'money_type' => 1,
+            'money_cash' => $available_cash,
+            'trade_type' => 1,
+            'trade_desc' => $trade_desc,
+            'reason' => $reason,
+            'sysetem_user' => '系统',
+            'status' => '1',
+        ]);
+        // 修改用余额
+        DB:: table('account_detailed')
+            -> where(['account_identity' => $account_identity])
+            -> update(['available_cash' => $available_cash, 'cash' => $cash]);
+        // 新增用户中奖信息
+        $content = $type == 1 ? '您的单式投注订单' . $order_id . '于' . $money_time . '成功回款' . $returnMoney . '该次投注流程结束,如有疑问请联系客服'
+            : '您的串式投注订单' . $order_id . '于' . $money_time . '成功回款' . $returnMoney . '该次投注流程结束,如有疑问请联系客服';
+        DB:: table('account_news') -> insert([
+            'identity' => $info_identity,
+            'account_identity' => $account_identity,
+            'title' => '投注订单回款通知',
+            'content' => $content,
+            'details' => $content,
+            'write_time' => $money_time,
+            'read_status' => -1,
+            'type' => 1,
+        ]);
+        // 新增中奖记录表
+        DB:: table('money_prize') -> insert([
+            'info_identity' => $info_identity,
+            'order_id' => $order_id,
+            'account_identity' => $account_identity,
+            'account_name' => $accountInfo -> account,
+            'game_name' => $game_name,
+            'buy_identity' => $buy_identity,
+            'money' => $money,
+            'money_time' => $money_time,
+            'status' => 1,
+            'prize_money' => $returnMoney,
+            'get_money' => $returnMoney - $money,
+        ]);
+    }
+
+
+    //单个串式订单的处理
+    public function  ChuanOrder($order_id){
+              $batch_id = $this->BuyDatasMainModel->batch_id ;
+              $matchModels = DB::table('money_buy_match')->where(['batch_id'=>$batch_id])->get();
+              if (empty($matchModels)) {   throw  new  \Exception('match 数据异常');}
+
+              $in_array = [] ;
+              foreach ($matchModels as $val){
+                  if (!in_array($val->result,[-1,1,2,3,4])){  throw  new  \Exception('match 比赛结果异常->'.$val->id); }
+
+                  if ($val->result == -1){
+                       $this->BuyDatasMainModel->wait_match_num = 0 ;
+                       $this->BuyDatasMainModel->prize_note = 0 ;
+                       $this->BuyDatasMainModel->settle_status = 2 ;
+                       $this->BuyDatasMainModel->gain_money = 0 ;
+
+                       $ret = $this->BuyDatasMainModel->save();
+                       if (!$ret){ throw  new \Exception('更新数据出错1!');   }
+
+                       $ret = DB::update('update money_buy_str  set settle_status=2,game_status=3,gain_money=0  where batch_id = ?', [$batch_id]);
+                       if(!($ret || $ret===0)){        throw  new \Exception('更新数据出错2!');      }
+                       return true ;
+                  }
+
+                  $in_array[] = ['odds'=>$val->odds,'winOrLose'=>$val->result] ;
+              }
+
+              $chuanNum = intval(substr($this->BuyDatasMainModel->str_type,0,1));
+              $lasPeilv  = $this->stringComputing([$in_array,$chuanNum]);
+              $money = sprintf('%.2f',$this->BuyDatasMainModel->money *  ( $lasPeilv - 1) ) ;
+
+              $this->insertData($order_id,$money,$this->BuyDatasMainModel->account_identity,2,$val->game_code,$this->BuyDatasMainModel->info_identity,$money);
+
+              return true ;
+
+                  /*
+                  $ret = DB::update('update money_buy_str  set settle_status=2 , game_status=1 , gain_money=?  where order_id = ?', [$money,$order_id]);
+                  if(!($ret || $ret===0)){                     throw  new \Exception('更新数据出错3!');             }
+
+                  $account_identity = $this->BuyDatasMainModel->account_identity ;
+                  $ret1 = DB::update("update  account_detailed  set  available_cash=available_cash+$money , cash=cash+$money  where  account_identity='$account_identity' ") ;
+
+                  $allbuyModel = $this->BuyDatasMainModel ;
+                  $dtime = date("Y-m-d H:i:s");
+                  $uuid = self::UUID();
+                  $userInfoArray = $this->getUserInfo($allbuyModel->account_name);
+                  $cashmoney = $userInfoArray['detail']->cash;
+
+                  $SQL  = "insert into money_details(info_identity,trade_id,account_name,account_identity,money,money_time,money_type,trade_desc,status,money_cash,trade_type) values";
+                  $SQL .= "('$uuid','$allbuyModel->order_id','$allbuyModel->account_name','$allbuyModel->account_identity','$money','$dtime',1,'中奖收入','1','$cashmoney',4)" ;
+
+                  $ret2 =  DB::insert($SQL);
+
+                  if ($ret1 && $ret2){
+                      return true;
+                  }
+
+                  throw  new \Exception('更新数据出错4!');
+                   */
+
+            }
+
+
+
+
+    }

+ 82 - 31
app/Lib/Settlement/SettlementSql.php

@@ -62,6 +62,9 @@ class SettlementSql
         return $this->makeData(1,'success',$this->sqlArray);
     }
 
+
+
+    //按赛事批量结算
     public function   doRun(){
 
 
@@ -82,6 +85,7 @@ class SettlementSql
                 return  $this->makeData(1,'本赛事无订单数据,退出');
             }
 
+
             $this->gameType = $ComendNoticModel->game_code ;
             $this->match_id =  $ComendNoticModel->match_id ;
 
@@ -89,10 +93,13 @@ class SettlementSql
             $this->RefClass = new  \ReflectionClass(  $this->AdapterObj ) ;
             $this->getCompResult($ComendNoticModel->game_code,$ComendNoticModel->match_id);
 
+
             $this->Settlement_simplex($this->gameType,$this->match_id);
             $this->Settlement_str($this->gameType,$this->match_id);
 
-            DB::rollback();
+
+            $this->writeStatusEndOk($ComendNoticModel);
+            DB::commit();
             return  $this->makeData(1,'success-all');
 
         }catch (\Exception $e){
@@ -122,26 +129,34 @@ class SettlementSql
         foreach ($buyKeyModel as $batch_id=>$val){
             $money = 0 ;
             $allgame_status = 0 ;
-            foreach ($buymatchKeyModles as $sub_batch_id=>$sval){
-
-                     $winorfalse = $this->winOrfalseInfo($sval);
-                     if (!in_array($winorfalse,[-1,1,2,3,4])){     throw  new  \Exception('胜负规则结果数据错!',4005);     }
-                     $this->makesql_up_buymatch_winorfalse($sval->id,$winorfalse,date("Y-m-d H:i:s"));
-
-                     if ($winorfalse != -1){
-                         $peilvretarr = $this->winOddsCalculation([['odds'=>$sval->odds,'winOrLose'=>$winorfalse]]);
-                         $money +=  $peilvretarr['returnMoney'] * $sval->bet_money ;
-                         $allgame_status++;
-                     }
+            foreach ($buymatchKeyModles as $sub_batch_id=>$fsval){
+
+                    foreach ($fsval as $sval) {
+                        $winorfalse = $this->winOrfalseInfo($sval);
+                        if (!in_array($winorfalse, [-1, 1, 2, 3, 4])) {
+                            throw  new  \Exception('胜负规则结果数据错!', 4005);
+                        }
+                        $this->makesql_up_buymatch_winorfalse($sval->id, $winorfalse, date("Y-m-d H:i:s"));
+
+                        if ($winorfalse != -1) {
+                            $peilvretarr = $this->winOddsCalculation([['odds' => $sval->odds, 'winOrLose' => $winorfalse]]);
+                            $money += $peilvretarr['returnMoney'] * $sval->bet_money;
+                            $allgame_status++;
+                        }
+                    }
             }
 
             $allgame_status = ($allgame_status>0 ) ?  1 : 2 ;
 
-            $sql = "update  money_buy_simplex   set   game_status=$allgame_status,wait_match_num=0,gain_money=$money where   match_id=$this->match_id and  batch_id=$batch_id   ";
+            $sql = " update  money_buy_simplex   set   game_status=$allgame_status,wait_match_num=0,gain_money=$money where   match_id=$this->match_id and  batch_id='$batch_id'   ";
             $this->sqlArray[] = $sql ;
 
-            $this->sql_accountdetail_money($val->account_identity,$money);
-            $this->sql_moneydetail_log($val,null,$money);
+
+
+            if ($money >0){
+                $this->sql_accountdetail_money($val->account_identity,$money);
+                $this->sql_moneydetail_log($val,null,$money);
+            }
 
             return true;
         }
@@ -216,13 +231,34 @@ class SettlementSql
     private  function  winOrfalseInfo($sval){
         $fun = $sval->odds_code ;
         $fun2 = $sval->p_code ;
-        if ( $this->RefClass->hasMethod($fun) ){
-            $winorfalse = $this->AdapterObj->$fun($sval,$this->resultModel,$this->resultRecords);
-        }elseif ( $this->RefClass->hasMethod($fun2) ){
-            $winorfalse = $this->AdapterObj->$fun2($sval,$this->resultModel,$this->resultRecords);
+
+        if ($sval->p_code != 'gj'){
+            if (empty($this->resultModel) ||  empty($this->resultRecords)){
+                throw  new \Exception('非冠军比赛结果数据不能为空');
+            }
+
+            if ( $this->RefClass->hasMethod($fun) ){
+                $winorfalse = $this->AdapterObj->$fun($sval,$this->resultModel,$this->resultRecords);
+            }elseif ( $this->RefClass->hasMethod($fun2) ){
+                $winorfalse = $this->AdapterObj->$fun2($sval,$this->resultModel,$this->resultRecords);
+            }else{
+                throw new \Exception('没有找到玩法输赢判断规则',40010);
+            }
         }else{
-            throw new \Exception('没有找到玩法输赢判断规则',40010);
+            $this->getGjDatas($sval);
+            if (empty($this->gjModel)){
+                throw  new \Exception('冠军比赛结果数据不能为空');
+            }
+
+            if ( $this->RefClass->hasMethod($fun) ){
+                $winorfalse = $this->AdapterObj->$fun($sval,$this->gjModel,[]);
+            }elseif ( $this->RefClass->hasMethod($fun2) ){
+                $winorfalse = $this->AdapterObj->$fun2($sval,$this->gjModel,[]);
+            }else{
+                throw new \Exception('没有找到玩法输赢判断规则',40010);
+            }
         }
+
         return $winorfalse ;
     }
 
@@ -279,24 +315,24 @@ class SettlementSql
 
 
     private function  sql_accountdetail_money($acount ,$moneycg){
-            $sql =  "update  account_detail  set    account_detailed  set available_cash=available_cash+$moneycg,cash=cash+$moneycg where   account_identity='$acount' ";
-            $this->sql[] = $sql ;
+            $sql =  "update  account_detailed  set available_cash=available_cash+$moneycg,cash=cash+$moneycg where   account_identity='$acount' ";
+            $this->sqlArray[] = $sql ;
     }
 
     private function sql_moneydetail_log($allbuyModel,$model,$money_diff){
+
             $uuid = self::UUID();
             $dtime = date("Y-m-d H:i:s");
-            $detailModel = DB::table('Account_detailed')->where(['account_identity',$allbuyModel->account_indentity])->first();
+            $detailModel = DB::table('account_detailed')->where('account_identity',$allbuyModel->account_identity)->first();
             if (!$detailModel){
-                throw  new   \Exception('查无此用户数据account_detail='.$allbuyModel->account_indentity,41002);
+                throw  new   \Exception('查无此用户数据account_detail='.$allbuyModel->account_identity,41002);
             }
             $money_cash =  $detailModel->cash ;
 
-            $SQL  =  "inser into account_detailed set identity='$uuid',trade_id='$allbuyModel->order_id',account_name='$allbuyModel->account_name', " ;
-            $SQL .=  "account_identity=='$allbuyModel->account_indentity',money='$money_diff',money_time='$dtime',money_type=1,  ";
-            $SQL .=  "trade_desc='中奖收入',status='成功',money_cash=$money_cash  " ;
+            $SQL  = "insert into money_details(identity,trade_id,account_name,account_identity,money,money_time,money_type,trade_desc,status,money_cash,trade_type) values";
+            $SQL .= "('$uuid','$allbuyModel->order_id','$allbuyModel->account_name','$allbuyModel->account_identity','$money_diff','$dtime',1,'中奖收入','1','$money_cash',4)" ;
 
-            $this->sql[] = $SQL ;
+            $this->sqlArray[] = $SQL ;
 
     }
 
@@ -366,7 +402,6 @@ class SettlementSql
     public function  writeStatusEndOk($comendnticeModel){
 
         $comendnticeModel->status = 4 ;
-        $comendnticeModel->pret = 1 ;
         $comendnticeModel->done_time = date("Y-m-d H:i:s");
         $comendnticeModel->logs = $comendnticeModel->logs.'end ok';
         $ret = $comendnticeModel->save();
@@ -393,12 +428,13 @@ class SettlementSql
              return $this->AccountArrays['$account_name'];
          }
 
-         $accountModel = DB::table('Account')->where(['account',$account_name])->first();
+         $accountModel = DB::table('account')->where('account',$account_name)->first();
          if (!$accountModel){
              throw  new   \Exception('查无此用户数据account='.$account_name,41002);
          }
 
-         $detailModel = DB::table('Account_detailed','Commons')->where(['account_identity',$accountModel->identity])->first();
+         $detailModel = DB::table('account_detailed')->where('account_identity',$accountModel->identity)->first();
+
          if (!$detailModel){
              throw  new   \Exception('查无此用户数据account_detail='.$accountModel->identity,41002);
          }
@@ -470,10 +506,12 @@ class SettlementSql
                 break;
         }
 
+        /*
         if (empty($model) || empty($models)){
             throw  new   \Exception('没找到比赛结果记录match_id_'.$type.'-'.$match_id,4007);
             return false;
         }
+        */
 
         $this->resultModel = $model;
         $this->resultRecords = $models ;
@@ -487,4 +525,17 @@ class SettlementSql
     }
 
 
+    //冠军比赛结果
+    public function  getGjDatas($matchModel){
+        if ( !empty($this->gjModel) ) {  return $this->gjModel ; }
+        $table = 'st_'.$matchModel->game_code.'_league_result';
+        $where = ['lg_id'=>$matchModel->lg_id,'game_name'=>$matchModel->odds_code];
+        $model = DB::table($table)->where($where)->first();
+        if (!empty($model)){
+            $this->gjModel = $model ;
+        }
+        return $model ;
+    }
+
+
 }

+ 307 - 0
app/Lib/Settlement/SettlementWinFail.php

@@ -0,0 +1,307 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/4/25
+ * Time: 14:10
+ */
+
+namespace App\Lib\Settlement;
+set_time_limit(600);
+ini_set('memory_limit', '256M');
+
+use Illuminate\Support\Facades\DB;
+use App\Models\Comendnotice  as ComendnoticeModel;
+
+use  App\Lib\Settlement\Adapter\ZqRule;
+use  App\Lib\Settlement\Adapter\LqRule;
+use  App\Lib\Settlement\Adapter\WqRule;
+use  App\Lib\Settlement\Adapter\BqRule ;
+
+//一场比赛结束,计算出对应 串式单式下单数据的 输赢并更新到money_buy_match对应记录
+class SettlementWinFail
+{
+
+     //比赛结束消息通知模型
+    public  $ComendNoticModel = null  ;
+
+
+    public $gameType = '' ;  //类型
+    public $match_id = 0 ;  //比赛ID
+
+    public $resultModel = null ; //比赛最终结果对像MODEL
+    public $resultRecords = [] ; //比赛中间结果对像数组;
+    public $gjModel = null ;  //冠军比赛结果数据
+
+    //类型映射
+    public $gameAllMap = [
+        'zq'=>'ZqRule',
+        'lq'=>'LqRule',
+        'wq'=>'WqRule',
+        'bq'=>'BqRule',
+    ];
+    private  $AdapterObj = null ;
+    private   $RefClass = null  ;
+
+
+    //按赛事批量结算
+    public function   doRun(){
+
+        try {
+
+            $ComendNoticModel = $this->getComendNoticeModel();
+            if (!$ComendNoticModel) {
+                return  $this->makeData(1,'没有要处理的数据,直接退出');
+            }
+            $this->writeStatusBegin($ComendNoticModel);
+
+            DB::beginTransaction ();
+
+            $allmatchs = DB::table('money_buy_match')->where(['game_code'=>$ComendNoticModel->game_code,'match_id'=>$ComendNoticModel->match_id,'result'=>0])->get();
+             if (empty($allmatchs)) {
+                $this->writeStatusEndOk($ComendNoticModel);
+                DB::commit();
+                return  $this->makeData(1,'本赛事无订单数据,退出');
+            }
+
+
+            $this->gameType = $ComendNoticModel->game_code ;
+            $this->match_id =  $ComendNoticModel->match_id ;
+
+            $this->setAdapterObj($ComendNoticModel->game_code);
+            $this->RefClass = new  \ReflectionClass(  $this->AdapterObj ) ;
+            $this->getCompResult($ComendNoticModel->game_code,$ComendNoticModel->match_id);
+
+            $this->Settlement_simplex($this->gameType,$this->match_id);
+            $this->Settlement_str($this->gameType,$this->match_id);
+
+
+            $this->writeStatusEndOk($ComendNoticModel);
+            DB::commit();
+            return  $this->makeData(1,'success-all');
+
+        }catch (\Exception $e){
+            DB::rollBack();
+            return $this->makeData(0,'false',['msg'=>$e->getMessage(),'code'=>$e->getCode()]) ;
+
+        }
+    }
+
+    //单式订单结算处理
+    private  function   Settlement_simplex($game_type,$match_id){
+        $buyModels = DB::table('money_buy_simplex')->where(['match_id'=>$match_id,'game_status'=>0])->get();
+        if (empty($buyModels)){ return true; }
+        $buymatchModles = DB::table('money_buy_match')->where(['match_id'=>$match_id,'bet_type'=>1,'result'=>0,'game_code'=>$game_type])->orderby('batch_id','asc')->get();
+        if (empty($buymatchModles)) { return true ; }
+
+        $buyKeyModel =  $buymatchKeyModles = [] ;
+        foreach ($buyModels as $val){
+            $batch_id = $val->batch_id;
+            $buyKeyModel[$batch_id] = $val;
+        }
+        foreach ($buymatchModles as $val){
+            $batch_id = $val->batch_id;
+            $buymatchKeyModles[$batch_id][] = $val;
+        }
+
+        foreach ($buyKeyModel as $batch_id=>$val){
+            foreach ($buymatchKeyModles as $sub_batch_id=>$fsval){
+                    foreach ($fsval as $sval) {
+                        $winorfalse = $this->winOrfalseInfo($sval);
+                        $this->makesql_up_buymatch_winorfalse($sval->id, $winorfalse, date("Y-m-d H:i:s"));
+                    }
+            }
+        }
+        return true;
+    }
+
+    //串式订单结算处理
+    private function   Settlement_str($game_type,$match_id){
+           $matchModels = DB::table('money_buy_match')->where(['match_id'=>$match_id,'bet_type'=>2,'game_code'=>$game_type])->get();
+           if (empty($matchModels)) {  return true; }
+
+           $batch_ids_array = [] ;
+           $matchKeyModels = [] ;
+           foreach ($matchModels as $val){
+                $matchKeyModels[$val->batch_id][] = $val ;
+                if (!in_array($val->batch_id,$batch_ids_array)){
+                    $batch_ids_array[] = $val->batch_id;
+                }
+           }
+
+           $buyModels =  DB::table('money_buy_str')->whereIn( 'batch_id',$batch_ids_array)->get();
+           $buyKeyModels = [] ;
+           if (empty($buyModels)) { return true ; }
+           foreach ($buyModels  as $val){
+               $buyKeyModels[$val->batch_id][] = $val ;
+           }
+
+           foreach ($matchKeyModels as $key=>$sval_2){
+               foreach ($sval_2 as $sval){
+                       if ( $sval->match_id != $this->match_id ){ continue ; }
+                       $winorfalse = $this->winOrfalseInfo($sval);
+                       $this->makesql_up_buymatch_winorfalse($sval->id,$winorfalse,date("Y-m-d H:i:s"));
+                       $sql = "update money_buy_str  set  wait_match_num=wait_match_num-1 where  batch_id='$sval->batch_id' ";
+                       DB::update($sql);
+               }
+           }
+    }
+
+    //输赢结果判断 $sval 为 money_buy_match  Model; 结果为  -1输  1赢  2平  3赢半平半  4输半平半
+    private  function  winOrfalseInfo($sval){
+        $fun = $sval->odds_code ;
+        $fun2 = $sval->p_code ;
+
+        if ($sval->p_code != 'gj'){
+            if (empty($this->resultModel) ||  empty($this->resultRecords)){
+                throw  new \Exception('非冠军比赛结果数据不能为空');
+            }
+
+            if ( $this->RefClass->hasMethod($fun) ){
+                $winorfalse = $this->AdapterObj->$fun($sval,$this->resultModel,$this->resultRecords);
+            }elseif ( $this->RefClass->hasMethod($fun2) ){
+                $winorfalse = $this->AdapterObj->$fun2($sval,$this->resultModel,$this->resultRecords);
+            }else{
+                throw new \Exception('没有找到玩法输赢判断规则',40010);
+            }
+        }else{
+            $this->getGjDatas($sval);
+            if (empty($this->gjModel)){
+                throw  new \Exception('冠军比赛结果数据不能为空');
+            }
+
+            if ( $this->RefClass->hasMethod($fun) ){
+                $winorfalse = $this->AdapterObj->$fun($sval,$this->gjModel,[]);
+            }elseif ( $this->RefClass->hasMethod($fun2) ){
+                $winorfalse = $this->AdapterObj->$fun2($sval,$this->gjModel,[]);
+            }else{
+                throw new \Exception('没有找到玩法输赢判断规则',40010);
+            }
+        }
+        if (!in_array($winorfalse,[-1,1,2,3,4])) {
+            throw new \Exception('输赢结果异常!');
+        }
+        return $winorfalse ;
+    }
+
+
+    private function  makesql_up_buymatch_winorfalse($id,$result,$utime){
+        $sql = " update  money_buy_match  set  result=$result,utime='$utime'  where id=$id  ";
+        DB::update($sql) ;
+
+        return true;
+    }
+
+     //设置 输赢 解析规则适配器
+    private  function  setAdapterObj($game_type){
+        $game_type = strtolower($game_type);
+        if ( !isset($this->gameAllMap)){  throw  new \Exception('赛事类型错误-'.$game_type,4002);   return false;  }
+
+        switch ($game_type){
+            case 'bq':
+                $this->AdapterObj = new BqRule();
+                break;
+            case  'lq':
+                $this->AdapterObj = new LqRule();
+                break;
+            case  'wq':
+                $this->AdapterObj = new WqRule();
+                break;
+            case  'zq':
+               $this->AdapterObj = new ZqRule();
+                break;
+        }
+        return  true ;
+    }
+
+
+    //返回数据
+    private function  makeData($status=1,$message='success',$data=''){
+        return [
+            'status' => $status ,
+            'message' =>$message,
+            'data' => $data ,
+        ] ;
+    }
+
+    //写处理状态
+    public function  writeStatusBegin($comendnticeModel){
+
+        $comendnticeModel->status = 1 ;
+        $comendnticeModel->done_time = date("Y-m-d H:i:s");
+        $comendnticeModel->pcount ++ ;
+        $comendnticeModel->logs = 'begin|';
+        $ret = $comendnticeModel->save();
+
+        return  $ret;
+    }
+
+    //写处理状态结束
+    public function  writeStatusEndOk($comendnticeModel){
+
+        $comendnticeModel->status = 4 ;
+        $comendnticeModel->done_time = date("Y-m-d H:i:s");
+        $comendnticeModel->logs = $comendnticeModel->logs.'end ok';
+        $ret = $comendnticeModel->save();
+
+        return  $ret;
+    }
+
+
+
+    //是否有需要进行结果算处理的赛事记录
+    public  function   getComendNoticeModel(){
+            $ret = (new ComendnoticeModel())->where('status',0)->orderby('id','asc')->first();
+
+            $this->ComendNoticModel = $ret;
+            return $ret;
+    }
+
+
+    //得到比赛最终结果记录 和 中间结果记录
+    public function  getCompResult($type,$match_id){
+        $model = null ;
+        switch ($type){
+            case 'bq':
+                $model = DB::table('st_bq_result')->where('match_id',$match_id)->first();
+                $models = DB::table('st_bq_result_record')->where('match_id',$match_id)->orderBy('id','asc')->get()->toArray();
+                break;
+            case  'lq':
+                $model = DB::table('st_lq_result')->where('match_id',$match_id)->first();
+                $models = DB::table('st_lq_result_record')->where('match_id',$match_id)->orderBy('id','asc')->get()->toArray();
+                break;
+            case  'wq':
+                $model = DB::table('st_wq_result')->where('match_id',$match_id)->first();
+                $models = DB::table('st_wq_result_record')->where('match_id',$match_id)->orderBy('id','asc')->get()->toArray();
+                break;
+            case  'zq':
+                $model = DB::table('st_zq_result')->where('match_id',$match_id)->first();
+                $models = DB::table('st_zq_result_record')->where('match_id',$match_id)->orderBy('id','asc')->get()->toArray();
+                break;
+        }
+
+        $this->resultModel = $model;
+        $this->resultRecords = $models ;
+
+        $ret = [
+            'result' => $model,
+            'records' => $models ,
+        ];
+        return $ret;
+
+    }
+
+
+    //冠军比赛结果
+    public function  getGjDatas($matchModel){
+        if ( !empty($this->gjModel) ) {  return $this->gjModel ; }
+        $table = 'st_'.$matchModel->game_code.'_league_result';
+        $where = ['lg_id'=>$matchModel->lg_id,'game_name'=>$matchModel->odds_code];
+        $model = DB::table($table)->where($where)->first();
+        if (!empty($model)){
+            $this->gjModel = $model ;
+        }
+        return $model ;
+    }
+
+}

+ 15 - 0
app/Models/MoneyBuy.php

@@ -627,4 +627,19 @@ class MoneyBuy extends BaseModel
         //        print_r($data);
         return $data->toArray();
     }
+
+    //根据订单ID返回数据
+    public function  getByOrder($order_id){
+        $data = $this->where('order_id',$order_id)->first();
+        return $data ;
+    }
+
+    //重新结算某个订单;
+    public function  reSelementOrder($order_id){
+
+
+     }
+
+
+
 }

+ 30 - 0
app/Models/MoneyBuyMatch.php

@@ -0,0 +1,30 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: scstf
+ * Date: 2018/9/28
+ * Time: 20:05
+ */
+
+namespace App\Models;
+
+
+use Illuminate\Database\Eloquent\Model;
+
+class MoneyBuyMatch extends Model
+{
+    protected $table='money_buy_match';
+
+    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 ;
+    }
+
+    
+
+
+}

+ 18 - 4
app/Models/MoneyBuyStr.php

@@ -16,14 +16,14 @@ class MoneyBuyStr extends BaseModel {
         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.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')
+                ->select('money_buy_str.id','money_buy_str.account_name','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);
         } 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.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')
+                ->select('money_buy_str.id','money_buy_str.account_name','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')
                 ->orderby('money_buy_str.money_time','desc')
                 ->paginate ($list);
         }
@@ -31,7 +31,7 @@ class MoneyBuyStr extends BaseModel {
             return -2021052003; //
         }
         //反水比例
-        $res = DB::table('setinfo')->where('infoname','放水赔率')->first();
+        $res = DB::table('setinfo')->where('infoname','fanshui')->first();
 
         for($i=0;$i<count($data);$i++){
             if($data[$i]->status==1){
@@ -72,7 +72,21 @@ class MoneyBuyStr extends BaseModel {
             $data[$i]->available_cash = $data[$i]->money_cash+$data[$i]->money.'.00';
             $data[$i]->account = $data[$i]->available_cash.' <span>'.$data[$i]->account_name.' </span> '.$data[$i]->frozen_cash;
 
-            $data[$i]->settle_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm resettlement" lay-event="detail" pid="id" lay-filter = "resettlement" uri="/admin/SoccerStringNoteList/resettlement/?id=" href="/admin/SoccerStringNoteList/resettlement/?id='.$data[$i]->id.'"> 重新结算 </a>';
+            if($data[$i]->settle_status == '未结算'){
+                $result = array();
+                $matchs = DB::table('money_buy_match')->where('batch_id',$data[$i]->batch_id)->where('bet_type',2)->get();
+                for($j=0;$j<count($matchs);$j++){
+                    $result[] = $matchs[$j]->result;
+                }
+                if(in_array(0,$result)){
+                    $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 resettlement" lay-event="detail" pid="id" lay-filter = "resettlement" uri="/admin/SoccerStringNoteList/resettlement/?id=" href="javascript:resettlement(\'/admin/SoccerStringNoteList/resettlement/?id='.$data[$i]->id.'\');"> 重新结算 </a>';
+            }
 
         }
         return $data->toArray();

+ 9 - 0
app/Models/SoccerLeague.php

@@ -23,5 +23,14 @@ class SoccerLeague extends BaseModel {
 		return $data->toArray();
     }
 
+    //赛事信息
+    function onlyleague($lg_id){
+        $data=$this->where('lg_id',$lg_id)->first();
+        if (!$data) {
+            return -5040000102; //无相关信息
+        }
+        return $data->toArray();
+    }
+
 
 }

+ 12 - 3
app/Models/SportsNoteList.php

@@ -24,7 +24,7 @@ class SportsNoteList extends BaseModel {
             return -2021052003; //
         }
         //反水比例
-        $res = DB::table('setinfo')->where('infoname','放水赔率')->first();
+        $res = DB::table('setinfo')->where('infoname','fanshui')->first();
 
         for($i=0;$i<count($data);$i++){
             if($data[$i]->settle_status==1){
@@ -57,7 +57,7 @@ class SportsNoteList extends BaseModel {
             if(!empty($league)){
                 $data[$i]->league = $league->name_chinese;
             }else{
-                $data[$i]->league = $data[$i]->lg_id;
+                $data[$i]->league = '';
             }
             //用户投注后账户金额
             $data[$i]->frozen_cash = $data[$i]->money_cash;
@@ -66,7 +66,16 @@ class SportsNoteList extends BaseModel {
             $data[$i]->account = $data[$i]->available_cash.'<br><span>'.$data[$i]->account_name.'</span><br>'.$data[$i]->frozen_cash;
 
             $content = DB::table('money_buy_match')->where('batch_id',$data[$i]->batch_id)->where('match_id',$data[$i]->match_id)->get();
-            $data[$i]->game_status = $data[$i]->game_status.'<br><a class="layui-btn layui-btn-sm reaudit" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/reaudit/?id=" href="/admin/SoccerNoteList/reaudit/?id='.$data[$i]->id.'"> 重新审核 </a>';
+            if($content[0]->result == '0'){
+                $data[$i]->game_status = $data[$i]->game_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]->game_status == '未处理'){
+                    $data[$i]->game_status = $data[$i]->game_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]->game_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>';
+                }
+            }
+
             for($j=0;$j<count($content);$j++){
                 $odds_code = $content[$j]->odds_code;
                 $result = DB::table('st_odds_code')->where('odds_code',$odds_code)->first();

+ 42 - 0
app/Models/Stzqleagueresult.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+//足球冠军赛事
+class Stzqleagueresult extends Model
+{
+	protected $table = 'st_zq_league_result';
+	public $timestamps = false;
+
+	function resultlist($list = 10, $page, $where = '')
+    {
+        if (is_array ($where) && count ($where) > 0) {
+            $data = $this->join('st_zq_league','st_zq_league.lg_id','=','st_zq_league_result.lg_id')
+                ->select($this->table.'.*','st_zq_league.name_chinese')
+                ->orderby('st_zq_league_result.id','desc')->where($where)->paginate ($list);
+        } else {
+            $data = $this->join('st_zq_league','st_zq_league.lg_id','=','st_zq_league_result.lg_id')
+                ->select($this->table.'.*','st_zq_league.name_chinese')
+                ->orderby('st_zq_league_result.id','desc')->paginate ($list);
+        }
+
+        if (!$data < 0) {
+            return -2021052003; //
+        }
+        return $data->toArray ();
+
+	}
+	
+	//足球赛事联赛查询
+	function allcompetition($lg_id){
+		$data = $this->where('lg_id',$lg_id)->select('id','home_team')->get();
+        if (!$data) {
+			return -5040000102; //无相关信息
+		}
+		return $data->toArray();
+	}
+	
+}
+
+?>

+ 22 - 0
resources/lang/zh-cn/gjmatch.php

@@ -0,0 +1,22 @@
+<?php
+return array(
+
+    //冠军赛事
+	'id' => 'id',
+	'lg_id' => '联赛id',
+	'game_name' => '玩法名称',
+    'result' => '结果',
+    'ctime' => '写入时间',
+	'utime' => '更新时间',
+    'status' => '状态',
+    'sousuo' => '搜索',
+    'select_status' => '搜索状态',
+    'lg_select' => '请选择所属赛事',
+    'name_chinese' => '所属联赛',
+
+    'sstatus'=>array(
+        '0' => '禁用',
+        '1' => '启用',
+    )
+
+);

+ 1 - 0
resources/lang/zh-cn/sportsnotelist.php

@@ -29,6 +29,7 @@ return array(
     'match_status' => '状态',
     'member_type' => '会员类型',
     'edit' => '修改',
+    'ifsettlement' => '结算状态',
 
     'str_type' => '模式',
     'detail_content' => '结算详细信息',

+ 6 - 0
resources/lang/zh-cn/status.php

@@ -356,6 +356,12 @@ return array(
 			'2' => '禁用',
 		),
 	),
+	'ifsettlement' => array(
+		'status' => array(
+			'1' => '未结算',
+			'2' => '已结算',
+		),
+	),
 	'notelist_type' => array(
 		'type' => array(
 			'zq' => '足球',

+ 101 - 0
resources/views/admin/gjmatch/add.blade.php

@@ -0,0 +1,101 @@
+@extends('vip.layouts')
+@section('content')
+
+<form class="layui-form" action="{{ url()->full() }}" id="submitForm" name="submitForm" method="post" eventType=eventAjaxForm>
+{!! csrf_field() !!}
+
+			<div class="layui-form-item">
+                <label class="layui-form-label">{{ trans('gjmatch.game_name') }}:</label>
+                <div class="layui-input-block">
+                <input type="text" name="game_name"   id="game_name"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($game_name) {{ $gjmatch['game_name'] }} @endisset" class="layui-input">
+                </div>
+            </div>
+			<div class="layui-form-item">
+                <label class="layui-form-label">{{ trans('gjmatch.result') }}:</label>
+                <div class="layui-input-block">
+                <input type="text" name="result"   id="result"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($gjmatch) {{ $gjmatch['result'] }} @endisset" class="layui-input">
+                <p style="color:red;">请输入:球员名,球员名</p>
+                </div>
+            </div>
+
+            <div class="layui-form-item layui-form">
+                <label class="layui-form-label">{{ trans('gjmatch.lg_id') }}:</label>
+                    <div class="layui-input-block">
+                    <select name="lg_id"  id="lg_id" lay-filter = 'sect'  lay-verify="required" autocomplete="off" class="layui-input"  eventType=event-query>
+                        <option value="">{{ trans('gjmatch.lg_select') }}</option>
+                        @foreach($data as $k=>$v)
+                            <option value="{{$v['lg_id']}}">{{$v['name_chinese']}}</option>
+                        @endforeach
+                    </select>
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+              <label class="layui-form-label">{{ trans('gjmatch.status') }}:</label>
+              <div class="layui-input-block">
+                <input type="radio" name="status" value="1" title="启用" checked >
+                <input type="radio" name="status" value="0" title="禁用">
+              </div>
+            </div>
+
+    @if(S('ACTION')!='view')
+      <div class="layui-form-item">
+        <div class="layui-input-block">
+          <button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>
+          <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+        </div>
+      </div>
+    @endif
+    </form>
+
+<script>
+    var data;
+    var lgid;
+    var res;
+    layui.use(['form'], function() {
+        var form = layui.form;
+
+        form.on('select(sect)', function(data) {
+            lgid = data.value;
+            $("#match_id").empty()
+            $.ajax({
+                type: 'POST',
+                dataType: 'json',
+                url: '/admin/Sportsfoot/saislist',
+                data: {lgid:lgid},
+                success: function(data) {
+                    if (data != undefined && data != null && data != "") {
+                        var html = "<option value=''>请选择所属赛事</option>";
+                        for (var i = 0; i < data.length; i++) {
+                            html += "<option value=" + data[i]["id"] + ">" + data[i]["home_team"] + "</option>";
+                        }
+                    $("#match_id").append(html);
+                            //重新渲染select
+                             form.render('select');
+                             // $("#match_id").empty()
+                    }
+                }
+            })
+        })
+      form.on('select(api)',function(data){
+        data = data.value;
+        // $("#match_id").empty()
+      })
+    });
+
+// function cbFormSuccess(data){
+// 	layer.msg(data.msg);
+// 	setTimeout(function(){
+//     window.location.href='/admin/Sportsfoot/index';
+// 		// parent.window.location.reload();
+// 	},2500);
+// }
+// lay('.test-item').each(function(){
+//     laydate.render({
+//         elem: this
+//         ,type: 'datetime'
+//         ,trigger: 'click'
+//     });
+// });
+</script>
+@endsection

+ 59 - 0
resources/views/admin/gjmatch/edit.blade.php

@@ -0,0 +1,59 @@
+@extends('vip.layouts')
+@section('content')
+<form class="layui-form" action="{{ url()->full() }}" id="submitForm" name="submitForm" method="post" eventType=eventAjaxForm>
+{!! csrf_field() !!}
+  <div class="layui-form-item">
+    <label class="layui-form-label">玩法名称</label>
+    <div class="layui-input-block">
+      <input type="text" name="game_name" required  lay-verify="required" placeholder="请输入玩法名称" autocomplete="off" value="{{ isset($data['game_name'])?$data['game_name']:'' }}" class="layui-input">
+    </div>
+  </div>
+  
+  <div class="layui-form-item">
+    <label class="layui-form-label">比赛状态:</label>
+        <div class="layui-input-block">
+            <input type="radio" name="status" value="1" title="启用" @if($data['status']==1) checked @endif >
+            <input type="radio" name="status" value="0" title="禁用" @if($data['status']==0) checked @endif>
+        </div>
+  </div>
+  
+  <div class="layui-form-item">
+    <label class="layui-form-label">所属联赛:</label>
+        <div class="layui-input-block">
+            <select name="lg_id"  id="lg_id" lay-filter = 'sect'  lay-verify="required" autocomplete="off" class="layui-input"  eventType=event-query>
+              <option value="@if($only['lg_id']) {{$only['lg_id']}} @endif">@if($only['name_chinese']) {{$only['name_chinese']}} @else {{ trans('gjmatch.lg_select') }} @endif</option>
+              @foreach($ldata as $k=>$v)
+                <option value="{{$v['lg_id']}}">{{$v['name_chinese']}}</option>
+              @endforeach
+            </select>
+        </div>
+  </div>
+
+@if(S('ACTION')!='view')
+  <div class="layui-form-item">
+    <div class="layui-input-block">
+      <button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>
+      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+    </div>
+  </div>
+@endif
+</form>
+
+<script>
+//Demo
+layui.use(['form'], function(){
+  var form = layui.form;
+
+  //监听提交
+  form.on('submit(submitForm)', function(data){
+    return true;
+  });
+});
+function cbFormSuccess(data){
+	layer.msg(data.msg);
+	setTimeout(function(){
+		parent.window.location.reload();
+	},2500);
+}
+</script>
+@endsection

+ 140 - 0
resources/views/admin/gjmatch/index.blade.php

@@ -0,0 +1,140 @@
+@extends('vip.layouts')
+@section('seo_title')
+    足球冠军赛事
+@endsection
+@section('content')
+    <style>
+        .layui-laydate-range {
+            width: auto;
+        }
+
+        .layui-form-switch em {
+            width: auto;
+        }
+
+        .layui-form-switch {
+            width: 44px;
+            line-height: 23px;
+        }
+
+        .layui-form-item .checkbox {
+            width: auto;
+        }
+    </style>
+
+    <script type="text/html" id="status">
+      @{{#if(d.status==0){ }}
+        <span>禁用</span>
+      @{{#} }}
+      @{{#if(d.status==1){ }}
+        <span>启用</span>
+      @{{#} }}
+    </script>
+
+    <script type="text/html" id="status">
+        @if(checkRriv('/admin/gjmatch/index'))<input type="checkbox" name="status" value="@{{d.id}}" lay-skin="switch" lay-text="进行中|已结束" lay-filter="openStatus" @{{ d.status == '1' ? 'checked' : '' }}>@endif
+    </script>
+
+    <div class="layui-row">
+        <div class="layui-col-xs12">
+            <form class="layui-form rewrite" eventType="eventForm"  action="">
+                <div class="layui-form-item">
+                    <div class="layui-inline">
+                        <label class="layui-form-label">{{ trans('gjmatch.sousuo') }}</label>
+                        <div class="layui-input-inline">
+                            <input type="text" name="home_team" id="home_team" eventType="event-query"  value="{{ $home_team }}" lay-verify="required" autocomplete="off" class="layui-input">
+                        </div>
+                        <div class="layui-input-inline checkbox">
+                            <input type="checkbox" name="sureblur" id="form_sureblur" lay-skin="switch" lay-text="精确|模糊" @if(!isset($sureblurs) || $sureblurs=='on') checked @endif  class="layui-input" eventType=event-query>
+                            <input type="hidden" name="sureblurs" id="form_sureblurs" lay-verify="required" autocomplete="off" class="layui-input" eventType=event-query  value="{{ $sureblurs }}">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">{{ trans('gjmatch.status') }}</label>
+                        <div class="layui-input-inline" style="width: 200px">
+                            <select name="status"  id="form_status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
+                                <option value="-1">{{ trans('gjmatch.select_status') }}</option>
+                                @foreach(trans('gjmatch.sstatus') as $k=>$v):
+                                    @if($status==$k))
+                                        <option value="{{$k}}" selected="selected">{{$v}}</option>
+                                    @else
+                                        <option value="{{$k}}">{{$v}}</option>
+                                    @endif
+                                @endforeach
+                            </select>
+                        </div>
+                   </div>
+                    <div class="layui-inline">
+                        <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" eventType="event-query-submit" style="opacity: 1; pointer-events: auto;">提交</a>
+                        <a  class="layui-btn   layui-btn-sm layui-btn-normal reset" data-type="reload" style="opacity: 1; pointer-events: auto;">重置</a>
+                        <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload" style="opacity: 1; pointer-events: auto;"><i class="layui-icon">ဂ</i></a>
+                        @if(checkRriv('/admin/gjmatch/add'))<a href="/admin/gjmatch/add" class="layui-btn layui-btn-sm ">添加</a>@endif
+                        @if(checkRriv('/admin/gjmatch/dele'))<a href="javascript:delWin('/admin/gjmatch/dele?id=');" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a>@endif
+                    </div>
+                </div>
+            </form>
+        </div>
+    </div>
+	<script>
+        $(function () {
+            $('body').on('click', 'a[eventtype="event-delete"]', function () {
+                var span = $(this).prev();
+                var id = span.attr('data-id');
+                // openWin('/admin/system/AddMenu','{{ trans("menu.menu_edit")}}','600px','500px',id);
+            })
+            $('body').on('click','#form_sureblur~.layui-form-switch',function(){
+            	var sus = $('#form_sureblur').next().text();
+            	if(sus=='精确'){
+            		$('#form_sureblurs').val('on');
+            	}else{
+            		$('#form_sureblurs').val('off');
+            	}
+            })
+        })
+	</script>
+@push('dataTableJS')
+/*var active = {
+    reload: function(){
+      //执行重载
+      table.reload('{{ $dataId }}', {
+        page: {
+          curr: 1 //重新从第 1 页开始
+        }
+        ,where: {
+            account:$("#form_account").val(),
+            register_ip:$('#form_register_ip').val(),
+            last_ip:$('#form_last_ip').val(),
+            register_url:$('#form_register_url').val(),
+            last_url:$('#form_last_url').val(),
+            regist_startime:$('#form_regist_startime').val(),
+            regist_endtime:$('#form_regist_endtime').val(),
+            statuss:$('#form_statuss').val(),
+            cash_small:$('#form_cash_small').val(),
+            cash_big:$('#form_cash_big').val(),
+            sureblur:$('.layui-form-switch').text(),
+        }
+      });
+    }
+  };
+$('.lay-btn-diy').on('click', function(){
+    var type = $(this).data('type');
+    active[type] ? active[type].call(this) : '';
+  });*/
+
+  //重置表单
+  $('.reset').on('click',function(){
+      $('input').val('');
+      $('#form_statuss').val('');
+      //var type = $(this).data('type');
+      //active[type] ? active[type].call(this) : '';
+  });
+  //刷新表单
+    $('.set').on('click',function(){
+    //var type = $(this).data('type');
+    //active[type] ? active[type].call(this) : '';
+    });
+
+@endpush
+
+    @include('vip.datatable')
+@endsection

+ 85 - 7
resources/views/sports/sports_notelist.blade.php

@@ -56,7 +56,10 @@
         tbody span{
             color: red;
         }
-        .reaudit{
+        .resettlement{
+            background-color: #FF5722;
+        }
+        .settlement{
             background-color: #FF5722;
         }
     </style>
@@ -72,7 +75,7 @@
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.notelist_type') }}</label>
-                        <div class="layui-input-inline" style="width: 100px">
+                        <div class="layui-input-inline" style="width: 70px">
                             <select name="type"  id="form_type"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
                                 <option value="-1"></option>
                                 @foreach(trans('status.notelist_type.type') as $k=>$v):
@@ -88,7 +91,7 @@
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.account') }}</label>
-                        <div class="layui-input-inline">
+                        <div class="layui-input-inline" style="width: 80px">
                             <input type="text" name="account" id="account" eventType="event-query"  value="{{ $account }}" lay-verify="required" autocomplete="off" class="layui-input">
                         </div>
                         <div class="layui-input-inline checkbox">
@@ -99,34 +102,51 @@
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.date') }}</label>
-                        <div class="layui-input-inline">
+                        <div class="layui-input-inline" style="width: 90px">
                             <input type="text" name="star_time" value="{{ $star_time }}" id="form_star_time" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item" eventType=event-query>
                         </div>
                     </div>~
                     <div class="layui-inline">
                         {{--<label class="layui-form-label">{{ trans('sportsnotelist.end_time') }}</label>--}}
-                        <div class="layui-input-inline">
+                        <div class="layui-input-inline" style="width: 90px">
                             <input type="text" name="end_time" value="{{ $end_time }}" id="end_time" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item" eventType=event-query>
                         </div>
                     </div>
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.order_id') }}</label>
-                        <div class="layui-input-inline">
+                        <div class="layui-input-inline" style="width: 80px">
                             <input type="text" name="order_id" id="order_id" eventType="event-query"  value="{{ $order_id }}" lay-verify="required" autocomplete="off" class="layui-input">
                         </div>
                     </div>
 
                     <div class="layui-inline">
                         <label class="layui-form-label">{{ trans('sportsnotelist.match_id') }}</label>
-                        <div class="layui-input-inline">
+                        <div class="layui-input-inline" style="width: 60px">
                             <input type="text" name="match_id" id="match_id" eventType="event-query"  value="{{ $match_id }}" lay-verify="required" autocomplete="off" class="layui-input">
                         </div>
                     </div>
 
+                    <div class="layui-inline">
+                        <label class="layui-form-label">{{ trans('sportsnotelist.ifsettlement') }}</label>
+                        <div class="layui-input-inline" style="width: 90px">
+                            <select name="status"  id="form_status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
+                                <option value="-1"></option>
+                                @foreach(trans('status.ifsettlement.status') as $k=>$v):
+                                @if($status==$k))
+                                <option value="{{$k}}" selected="selected">{{$v}}</option>
+                                @else
+                                    <option value="{{$k}}">{{$v}}</option>
+                                @endif
+                                @endforeach
+                            </select>
+                        </div>
+                    </div>
+
                     <div class="layui-inline">
                         <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" eventType="event-query-submit" style="opacity: 1; pointer-events: auto;">提交</a>
                         <a  class="layui-btn   layui-btn-sm layui-btn-normal reset" data-type="reload" style="opacity: 1; pointer-events: auto;">重置</a>
+                        @if(checkRriv('/admin/SoccerNoteList/batchsettlement'))<a href="javascript:batchsettlement('/admin/SoccerNoteList/batchsettlement');" class="layui-btn layui-btn-sm  layui-btn-danger">批量结算</a>@endif
                         <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload" style="opacity: 1; pointer-events: auto;"><i class="layui-icon">ဂ</i></a>
                         {{--@if(checkRriv('/admin/SportsSoccer/add'))<a href="/admin/SportsSoccer/add" class="layui-btn layui-btn-sm ">添加</a>@endif--}}
                         {{--@if(checkRriv('/admin/SoccerNoteList/orderstatus'))<a href="/admin/SoccerNoteList/orderstatus" class="layui-btn layui-btn-sm ">订单状态审核</a>@endif--}}
@@ -236,6 +256,64 @@
 
     }
     @endpush
+    <script type="text/javascript">
+        //批量结算
+        function batchsettlement(url) {
+            layer.confirm('是否确认批量结算?', {
+                btn: ['确认', '取消'] //按钮
+            }, function() {
+                $.getJSON(url, function(data, textStatus) {
+                    if (data.status == '1') {
+                        reloadDataTable();
+                        layer.msg('批量结算成功');
+                    } else {
+                        layer.msg(data.msg);
+                    }
+                });
+            }, function() {
+
+            });
+
+        }
+        //单式注单结算
+        function settlement(url,ids) {
+            layer.confirm('是否确认结算?', {
+                btn: ['确认', '取消'] //按钮
+            }, function() {
+                $.getJSON(url, function(data, textStatus) {
+                    //console.log(data);
+                    if (data.status == '1') {
+                        reloadDataTable();
+                        layer.msg('结算成功');
+                    } else {
+                        layer.msg(data.msg);
+                    }
+                });
+            }, function() {
+
+            });
+
+        }
+        //重新结算
+        function resettlement(url) {
+            layer.confirm('是否确认重新结算?', {
+                btn: ['确认', '取消'] //按钮
+            }, function() {
+                $.getJSON(url, function(data, textStatus) {
+                    //console.log(data);
+                    if (data.status == '1') {
+                        reloadDataTable();
+                        layer.msg('重新结算成功');
+                    } else {
+                        layer.msg(data.msg);
+                    }
+                });
+            }, function() {
+
+            });
+
+        }
+    </script>
 
     @include('vip.datatable')
 @endsection

+ 80 - 1
resources/views/sports/sports_stringnotelist.blade.php

@@ -60,6 +60,9 @@
         .resettlement{
             background-color: #FF5722;
         }
+        .settlement{
+            background-color: #FF5722;
+        }
     </style>
 
     <script type="text/html" id="status">
@@ -102,12 +105,28 @@
                         </div>
                     </div>
 
+                    <div class="layui-inline">
+                        <label class="layui-form-label">{{ trans('sportsnotelist.ifsettlement') }}</label>
+                        <div class="layui-input-inline" style="width: 100px">
+                            <select name="status"  id="form_status"  lay-verify="" autocomplete="off" class="layui-input"  eventType=event-query>
+                                <option value="-1"></option>
+                                @foreach(trans('status.ifsettlement.status') as $k=>$v):
+                                @if($status==$k))
+                                <option value="{{$k}}" selected="selected">{{$v}}</option>
+                                @else
+                                    <option value="{{$k}}">{{$v}}</option>
+                                @endif
+                                @endforeach
+                            </select>
+                        </div>
+                    </div>
+
                     <div class="layui-inline">
                         <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" eventType="event-query-submit" style="opacity: 1; pointer-events: auto;">提交</a>
                         <a  class="layui-btn   layui-btn-sm layui-btn-normal reset" data-type="reload" style="opacity: 1; pointer-events: auto;">重置</a>
+                        @if(checkRriv('/admin/SoccerstringNoteList/batchsettlement'))<a href="javascript:batchsettlement('/admin/SoccerstringNoteList/batchsettlement');" class="layui-btn layui-btn-sm  layui-btn-danger">批量结算</a>@endif
                         <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload" style="opacity: 1; pointer-events: auto;"><i class="layui-icon">ဂ</i></a>
                         {{--@if(checkRriv('/admin/SoccerstringNoteList/add'))<a href="/admin/SoccerstringNoteList/add" class="layui-btn layui-btn-sm ">添加</a>@endif--}}
-                        {{--@if(checkRriv('/admin/SoccerstringNoteList/orderstatus'))<a href="/admin/SoccerstringNoteList/orderstatus" class="layui-btn layui-btn-sm ">订单状态审核</a>@endif--}}
                         @if(checkRriv('/admin/SoccerstringNoteList/delete'))<a href="javascript:delWin('/admin/SoccerstringNoteList/delete?id=');" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a>@endif
                     </div>
 
@@ -211,7 +230,67 @@
 
 
     }
+
     @endpush
 
+    <script type="text/javascript">
+        //批量结算
+        function batchsettlement(url) {
+            layer.confirm('是否确认批量结算?', {
+                btn: ['确认', '取消'] //按钮
+            }, function() {
+                $.getJSON(url, function(data, textStatus) {
+                    if (data.status == '1') {
+                        reloadDataTable();
+                        layer.msg('批量结算成功');
+                    } else {
+                        layer.msg(data.msg);
+                    }
+                });
+            }, function() {
+
+            });
+
+        }
+        //串关注单结算
+        function settlement(url,ids) {
+            layer.confirm('是否确认结算?', {
+                btn: ['确认', '取消'] //按钮
+            }, function() {
+                $.getJSON(url, function(data, textStatus) {
+                    //console.log(data);
+                    if (data.status == '1') {
+                        reloadDataTable();
+                        layer.msg('结算成功');
+                    } else {
+                        layer.msg(data.msg);
+                    }
+                });
+            }, function() {
+
+            });
+
+        }
+        //重新结算
+        function resettlement(url) {
+            layer.confirm('是否确认重新结算?', {
+                btn: ['确认', '取消'] //按钮
+            }, function() {
+                $.getJSON(url, function(data, textStatus) {
+                    //console.log(data);
+                    if (data.status == '1') {
+                        reloadDataTable();
+                        layer.msg('重新结算成功');
+                    } else {
+                        layer.msg(data.msg);
+                    }
+                });
+            }, function() {
+
+            });
+
+        }
+    </script>
+
     @include('vip.datatable')
 @endsection