@extends('base.base')
@section('base')
    <style>

    </style>
    <!-- 内容区域 -->
    <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>
                                @if ($specialCs)
                                    &nbsp;&nbsp;{{ __('auto.全员可审核新订单状态：') }}{{$normalCsOpen=="open"?__('auto.开启'):__('auto.关闭')}}
                                <button class="btn btn-gradient-dark btn-sm"
                                        onclick="switchNormalCs()">{{ __('auto.切换') }}
                                </button>
                                @endif

                            <form class="well form-inline margin-top-20" method="get"
                                  action='{{$api_url}}'>
                                <div>
                                    @csrf
                                    <spen style="padding-left: 10px">{{ __('auto.会员ID：') }}</spen>
                                    <input class="form-control" type="text" name="GameID" id="GameID"
                                           style="width: 10%; " value="{{$GameID}}">
                                    <spen style="padding-left: 10px">{{ __('auto.额度查询：') }}</spen>
                                    <input class="form-control" type="text" name="withdraw_search" id="GameID"
                                           style="width: 10%; " value="{{$withdraw_search}}">

                                    <spen style="padding-left: 10px">{{ __('auto.订单号查询：') }}</spen>
                                    <input class="form-control" type="text" name="orderID" id="orderID"
                                           style="width: 10%; " value="{{$orderID}}">

                                    <spen style="padding-left: 10px">{{ __('auto.额度筛选：') }}</spen>
                                    <select class="form-control" name="withdraw" value="" style="color: black">
                                        <option value="">{{ __('auto.全部') }}</option>


                                        <option value="100" @if ($withdraw == 100)
                                        selected
                                            @endif>100{{ __('auto.以下（不含100）') }}
                                        </option>


                                        <option value="500" @if ($withdraw == 500)
                                        selected
                                            @endif>100-500（{{ __('auto.含500）') }}
                                        </option>


                                        <option value="1000" @if ($withdraw == 1000)
                                        selected
                                            @endif>500-1000({{ __('auto.含1000）') }}
                                        </option>

                                        <option value="1001" @if ($withdraw == 1001)
                                        selected
                                            @endif>1000{{ __('auto.以上（不含') }}1000)
                                        </option>

                                    </select>
                                    <spen style="padding-left: 10px">{{ __('auto.渠道搜索：') }}</spen>
                                    <select class="form-control" name="Channel" value="" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>
                                        @foreach($allChannel as $key=>$val)
                                            <option value="{{$val}}"
                                                    @if($val == $Channel) selected @endif>{{$val}}</option>
                                        @endforeach

                                    </select>


                                    <spen style="padding-left: 10px">{{ __('auto.当前状态筛选：') }}</spen>
                                    <select class="form-control" name="state" value="" style="color: black">
                                        <option value="100" @if ($state == 100)
                                        selected
                                            @endif>{{ __('auto.全部') }}
                                        </option>
                                        <option value="2" @if ($state == 2)
                                        selected
                                            @endif>{{ __('auto.已完成') }}
                                        </option>
                                        <option value="-1" @if ($state == -1)
                                        selected
                                            @endif>{{ __('auto.已拒绝') }}
                                        </option>
                                        <option value="1" @if ($state == 1)
                                        selected
                                            @endif>{{ __('auto.审核中') }}
                                        </option>
                                        <option value="5" @if ($state == 5)
                                        selected
                                            @endif>{{ __('auto.处理中') }}

                                        <option value="6" @if ($state == 6)
                                        selected
                                            @endif>{{ __('auto.第三方订单失败') }}
                                        </option>
                                        <option value="7" @if ($state == 7)
                                        selected
                                            @endif>{{ __('auto.三方账单清算中') }}
                                        <option value="4" @if ($state == 4)
                                        selected
                                            @endif>{{ __('auto.系统回收') }}


                                    </select><br>
                                    <spen style="padding-left: 10px">{{ __('auto.咖啡搜索：') }}</spen>
                                    <select class="form-control" name="payState" value="" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>

                                        <option value="1"
                                                @if(1 == $payState) selected @endif>{{ __('auto.已咖啡') }}
                                        </option>
                                        <option value="2"
                                                @if(2 == $payState) selected @endif>{{ __('auto.未咖啡') }}

                                    </select>
                                    <spen style="padding-left: 10px">{{ __('auto.申请茶叶时间选择：') }}</spen>
                                    <input type="datetime-local" step="01" name="start_time" id="start_time"
                                           class="form-control" value="{{$start_time}}" onclick="start_times()"/>
                                    <input type="datetime-local" step="01" name="end_time" id='end_time'
                                           class="form-control" value="{{$end_time}}" onclick="end_times()"/>
                                    <spen style="padding-left: 10px">{{ __('auto.订单完成时间选择：') }}</spen>
                                    <input type="datetime-local" step="01" name="final_start_time" id="final_start_time"
                                           class="form-control" value="{{$final_start_time}}"
                                           onclick="final_start_times()"/>
                                    <input type="datetime-local" step="01" name="final_end_time" id='final_end_time'
                                           class="form-control" value="{{$final_end_time}}"
                                           onclick="final_end_times()"/>

                                    <spen style="padding-left: 10px">{{ __('auto.包名搜索：') }}</spen>
                                    <select class="form-control" name="PackgeName" value="" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>
                                        @foreach($ChannelPackageName as $val)
                                            <option value="{{$val}}" @if ($PackgeName == $val)
                                            selected
                                                @endif>{{$val}}</option>
                                        @endforeach
                                    </select>

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

                                    <a href="{{$api_url}}?excel=1&GameID={{$GameID}}&withdraw_search={{$withdraw_search}}&orderID={{$orderID}}&withdraw={{$withdraw}}&start_time={{$start_time}}&end_time={{$end_time}}&final_start_time={{$final_start_time}}&final_end_time={{$final_end_time}}&state={{$state}}"
                                       class="btn btn-sm btn-gradient-light btn-icon-text">{{ __('auto.导出') }}</a>


                                </div>


                            </form>
                            <table class="table table-bordered" style="table-layout: fixed">
                                <thead>
                                <tr>
                                    <th width="10%">{{ __('auto.单号') }}</th>
                                    <th width="10%">{{ __('auto.玩家') }}id</th>
                                    <th width=6%">{{ __('auto.渠道') }}</th>
                                    <th width="10%">{{ __('auto.提款名字') }}</th>
                                    <th width="15%">{{ __('auto.邮箱') }}</th>
                                    <th width="10%">CPF/MAC</th>
                                    <th width="10%">{{ __('auto.电话') }}</th>
{{--                                    <th width="10%">{{ __('auto.银行卡') }}/clabe</th>--}}
                                    <th width="6%">IP</th>
                                    <th width="10%">
                                        <span id="create_time">{{ __('auto.提交时间') }}</span>

                                        <svg t="1611284352657" class="icon2" onclick="create_times(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="create_times(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>
                                    </th>
                                    <th width="9%">{{ __('auto.茶叶申请额度') }}</th>
                                    <th width="9%">{{ __('auto.实际到账金额') }}</th>
                                    <th width="9%">{{ __('auto.扣除手续费用') }}</th>
                                    <th width="10%">{{ __('auto.审核状态') }}</th>
                                    <th width="10%">{{ __('auto.风险提示') }}</th>
                                    <th width="10%">{{ __('auto.风险评估') }}</th>
                                    <th width="5%">{{ __('auto.备注') }}</th>
                                    <th width="10%">{{ __('auto.审核操作') }}</th>

                                </tr>
                                </thead>
                                <tbody class="search_checkbox">
{{--                                <h4>--}}
{{--                                    {{ __('auto.申请金额：') }}--}}
{{--                                    {{$applyUserCount->userCount ?? 0}} {{ __('auto.人') }} {{$applyUserCount->count ?? 0}}--}}
{{--                                    {{ __('auto.笔') }}&nbsp;&nbsp;{{ __('auto.总计：') }}{{$applyUserCount->WithDraw ?? 0}} &nbsp;&nbsp;--}}
{{--                                    {{ __('auto.实际到账：') }}--}}
{{--                                    {{$overUserCount->userCount ?? 0}} {{ __('auto.人') }}&nbsp;&nbsp;--}}
{{--                                    {{$overUserCount->count ?? 0}} {{ __('auto.笔') }}&nbsp;&nbsp;--}}
{{--                                    {{$overUserCount->WithDraw ?? 0}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--}}
{{--                                </h4>--}}

                                @foreach($list as $k=>$item)
                                    <tr>
                                        <td>{{$item->OrderId}}</td>
                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$item->UserID}}">
                                                {{$item->GameID}}
                                            </a>
                                        </td>
                                        <td>{{$item->Channel}}</td>
                                        <td>
                                            @if ($item->PixType < 10)
                                                {{$item->BankUserName}}<span style="color: red">{{$item->sameNameNum>1?"[".$item->sameNameNum."]":""}}</span>
                                            @else
                                                {{ $item->AccountsBank }}
                                            @endif
                                        </td>
                                        <td>
                                            @if ($item->PixType < 10)
                                                {{$item->EmailAddress}}<span style="color: red">{{$item->sameEmailNum>1?"[".$item->sameEmailNum."]":""}}</span>
                                            @else
                                                {{ $item->AdhaarNumber }}
                                            @endif
                                        </td>
                                        <td>
                                            <span style="color: red">{{$item->sameCpfCount>1?"[".$item->sameCpfCount."]":""}}</span>
                                            /
                                            <span style="color: red">{{$item->sameMac>1?"[".$item->sameMac."]":""}}</span>
                                        </td>
                                        <td>
                                            @if ($item->PixType < 10)
                                                {{$item->PhoneNumber}}
                                            @else
                                                {{ $item->IFSCNumber }}
                                            @endif
                                        </td>

                                        <td>
                                            <span style="color: red">{{$item->sameIP>1?"[".$item->sameIP."]":""}}</span>
                                        </td>
                                        <td>{{date('Y-m-d H:i:s',strtotime($item->CreateDate))}}</td>
                                        <td>{{$item->actual_arrival}}</td>
                                        <td>{{$item->WithDraw}}</td>
                                        <td>{{$item->ServiceFee}}</td>
                                        <td>
                                            {!! $item->States !!}
                                        </td>
                                        <td>
                                            @if ($item->gear == '低')
                                                <span style="color: green">{{__('auto.低')}}</span>
                                            @elseif($item->gear == '普通')
                                                {{__('auto.普通')}}
                                            @elseif($item->gear == '较高')
                                                <span style="color: red">{{__('auto.较高')}}</span>
                                            @elseif($item->gear == '高')
                                                <span style="color: red">{{__('auto.高')}}</span>
                                            @endif
                                            <br>
                                            {{$item->assessment}}
                                        </td>

                                        <td>
                                            <button class="btn btn-gradient-dark btn-sm"
                                                    onclick="show('{{$item->gear}}',{{$item->UserID}})">{{ __('auto.查看') }}
                                            </button>
                                        </td>
                                        <td contentEditable="true"
                                            onblur="remarks(this,{{$item->RecordID}})"
                                            style="vertical-align: top">{{$item->remarks}}</td>
                                        <td>
{{--                                            @if (empty(hidden()) || hidden() == 'general_administrator' || hidden() == 'customer_service1' || hidden() == 'customer_service2')--}}
                                                @if ($item->State == 1)
                                                    <button type="button"
                                                            class="btn btn-sm btn-gradient-success btn-icon-text"
                                                            onclick="update({{$item->RecordID}},'agree')">
                                                        {{ __('auto.通过') }}
                                                        <i class="mdi mdi-file-check btn-icon-append"></i>
                                                    </button>
                                                    <button type="button"
                                                            class="btn btn-sm btn-gradient-dark btn-icon-text"
                                                            onclick="update({{$item->RecordID}},'turn_down')">
                                                        {{ __('auto.拒绝') }}
                                                        <i class="mdi mdi-file-check btn-icon-append"></i>
                                                    </button>
                                                    <button type="button" class="btn btn-sm btn-dribbble btn-icon-text"
                                                            onclick="update({{$item->RecordID}},'refuse')">
                                                        {{ __('auto.清退') }}
                                                        <i class="mdi mdi-file-check btn-icon-append"></i>
                                                    </button>
                                                    <button type="button"
                                                            class="btn btn-sm btn-gradient-dark btn-icon-text"
                                                            onclick="recovery({{$item->RecordID}},'recovery')">
                                                        {{ __('auto.回收') }}
                                                        <i class="mdi mdi-file-check btn-icon-append"></i>
                                                    </button>
                                                    @if ($item->locking == 1)
                                                        <button type="button"
                                                                class="btn btn-sm btn-facebook  btn-icon-text"
                                                                onclick="locking({{$item->RecordID}})">
                                                            {{ __('auto.解锁') }}
                                                            <i class="mdi mdi-file-check btn-icon-append"></i>
                                                        </button>
                                                    @else
                                                        <button type="button"
                                                                class="btn btn-sm btn-google btn-icon-text"
                                                                onclick="locking({{$item->RecordID}})">
                                                            {{ __('auto.锁定') }}
                                                            <i class="mdi mdi-file-check btn-icon-append"></i>
                                                        </button>
                                                    @endif
                                                @endif
{{--                                            @endif--}}
                                        </td>

                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix" id="pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                         'list'=>$list,
                                        'GameID'=>$GameID,
                                        'withdraw_search'=>$withdraw_search,
                                        'withdraw'=>$withdraw,
                                        'state'=>$state,
                                        'payState' => $payState,
                                        'start_time'=>$start_time,
                                        'end_time'=>$end_time,
                                        'payState' => $payState,
                                        'final_start_time' => $final_start_time,
                                        'final_end_time' => $final_end_time,
                                         'agent' =>$agent,
                                         'Channel' => $Channel

                                    ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        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
        }

        function final_start_times() {

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

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

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

        function recovery(id) {
            myConfirm("{{ __('auto.是否继续') }}?", function () {
                myRequest("/admin/withdrawal/recovery/" + id, "post", {}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 2000)

                });
            });
        }
        function switchNormalCs() {

            let opstatus='{{$normalCsOpen=="open"?"close":"open"}}';

            myConfirm("{{ __('auto.是否继续') }}?", function () {
                myRequest("/admin/withdrawal/switchCs" , "post", {normalCsOpen:opstatus}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 2000)

                });
            });
        }

        function locking(id) {
            myConfirm("{{ __('auto.是否继续') }}?", function () {
                myRequest("/admin/withdrawal/locking/" + id, "post", {}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 2000)

                });
            });
        }

        // 提交时间排序
        var create_time = '{{$create_time ?? ''}}'
        if (create_time !== '') {
            document.getElementById("create_time").style.color = "blue";
            if (create_time == 'asc') {
                $(".create_time svg:eq(0)").children('path').attr('fill', 'red');
            } else {
                $(".create_time svg:eq(1)").children('path').attr('fill', 'red');
            }
        }

        function remarks(obj, RecordID) {
            remark = $(obj).html();
            myRequest("/admin/withdrawal/remarks/" + RecordID, "post", {remark}, function (res) {
                layer.msg(res.msg)
                setTimeout(function () {
                    window.location.reload();
                }, 1500)
            });
        }

        // 提交时间排序
        function create_times(obj, val) {
            document.getElementById("create_time").style.color = "blue";
            if (val == 'asc') {
                $(obj).children('path').attr('fill', 'red')
                $(".create_time svg:eq(1)").children('path').attr('fill', '#707071');

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

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


        function show(gear, UserID) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.风险评估等级') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['80%', '98%'],
                content: '/admin/withdrawal/risk_assessment/' + UserID + '?gear=' + gear
            });
        }

        function update(id, type) {
            if (id === 0) {
                var num = document.getElementsByName('checkbox');

                var str = '';
                for (var i = 0; i < num.length; i++) {
                    if (num[i].checked) {
                        str = str + num[i].id + ',';
                    }
                }

                if (str == '') {
                    alert('{{ __('auto.请选择要操作的数据') }}');
                    return false;
                }
                id = str.substr(0, str.length - 1);
            }

            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '90%'],
                content: '/admin/withdrawal/verify?ids=' + id + '&type=' + type
            });
        }

        function refuse() {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '90%'],
                content: '/admin/withdrawal/verify'
            });
        }

        function checkbox() {
            var num = document.getElementsByName('checkbox');
            for (var i = 0; i < num.length; i++) {
                if (num[i].checked) {
                    num[i].checked = false;
                } else {
                    num[i].checked = true;
                }
            }
        }

    </script>
@endsection
