彭俊 6 éve
szülő
commit
85a046ea66

+ 129 - 18
app/Http/Controllers/Admin/SoccerNoteListController.php

@@ -14,6 +14,7 @@ use Illuminate\Support\Facades\DB;
 Use App\Lib\Settlement\SettlementOrder;
 Use App\Lib\Settlement\SettlementWinFail;
 use App\Models;
+use App\Models\MoneyBuySimplex as MoneyBuySimplexModel;
 use Request;
 
 /**
@@ -111,7 +112,7 @@ class SoccerNoteListController extends Controller
         $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
         $type = Request::has('type') ? Request::get('type') : 'zq';
         $where = array();
-        $where[] = array('money_buy_simplex.is_champion',1);
+        $where[] = array('money_buy_simplex.is_champion', 1);
         if (!empty($account)) {
             if (empty($sureblur) || $sureblur == 'off') {
                 $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
@@ -249,7 +250,7 @@ class SoccerNoteListController extends Controller
         $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
         $type = Request::has('type') ? Request::get('type') : 'zq';
         $where = array();
-        $where[] = array('money_buy_simplex.is_champion','<>',1);
+        $where[] = array('money_buy_simplex.is_champion', '<>', 1);
         if (!empty($account)) {
             if (empty($sureblur) || $sureblur == 'off') {
                 $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
@@ -278,16 +279,16 @@ class SoccerNoteListController extends Controller
         }
 
         //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
-        if($order_status == 1 || $order_status == 2 || $order_status == 3){
+        if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
             $where[] = array('money_buy_simplex.status', '=', $order_status);
         }
         //4 5为结算状态 4未结算 5已结算
-        if($order_status == 4){
-            $status  = 1;
+        if ($order_status == 4) {
+            $status = 1;
             $where[] = array('money_buy_simplex.settle_status', '=', $status);
         }
-        if($order_status == 5){
-            $status  = 2;
+        if ($order_status == 5) {
+            $status = 2;
             $where[] = array('money_buy_simplex.settle_status', '=', $status);
         }
         /*
@@ -424,16 +425,16 @@ class SoccerNoteListController extends Controller
         }
 
         //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
-        if($order_status == 1 || $order_status == 2 || $order_status == 3){
+        if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
             $where[] = array('money_buy_simplex.status', '=', $order_status);
         }
         //4 5为结算状态 4未结算 5已结算
-        if($order_status == 4){
-            $status  = 1;
+        if ($order_status == 4) {
+            $status = 1;
             $where[] = array('money_buy_simplex.settle_status', '=', $status);
         }
-        if($order_status == 5){
-            $status  = 2;
+        if ($order_status == 5) {
+            $status = 2;
             $where[] = array('money_buy_simplex.settle_status', '=', $status);
         }
 
@@ -581,7 +582,7 @@ class SoccerNoteListController extends Controller
         $sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
         $type = Request::has('type') ? Request::get('type') : 'zq';
         $where = array();
-        $where[] = array('money_buy_simplex.is_champion','<>',1);
+        $where[] = array('money_buy_simplex.is_champion', '<>', 1);
         if (!empty($account)) {
             if (empty($sureblur) || $sureblur == 'off') {
                 $where[] = array('money_buy_simplex.account_name', 'like', '%' . $account . '%');
@@ -610,16 +611,16 @@ class SoccerNoteListController extends Controller
         }
 
         //调整状态查询 1,2,3为订单状态 1投注 2作废 3撤单
-        if($order_status == 1 || $order_status == 2 || $order_status == 3){
+        if ($order_status == 1 || $order_status == 2 || $order_status == 3) {
             $where[] = array('money_buy_simplex.status', '=', $order_status);
         }
         //4 5为结算状态 4未结算 5已结算
-        if($order_status == 4){
-            $status  = 1;
+        if ($order_status == 4) {
+            $status = 1;
             $where[] = array('money_buy_simplex.settle_status', '=', $status);
         }
-        if($order_status == 5){
-            $status  = 2;
+        if ($order_status == 5) {
+            $status = 2;
             $where[] = array('money_buy_simplex.settle_status', '=', $status);
         }
 
@@ -940,7 +941,117 @@ class SoccerNoteListController extends Controller
         }
 
         return responseToJson(1, '更新成功');
+    }
+
+
+//单式订单直接手动设置比赛结果 --> 提交胜负判断处理以及 --> 提交结算
+    public function manualmatchpdate_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, '订单数据错误');
+        }
+
+        $restModel = '';
+        switch ($game_code) {
+            case 'zq':
+                $restModel = DB::table('st_zq_result')->where([['match_id', '=', $match_id]])->first();
+                break;
+            case 'lq':
+                $restModel = DB::table('st_lq_result')->where([['match_id', '=', $match_id]])->first();
+                break;
+            case 'wq':
+                $restModel = DB::table('st_wq_result')->where([['match_id', '=', $match_id]])->first();
+                break;
+            case 'bq':
+                $restModel = DB::table('st_bq_result')->where([['match_id', '=', $match_id]])->first();
+                break;
+        }
+        if (empty($restModel)) {
+            return responseToJson(0, '赛事结果记录没有找到,数据错误');
+        }
+
+        if ($game_code == 'zq') {
+            $home = intval($pdatas['home']);
+            $guest = intval($pdatas['guest']);
+            $restModel->home_score = $home;
+            $restModel->guest_score = $guest;
+            $restModel->corner_ball = json_decode($restModel->corner_ball, 256);
+            $restModel->penalty_card = json_decode($restModel->penalty_card, 256);
+            $restModel->first_score = json_decode($restModel->first_score, 256);
+            $restModel->warn_more = json_decode($restModel->warn_more, 256);
+
+            $buyModel->single_result = json_encode([$restModel], 256);
+            $buyModel->result_flag = 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, '更新失败1');
+        }
+
+
+        return responseToJson(0, '未做更新', ['order_id' => $order_id, 'game_code' => $game_code, 'match_id' => $game_code, 'datas' => $pdatas]);
+
+    }
+
+    //先提交输赢,再结算
+    private function do_win_set($order_id, $game_code, $match_id)
+    {
+        $winret = $this->do_winfail($order_id, $game_code, $match_id);
+        if ($winret['status'] == 1) {
+            $setret = $this->do_settelement($order_id, $game_code, $match_id);
+            if ($setret['status'] == 1) {
+                return ['status' => 1, 'msg' => 'success', 'data' => []];
+            } else {
+                return ['status' => 0, 'msg' => 'failse', 'data' => $setret['msg']];
+            }
+        } else {
+            return ['status' => 0, 'msg' => 'failse', 'data' => $winret['msg']];
+        }
+    }
+
+
+    //单订单手动提交输赢计算
+    private function do_winfail($order_id, $game_code, $match_id)
+    {
+        $data = [
+            'token' => session('adminInfo.token'),    //外网
+            'order_id' => $order_id,
+        ];
+        $ret = $this->request_post(config('sconstant.url') . '/DoWinFailOneOrder', $data);
+        return json_decode($ret, true);
+    }
 
+    //单订单手动提交结算
+    private function do_settelement($order_id, $game_code, $match_id)
+    {
+        $data = [
+            'token' => session('adminInfo.token'),    //外网
+            'order_ids' => $order_id,
+            'bettype' => 1,
+            'settype' => 2,
+            'game_code' => $game_code,
+            'match_id' => $match_id,
+            'change_status' => 0,
+            'is_manual' => 1,
+        ];
+        $ret = $this->request_post(config('sconstant.url') . '/Settelement', $data);
+        return json_decode($ret, true);
     }
 
 

+ 4 - 0
app/Http/Model/StZqResult.php

@@ -518,6 +518,10 @@ class StZqResult extends Model
         $warn_json = self::where(['match_id' => $match_id])->SELECT('warn_more')->first()->warn_more;
         //转数组
         $warn_arr = json_decode($warn_json,true);
+        //删除初始 危险球 数据
+        foreach($warn_arr as $k=>$v){
+            if($v['rtype'] == 0) unset($warn_arr[$k]);
+        }
 
         if($match_id > 0 and !empty($warn_data)){
             $data = [];

+ 14 - 0
app/Models/MoneyBuySimplex.php

@@ -0,0 +1,14 @@
+<?php
+namespace App\Models;
+
+use DB;
+
+class MoneyBuySimplex extends BaseModel
+{
+
+    protected $table = "money_buy_simplex";
+    public $timestamps = false;
+
+
+
+}

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

@@ -13,7 +13,8 @@
         @{{#} }}
         -->
 
-        <button style="margin-left: 0;" onclick="setScore('@{{d.order_id}}','@{{d.match_id}}')" class="layui-btn layui-btn-sm settlement">手动设置比分</button>
+        <!--<button style="margin-left: 0;" onclick="setScore('@{{d.order_id}}','@{{d.match_id}}')" class="layui-btn layui-btn-sm settlement">手动设置比分</button>-->
+        <button style="margin-left: 0;" onclick="setScore_v2('@{{d.order_id}}','@{{d.match_id}}','@{{d.game_code}}')"  class="layui-btn layui-btn-sm settlement">手动设置比分</button>
 
         @{{#if(d.settle_status==1){ }}
             <span>未结算</span>
@@ -407,6 +408,88 @@
             })
         }
 
+
+
+        // 设置结算比分
+        function setScore_v2(order_id, match_id, game_code) {
+
+            if (game_code != 'zq') {
+                layer.msg("暂时只支持 足球 手动单订单改结果!");
+                return false;
+            }
+
+            let content = '';
+            let content_zq = '<div style="width: 100%;height:25px;"></div><div class="layui-form-item">' +
+                '  <div class="layui-inline">' +
+                '    <label class="layui-form-label">全场</label>' +
+                '    <div class="layui-input-inline" style="width: 100px;">' +
+                '      <input type="text" name="set_zq_home_score" id="set_zq_home_score" placeholder="主队得分"   required   autocomplete="off" class="layui-input">' +
+                '    </div>' +
+                '    <div class="layui-form-mid"></div>' +
+                '    <div class="layui-input-inline" style="width: 100px;">' +
+                '      <input type="text" name="set_zq_guest_score"  id="set_zq_guest_score"  placeholder="客队得分"   required   autocomplete="off" class="layui-input">' +
+                '    </div>' +
+                '  </div>' +
+                '</div>';
+
+            let content_wq = '';
+            let content_bq = '';
+            let content_lq = '';
+            let matchdata = '';
+
+            if (game_code == 'zq') {
+                content = content_zq;
+            } else if (game_code == 'lq') {
+                content = content_lq;
+            } else if (game_code == 'bq') {
+                content = content_bq;
+            } else if (game_code == 'wq') {
+                content = content_wq;
+            }
+            layer.open({
+                area: ['600px', '400px'], //宽高
+                type: 1,
+                title: '设置比分',
+                content: content, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响,
+                btn: ['提交', '取消'],
+                yes: function (index, layero) {
+                    if (game_code == 'zq') {
+                        matchdata = JSON.stringify({
+                            home: $("#set_zq_home_score").val(),
+                            guest: $("#set_zq_guest_score").val()
+                        });
+                    }
+                    // 请求设置接口
+                    $.ajax({
+                        type: 'POST',
+                        dataType: 'json',
+                        url: '/admin/SoccerNoteList/manualmatchpdate_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 {
+                                console.log(res);
+                                layer.alert("服务器异常1", {title: '友情提示', icon: 2});
+                            }
+                        },
+                        error: function () {
+                            layer.alert("服务器异常2", {title: '友情提示', icon: 2});
+                        }
+                    })
+
+
+                    return true;
+                },
+            });
+
+        }
+
+
+
         // 设置结算比分
         function setScore(order_id, match_id) {
           // 请求订单数据