@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="page-header">
                <h3 class="page-title">
                     <span class="page-title-icon bg-gradient-primary text-white mr-2">
                        <i class="mdi mdi-settings"></i>
                    </span>
                    {{ __('auto.推广奖金审核') }}
                </h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">{{ __('auto.推广奖金审核') }}</a></li>
                        <li class="breadcrumb-item active" aria-current="page">{{ __('auto.推广赚金') }}</li>
                    </ol>
                </nav>
            </div>

            <div class="row">
                <div class="col-lg-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">{{ __('auto.推广奖金审核') }}</h4>
                            <form class="well form-inline margin-top-20" method="get" action='/admin/extension/verify'>

                                <spen style="padding-left: 10px">{{ __('auto.会员ID：') }}</spen>
                                <input class="form-control" type="text" name="GameID" style="width: 10%; "
                                       value="{{$GameID}}">

                                <spen style="padding-left: 10px">{{ __('auto.手机号：') }}</spen>
                                <input class="form-control" type="text" name="mobile" style="width: 10%; "
                                       value="{{$mobile}}">
                                <spen style="padding-left: 10px">{{ __('auto.上级ID：') }}</spen>
                                <input class="form-control" type="text" name="SpreaderID" style="width: 10%; "
                                       value="{{$SpreaderID}}">
                                <spen style="padding-left: 10px">{{ __('auto.昵称：') }}</spen>
                                <input class="form-control" type="text" name="NickName" style="width: 10%; "
                                       value="{{$NickName}}">

                                <spen style="padding-left: 10px">{{ __('auto.选择注册时间：') }}</spen>
                                <input type="datetime-local" step="01" name="start_time" class="form-control"
                                       value="{{$start_time}}" id="start_time" onclick="start_times()"/>&nbsp;&nbsp;
                                <input type="datetime-local" step="01" name="end_time" class="form-control"
                                       value="{{$end_time}}" id="end_time" onclick="end_times()"/>&nbsp;&nbsp;

                                <input type="hidden" name="Type" value="{{$Type}}">
                                <input type="hidden" name="FinalScore" value="{{$FinalScoreSort}}">
                                <input type="hidden" name="Sort" value="{{$Sort}}">

                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                <a href="/admin/extension/verify"
                                   class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>&nbsp;&nbsp;

                            </form>


                            <br>
                            <label for="register">
                                <input type="checkbox" class="form-group" name="Type" value="1" id="register"
                                       onclick="typeFunc()" @if (strpos($Type,'1') !== false)
                                       checked
                                    @endif> {{ __('auto.邀请好友注册奖金') }}
                            </label>

                            <label for="game">
                                <input type="checkbox" class="form-group" name="Type" value="2" id="game"
                                       onclick="typeFunc()" @if (strpos($Type,'2') !== false)
                                       checked
                                    @endif> {{ __('auto.邀请好友游戏奖金') }}
                            </label>

                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <label for="">
                                {{ __('auto.当前审核可见金额') }} ：{{$visibleAmount->StatusValue}}
                                <button class="btn-sm btn-gradient-dark" onclick="visibleAmountFunc()">{{ __('auto.修改') }}</button>
                            </label>

                            <label for="">
                                {{ __('auto.可领额度档位上限配置修改') }} ：{{$UpperLimit->StatusValue}}
                                <button class="btn-sm btn-gradient-dark" onclick="upperLimitFunc()">{{ __('auto.修改') }}</button>
                            </label>


                            {{ __('auto.自动审核：') }}
                            @if ($AutoVerify == 1)
                                {{ __('auto.已开启') }} <button class="btn btn-sm btn-gradient-dark" onclick="autoVerify(0)">{{ __('auto.关闭') }}</button>
                            @else
                                {{ __('auto.已关闭') }} <button class="btn btn-sm btn-gradient-dark" onclick="autoVerify(1)">{{ __('auto.开启') }}</button>
                            @endif

                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.会员') }}ID</th>
                                    <th>TA{{ __('auto.的上级') }}ID</th>
                                    <th>{{ __('auto.总奖励') }}</th>
                                    <th>
                                        <div class="FinalScore">
                                            {{ __('auto.历史通过审核金') }}
                                            <svg t="1611284352657" class="icon2" onclick="FinalScoreFunc(this,'asc')"
                                                 viewBox="0 0 1024 1024" version="1.1"
                                                 xmlns="http://www.w3.org/2000/svg" p-id="4118" width="14">
                                                <path
                                                    d="M541.866667 285.866667l345.6 345.6c17.066667 17.066667 17.066667 42.666667 0 59.733333-8.533333 8.533333-19.2 12.8-29.866667 12.8H168.533333c-23.466667 0-42.666667-19.2-42.666666-42.666667 0-10.666667 4.266667-21.333333 12.8-29.866666l343.466666-345.6c17.066667-17.066667 42.666667-17.066667 59.733334 0z"
                                                    p-id="4119" fill="#707072">

                                                </path>
                                            </svg>

                                            <svg t="1611283709864" class="icon1" onclick="FinalScoreFunc(this,'desc')"
                                                 viewBox="0 0 1024 1024" version="1.1"
                                                 xmlns="http://www.w3.org/2000/svg" p-id="3148" width="14">
                                                <path
                                                    d="M482.133333 738.133333L136.533333 392.533333c-17.066667-17.066667-17.066667-42.666667 0-59.733333 8.533333-8.533333 19.2-12.8 29.866667-12.8h689.066667c23.466667 0 42.666667 19.2 42.666666 42.666667 0 10.666667-4.266667 21.333333-12.8 29.866666L541.866667 738.133333c-17.066667 17.066667-42.666667 17.066667-59.733334 0z"
                                                    p-id="3149" fill="#707071">

                                                </path>
                                            </svg>
                                        </div>
                                    </th>
                                    <th>{{ __('auto.可领金额') }}</th>
                                    <th>{{ __('auto.账号创建时间') }}</th>
                                    <th>
                                        <div class="TotalScore">
                                            {{ __('auto.待审金额') }}
                                            <svg t="1611284352657" class="icon2" onclick="totalScoreFunc(this,'asc')"
                                                 viewBox="0 0 1024 1024" version="1.1"
                                                 xmlns="http://www.w3.org/2000/svg" p-id="4118" width="14">
                                                <path
                                                    d="M541.866667 285.866667l345.6 345.6c17.066667 17.066667 17.066667 42.666667 0 59.733333-8.533333 8.533333-19.2 12.8-29.866667 12.8H168.533333c-23.466667 0-42.666667-19.2-42.666666-42.666667 0-10.666667 4.266667-21.333333 12.8-29.866666l343.466666-345.6c17.066667-17.066667 42.666667-17.066667 59.733334 0z"
                                                    p-id="4119" fill="#707072">

                                                </path>
                                            </svg>

                                            <svg t="1611283709864" class="icon1" onclick="totalScoreFunc(this,'desc')"
                                                 viewBox="0 0 1024 1024" version="1.1"
                                                 xmlns="http://www.w3.org/2000/svg" p-id="3148" width="14">
                                                <path
                                                    d="M482.133333 738.133333L136.533333 392.533333c-17.066667-17.066667-17.066667-42.666667 0-59.733333 8.533333-8.533333 19.2-12.8 29.866667-12.8h689.066667c23.466667 0 42.666667 19.2 42.666666 42.666667 0 10.666667-4.266667 21.333333-12.8 29.866666L541.866667 738.133333c-17.066667 17.066667-42.666667 17.066667-59.733334 0z"
                                                    p-id="3149" fill="#707071">

                                                </path>
                                            </svg>
                                        </div>
                                    </th>
                                    <th>{{ __('auto.金额类型') }}</th>
                                    <th width="170px">{{ __('auto.来源玩家') }}</th>
                                    <th>{{ __('auto.所有下级人数') }}</th>
                                    <th>{{ __('auto.直属下级') }}</th>
                                    <th>{{ __('auto.下下级') }}</th>
                                    <th>{{ __('auto.操作') }}</th>
                                    <th>{{ __('auto.备注') }}</th>
                                </tr>
                                </thead>
                                <tbody>

                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$v->UserID}}">
                                                {{$v->GameID}}
                                            </a>
                                        </td>
                                        <td>{{ $v->SpreaderID }}</td>
                                        <td>{{$v->Total}}</td>
                                        <td>{{ $v->FinalScore }}</td>
                                        <td>{{CollectableScore($v->UserID,$v->Type)}}</td>
                                        <td>{{$v->RegisterDate}}</td>
                                        <td>{{$v->TotalScore}}</td>
                                        <td>
                                            @if ($v->Type == 1)
                                                {{ __('auto.注册') }}
                                            @elseif($v->Type == 2)
                                                {{ __('auto.对局') }}
                                            @endif
                                        </td>

                                        <td>
                                            @if ($v->count > 0)
                                                <a href="javascript:void(0)"
                                                   onclick="userSourceFunc({{$v->UserID}},{{$v->Type}},{{$v->GameID}})">{{$v->count}}</a>
                                                ({{$v->rechargeCount}}{{ __('auto.人') }} / {{$v->RechargeSum}})
                                            @else
                                                {{$v->count}}
                                            @endif
                                        </td>

                                        <td>{{$v->downCount1 + $v->downCount2}}</td>
                                        <td>
                                            @if ($v->downCount1 > 0)
                                                <a href="/admin/user/bind_list?Higher1ID={{$v->UserID}}&source=2&start_time={{$start_time}}&end_time={{$end_time}}&GameID={{$GameID}}&SpreaderID={{$SpreaderID}}&NickName={{$NickName}}&Type={{$Type}}&Sort={{$Sort}}&FinalScoreSort={{$FinalScoreSort}}">
                                                    {{$v->downCount1}}
                                                </a>
                                            @else
                                                {{$v->downCount1}}
                                            @endif

                                        </td>
                                        <td>
                                            @if ($v->downCount2 > 0)
                                                <a href="/admin/user/bind_list?Higher2ID={{$v->UserID}}&source=2&start_time={{$start_time}}&end_time={{$end_time}}&GameID={{$GameID}}&SpreaderID={{$SpreaderID}}&NickName={{$NickName}}&Type={{$Type}}&Sort={{$Sort}}&FinalScoreSort={{$FinalScoreSort}}">
                                                    {{$v->downCount2}}
                                                </a>
                                            @else
                                                {{$v->downCount2}}
                                            @endif

                                        </td>

                                        <td>
                                            <button class="btn btn-sm btn-gradient-dark"
                                                    onclick="update({{$v->id}},'Status',1,{{$v->UserID}},{{$v->TotalScore}})">{{ __('auto.通过') }}
                                            </button>

                                            @if ($v->OverLook == 1)
                                                <button class="btn btn-sm btn-gradient-success">{{ __('auto.已忽略') }}
                                                </button>
                                            @else
                                                <button class="btn btn-sm btn-gradient-dark"
                                                        onclick="update({{$v->id}},'OverLook',1)">{{ __('auto.忽略') }}
                                                </button>
                                            @endif
                                        </td>

                                        <td  contentEditable="true"
                                             onblur="remarks(this,{{$v->UserID}})" style="vertical-align: top">{{$v->Remarks}}
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix">

                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'start_time' => $start_time,
                                        'end_time' => $end_time,
                                        'GameID' => $GameID,
                                        'SpreaderID' => $SpreaderID,
                                        'NickName' => $NickName,
                                        'Type' => $Type,
                                        'Sort' => $Sort
                                    ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        var dataObj = {
            'GameID': '{{$GameID}}',
            'mobile': '{{$mobile}}',
            'SpreaderID': '{{$SpreaderID}}',
            'NickName': '{{$NickName}}',
            'start_time': '{{$start_time}}',
            'end_time': '{{$end_time}}',
            'Sort':'{{$Sort}}',
            'FinalScoreSort' : '{{$FinalScoreSort}}',
            'Type':'{{$Type}}'
        }


        // 自动审核开关
        function autoVerify(StatusValue) {
            myRequest("/admin/extension/auto_verify", "post", {StatusValue}, function (res) {
                layer.msg(res.msg)
                setTimeout(function () {
                    window.location.reload();
                }, 1500)
            });
        }
        // 类型搜索
        function typeFunc() {

            //这样获取的是一个数组
            var ci = document.getElementsByName("Type");

            var type = ''

            // 遍历复选框数组  如果被选中ci[i].checked的值就是true
            for (var i = 0; i < ci.length; i++) {
                if (ci[i].checked == true) {
                    type += ci[i].value + ','
                }
            }

            dataObj.Type = type
            $.ajax({
                type: "get",
                url: "/admin/extension/verify",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data: dataObj,
                success: function (msg) {
                    if (msg) {
                        $(".main-panel").html(msg)
                    }
                }
            })

            console.log(type)
        }

        // 可见金额
        function visibleAmountFunc() {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.当前审核可见金额') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['60%', '70%'],
                content: '/admin/extension/verify_score'
            });
        }

        // 修改审核状态 -- 通过
        function update(id, field, value,UserID,TotalScore) {
            myConfirm("{{ __('auto.操作不可逆,是否继续') }}?", function () {
                myRequest("/admin/extension/verify_update/" + id, "post", {field, value,UserID,TotalScore}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                });
            });
        }

        // 修改上限配置
        function upperLimitFunc() {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['60%', '70%'],
                content: '/admin/extension/upper_limit'
            });
        }

        // 奖励来源
        function userSourceFunc(UserID, Type, GameID) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.奖金来源') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '80%'],
                content: '/admin/extension/user_source?UserID=' + UserID + '&Type=' + Type + '&GameID=' + GameID
            });
        }


        // 上下排序
        function totalScoreFunc(obj, val) {

            if (val == 'asc') {
                $(".TotalScore svg:eq(1)").children('path').attr('fill', '#707071');
                $(obj).children('path').attr('fill', 'red')

            } else {
                $(obj).children('path').attr('fill', 'red')
                $(".TotalScore svg:eq(0)").children('path').attr('fill', '#707071');
            }

            dataObj.Sort = val

            $.ajax({
                type: "get",
                url: "/admin/extension/verify",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data: dataObj,
                success: function (msg) {

                    if (msg) {
                        $(".main-panel").html(msg)

                    }
                }
            })
        }
        // 审核通过金上下排序
        function FinalScoreFunc(obj, val) {

            if (val == 'asc') {
                $(".FinalScoreFunc svg:eq(1)").children('path').attr('fill', '#707071');
                $(obj).children('path').attr('fill', 'red')

            } else {
                $(obj).children('path').attr('fill', 'red')
                $(".FinalScoreFunc svg:eq(0)").children('path').attr('fill', '#707071');
            }

            dataObj.FinalScoreSort = val

            $.ajax({
                type: "get",
                url: "/admin/extension/verify",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data: dataObj,
                success: function (msg) {

                    if (msg) {
                        $(".main-panel").html(msg)

                    }
                }
            })
        }

        // 添加备注
        function remarks(obj, UserID) {
            var Remarks = $(obj).html();
            myRequest("/admin/extension/verify_remarks/" + UserID, "post", {Remarks}, function (res) {
                layer.msg(res.msg)
                // setTimeout(function () {
                //     window.location.reload();
                // }, 1500)
            });
        }

        function start_times() {

            getFormat('00', '00', '00');

            document.getElementById("start_time").value = format
        }

        function end_times() {
            getFormat('23', '59', '59');
            document.getElementById("end_time").value = format
        }

    </script>
@endsection
