浏览代码

追加推送 4/29

彭俊 6 年之前
父节点
当前提交
64996dcfd5

+ 63 - 23
app/Http/Controllers/Admin/SoccerNoteListController.php

@@ -34,16 +34,16 @@ class SoccerNoteListController extends Controller
         $dt->setLang('sportsnotelist');
         //$dt->addColsFields('id', array('templet' => '#userdetail', 'sort' => true, 'width' => 80));
         $dt->addColsFields('match_id_order', array('templet' => '#userdetail', 'sort' => true, 'width' => 200));
-        $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 150));
-        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 150));
-        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
+        $dt->addColsFields('league', array('templet' => '#userdetail', 'sort' => false, 'width' => 130));
+        $dt->addColsFields('home_guest', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
+        $dt->addColsFields('content', array('templet' => '#userdetail', 'sort' => false, 'width' => 230));
         $dt->addColsFields('money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
         $dt->addColsFields('water_return', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
         $dt->addColsFields('prize_money', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
         $dt->addColsFields('result', array('templet' => '#userdetail', 'sort' => false, 'width' => 80));
         $dt->addColsFields('money_match_time', array('templet' => '#userdetail', 'sort' => false, 'width' => 200));
         $dt->addColsFields('account', array('templet' => '#userdetail', 'sort' => false, 'width' => 120));
-        $dt->addColsFields('game_status', array('templet' => '#userdetail', 'sort' => false, 'width' => 70));
+        $dt->addColsFields('game_status', array('sort' => false, 'width' => 90));
         //$arr[] = 'view';
 //        if (checkRriv('/admin/SoccerNoteList/edit')) {
 //            $arr[] = 'edit';
@@ -100,31 +100,71 @@ class SoccerNoteListController extends Controller
 
 
     /**
-     *单审核
+     *单式注单重新审核
      */
-    public function orderstatus(Req $req) {
-        $id = $req->input('id');
-        if (empty($id)) {
-            return responseToJson(-2001); //id������
-        }
-        $ids = explode(',', $id);
-        if (!is_array($ids) && intval($ids) < 0) {
-            return responseToJson(-2002); //id����
+    public function reaudit(Req $req) {
+        $id = $req->id;
+        if (intval($id) < 1) {
+            return -1;
         }
-        if (is_array($ids) && count($ids) > 0) {
-            foreach ($ids as $k => $v) {
-                if (intval($v) < 1) {
-                    unset($ids[$k]);
-                }
+        $order = DB::table('money_buy_simplex')->where('id',$id)->first();
+        //获取此订单下包含的赛事玩法
+        $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;
+
+        //减本金
+//        for($i=0;$i<count($matchs);$i++){
+//            $money = $matchs[$i]->bet_money;
+//            if($matchs[$i]->result == 0){            //未处理
+//                return "<script>history.go(-1);</script>";
+//            }else if($matchs[$i]->result == -1){     //输
+//                $money = 0-$matchs[$i]->bet_money;
+//            }else if($matchs[$i]->result == 1){      //赢
+//                $odds = $matchs[$i]->odds;
+//                $money = $money*$odds-$matchs[$i]->bet_money;
+//            }else if($matchs[$i]->result == 2){      //平
+//                $money = 0;
+//            }else if($matchs[$i]->result == 3){      //赢半平半
+//                $odds = $matchs[$i]->odds;
+//                $money = $money/2*$odds+$money/2*1-$matchs[$i]->bet_money;
+//            }else if($matchs[$i]->result == 4){      //输半平半
+//                $money = $money/2*1-$matchs[$i]->bet_money;
+//            }
+//            $win_money = $win_money+$money;
+//        }
+
+        //不减本金
+        for($i=0;$i<count($matchs);$i++){
+            $money = $matchs[$i]->bet_money;
+            if($matchs[$i]->result == 0){            //未处理
+                return "<script>history.go(-1);</script>";
+            }else if($matchs[$i]->result == -1){     //输
+                $money = 0;
+            }else if($matchs[$i]->result == 1){      //赢
+                $odds = $matchs[$i]->odds;
+                $money = $money*$odds;
+            }else if($matchs[$i]->result == 2){      //平
+                $money = $money*1;
+            }else if($matchs[$i]->result == 3){      //赢半平半
+                $odds = $matchs[$i]->odds;
+                $money = $money/2*$odds+$money/2*1;
+            }else if($matchs[$i]->result == 4){      //输半平半
+                $money = $money/2*1;
             }
+            $win_money = $win_money+$money;
         }
 
-        $rows = \App\Models\SportsNoteList::whereIn('id', $ids)->delete();
-        if (!$rows) {
-            return responseToJson(-2003); //id����
+        $model = new \App\Models\SportsNoteList();
+        $model = $model::find($id);
+        if($win_money < $order->money){
+            $model->game_status = 2;
+        }else if($win_money >= $order->money){
+            $model->game_status = 1;
         }
-        return responseToJson(1, trans('menu.delete_success')); //id����
-
+        $model->settle_status = 2;
+        $model->gain_money = $win_money;
+        $model->save();
+        return "<script>history.go(-1);</script>";
     }
 
 

+ 11 - 3
app/Http/Controllers/Admin/SoccerStringNoteListController.php

@@ -132,7 +132,8 @@ class SoccerStringNoteListController extends Controller
         }
         $order = DB::table('money_buy_str')->where('id',$id)->first();
         $m = explode('串',$order->str_type);
-        $matchs = DB::table('money_buy_match')->where('batch_id',$order->batch_id)->get()->toArray();
+        //获取此订单下包含的赛事
+        $matchs = DB::table('money_buy_match')->where('batch_id',$order->batch_id)->where('bet_type',2)->get()->toArray();
         function combination($a, $m) {
             $r = array();
             $n = count($a);
@@ -158,7 +159,9 @@ class SoccerStringNoteListController extends Controller
         for($i=0;$i<count($arr);$i++){
             $money = $order->money/count($arr);
             for($j=0;$j<count($arr[$i]);$j++){
-                if($arr[$i][$j]->result == -1){           //输
+                 if($arr[$i][$j]->result == 0){           //未处理
+                     return "<script>history.go(-1);</script>";
+                 }else if($arr[$i][$j]->result == -1){    //输
                     $win_money = 0;
                     $model = new \App\Models\MoneyBuyStr();
                     $model = $model::find($id);
@@ -177,10 +180,15 @@ class SoccerStringNoteListController extends Controller
                     $money = $money/2*1;
                 }
             }
-            $win_money = $win_money+$money-$order->money/count($arr);
+            //减本金
+            //  $win_money = $win_money+$money-$order->money/count($arr);
+
+            //不减本金
+            $win_money = $win_money+$money;
         }
         $model = new \App\Models\MoneyBuyStr();
         $model = $model::find($id);
+        $model->settle_status = 2;
         $model->gain_money = $win_money;
         $model->save();
         return "<script>history.go(-1);</script>";

+ 11 - 4
app/Http/Controllers/Api/SettlementController.php

@@ -3,16 +3,23 @@ namespace App\Http\Controllers\Api;
 use App\Http\Controllers\Controller;
 use App\Lib\Settlement\SettlementSql;
 use App\Lib\Settlement\Adapter\ZqRule;
-
-
+use App\Lib\Settlement\Adapter\LqRule;
 
 class SettlementController extends Controller{
     public function index(){
-        $dd = new ZqRule();
+        $dd = new LqRule();
 
-        dd($dd->bodanRule(1,2,1));
+        dd($dd->capotRule(1,2,1));
     }
     public function dd(){
         dd(1111);
     }
+
+    public function  debug(){
+        $obj = new SettlementSql();
+        $ret = $obj->doRun();
+        var_dump($ret);
+
+    }
+
 }

+ 478 - 0
app/Lib/Settlement/Adapter/BqRule.php

@@ -11,4 +11,482 @@ namespace App\Lib\Settlement\Adapter;
 class BqRule
 {
 
+    /**
+     * 让球公共函数
+     * @param mixed $model 注单表数据
+     * @param mixed $difference 分差
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function concedeCommon($model, $difference){
+        // 让球个数
+        $condition = intval($model -> condition);
+        // 差值
+        $resultScore = $difference + $condition;
+        if ($resultScore > 0) {
+            $result = 1;
+        } elseif ($resultScore < 0) {
+            $result = -1;
+        } else {
+            $result = 2;
+        }
+
+        return $result;
+    }
+
+    /**
+     * 大小公共函数
+     * @param mixed $model 注单表数据
+     * @param mixed $allGoal 总分
+     * @param mixed $size 大小 1:大  -1:小
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function sizeCommon($model, $allGoal, $size){
+        // 总球条件
+        $condition = intval($model -> condition);
+        // 差值
+        if ($size == 1) {
+            $resultScore = $allGoal - $condition;
+        } else {
+            $resultScore = $condition - $allGoal;
+        }
+        if ($resultScore > 0) {
+            $result = 1;
+        } elseif ($resultScore < 0) {
+            $result = -1;
+        } else {
+            $result = 2;
+        }
+
+        return $result;
+    }
+
+    /**
+     * 全场|主队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_concede_home($model, $resultModel, $resultRecords){
+        // 主队得分
+        $homeScore = intval($resultModel -> home_score);
+        // 客队得分
+        $guestScore = intval($resultModel -> guest_score);
+        // 分差 - 主 :客
+        $difference = $homeScore - $guestScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 全场|客队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_concede_guest($model, $resultModel, $resultRecords){
+        // 主队得分
+        $homeScore = intval($resultModel -> home_score);
+        // 客队得分
+        $guestScore = intval($resultModel -> guest_score);
+        // 分差 - 客 :主
+        $difference = $guestScore - $homeScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 上半场|主队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_half_concede_home($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $upResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$upResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$upResultKey] -> guest_score);
+        // 分差 - 主 :客
+        $difference = $homeScore - $guestScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 上半场|客队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_half_concede_guest($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $upResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$upResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$upResultKey] -> guest_score);
+        // 分差 - 客 :主
+        $difference = $guestScore - $homeScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 第一节|主队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_one_concede_home($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $oneResultKey = array_search('第一节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$oneResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$oneResultKey] -> guest_score);
+        // 分差 - 主 :客
+        $difference = $homeScore - $guestScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 第一节|客队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_one_concede_guest($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $oneResultKey = array_search('第一节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$oneResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$oneResultKey] -> guest_score);
+        // 分差 - 客 :主
+        $difference = $guestScore - $homeScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 第二节|主队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_two_concede_home($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $oneResultKey = array_search('第一节', array_column($newResultRecords, 'match_process'));
+        $twoResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$twoResultKey] -> home_score) - intval($newResultRecords[$oneResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$twoResultKey] -> guest_score) - intval($newResultRecords[$oneResultKey] -> guest_score);
+        // 分差 - 主 :客
+        $difference = $homeScore - $guestScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 第二节|客队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_two_concede_guest($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $oneResultKey = array_search('第一节', array_column($newResultRecords, 'match_process'));
+        $twoResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$twoResultKey] -> home_score) - intval($newResultRecords[$oneResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$twoResultKey] -> guest_score) - intval($newResultRecords[$oneResultKey] -> guest_score);
+        // 分差 - 客 :主
+        $difference = $guestScore - $homeScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 第三节|主队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_three_concede_home($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $twoResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        $threeResultKey = array_search('第三节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$threeResultKey] -> home_score) - intval($newResultRecords[$twoResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$threeResultKey] -> guest_score) - intval($newResultRecords[$twoResultKey] -> guest_score);
+        // 分差 - 主 :客
+        $difference = $homeScore - $guestScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 第三节|客队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_three_concede_guest($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $twoResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        $threeResultKey = array_search('第三节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$threeResultKey] -> home_score) - intval($newResultRecords[$twoResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$threeResultKey] -> guest_score) - intval($newResultRecords[$twoResultKey] -> guest_score);
+        // 分差 - 客 :主
+        $difference = $guestScore - $homeScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 第四节|主队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_four_concede_home($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $threeResultKey = array_search('第三节', array_column($newResultRecords, 'match_process'));
+        $fourResultKey = array_search('第四节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$fourResultKey] -> home_score) - intval($newResultRecords[$threeResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$fourResultKey] -> guest_score) - intval($newResultRecords[$threeResultKey] -> guest_score);
+        // 分差 - 主 :客
+        $difference = $homeScore - $guestScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 第四节|客队|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_four_concede_guest($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $threeResultKey = array_search('第三节', array_column($newResultRecords, 'match_process'));
+        $fourResultKey = array_search('第四节', array_column($newResultRecords, 'match_process'));
+        // 主队得分
+        $homeScore = intval($newResultRecords[$fourResultKey] -> home_score) - intval($newResultRecords[$threeResultKey] -> home_score);
+        // 客队得分
+        $guestScore = intval($newResultRecords[$fourResultKey] -> guest_score) - intval($newResultRecords[$threeResultKey] -> guest_score);
+        // 分差 - 客 :主
+        $difference = $guestScore - $homeScore;
+
+        return $this -> concedeCommon($model, $difference);
+    }
+
+    /**
+     * 总进球|全场|大
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_total_sizes_big($model, $resultModel, $resultRecords){
+        // 总进球数
+        $allGoal = intval($resultModel -> home_score) + intval($resultModel -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, 1);
+    }
+
+    /**
+     * 总进球|全场|小
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_total_sizes_small($model, $resultModel, $resultRecords){
+        // 总进球数
+        $allGoal = intval($resultModel -> home_score) + intval($resultModel -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, -1);
+    }
+
+    /**
+     * 总进球|上半场|大
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_half_total_sizes_big($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $upResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$upResultKey] -> home_score) + intval($newResultRecords[$upResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, 1);
+    }
+
+    /**
+     * 总进球|上半场|小
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_half_total_sizes_small($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $upResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$upResultKey] -> home_score) + intval($newResultRecords[$upResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, -1);
+    }
+
+    /**
+     * 总进球|第一节|大
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_one_total_sizes_big($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $oneResultKey = array_search('第一节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$oneResultKey] -> home_score) + intval($newResultRecords[$oneResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, 1);
+    }
+
+    /**
+     * 总进球|第一节|小
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_one_total_sizes_small($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $oneResultKey = array_search('第一节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$oneResultKey] -> home_score) + intval($newResultRecords[$oneResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, -1);
+    }
+
+    /**
+     * 总进球|第二节|大
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_two_total_sizes_big($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $oneResultKey = array_search('第一节', array_column($newResultRecords, 'match_process'));
+        $twoResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$twoResultKey] -> home_score) + intval($newResultRecords[$twoResultKey] -> guest_score)
+                - intval($newResultRecords[$oneResultKey] -> home_score) - intval($newResultRecords[$oneResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, 1);
+    }
+
+    /**
+     * 总进球|第二节|小
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_two_total_sizes_small($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $oneResultKey = array_search('第一节', array_column($newResultRecords, 'match_process'));
+        $twoResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$twoResultKey] -> home_score) + intval($newResultRecords[$twoResultKey] -> guest_score)
+            - intval($newResultRecords[$oneResultKey] -> home_score) - intval($newResultRecords[$oneResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, -1);
+    }
+
+    /**
+     * 总进球|第三节|大
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_three_total_sizes_big($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $twoResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        $threeResultKey = array_search('第三节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$threeResultKey] -> home_score) + intval($newResultRecords[$threeResultKey] -> guest_score)
+                - intval($newResultRecords[$twoResultKey] -> home_score) - intval($newResultRecords[$twoResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, 1);
+    }
+
+    /**
+     * 总进球|第三节|小
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_three_total_sizes_small($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $twoResultKey = array_search('第二节', array_column($newResultRecords, 'match_process'));
+        $threeResultKey = array_search('第三节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$threeResultKey] -> home_score) + intval($newResultRecords[$threeResultKey] -> guest_score)
+            - intval($newResultRecords[$twoResultKey] -> home_score) - intval($newResultRecords[$twoResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, -1);
+    }
+
+    /**
+     * 总进球|第四节|大
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_four_total_sizes_big($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $threeResultKey = array_search('第三节', array_column($newResultRecords, 'match_process'));
+        $fourResultKey = array_search('第四节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$fourResultKey] -> home_score) + intval($newResultRecords[$fourResultKey] -> guest_score)
+                - intval($newResultRecords[$threeResultKey] -> home_score) - intval($newResultRecords[$threeResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, 1);
+    }
+
+    /**
+     * 总进球|第四节|小
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function lq_four_total_sizes_small($model, $resultModel, $resultRecords){
+        $newResultRecords = array_reverse($resultRecords);
+        $threeResultKey = array_search('第三节', array_column($newResultRecords, 'match_process'));
+        $fourResultKey = array_search('第四节', array_column($newResultRecords, 'match_process'));
+        // 总进球数
+        $allGoal = intval($newResultRecords[$fourResultKey] -> home_score) + intval($newResultRecords[$fourResultKey] -> guest_score)
+            - intval($newResultRecords[$threeResultKey] -> home_score) - intval($newResultRecords[$threeResultKey] -> guest_score);
+        return $this -> sizeCommon($model, $allGoal, -1);
+    }
 }

+ 12 - 0
app/Lib/Settlement/Adapter/LqRule.php

@@ -7,8 +7,20 @@
  */
 
 namespace App\Lib\Settlement\Adapter;
+use Illuminate\Support\Facades\DB;
 
 class LqRule
 {
 
+    /**
+     * 篮球 独赢规则
+     */
+    public function capotRule($bet_match,$result_match,$result_match_r){
+        $bet_match = DB::table('money_buy_match')->where('match_id', 3144414)->first();
+        $result_match = DB::table('st_lq_result')->where('match_id', 3144414)->first();
+        $result_match_r = DB::table('st_lq_result_record')->where('match_id', 3144414)->get()->toArray();
+
+        dd($bet_match);
+    }
+
 }

+ 387 - 19
app/Lib/Settlement/Adapter/ZqRule.php

@@ -7,37 +7,373 @@
  */
 
 namespace App\Lib\Settlement\Adapter;
-use Illuminate\Support\Facades\DB;
-
 
 class ZqRule
-
 {
+    /**
+     * 全场|[主、客]|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @param mixed $type 1:代表主队让球   2:代表客队让球
+     * @param mixed $size 1:大 -1:小(如果是让球大小玩法才传入该字段)
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function concedeFull($model, $resultModel, $resultRecords, $type, $size = ''){
+         // 主队得分
+        $homeScore = intval($resultModel -> home_score);
+        // 客队得分
+        $guestScore = intval($resultModel -> guest_score);
+        $difference = 0;
+        // 分差 - 主 :客
+        if ($type == 1) {
+            $difference = $homeScore - $guestScore;
+        } else {
+            // 分差 - 客 :主
+            $difference = $guestScore - $homeScore;
+        }
+        // 让球个数
+        $condition = explode("/", $model -> condition);
+        $resultArr = [];
+        // 循环对比让球后输赢
+        foreach ($condition as $value) {
+            $absValue = abs($value);
+            if (substr($model -> condition, 0, 1) == '-') {
+                $resultScore = $difference - $absValue;
+            } else {
+                $resultScore = $difference + $absValue;
+            }
+            if ($resultScore > 0) {
+                $resultArr[] = 1;
+            } elseif ($resultScore < 0) {
+                $resultArr[] = -1;
+            } else {
+                $resultArr[] = 2;
+            }
+        }
+        // 去重
+        $resultUniqueArr = array_unique($resultArr);
+        // 循环对比让球后输赢
+        $count = count($resultUniqueArr);
+        if ($size == -1) {
+            if ($count == 1) {
+                if ($resultUniqueArr[0] == 1) {
+                    return -1;
+                } elseif ($resultUniqueArr[0] == 2) {
+                    return 2;
+                } else {
+                    return 1;
+                }
+            } elseif (in_array(1, $resultUniqueArr)) {
+                return 4;
+            } else {
+                return 3;
+            }
+        } else {
+            if ($count == 1) {
+                return $resultUniqueArr[0];
+            } elseif (in_array(1, $resultUniqueArr)) {
+                return 3;
+            } else {
+                return 4;
+            }
+        }
+     }
 
-    ////////////////////////根据规则判断输赢
-    //让球大小
-     public  function    concede_size($model,$resultModel,$resultRecords){
+    /**
+     * 半场|[主、客]|让球
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @param mixed $whoType 1:代表主队让球   2:代表客队让球
+     * @param mixed $halfType 1:上半场   2:下半场
+     * @param mixed $size 1:大 -1:小(如果是让球大小玩法才传入该字段)
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function concedeHalf($model, $resultModel, $resultRecords, $whoType, $halfType, $size = ''){
+        $half = [1 => '上半场', 2 => '下半场'];
+        // 倒叙
+        $newResultRecords = array_reverse($resultRecords);
+        // 查询最后的上半场的key值
+        $upResultKey = array_search($half[1], array_column($newResultRecords, 'match_process'));
+        $homeScore = 0;
+        $guestScore = 0;
+        if ($halfType == 1) {
+            // 主队得分
+            $homeScore = intval($newResultRecords[$upResultKey] -> home_score);
+            // 客队得分
+            $guestScore = intval($newResultRecords[$upResultKey] -> guest_score);
+        } else {
+            // 查询最后的下半场的key值
+            $downResultKey = array_search($half[2], array_column($newResultRecords, 'match_process'));
+            // 下半场主队得分
+            $homeScore = intval($newResultRecords[$downResultKey] -> home_score) - intval($newResultRecords[$upResultKey] -> home_score);
+            // 下半场客队得分
+            $guestScore = intval($newResultRecords[$downResultKey] -> guest_score) - intval($newResultRecords[$upResultKey] -> guest_score);
+        }
+        $difference = 0;
+        // 分差 - 主 :客
+        if ($whoType == 1) {
+            $difference = $homeScore - $guestScore;
+        } else {
+            // 分差 - 客 :主
+            $difference = $guestScore - $homeScore;
+        }
+        // 让球个数
+        $condition = explode("/", $model -> condition);
+        $resultArr = [];
+        // 循环对比让球后输赢
+        foreach ($condition as $value) {
+            $absValue = abs($value);
+            if (substr($model -> condition, 0, 1) == '-') {
+                $resultScore = $difference - $absValue;
+            } else {
+                $resultScore = $difference + $absValue;
+            }
+            if ($resultScore > 0) {
+                $resultArr[] = 1;
+            } elseif ($resultScore < 0) {
+                $resultArr[] = -1;
+            } else {
+                $resultArr[] = 2;
+            }
+        }
+        // 去重
+        $resultUniqueArr = array_unique($resultArr);
+        // 循环对比让球后输赢
+        $count = count($resultUniqueArr);
+        // 如果猜的是让球大小且猜的是小则运行
+        if ($size == -1) {
+            if ($count == 1) {
+                if ($resultUniqueArr[0] == 1) {
+                    return -1;
+                } elseif ($resultUniqueArr[0] == 2) {
+                    return 2;
+                } else {
+                    return 1;
+                }
+            } elseif (in_array(1, $resultUniqueArr)) {
+                return 4;
+            } else {
+                return 3;
+            }
+        } else {
+            if ($count == 1) {
+                return $resultUniqueArr[0];
+            } elseif (in_array(1, $resultUniqueArr)) {
+                return 3;
+            } else {
+                return 4;
+            }
+        }
+     }
 
+    /**
+     * 总进球全场|[主、客、全]|大小
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @param mixed $type 1:主队  2:客队 0:全部进球 (目前只传 0)
+     * @param mixed $size 1:大  -1:小
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function sizeFull($model, $resultModel, $resultRecords, $type, $size){
+        // 总进球数
+        $allGoal = intval($resultModel -> home_score) + intval($resultModel -> guest_score);
+        // 主队进球数
+        $homeGoal = intval($resultModel -> home_score);
+        // 客队进球数
+        $guestGoal = intval($resultModel -> guest_score);
+        // 条件
+        $condition = explode("/", $model -> condition);
+        $resultArr = [];
+        // 循环对比输赢
+        foreach ($condition as $value) {
+            $absValue = abs($value);
+            if ($type == 1) {
+                $resultScore = $homeGoal - $absValue;
+            } elseif ($type == 2) {
+                $resultScore = $guestGoal - $absValue;
+            } else {
+                $resultScore = $allGoal - $absValue;
+            }
 
-     }
+            if ($resultScore > 0) {
+                $resultArr[] = 1;
+            } elseif ($resultScore < 0) {
+                $resultArr[] = -1;
+            } else {
+                $resultArr[] = 0;
+            }
+        }
+        // 去重
+        $resultUniqueArr = array_unique($resultArr);
 
-     //全场|主队|让球
-    public  function   concede_home($model,$resultModel,$resultRecords){
-            $zhiball = intval($resultModel->home_score) ;
-            $keballs = intval($resultModel->guest_score) ;
-            $cond = intval($model->condition) ;
-            $cha = $zhiball - $keballs - $cond ;
+        // 循环对比让球后输赢
+        $count = count($resultUniqueArr);
+        if ($count == 1) {
+            // 如果猜中
+            if ($resultUniqueArr[0] == $size) {
+                return 1;
+            } elseif ($resultUniqueArr[0] == 0) {
+                // 如果平
+                return 2;
+            } else {
+                // 如果猜错
+                return -1;
+            }
+        } elseif (in_array($size, $resultUniqueArr)) {
+            return 3;
+        } else {
+            return 4;
+        }
+    }
 
-            if ($cha  >0 ){ return 1; }
-            if($cha ==0 ) { return 2 ;}
-            return -1 ;
-     }
+    /**
+     * 半场|[主、客、全]|大小
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @param mixed $type 1:主队  2:客队 0:全部进球 (目前只传 0)
+     * @param mixed $size 1:大  -1:小
+     * @param mixed $halfType 1:上半场   2:下半场
+     * @return string 1:赢  -1:输  2:平  3:赢半平半  4:输半平半
+     */
+    public function sizeHalf($model, $resultModel, $resultRecords, $type, $size, $halfType){
+        $half = [1 => '上半场', 2 => '下半场'];
+        // 倒叙
+        $newResultRecords = array_reverse($resultRecords);
+        // 查询最后的上半场的key值
+        $upResultKey = array_search($half[1], array_column($newResultRecords, 'match_process'));
+        if ($halfType == 1) {
+            // 上半场总进球数
+            $allGoal = intval($newResultRecords[$upResultKey] -> home_score) + intval($newResultRecords[$upResultKey] -> guest_score);
+            // 上半场主队进球数
+            $homeGoal = intval($newResultRecords[$upResultKey] -> home_score);
+            // 上半场客队进球数
+            $guestGoal = intval($newResultRecords[$upResultKey] -> guest_score);
+        } else {
+            // 查询最后的下半场的key值
+            $downResultKey = array_search($half[2], array_column($newResultRecords, 'match_process'));
+            // 下半场总进球数
+            $allGoal = intval($newResultRecords[$downResultKey] -> home_score) + intval($newResultRecords[$downResultKey] -> guest_score) -
+                intval($newResultRecords[$upResultKey] -> home_score) + intval($newResultRecords[$upResultKey] -> guest_score);
+            // 下半场主队进球数
+            $homeGoal = intval($newResultRecords[$downResultKey] -> home_score) - intval($newResultRecords[$upResultKey] -> home_score);
+            // 下半场客队进球数
+            $guestGoal = intval($newResultRecords[$downResultKey] -> guest_score) - intval($newResultRecords[$upResultKey] -> guest_score);
+        }
+        // 条件
+        $condition = explode("/", $model -> condition);
+        $resultArr = [];
+        // 循环对比输赢
+        foreach ($condition as $value) {
+            $absValue = abs($value);
+            if ($type == 1) {
+                $resultScore = $homeGoal - $absValue;
+            } elseif ($type == 2) {
+                $resultScore = $guestGoal - $absValue;
+            } else {
+                $resultScore = $allGoal - $absValue;
+            }
 
-     //主队全场让球条件
-    public  function  concede_home_rule($model,$resultModel,$resultRecords){
+            if ($resultScore > 0) {
+                $resultArr[] = 1;
+            } elseif ($resultScore < 0) {
+                $resultArr[] = -1;
+            } else {
+                $resultArr[] = 0;
+            }
+        }
+        // 去重
+        $resultUniqueArr = array_unique($resultArr);
 
+        // 循环对比让球后输赢
+        $count = count($resultUniqueArr);
+        if ($count == 1) {
+            // 如果猜中
+            if ($resultUniqueArr[0] == $size) {
+                return 1;
+            } elseif ($resultUniqueArr[0] == 0) {
+                // 如果平
+                return 2;
+            } else {
+                // 如果猜错
+                return -1;
+            }
+        } elseif (in_array($size, $resultUniqueArr)) {
+            return 3;
+        } else {
+            return 4;
+        }
     }
 
+    /**
+     * 全场|[主、客、平]|独赢
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @param mixed $type 1:主队  2:客队 0:平
+     * @return string 1:赢  -1:输
+     */
+    public function winFull($model, $resultModel, $resultRecords, $type){
+        // 主队得分
+        $homeScore = intval($resultModel -> home_score);
+        // 客队得分
+        $guestScore = intval($resultModel -> guest_score);
+        $difference = $homeScore - $guestScore;
+        if ($difference > 0 && $type == 1) {
+            return 1;
+        } elseif ($difference < 0 && $type == 2) {
+            return 1;
+        } elseif ($difference == 0 && $type == 0) {
+            return 1;
+        } else {
+            return -1;
+        }
+    }
+
+    /**
+     * 半场|[主、客、平]|独赢
+     * @param mixed $model 注单表数据
+     * @param mixed $resultModel 结果表数据
+     * @param mixed $resultRecords 结果记录表数据
+     * @param mixed $type 1:主队  2:客队 0:平
+     * @param mixed $halfType 1:上半场   2:下半场
+     * @return string 1:赢  -1:输
+     */
+    public function winHalf($model, $resultModel, $resultRecords, $type, $halfType){
+        $half = [1 => '上半场', 2 => '下半场'];
+        // 倒叙
+        $newResultRecords = array_reverse($resultRecords);
+        // 查询最后的上半场的key值
+        $upResultKey = array_search($half[1], array_column($newResultRecords, 'match_process'));
+        $homeScore = 0;
+        $guestScore = 0;
+        if ($halfType == 1) {
+            // 主队得分
+            $homeScore = intval($newResultRecords[$upResultKey] -> home_score);
+            // 客队得分
+            $guestScore = intval($newResultRecords[$upResultKey] -> guest_score);
+        } else {
+            // 查询最后的下半场的key值
+            $downResultKey = array_search($half[2], array_column($newResultRecords, 'match_process'));
+            // 下半场主队得分
+            $homeScore = intval($newResultRecords[$downResultKey] -> home_score) - intval($newResultRecords[$upResultKey] -> home_score);
+            // 下半场客队得分
+            $guestScore = intval($newResultRecords[$downResultKey] -> guest_score) - intval($newResultRecords[$upResultKey] -> guest_score);
+        }
+        $difference = $homeScore - $guestScore;
+        if ($difference > 0 && $type == 1) {
+            return 1;
+        } elseif ($difference < 0 && $type == 2) {
+            return 1;
+        } elseif ($difference == 0 && $type == 0) {
+            return 1;
+        } else {
+            return -1;
+        }
+    }
 
     //  first_last_ball最先/最后进球 开始-----------------------
     //主队|最先进球
@@ -154,5 +490,37 @@ class ZqRule
         return $result;
     }
 
+    //结果单/双 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球
+    public function  Singledouble($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;
+        }else{
+            $data = 2;
+        }
+        if($data = intval($model->condition)){
+            return 1;
+        }else{
+            return -1;
+        }
+
+    } 
+
+    //结果总数 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球 u_home_score 上半场-主队进球数 u_guest_score 上半场-客队进球数
+    public function  Totalnum($model,$resultModel,$resultRecords){
+        //全场总进球数
+        $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score) + intval($resultModel->guest_rate) + intval($resultModel->home_rate);
+        //上半场总进球数
+        $Firsthalftod = intval($resultModel->home_score) + intval($resultModel->guest_score) + intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
+        
+        $qjnum = explode(',', $model->condition);
+        if($qjnum[0]<$resulttod and $qjnum[1]>$resulttod){
+            return 1;
+        }else{
+            return -1;
+        }
+
+    }
+
 
 }

+ 280 - 64
app/Lib/Settlement/SettlementSql.php

@@ -10,6 +10,14 @@ 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 ;
+
 
 class SettlementSql
 {
@@ -49,108 +57,285 @@ class SettlementSql
     private   $RefClass = null  ;
 
 
+    public function   GetSQL(){
+        return $this->makeData(1,'success',$this->sqlArray);
+    }
+
     public function   doRun(){
 
 
         try {
-            _beginTransaction();
+            DB::beginTransaction ();
 
             $ComendNoticModel = $this->getComendNoticeModel();
             if (!$ComendNoticModel) {
-                _commit();
-                return  $this->makeData();
+                DB::commit ();
+                return  $this->makeData(1,'没有要处理的数据,直接退出');
             }
             $this->writeStatusBegin($ComendNoticModel);
 
-            $allmatchs = $this->getAllMatchIdArrays($ComendNoticModel->game_code, $ComendNoticModel->match_id, 2);
-            $this->setAdapterObj( $ComendNoticModel->game_code );
-            $this->RefClass = new  \ReflectionClass(  $this->setAdapterObj ) ;
-            $this->getCompResult($ComendNoticModel->game_code,$ComendNoticModel->match_id);
-
-
-            if (!$allmatchs) {
+            $allmatchs = $this->getAllMatchIdArrays($ComendNoticModel->game_code, $ComendNoticModel->match_id, 0);
+             if (empty($allmatchs)) {
                 $this->writeStatusEndOk($ComendNoticModel);
-                _commit();
-                return  $this->makeData();
+                DB::commit();
+                return  $this->makeData(1,'本赛事无订单数据,退出');
             }
 
+            $this->setAdapterObj($ComendNoticModel->game_code);
+            $this->RefClass = new  \ReflectionClass(  $this->AdapterObj ) ;
+            $this->getCompResult($ComendNoticModel->game_code,$ComendNoticModel->match_id);
+
             foreach ($allmatchs  as $buymatchmodel){
-                    $this->doSettlement($buymatchmodel);
+                    $this->domatchPresess($buymatchmodel);
             }
 
-            _commit();
-            return  $this->makeData();
+            DB::rollback();
+            return  $this->makeData(1,'success-all');
 
         }catch (\Exception $e){
-            _rollBack();
+            DB::rollBack();
             return $this->makeData(0,'false',['msg'=>$e->getMessage(),'code'=>$e->getCode()]) ;
 
         }
-
     }
 
 
     //拼装  逻辑 sql;
-    private  function  doSettlement($model){
+    private  function  domatchPresess($model){
         $fun = $model->odds_code ;
         if ( $this->RefClass->hasMethod( $fun)){
                 $winorfalse = $this->AdapterObj->$fun($model,$this->resultModel,$this->resultRecords);
                 $this->makesql_up_buymatch_winorfalse($model->id,$winorfalse,date("Y-m-d H:i:s"));
-                if ($winorfalse == -1){
-                    $this->masql_up_buymatch_false($model->batch_id);
+
+                if ($model->bet_type ==2){
+                      if ($winorfalse == -1){
+                          //串式,一个错,全部错了.....
+                          $this->makesql_up_serial_lose($model);
+                          return ;
+                      }
+                }
+
+                $mainmodels = $this->GetBuyStrBatchIdArrays($model->batch_id,$model->bet_type);
+                $lessCount = $mainmodels[0]->wait_match_num;
+                if ($lessCount > 0 ){
+                    //还有没结束的赛事,不急做结算处理
+                    $this->wait_match_num_desc($model->batch_id,$model->bet_type);
+                    return  true  ;
                 }
 
+                $this->doSettlement($model);
+
+        }else{
+            throw  new  \Exception('找不到此玩法的胜负规则逻辑!',4005);
+        }
+    }
+
+    private function   wait_match_num_desc($batch_id,$type){
+        $table = ($type ==1)? 'money_buy_simplex': 'money_buy_str';
+        $sql = "update  $table  set    wait_match_num=wait_match_num-1 where  batch_id='$batch_id' ";
+        $this->sqlArray[] = $sql;
+    }
+
+    //实现结算相关的逻辑
+    //逐个计算每个下单情况给用户加钱  {加用户余额,写流水详细}
+    private function  doSettlement($model){
+           $batchid = $model->batch_id ;
+           $bettype = $model->bet_type ;
+
+
+           $allbatchModels = $this->getAllBatchIdArrays($model->game_code,$batchid);
+           //存在相同比赛不同玩法串式,先前已经输的情况下,此时没有数据了....
+           if (empty($allbatchModels)){      return true;        }
+
+           $allbuyModels = $this->GetBuyStrBatchIdArrays($batchid,$bettype);
+           $account_identity = '';
+
+           if ($bettype ==2){
+               //串式投注
+               $con_arr = [] ;
+               foreach ($allbatchModels as $batchModel){
+                   $con_arr[] = ['odds'=>$batchModel->odds,'winorlose'=>$batchModel->result,'money'=>1];
+               }
+               $peilvArray = $this->winOddsCalculation(2,$con_arr);
+               foreach  ($allbuyModels as $buyModel){
+                       if  ($account_identity==''){    $account_identity = $buyModel->account_identity;   }
+                       $money = sprintf("%.2f",$buyModel->money * $peilvArray['returnMoney']) ;
+                       $sql = "update  money_buy_str set gain_money=$money  where  batch_id='$batchid' and id=$buyModel->id ";
+                       $this->sqlArray[] = $sql ;
+               }
+
+           }else{
+               //单式投注
+               $money = 0 ;
+               if  ( $account_identity ==''){    $account_identity = $allbuyModels['0']->account_identity;   }
+               $money = 0 ;
+               foreach ($allbatchModels as $batchModel){
+                   $con_arr[] = ['odds'=>$model->odds,'winorlose'=>$batchModel->result,'money'=>$allbuyModels['0']->money];
+                   $money_odds_array = $this->winOddsCalculation(1,$con_arr);
+                   $money += sprintf("%.2f",$batchModel->bet_money * $money_odds_array['returnMoney'] ) ;
+               }
+
+               $sql = "update  money_buy_simplex set gain_money=$money  where  batch_id=$batchid ";
+               $this->sqlArray[] = $sql ;
+           }
+
+           $money_diff = $this->get_money_chage($batchid,$bettype);
+           $this->sql_accountdetail_money($account_identity,$money_diff);
+           $this->sql_moneydetqil_log($allbuyModels['0'],$model,$money_diff);
+
+    }
+
+    /**
+     * 注单返现计算
+     * @param mixed $dataArray 结果表数据 [['odds'=>xx,'winOrLose'=>1],[...]];
+     * @return array 注单返现额
+     */
+    private function   winOddsCalculation($dataArray){
+        $returnMoney = 1;
+        // 循环计算每注返现赔率
+        foreach ($dataArray as $value) {
+            $odds = intval($value['odds']);
+            // 因结果不同更改赔率
+            switch (intval($value['winOrLose'])) {
+                case 1:
+                    $oddsDiscount = 1 + $odds * 1;
+                    break;
+                case 2:
+                    $oddsDiscount = 1;
+                    break;
+                case 3:
+                    $oddsDiscount = 1 + $odds * 0.5;
+                    break;
+                default:
+                    $oddsDiscount = 0.5;
+            }
+            // 计算每注返现
+            $returnMoney = $returnMoney * $oddsDiscount;
+        }
+        // 计算赚钱
+        $earnMoney = $returnMoney - 1;
+
+        return ['earnMoney' => $earnMoney, 'returnMoney' => $returnMoney];
+    }
+
+
+
+
+    /**
+     * 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;
+    }
+
+
+    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 ;
+    }
+
+    private function sql_moneydetqil_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();
+            if (!$detailModel){
+                throw  new   \Exception('查无此用户数据account_detail='.$allbuyModel->account_indentity,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  " ;
 
+            $this->sql[] = $SQL ;
 
+    }
 
 
+
+    //计算  某个比赛结束后  对应订单的资金变化
+    private function  get_money_chage($batch_id,$type){
+        if ($type ==1 ){
+            $ret = DB::select("select  sum(gain_money-money) as dfmoney  from  money_buy_simplex  where   batch_id='$batch_id'");
+            if (!isset( $ret['0']['dfmoney'])){
+                throw  new \Exception("资金变化不正确!");
+            }
+            $moneydiff = sprintf("%.2f",$ret['0']['dfmoney']);
         }else{
-            throw  new  \Exception('找不到此玩法的胜负规则逻辑!',4005);
+
+            $ret = DB::select("select  sum(gain_money-money) as dfmoney  from  money_buy_str  where   batch_id='$batch_id'");
+            if (!isset( $ret['0']['dfmoney'])){
+                throw  new \Exception("资金变化不正确!");
+            }
+            $moneydiff = sprintf("%.2f",$ret['0']['dfmoney']);
         }
+
+        return $moneydiff ;
     }
 
+    //生成串式失败的逻辑sql;
+    private function  makesql_up_serial_lose($model){
+            $batchid = $model->batch_id ;
+            $sql = "update  money_buy_match   set  result=-1  where  bet_type=2 and  batch_id=$batchid  ";
+            $this->sqlArray[] = $sql;
+
+            $sql = "update  money_buy_str   set   game_status=3,wait_match_num=0 where   batch_id=$batchid   ";
+            $this->sqlArray[] = $sql ;
+
+            return true ;
+    }
 
     private function  makesql_up_buymatch_winorfalse($id,$result,$utime){
         $sql = " update  money_buy_match  set  result=$result,utime=$utime  where id=$id  limit 1";
         $this->sqlArray[] = $sql;
         return true;
     }
-    private function masql_up_buymatch_false($batch_id){
+
+ /*
+    private function masql_up_buymatch_false($batch_id,$type,$match_id=0){
         $uptime = date("Y-m-d H:i:s");
-        $sql = " update  money_buy_match  set  result=-1 ,utime=$uptime,status=1  where batch_id=$batch_id  ";
+        $sql = " update  money_buy_match  set  result=-1 ,utime=$uptime,status=0  where batch_id=$batch_id  ";
         $this->sqlArray[] = $sql;
 
-        $sql =  "update  money_buy_str  set   settle_status=1,game_status=3 ,wait_match_num=0  where  batch_id=$batch_id " ;
+        if ($type==2){
+            $sql =  "update  money_buy_str  set   settle_status=1,game_status=3 ,wait_match_num=0  where  batch_id=$batch_id " ;
+        }else{
+            $sql =  "update  money_buy_simplex  set   settle_status=1,game_status=3 ,wait_match_num=wait_match_num-1   where  batch_id=$batch_id  and  match_id=$match_id " ;
+        }
         $this->sqlArray[] = $sql;
 
         return true ;
     }
+   */
 
 
 
 
-
+    //设置 输赢 解析规则适配器
     private  function  setAdapterObj($game_type){
-
-        if ( isset($this->gameAllMap)){  throw  new \Exception('赛事类型错误',4002);   return false;  }
+        $game_type = strtolower($game_type);
+        if ( !isset($this->gameAllMap)){  throw  new \Exception('赛事类型错误-'.$game_type,4002);   return false;  }
 
         switch ($game_type){
             case 'bq':
-                C()->set('BqRule','\Biz\Settlement\Adapter\BqRule');
-                $this->AdapterObj = C()->get('BqRule');
+                $this->AdapterObj = new BqRule();
                 break;
             case  'lq':
-                C()->set('LqRule','\Biz\Settlement\Adapter\LqRule');
-                $this->AdapterObj = C()->get('LqRule');
+                $this->AdapterObj = new LqRule();
                 break;
             case  'wq':
-                C()->set('WqRule','\Biz\Settlement\Adapter\WqRule');
-                $this->AdapterObj = C()->get('WqRule');
+                $this->AdapterObj = new WqRule();
                 break;
             case  'zq':
-                C()->set('ZqRule','\Biz\Settlement\Adapter\ZqRule');
-                $this->AdapterObj = C()->get('ZqRule');
+               $this->AdapterObj = new ZqRule();
                 break;
         }
         return  true ;
@@ -168,52 +353,75 @@ class SettlementSql
 
     //写处理状态
     public function  writeStatusBegin($comendnticeModel){
+
         $comendnticeModel->status = 1 ;
-        $comendnticeModel->pupdatetime = date("Y-m-d H:i:s");
+        $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->pret = 1 ;
-        $comendnticeModel->puodateendtime = date("Y-m-d H:i:s");
+        $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 = lm('Comendnotice','Commons')->wherer('status',0)->order('id','asc')->first();
+            $ret = (new ComendnoticeModel())->where('status',0)->orderby('id','asc')->first();
+
             $this->ComendNoticModel = $ret;
             return $ret;
     }
 
 
-    public function  getAllMatchIdArrays( $type,$matchid ,$bet_type=2,$result = 0 ){
-            $ret = lm('Money_buy_match','Commons')->where(['game_code'=>$type,'match_id'=>$matchid,'bet_type'=>$bet_type,'result'=>$result])->find();
+    //某个赛事 所有下单数据记录
+    public function  getAllMatchIdArrays( $type,$matchid , $result = 0 ){
+            if (is_null($result)){
+                $ret = DB::table('money_buy_match')->where(['game_code'=>$type,'match_id'=>$matchid])->get();
+            }else{
+                $ret = DB::table('money_buy_match')->where(['game_code'=>$type,'match_id'=>$matchid,'result'=>$result])->get();
+            }
+
             $this->AllMatchIdArrays = $ret;
             return $ret;
     }
 
+    public function  getAllBatchIdArrays($type,$batchid,$owhere=[]){
+        if (!empty($owhere)){
+            $where = array_merge(['game_code'=>$type,'batch_id'=>$batchid],$owhere);
+        }else{
+            $where = ['game_code'=>$type,'batch_id'=>$batchid] ;
+        }
+
+        $ret = DB::table('money_buy_match')->where($where)->order('id','asc')->get();
+        //if (empty($ret)){  throw new  \Exception('没有记录' ,4008);}
+        return $ret;
+    }
 
+    //获取到某个用户的account模型和detail模型,用于用户的余额计算等使用
     public function  getUserInfo($account_name){
          if (isset($this->AccountArrays[$account_name])){
              return $this->AccountArrays['$account_name'];
          }
 
-         $accountModel = lm('Account','Commons')->where(['account',$account_name])->first();
+         $accountModel = DB::table('Account')->where(['account',$account_name])->first();
          if (!$accountModel){
              throw  new   \Exception('查无此用户数据account='.$account_name,41002);
          }
 
-         $detailModel = lm('Account_detailed','Commons')->where(['account_identity',$accountModel->identity])->first();
+         $detailModel = DB::table('Account_detailed','Commons')->where(['account_identity',$accountModel->identity])->first();
          if (!$detailModel){
              throw  new   \Exception('查无此用户数据account_detail='.$accountModel->identity,41002);
          }
@@ -227,30 +435,37 @@ class SettlementSql
          return $ret;
      }
 
-
-    public function  GetMatchBatchIdArrays($batch_id){
-            if (isset($this->MatchBatchIdArrays[$batch_id])){
-                return   $this->MatchBatchIdArrays[$batch_id];
+    //获取到某个用户某个赛事的下单记录集[]
+    public function  GetMatchBatchIdArrays($batch_id,$type){
+            if (isset($this->MatchBatchIdArrays[$type][$batch_id])){
+                // return   $this->MatchBatchIdArrays[$type][$batch_id];
             }
-            $all = lm("Money_buy_match")->getByBatchId($batch_id);
+            $all = DB::table("money_buy_match")->where(['batch_id',$batch_id,'result'=>0])->get();
             if (!$all) {
                 throw  new  \Exception('无效的Money_buy_str->batch_id='.$batch_id , 41001);
             }
-            $this->MatchBatchIdArrays[$batch_id] = $all ;
+            $this->MatchBatchIdArrays[$type][$batch_id] = $all ;
             return $all ;
     }
 
-
-    public function  GetBuyStrBatchIdArrays($batch_id){
+    //根据购买批次 获取下单信息
+    public function  GetBuyStrBatchIdArrays($batch_id,$type){
 
         if (isset($this->BuyStrBatchIdArrays[$batch_id])){
-            return   $this->BuyStrBatchIdArrays[$batch_id];
+            // return   $this->BuyStrBatchIdArrays[$batch_id];
         }
-        $all = lm("Money_buy_str")->getByBatchId($batch_id);
+
+        if ($type==2)
+        {
+            $all = DB::table("money_buy_str")->where(['batch_id'=>$batch_id,'game_status'=>0])->get();
+        }else{
+            $all = DB::table("money_buy_simplex")->where(['batch_id'=>$batch_id,'game_status'=>0])->get();
+        }
+
         if (!$all) {
-            throw  new  \Exception('无效的Money_buy_str->batch_id='.$batch_id , 41001);
+            throw  new  \Exception('无效的batch_id='.$batch_id , 41001);
         }
-        $this->BuyStrBatchIdArrays[$batch_id] = $all ;
+       // $this->BuyStrBatchIdArrays[$batch_id] = $all ;
         return $all ;
 
     }
@@ -261,23 +476,24 @@ class SettlementSql
         $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)->orderBy('id','asc')->get();
+                $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 = lm('St_lq_resultn','Commons')->where('match_id',$match_id)->first();
-                $models = lm('St_lq_result_record','Commons')->where('match_id',$match_id)->orderBy('id','asc')->get();
+                $model = DB::table('st_lq_resultn')->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 = lm('St_wq_result','Commons')->where('match_id',$match_id)->first();
-                $models = lm('St_wq_result_record','Commons')->where('match_id',$match_id)->orderBy('id','asc')->get();
+                $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 = lm('St_zq_result','Commons')->where('match_id',$match_id)->first();
-                $models = lm('St_zq_result_record','Commons')->where('match_id',$match_id)->orderBy('id','asc')->get();
+                $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;
         }
-        if (empty($model)){
+
+        if (empty($model) || empty($models)){
             throw  new   \Exception('没找到比赛结果记录match_id_'.$type.'-'.$match_id,4007);
             return false;
         }

+ 2 - 4
app/Models/MoneyBuyStr.php

@@ -80,9 +80,11 @@ class MoneyBuyStr extends BaseModel {
         $data = array();
         $data['all_money'] = $this->sum('money');
         $data['all_prize_money'] = $this->sum('prize_money');
+        $data['alraedy_prize_money'] = $this->where('settle_status','2')->sum('gain_money');
         if (!empty($where) && is_array($where)) {
             $data['all_money'] = $this->where($where)->sum('money');
             $data['all_prize_money'] = $this->where($where)->sum('prize_money');
+            $data['alraedy_prize_money'] = $this->where($where)->where('settle_status','2')->sum('gain_money');
         }
 
         return $data;
@@ -134,11 +136,7 @@ class MoneyBuyStr extends BaseModel {
                 $data[$i]->result = '输半平半';
             }
         }
-
         return $data->toArray();
     }
 
-
-
-
 }

+ 8 - 15
app/Models/SportsNoteList.php

@@ -16,8 +16,7 @@ class SportsNoteList extends BaseModel {
         $data = $this
             ->join('money_details','money_details.info_identity','=','money_buy_simplex.info_identity')
             ->join('st_'.$type.'_competition','st_'.$type.'_competition.match_id','=','money_buy_simplex.match_id')
-            //->join('money_buy_match','money_buy_match.order_id','=','money_buy.order_id')
-            //->join('st_'.$type.'_league','st_'.$type.'_league.lg_id','=','money_buy_match.lg_id')
+            ->select('money_buy_simplex.id','money_buy_simplex.account_name','money_buy_simplex.order_id','money_buy_simplex.money','money_buy_simplex.prize_money','money_buy_simplex.status','money_buy_simplex.money_time','money_buy_simplex.settle_status','money_buy_simplex.gain_money','money_buy_simplex.game_code','money_buy_simplex.match_id','money_buy_simplex.game_status','st_'.$type.'_competition.home_team','st_'.$type.'_competition.guest_team','st_'.$type.'_competition.match_date','st_'.$type.'_competition.match_time','st_'.$type.'_competition.lg_id','money_details.money_cash','money_buy_simplex.batch_id')
             ->where($where)
             ->orderby('money_buy_simplex.money_time','desc')
             ->paginate ($list);
@@ -28,24 +27,17 @@ class SportsNoteList extends BaseModel {
         $res = DB::table('setinfo')->where('infoname','放水赔率')->first();
 
         for($i=0;$i<count($data);$i++){
-            if($data[$i]->status==1){
-                $data[$i]->status = '投注';
-            }else if($data[$i]->status==2){
-                $data[$i]->status = '追号';
-            }else if($data[$i]->status==4){
-                $data[$i]->status = '撤单';
-            }
             if($data[$i]->settle_status==1){
                 $data[$i]->settle_status = '未结算';
             }else if($data[$i]->settle_status==2){
                 $data[$i]->settle_status = '已结算';
             }
             if($data[$i]->game_status==0){
-                $data[$i]->game_status = '待开奖';
+                $data[$i]->game_status = '未处理';
             }else if($data[$i]->game_status==1){
-                $data[$i]->game_status = '中奖';
+                $data[$i]->game_status = '';
             }else if($data[$i]->game_status==2){
-                $data[$i]->game_status = '未中奖';
+                $data[$i]->game_status = '';
             }
             $data[$i]->match_id_order = '<span>'.$data[$i]->match_id.'</span><br>'.$data[$i]->order_id;
 
@@ -69,7 +61,8 @@ class SportsNoteList extends BaseModel {
             $data[$i]->available_cash = $data[$i]->money+$data[$i]->money_cash.'.00';
             $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)->get();
+            $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>';
             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();
@@ -92,11 +85,11 @@ class SportsNoteList extends BaseModel {
         $data = array();
         $data['all_money'] = $this->sum('money');
         $data['all_prize_money'] = $this->sum('prize_money');
-        $data['alraedy_prize_money'] = $this->where('game_status','1')->sum('prize_money');
+        $data['alraedy_prize_money'] = $this->where('settle_status','2')->sum('gain_money');
         if (!empty($where) && is_array($where)) {
             $data['all_money'] = $this->where($where)->sum('money');
             $data['all_prize_money'] = $this->where($where)->sum('prize_money');
-            $data['alraedy_prize_money'] = $this->where($where)->where('game_status','1')->sum('prize_money');
+            $data['alraedy_prize_money'] = $this->where($where)->where('settle_status','2')->sum('gain_money');
         }
 
         return $data;

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

@@ -26,6 +26,7 @@ return array(
     'prize' => '开奖号码',
     'settle_status' => '状态',
     'game_status' => '状态',
+    'match_status' => '状态',
     'member_type' => '会员类型',
     'edit' => '修改',
 

+ 4 - 1
resources/views/sports/sports_notelist.blade.php

@@ -56,6 +56,9 @@
         tbody span{
             color: red;
         }
+        .reaudit{
+            background-color: #FF5722;
+        }
     </style>
 
     <script type="text/html" id="status">
@@ -220,7 +223,7 @@
     for(var i in data){
     data[i]=parseFloat(data[i]);
     }
-    str+='<p class="bottom-txt">总投注金额:<span class="blue">'+data.all_money+'</span> , 总可赢金额:<span class="green">'+data.all_prize_money+'</span> , 已赢金额:<span class="green">'+data.alraedy_prize_money+'</span></p>'
+    str+='<p class="bottom-txt">总投注金额:<span class="blue">'+data.all_money+'</span> , 总可赢金额:<span class="red">'+data.all_prize_money+'</span> , 已赢金额:<span class="green">'+data.alraedy_prize_money+'</span></p>'
     {{--str+='<p class="bottom-txt">总金额:<span class="blue">'+data.all_money+'</span> , 成功:<span class="green">'+data.success_money+'</span> , 手续费:<span class="red">'+data.service_money+'</span> , 处理中:<span class="yellow">'+data.handing+'</span></p>'--}}
     $('#statistics').html(str);
     var height1=$('.layui-table-view').height();

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

@@ -200,7 +200,7 @@
     for(var i in data){
     data[i]=parseFloat(data[i]);
     }
-    str+='<p class="bottom-txt">总投注金额:<span class="blue">'+data.all_money+'</span> , 总可赢金额:<span class="green">'+data.all_prize_money+'</span></p>'
+    str+='<p class="bottom-txt">总投注金额:<span class="blue">'+data.all_money+'</span> , 总可赢金额:<span class="red">'+data.all_prize_money+'</span> , 已赢金额:<span class="green">'+data.alraedy_prize_money+'</span></p>'
     $('#statistics').html(str);
     var height1=$('.layui-table-view').height();
     var height2=$('#statistics').height();