彭俊 6 лет назад
Родитель
Сommit
636e598d8c

+ 42 - 0
app/Http/Controllers/Admin/SoccerNoteListController.php

@@ -966,6 +966,48 @@ class SoccerNoteListController extends Controller
         return responseToJson(1, '更新成功');
     }
 
+//冠军注单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算
+    public function matchpdate_v2(Req $req)
+    {
+        $order_id = isset($req->order_id) ? $req->order_id : 0;
+        $game_code = isset($req->game_code) ? $req->game_code : 0;
+        $match_id = isset($req->match_id) ? $req->match_id : 0;
+        $pdatas = isset($req->matchdata) ? $req->matchdata : [];
+        $pdatas = json_decode($pdatas, true);
+        if (empty($order_id) || empty($game_code) || empty($match_id) || empty($pdatas)) {
+            return responseToJson(0, '参数错误');
+        }
+
+        $buyModel = (new MoneyBuySimplexModel())->where([['order_id', '=', $order_id]])->first();
+        if (empty($buyModel)) {
+            return responseToJson(0, '订单数据错误');
+        }
+
+        $game_name = $pdatas['odds_code'];
+        $result = $pdatas['result'];
+        $res = [];
+        $res['lg_id'] = $match_id;
+        $res['game_name'] = $game_name;
+        $res['result'] = $result;
+
+        $buyModel->single_result = json_encode([$res], 256);
+        //$buyModel->single_result = '{"lg_id":'.$match_id.',"game_name":'.$game_name.',"game_name":'.$result.',"game_name":'.time().'}';
+        $buyModel->result_flag = 1;
+        $buyModel->is_manual = 1;
+        $ret = $buyModel->save();
+
+        if ($ret) {
+            $ret2 = $this->do_win_set($order_id, $game_code, $match_id);
+            if ($ret2['status'] == 1) {
+                return responseToJson(1, '操作成功!');
+            } else {
+                return responseToJson(0, '操作失败2!--' . $ret2['data']);
+            }
+        }
+        return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
+
+    }
+
 
 //单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算
     public function manualmatchpdate_v2(Req $req)

+ 1 - 1
app/Http/Controllers/Admin/SportsSoccerController.php

@@ -249,7 +249,7 @@ class SportsSoccerController extends Controller
     }
 
     /**
-     *修改赛事1
+     *修改赛事11
      */
     function edit(Req $req)
     {

+ 24 - 4
app/Http/Controllers/Api/CrontabController.php

@@ -4,10 +4,12 @@ namespace App\Http\Controllers\Api;
 
 use Illuminate\Routing\Controller as BaseController;
 use App\Http\Response\Response;
+use Illuminate\Http\Request as Req;
 use Illuminate\Support\Facades\DB;
 use App\Lib\Biz\Sport\Common as commonFunction;
 use App\Http\Model\StZqMatch as StMatchModel;
 use App\Models\SportsNoteList as SportsNoteListModel;
+use \App\Models\System_user;
 
 /**
  * 定时处理任务
@@ -25,9 +27,15 @@ class CrontabController extends BaseController{
 
     /**
      * 定时执行 滚球投注危险球审核
-     * 每分钟执行一次
+     * 每分钟执行一次1
      */
-    public function HandleOrder(){
+    public function HandleOrder(Req $data){
+        //验证token
+        $user = new System_user;
+        if (empty($data->token)) return Response::generate('未获取到token', Response::TOKEN_ERR);
+        $token = $user::where(['token' => $data->token])->value('token');
+        if (empty($token)) return Response::generate('token验证不通过', Response::TOKEN_ERR);
+
         try {
             //开启事务
             DB::beginTransaction();
@@ -53,7 +61,13 @@ class CrontabController extends BaseController{
      * 定时执行 处理到时间应该开始而未开始的赛事
      * 每分钟执行一次
      */
-    public function HandleMatch(){
+    public function HandleMatch(Req $data){
+         //验证token
+        $user = new System_user;
+        if (empty($data->token)) return Response::generate('未获取到token', Response::TOKEN_ERR);
+        $token = $user::where(['token' => $data->token])->value('token');
+        if (empty($token)) return Response::generate('token验证不通过', Response::TOKEN_ERR);
+
         try {
             //开启事务
             DB::beginTransaction();
@@ -77,7 +91,13 @@ class CrontabController extends BaseController{
     /**
      * 定时执行 处理时间段内赛事已取消的注单1
      */
-    public function HandleOrderInvalid(){
+    public function HandleOrderInvalid(Req $data){
+        //验证token
+        $user = new System_user;
+        if (empty($data->token)) return Response::generate('未获取到token', Response::TOKEN_ERR);
+        $token = $user::where(['token' => $data->token])->value('token');
+        if (empty($token)) return Response::generate('token验证不通过', Response::TOKEN_ERR);
+
         try {
             //开启事务
             DB::beginTransaction();

+ 13 - 1
app/Lib/Biz/Sport/Common.php

@@ -1668,7 +1668,19 @@ class Common
         }
     }
 
-   
+    /**
+     * 匹配字符串中 是否包含某个字符串
+     * $strAll str 目标字符串
+     * $needle str 搜索字符串
+     */
+    public static function checkstr($strAll,$needle){
+        $tmparray = explode($needle,$strAll);
+        if(count($tmparray)>1){
+         return 1;
+        } else{
+         return 0;
+        }
+    }
 }
 
 ?>

+ 1 - 1
app/Models/Comendnotice.php

@@ -30,7 +30,7 @@ class Comendnotice extends BaseModel
                 $insertArr['game_start_time'] = $game_start_time;
             }
             $res = $this->insert($insertArr);
-            if (!$res) {
+            if (!$res) {                      
                 return -6030001222;
             }
         }

+ 11 - 0
app/Models/MoneyBuySimplex.php

@@ -23,28 +23,39 @@ class MoneyBuySimplex extends BaseModel
         if (empty($Ordermodel)) {
             return false;
         }
+        $odds_code = \App\Models\MoneyBuyMatch::where('batch_id',$Ordermodel->batch_id)->first();
+        $Ordermodel->odds_code = $odds_code->odds_code;
         $game_code = $Ordermodel->game_code;
         $match_id = $Ordermodel->match_id;
 
         switch ($game_code) {
             case 'zq':
                 $model = new Stzqresult();
+                $models = new \App\Models\Stzqleagueresult();
                 break;
             case 'lq':
                 $model = new Stlqresult();
+                $models = new \App\Models\Stlqleagueresult();
                 break;
             case 'bq':
                 $model = new Stbqresult();
+                $models = new \App\Models\Stbqleagueresult();
                 break;
             default;
                 $model = new Stwqresult();
+                $models = new \App\Models\Stwqleagueresult();
                 break;
         }
         $resultModel = $model->where([['match_id', '=', $match_id]])->first();
+        $resultsModel = $models->where([['lg_id', '=', $match_id]])->first();
+        if(empty($resultsModel)){
+            $resultsModel['result'] = '';
+        }
 
         return [
             'order' => $Ordermodel,
             'result' => $resultModel,
+            'results' => $resultsModel,
         ];
 
     }

+ 63 - 27
app/Models/SportsNoteList.php

@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\DB;
 use App\Lib\Biz\Sport\Common as commonFunction;
 use App\Models\MoneyBuyMatchb;
 use App\Http\Response\Response;
-use App\Http\Model\StZqResult;
+use App\Http\Model\StZqResult as StZqResultModel;
 
 use App\Http\Model\StZqMatch as ZqMatchModel;
 use App\Http\Model\StLqMatch as LqMatchModel;
@@ -104,6 +104,7 @@ class SportsNoteList extends BaseModel
         foreach($content as $k=>$v){
             foreach($result as $kk=>$vv){
                 if($v->odds_code == $vv->odds_code){
+                    $v->odds_name = $vv->odds_name;
                     $v->content = $vv->odds_name . '<br>' . $v->condition . '@' . $v->odds . ' ¥' . $v->bet_money . '<br>';
                 }
             }
@@ -205,16 +206,41 @@ class SportsNoteList extends BaseModel
             } else if ($v->status == 3) {
                 $v->order_status = '撤单<br>'.$settle_status;
             }
+            
+            /*
+            //获取 投注玩法名称
+            $odds_name = $contentData['odds_name'];
+            //根据球类/玩法名称 获取需设置比分项 
+            $ScoreTitle = $this->getScoreTitle($odds_name,$type);
+
+            if($v->is_champion == 1){
+                $function = 'setResult_v2';
+            }else{
+                $function = 'setScore_v2';
+            }
 
             //操作
-            if($v->status==1){
+            //未结算时 加载结算按钮
+            if($v->status==1 and $v->settle_status ==1){
+                $v->game_status = '
+                <button style="margin-left: 0;" onclick="setScore_v2(\'' . $v->order_id . '\',\''.$v->match_id.'\',\''.$type.'\',\''.$ScoreTitle.'\')"  class="layui-btn layui-btn-sm settlement">结算</button>';
+            }else{
                 $v->game_status = '
                 <button style="margin-left: 0;" onclick="setScore_v2(\'' . $v->order_id . '\',\''.$v->match_id.'\',\''.$type.'\')"  class="layui-btn layui-btn-sm settlement">结算</button>
                 <br>
                 <a class="layui-btn layui-btn-sm invalid" style="background-color:red" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $v->id . '\',\''.$v->order_id.'\',\''.$v->league.'\');"> 作废 </a>';
+      
+            } 
+            */
+
+            if($v->status==1){
+                $v->game_status = '
+                <button style="margin-left: 0;" onclick="'.$function.'(\'' . $v->order_id . '\',\''.$v->match_id.'\',\''.$type.'\')"  class="layui-btn layui-btn-sm settlement">结算</button>
+                <br>
+                <a class="layui-btn layui-btn-sm invalid" style="background-color:red" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $v->id . '\',\''.$v->order_id.'\',\''.$v->league.'\');"> 作废 </a>';
             }else{
                 $v->game_status = '
-                <button style="margin-left: 0;" onclick="setScore_v2(\'' . $v->order_id . '\',\''.$v->match_id.'\',\''.$type.'\')"  class="layui-btn layui-btn-sm settlement">结算</button>
+                <button style="margin-left: 0;" onclick="'.$function.'(\'' . $v->order_id . '\',\''.$v->match_id.'\',\''.$type.'\')"  class="layui-btn layui-btn-sm settlement">结算</button>
                 <br>
                 <a class="layui-btn layui-btn-sm invalid" style="background-color:red" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $v->id . '\',\''.$v->order_id.'\',\''.$v->league.'\');"> 作废 </a>';
       
@@ -222,6 +248,38 @@ class SportsNoteList extends BaseModel
         }
         return $orderData->toArray();
     }
+    /**
+     * 根据球类/玩法名称 获取需设置比分项 
+     */
+    public function getScoreTitle($oddsName,$gameCode){
+        //足球
+        if($gameCode == 'zq'){
+            //上半场
+            $ScoreTitle_h = commonFunction::checkstr($oddsName,'上半场');
+            //全场
+            $ScoreTitle_f = commonFunction::checkstr($oddsName,'全场');
+            //角球
+            $ScoreTitle_c = commonFunction::checkstr($oddsName,'角球');
+            //有上半场 无角球 为上半场比分
+            if($ScoreTitle_h == 1 and $ScoreTitle_c == 0){
+                $ScoreTitle = '上半场比分';
+            }
+            //有上半场 有角球 为角球上半场比分
+            if($ScoreTitle_h == 1 and $ScoreTitle_c == 1){
+                $ScoreTitle = '角球上半场比分';
+            }
+            //有全场 无角球 为全场比分
+            if($ScoreTitle_f == 1 and $ScoreTitle_c == 0){
+                $ScoreTitle = '全场比分';
+            }
+            //有全场 有角球 为角球全场比分
+            if($ScoreTitle_f == 1 and $ScoreTitle_c == 1){
+                $ScoreTitle = '角球全场比分';
+            }
+        }
+
+        return $ScoreTitle;
+    }
 
     /**
      * 拼接 订单详情 字段内容
@@ -256,29 +314,8 @@ class SportsNoteList extends BaseModel
             $content_str['result'] = '输半平半';
         }
 
-        /*
         //普通赛事注单 详情
         if($order->is_champion == 0){
-            if ($content_str['result'] == '未处理' || $order->status > 1) {
-                $content = $content1.$content_str['content'];
-            }
-            else if($order->status == 1) {
-                $content = $content1.$content_str['content']. '<span>' . $content_str['result'] . '</span>(' . $content_str['matchresult'] . ')<br>';
-            }
-        }
-        //冠军联赛注单 详情
-        else{
-            if ($content_str['result'] == '未处理' || $order->status > 1) {
-                $content = $content_str['home_team'] . '<br>' . $order->content . $content_str['odds_code'] . '<br>' . $content_str['condition'] . ' ' . $order->team . '@' . $content_str['odds'] . ' ¥' . $content_str['bet_money'] . '<br>';
-            } else {
-                $content = $content_str['home_team'] . '<br>' . $order->content . $content_str['odds_code'] . '<br>' . $content_str['condition'] . ' ' . $order->team . '@' . $content_str['odds'] . ' ¥' . $content_str['bet_money'] . '<br><span>' . $content_str['result'] . '</span>(' . $content_str['matchresult'] . ')<br>';
-            }
-        }
-        return $content;
-        */
-
-         //普通赛事注单 详情
-         if($order->is_champion == 0){
             if ($content_str['result'] == '未处理' || $order->status > 1) {
                 $content_str['content'] = $content1.$content_str['content'];
             }
@@ -294,7 +331,6 @@ class SportsNoteList extends BaseModel
                 $content_str['content'] = $content_str['home_team'] . '<br>' . $order->content . $content_str['odds_code'] . '<br>' . $content_str['condition'] . ' ' . $order->team . '@' . $content_str['odds'] . ' ¥' . $content_str['bet_money'] . '<br><span>' . $content_str['result'] . '</span>(' . $content_str['matchresult'] . ')<br>';
             }
         }
-
     
         return $content_str;
     }
@@ -1448,7 +1484,7 @@ class SportsNoteList extends BaseModel
             }
 
             //去重 获取赛事危险球数据
-            $warn_json_data = StZqResult::whereIn('match_id',$match_ids)->SELECT('match_id','warn_more')->get()->toArray();
+            $warn_json_data = StZqResultModel::whereIn('match_id',$match_ids)->SELECT('match_id','warn_more')->get()->toArray();
 
             //获取审核不通过订单 订单号
             $order_ids_n = [];
@@ -1532,7 +1568,7 @@ class SportsNoteList extends BaseModel
             }
 
             //去重 获取赛事危险球数据
-            $warn_json_data = StZqResult::whereIn('match_id',$match_ids)->SELECT('match_id','warn_more')->get()->toArray();
+            $warn_json_data = StZqResultModel::whereIn('match_id',$match_ids)->SELECT('match_id','warn_more')->get()->toArray();
 
             //获取审核不通过订单 订单号
             $order_ids_n = [];

+ 102 - 28
resources/views/sports/sports_notelist.blade.php

@@ -423,28 +423,89 @@
             })
         }
 
+        // 设置结算结果
+        function setResult_v2(order_id, match_id, game_code){
+            $.getJSON("/admin/SoccerNoteList/manualmatchget_v2", {'order_id': order_id}, function (res) {
+                if (1 == res.status) {
+                    setResult_v2_game(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code);
+
+                } else {
+                    layer.alert("数据拉取失败!", {title: '友情提示', icon: 2});
+                }
+            });
+        }
+
+        function setResult_v2_game(orderObj, resultObj,resultsObj,order_id,match_id,game_code) {
+            let content = '<div style="width: 100%;height:25px;"></div><div class="layui-form-item">' +
+                        '  <div class="layui-inline">' +
+                        '    <label class="layui-form-label" style="width:100px;">冠军注单玩法:</label>' +
+                        '    <label class="layui-form-label"  style="width:120px;">'+orderObj.odds_code+'</label>' +
+                        '    <div class="layui-input-inline" style="width: 150px;">' +
+                        '      <input type="hidden" name="odds_code" id="odds_code" placeholder=""  value="' + orderObj.odds_code +'"  required   autocomplete="off" class="layui-input">' +
+                        '      <input type="text" name="result" id="result" placeholder=""  value="' + resultsObj.result +'"  required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '  </div>'+
+                      '</div>';
+
+            layer.open({
+                area: ['700px', '200px'], //宽高
+                type: 1,
+                title: '设置比分',
+                content: content, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响,
+                btn: ['提交', '取消'],
+                yes: function (index, layero) {
+                    matchdata = JSON.stringify({
+                        odds_code: $("#odds_code").val(),
+                        result: $("#result").val(),
+                    });
+                    console.log(matchdata);
+                    ajax_setResult_all_v2(order_id,game_code,match_id,matchdata);
+                    return true;
+                },
+            });
+        }
+
+        function  ajax_setResult_all_v2(order_id, game_code, match_id, matchdata){
+            // 请求设置接口
+            $.ajax({
+                type: 'POST',
+                dataType: 'json',
+                url: '/admin/SoccerNoteList/matchpdate_v2',
+                data: {order_id: order_id, game_code: game_code, match_id: match_id, matchdata: matchdata},
+                success: function (res) {
+                    if (1 == res.status) {
+                        layer.alert("设置成功", {title: '友情提示', icon: 1, closeBtn: 0}, function () {
+                            window.location.reload();
+                        });
+                    } else {
+                        layer.alert("服务器异常(0)", {title: '友情提示', icon: 2});
+                    }
+                },
+                error: function () {
+                    layer.alert("服务器异常(1)", {title: '友情提示', icon: 2});
+                }
+            })
+        }
+
 
 
         // 设置结算比分
         function setScore_v2(order_id, match_id, game_code) {
-            // var order_id =
-            // var match_id =
-            // var game_code =
             $.getJSON("/admin/SoccerNoteList/manualmatchget_v2", {'order_id': order_id}, function (res) {
                 if (1 == res.status) {
                     //console.log(res);
                     switch (game_code) {
                         case 'zq':
-                            setScore_v2_zq(res.data.order, res.data.result,order_id, match_id, game_code);
+                            setScore_v2_zq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code);
                             break;
                         case 'lq':
-                            setScore_v2_lq(res.data.order, res.data.result,order_id, match_id, game_code);
+                            setScore_v2_lq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code);
                             break;
                         case 'bq':
-                            setScore_v2_bq(res.data.order, res.data.result,order_id, match_id, game_code);
+                            setScore_v2_bq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code);
                             break;
                         case 'wq':
-                            setScore_v2_wq(res.data.order, res.data.result,order_id, match_id, game_code);
+                            setScore_v2_wq(res.data.order, res.data.result,res.data.results,order_id, match_id, game_code);
                             break;
                     }
                 } else {
@@ -478,26 +539,38 @@
         }
         */
 
-        function setScore_v2_zq(orderObj, resultObj,order_id,match_id,game_code) {
-            let content = '<div style="width: 100%;height:25px;"></div><div class="layui-form-item">' +
-                '  <div class="layui-inline">' +
-                '    <label class="layui-form-label" style="width:60px;">进球数:</label>' +
-                '    <label class="layui-form-label"  style="width:100px;">上半场[主/客]</label>' +
-                '    <div class="layui-input-inline" style="width: 50px;">' +
-                '      <input type="text" name="set_zq_home_score" id="set_zq_home_score_u" placeholder="主"  value="' + resultObj.u_home_score +'"  required   autocomplete="off" class="layui-input">' +
-                '    </div>' +
-                '    <div class="layui-input-inline" style="width: 50px;">' +
-                '      <input type="text" name="set_zq_guest_score"  id="set_zq_guest_score_u"  placeholder="客"  value="' + resultObj.u_guest_score +'"   required   autocomplete="off" class="layui-input">' +
-                '    </div>' +
-                '    <label class="layui-form-label"  style="width:100px;">全场[主/客]</label>' +
-                '    <div class="layui-input-inline" style="width: 50px;">' +
-                '      <input type="text" name="set_zq_home_score" id="set_zq_home_score" placeholder="主"  value="' + resultObj.home_score +'"   required   autocomplete="off" class="layui-input">' +
-                '    </div>' +
-                '    <div class="layui-input-inline" style="width: 50px;">' +
-                '      <input type="text" name="set_zq_guest_score"  id="set_zq_guest_score"  placeholder="客"   value="' + resultObj.guest_score +'"     required   autocomplete="off" class="layui-input">' +
-                '    </div>' +
-                '  </div>' +
-                '</div>';
+        function setScore_v2_zq(orderObj, resultObj,resultsObj,order_id,match_id,game_code) {
+            console.log(resultsObj.result);
+            let content = '<div style="width: 100%;height:25px;"></div><div class="layui-form-item">' ;
+            if(orderObj['is_champion'] == 1){
+                content += '  <div class="layui-inline">' +
+                        '    <label class="layui-form-label" style="width:100px;">冠军注单玩法:</label>' +
+                        '    <label class="layui-form-label"  style="width:120px;">'+orderObj.odds_code+'</label>' +
+                        '    <div class="layui-input-inline" style="width: 150px;">' +
+                        '      <input type="text" name="result" id="result" placeholder=""  value="' + resultsObj.result +'"  required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '  </div>' ;
+            }else{
+                content += '  <div class="layui-inline">' +
+                        '    <label class="layui-form-label" style="width:60px;">进球数:</label>' +
+                        '    <label class="layui-form-label"  style="width:100px;">上半场[主/客]</label>' +
+                        '    <div class="layui-input-inline" style="width: 50px;">' +
+                        '      <input type="text" name="set_zq_home_score" id="set_zq_home_score_u" placeholder="主"  value="' + resultObj.u_home_score +'"  required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '    <div class="layui-input-inline" style="width: 50px;">' +
+                        '      <input type="text" name="set_zq_guest_score"  id="set_zq_guest_score_u"  placeholder="客"  value="' + resultObj.u_guest_score +'"   required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '    <label class="layui-form-label"  style="width:100px;">全场[主/客]</label>' +
+                        '    <div class="layui-input-inline" style="width: 50px;">' +
+                        '      <input type="text" name="set_zq_home_score" id="set_zq_home_score" placeholder="主"  value="' + resultObj.home_score +'"   required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '    <div class="layui-input-inline" style="width: 50px;">' +
+                        '      <input type="text" name="set_zq_guest_score"  id="set_zq_guest_score"  placeholder="客"   value="' + resultObj.guest_score +'"     required   autocomplete="off" class="layui-input">' +
+                        '    </div>' +
+                        '  </div>' ;
+            }
+
+            content += '</div>';
 
             layer.open({
                 area: ['700px', '200px'], //宽高
@@ -512,13 +585,14 @@
                             home_u: $("#set_zq_home_score_u").val(),
                             guest_u: $("#set_zq_guest_score_u").val(),
                         });
-
+console.log(matchdata);
                     ajax_setScore_all_v2(order_id,game_code,match_id,matchdata);
                     return true;
                 },
             });
         }
 
+
         function setScore_v2_lq(orderObj, resultObj,order_id,match_id,game_code) {
             let home = JSON.parse(resultObj.home_score);
             let guest = JSON.parse(resultObj.guest_score);

+ 0 - 1
测试钩子.txt

@@ -1 +0,0 @@
-12344111111