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

        .layui-form-switch em {
            width: auto;
        }

        .layui-form-switch {
            width: 44px;
            line-height: 23px;
        }

        .layui-form-item .checkbox {
            width: auto;
        }

        .statistics{
            margin: 0 auto;
            text-align: center;
            margin-bottom: 5px;
        }

        .red{
            color: red;
            font-weight: bold;
        }
    </style>
    <!---注单管理-->
    <div class="layui-row">
        <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">开始时间：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="start_time" id="start_time"  lay-verify=""
                                   autocomplete="off" class="layui-input test-item" eventType=event-query
                                   value="{{ $start_time }}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">结束时间：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="end_time" id="end_time" placeholder=" - " lay-verify=""
                                   autocomplete="off" class="layui-input test-item" eventType=event-query
                                   value="{{ $end_time }}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">本站用户名：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="account_name" id="account_name" lay-verify="" autocomplete="off" eventType=event-query
                                   class="layui-input" value="">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">真人用户名：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="UserName" id="UserName" lay-verify="" autocomplete="off" eventType=event-query
                                   class="layui-input" value="">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">订单ID：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="OrderID" id="OrderID" lay-verify="" autocomplete="off" eventType=event-query
                                   class="layui-input" value="">
                        </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>
                        </a>
                        <a class="layui-btn layui-btn-sm" id="get_betting" data-type="reload" style="opacity: 1; pointer-events: auto;">获取投注流水</a>
                        <a class="layui-btn layui-btn-sm" id="update_betting" data-type="reload" style="opacity: 1; pointer-events: auto;">更新投注流水</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
    @push('dataTableJS')
        $('.layui-table-page').after('<div id="statistics" class="statistics"></div>');
        function dataTableLoadFinished(res,curr,count)
        {
            console.log('res',res);
            console.log('curr',curr);
            console.log('count',count);
            var str = '';
            var datau=res.data;
            var bettingamount = 0,winLoseamount = 0,validamount = 0,revenue = 0;
            for(var i = 0; i < datau.length; i++)
            {
                bettingamount += parseFloat(res.data[i]['BetAmount']);
                winLoseamount += parseFloat(res.data[i]['Money']);
                if(res.data[i]['Status'] !='None' && res.data[i]['Status'] !='Revoke')
                {
                    validamount += parseFloat(res.data[i]['BetAmount']);
                }
            }
            $('#statistics').html('');

            str = '<p>本页共'+ datau.length +'条注单；总投注金额：<span class="red">'+ bettingamount.toFixed(2) +'RMB</span>；总输赢金额：<span class="red">'+ winLoseamount.toFixed(2) +'RMB</span>；总有效投注额：<span class="red">'+ validamount.toFixed(2) +'RMB</span></p>';

            str += '<p>本类共{{ $total['count'] }}条注单；总投注金额：<span class="red">{{ $total['totalMoney'] }}RMB</span>；总输赢金额：<span class="red">{{ $total['Money'] }}RMB</span>；总有效投注额：<span class="red">{{ $total['effectMoney'] }}RMB</span></p>';
            $('#statistics').html(str);
        }
    @endpush
    @include('vip.datatable')
    <script>
        $('#get_betting').on('click',function(){
            var start = $('#start_time').val();
            var end = $('#end_time').val();

            if(start == ''){
                layer.msg('请选择开始时间');
                return false;
            }
            if(end == ''){
                layer.msg('请选择结束时间');
                return false;
            }
            layer.open({
                type: 2,
                area: ['500px', '450px'],
                title: false,
                closeBtn: 0,
                shadeClose: true,
                skin: 'layui-bg-gray',
                content: '/admin/FyGame/getBetting?start_time='+start+'&end_time='+end
            });
        });

        $('#update_betting').on('click',function(){
            var start = $('#start_time').val();
            var end = $('#end_time').val();

            if(start == ''){
                layer.msg('请选择开始时间');
                return false;
            }
            if(end == ''){
                layer.msg('请选择结束时间');
                return false;
            }
            layer.open({
                type: 2,
                area: ['500px', '450px'],
                title: false,
                closeBtn: 0,
                shadeClose: true,
                skin: 'layui-bg-gray',
                content: '/admin/FyGame/updateBetting?start_time='+start+'&end_time='+end
            });
        });

    </script>
@endsection
