@extends('vip.layouts')
@section('seo_title')
    {{ trans('menu.betRecord') }}
@endsection
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }

        .menu {
            position: fixed;
            left: 0px;
            top: 20px;
            height: 500px;
            overflow: auto;
        }
        .layui-table-cell {
            line-height: 15px;
        }


        .red {
            color: red;
        }

        .blue {
            color: #1E9FFF;
        }

        .green {
            color: green;
        }

        .yellow {
            color: #ffca10;
        }

        .menu {
            width: 140px;
        }

        /*.text {*/
            /*width: 88%;*/
        /*}*/
    </style>
    @push('dataTableJS')
        var menu = [];
        $.ajax({
        type: 'get',
        url: '/admin/game/GameList',
        data: {},
        dataType: 'json',
        async: false,
        success: function (json) {
        menu = json;
        }
        });
        //获取表头
        var tit=function (game){
        var header=[];
        $.ajax({
        type: 'post',
        url: '/admin/game/index?data=1&game='+ game,
        data: {},
        dataType: 'json',
        async: false,
        success: function (json) {
        header=json.data.dataCols
        }
        });
        return header;
        }

        /*var active = {
        reload: function(){
        //执行重载
        table.reload('{{ $dataId }}', {
        page: {
        curr: 1 //重新从第 1 页开始
        }
        ,where: {
            account_name:$("#form_account_name").val(),
            order_id:$('#form_order_id').val(),
            name:$('#form_name').val(),
            game_no:$('#form_game_no').val(),
            bet_small:$('#form_bet_small').val(),
            bet_big:$('#form_bet_big').val(),
            winfail_small:$('#form_winfail_small').val(),
            winfail_big:$('#form_winfail_big').val(),
            money_big:$('#form_money_big').val(),
            money_small:$('#form_money_small').val(),
            game_status:$('#form_game_status').val(),
            star_time:$('#form_star_time').val(),
            end_time:$('#form_end_time').val(),
        }
        });
        }
        };
        $('.lay-btn-diy').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
        });*/

        {{--$(document).on('click','.user',function(){--}}
        {{--var type = $(this).data('type');--}}
        {{--var search=$(this).data('odds')--}}
        {{--var value=$(this).text();--}}
        {{--$("#form_game_no").val('');--}}
        {{--$("#form_account_name").val('');--}}
        {{--$('#form_'+search).val(value);--}}
        {{--active[type] ? active[type].call(this) : '';--}}
        {{--})--}}


        //重置表单
        $('.reset').on('click',function(){
        var game=$('#form_name').val();
        $('input').val('');
        $('#name').val(game);
        form.render('select', 'test2');
        //console.log($('#name').find("option[value="+game+"]"));
        //$('#name').find("option[value="+game+"]").attr("selected","selected");
        $('#trade_type').val('');
//        var type = $(this).data('type');
//        active[type] ? active[type].call(this) : '';
        });

        //刷新表单
//        $('.set').on('click',function(){
//        $('input').val('');
//        $('#type').val('');
//        var type = $(this).data('type');
//        active[type] ? active[type].call(this) : '';
//        });


        var height = document.documentElement.clientHeight;
        $('.menu').css({height: (height-30)});

        function dataTableLoadFinished(res,curr,count){
        var str='';
        if(document.getElementById("statistics")){

        }else{
        $('.layui-table-page').after('<div id="statistics"></div>');
        }
        $('[eventType=event-view]').attr('win-width','950px');



        var datau=res.data;
        var total_bet_money=0,win_money=0;
        for(var i=0;i<datau.length;i++){
        total_bet_money+=parseFloat(datau[i].money);
        win_money+=parseFloat(datau[i].get_money);
        }
        str+='<p>当页总投注金额：<span class="blue">'+total_bet_money+'</span>,当页平台赢取金额：';
        if(win_money<0){
            str+='<span class="red">'+ (-1*win_money)+'</span></p>';
        }else{
            str+='<span class="green">'+ (-1*win_money)+'</span></p>';
        }
        $.ajax({
        type: 'get',
        url: '/admin/game/allTotal',
        data: {where:res.extras},
        dataType: 'json',
        //async: false,
        success: function (data) {
        var data=data.data;
        str+='<p>总投注金额：<span class="blue">'+data.bet_money+'</span>,平台总输赢结果：'
        if(data.get_money>0){
            str+=' <span class="red">'+data.get_money+'</span>';
        }else{
            str+=' <span class="green">'+data.get_money+'</span>';
        }

            $('#statistics').html(str);
            var height1=$('.layui-table-view').height();
            var height2=$('#statistics').height();
            $('.layui-table-view').css({height:(height1+height2)});
            }
            });


            }

            @endpush
            <script type="text/html" id="account">
                <a href="/admin/game/index?account_name=@{{d.account_name}}&name=@{{ d.game }}&star_time=&end_time=" class="user" data-odds="account_name" data-type="reload">@{{d.account_name}}</a>
                <br>
                <span style="color:#afafaf;">@{{ d.remark }}</span>
            </script>
            <script type="text/html" id="gameNo">
                <span style="word-break:break-all"><a href="/admin/game/index?game_no=@{{d.game_no}}&game=@{{ d.game }}&star_time=&end_time=" class="user" data-odds="game_no"
                                                      data-type="reload">@{{d.game_no}}</a>
        @{{#if(d.prizes_code==-1){ }}
        <p style="color: red">未开奖</p>
        @{{#}else{ }}
         <p>@{{d.prizes_code}}</p>
          @{{#}}}
        </span>
            </script>

            <script type="text/html" id="money_time">
               @{{ d.order_id }}
                <br/>
                @{{ d.money_time }}
            </script>
            <script type="text/html" id="moneynew">
               @{{ d.money }}
                <br/>
                
            </script>

            <script type="text/html" id="aftercash">
               <!--  @{{#if(d.game_status == 1){ }}
                <p style="color:red;">@{{ d.game_status }}</p>
                @{{#}else{ }}
                <p style="color:green;">@{{ d.game_status }}</p>
                @{{#} }} -->

                @{{#if(d.game_status=="中奖"){ }}
                <p style="color:red;">@{{d.game_status}}</p>
                @{{#}else{ }}
                @{{#if(d.game_status=="未中奖"||d.game_status=='和'){ }}
                 <p style="color:green;">@{{d.game_status}}</p>
                @{{#}else{ }}
                 @{{#if(d.game_status=="待开奖"){ }}
                 <p style="color:blue;">@{{d.game_status}}</p>
                 @{{#}else{ }}
                 <p style="color:#00868B;">@{{d.game_status}}</p>
                @{{#} }}
                @{{#} }}
                @{{#} }}


            </script>

            <script type="text/html" id="money">
                @{{#if(d.get_money>0){ }}
                <p style="color:red;">@{{d.get_money}}</p>
                @{{#}else{ }}
                 <p style="color:green;">@{{d.get_money}}</p>
                @{{#} }}
            </script>

            <script type="text/html" id="tool">
                @{{#if(d.game_status!=="撤单"){ }}
                <a class="layui-btn layui-btn-xs layui-bg-orange" href="/admin/gameShut/index?order_id=@{{d.order_id}}&game_name=@{{d.game_name}}">作废</a>
                @{{#} }}
                <a class="layui-btn layui-btn-primary layui-btn-xs layui-bg-blue" lay-event="detail" href="/admin/game/view/?id=@{{d.id}}&game_no=@{{ d.game_no }}&sum_code=@{{ d.sum_code }}&game_name=@{{d.game_name}}">查看</a>
            </script>
            <!---注单管理-->
        <div class="layui-row">

            <!--<div class="layui-col-sm1 layui-col-md1 menu">
                 tree
                <ul id="tree" class="tree-table-tree-box"></ul>
            </div>-->
            <div class="layui-col-sm12 layui-col-md12 text" >

                <form class="layui-form rewrite" eventType=eventForm>
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.bet_area') }}</label>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="bet_small" id="form_bet_small" value="{{$bet_small}}" placeholder="0" autocomplete="off" class="layui-input" eventType=event-query>
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="bet_big" id="form_bet_big" value="{{$bet_big}}" placeholder="0" autocomplete="off"
                                       class="layui-input" eventType=event-query>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.winfail_area') }}</label>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="winfail_small" id="form_winfail_small" placeholder="0"
                                       autocomplete="off" class="layui-input" value="{{$winfail_small}}" eventType=event-query >
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline" style="width: 100px;">
                                <input type="text" name="winfail_big" id="form_winfail_big" placeholder="0"
                                       autocomplete="off" value="{{$winfail_big}}"
                                       class="layui-input" eventType=event-query>
                            </div>

                        </div>
                        <div class="layui-inline">
                            <!--用户名-->
                            <label class="layui-form-label">{{ trans('gamemenu.account_name') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="account_name" id="form_account_name" lay-verify="required"
                                       autocomplete="off" class="layui-input" value="{{$account_name}}" eventType="event-query">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.order_id') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="order_id" id="form_order_id" lay-verify="" autocomplete="off"
                                       class="layui-input" value="{{$order_id}}" eventType="event-query">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.name') }}</label>
                            <div class="layui-input-inline layui-form" lay-filter="test2" style="width: 125px">
                                <select name="game" id="form_game"  autocomplete="off" eventType="event-query">
                                    <option value="">{{ trans('gamemenu.select_game') }}</option>
                                    @foreach($gameList as $k=>$v):
                                        @if(checkRriv('/bet/game/'.$v['gameCode']))
                                            @if($game==$v['gameCode'])
                                                <option value="{{$v['gameCode']}}" selected="selected">{{$v['name']}}</option>
                                            @else
                                                <option value="{{$v['gameCode']}}">{{$v['name']}}</option>
                                            @endif
                                        @endif
                                    @endforeach
									
									{{--@if($game=='sixlottery')--}}
										{{--<option value="sixlottery" selected="selected">{{trans('gamemenu.sixlottery')}}</option>--}}
									{{--@else--}}
										{{--<option value="sixlottery">{{trans('gamemenu.sixlottery')}}</option>--}}
									{{--@endif--}}
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.game_status') }}</label>
                            <div class="layui-input-inline" style="width: 125px">
                                <select name="game_status" id="form_game_status" lay-verify="" autocomplete="off"
                                        class="layui-input" eventType=event-query>
                                    <option value="5">{{ trans('gamemenu.select_status') }}</option>
                                    @foreach(trans('status.money_buy.game_status') as $k=>$v)
                                        @if($game_status==$k){
                                            <option value="{{$k}}" selected>{{$v}}</option>
                                        @else
                                            <option value="{{$k}}">{{$v}}</option>
                                        @endif
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">投注点</label>
                            <div class="layui-input-inline" style="width: 125px">
                                <select name="game_point" id="form_game_point" lay-verify="" autocomplete="off"
                                        class="layui-input" eventType=event-query>
                                    <option value="">请选择</option>
                                    <option value="1001" @if(Request::get('game_point') == 1001) selected @endif>pc投注</option>
                                    <option value="1002" @if(Request::get('game_point') == 1002) selected @endif>wap投注</option>
                                    <option value="1003" @if(Request::get('game_point') == 1003) selected @endif>长龙投注</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">

                            <label class="layui-form-label">{{ trans('gamemenu.game_no') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="game_no" id="form_game_no" lay-verify="" autocomplete="off" eventType=event-query
                                       class="layui-input" value="{{Request::get('no')?Request::get('no'):$game_no}}">
                            </div>

                        </div>
                        <div class="layui-inline">


                            <label class="layui-form-label">{{ trans('gamemenu.star_time') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="star_time" id="form_star_time" placeholder=" - " lay-verify=""
                                       autocomplete="off" class="layui-input test-item" eventType=event-query
                                       value="{{$star_time}}">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">{{ trans('gamemenu.end_time') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="end_time" id="form_end_time" placeholder=" - " lay-verify=""
                                       autocomplete="off" class="layui-input test-item" eventType=event-query
                                       value="{{$end_time}}">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <a class="layui-btn layui-btn-sm lay-btn-diy" data-type="reload"  eventType=event-query-submit
                               style="opacity: 1; pointer-events: auto;">提交</a>
                            <a class="layui-btn   layui-btn-sm  layui-btn-normal reset" data-type="reload"
                               style="opacity: 1; pointer-events: auto;">重置</a>
                            <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload"
                               style="opacity: 1; pointer-events: auto;" href="javascript:window.location.reload()">
                                <i class="layui-icon">ဂ</i>
                            @if(checkRriv('/admin/Game/checkPwd'))<a  class="layui-btn layui-btn-sm" data-type="reload" style="opacity: 1; pointer-events: auto;" onclick="exportWord()">导出</a>@endif
                            </a>
                        </div>
                    </div>
                </form>
                @include('vip.datatable')
            </div>
        </div>


        <script>
            /**
             *
             * @param url
             * @param title
             */
            function shutOrder(url,name) {
                layer.confirm('是否确认作废用户'+name+'的该条订单？', {
                    btn: ['确认', '取消'] //按钮
                }, function() {
                    $.getJSON(url, function(data, textStatus) {
                        if (data.status == '1') {
                            layer.msg('作废成功');
                            reloadDataTable();
                        } else {
                            layer.msg(data.msg);
                        }
                    });
                }, function() {
                });
            }

            function exportWord(){
    //          var data = setData();
                $.post("/admin/Game/checkPwd",$("form").serialize(),function(data1){
                var url = data1.data; //回调函数，返回值是地址，data
                console.log(url);
                window.location.href=url;
    //          $('#submitForm').submit(url);
            });
        }
        </script>
@endsection
