@extends('vip.layouts')
@section('seo_title')
    订单管理
@endsection
@section('content')
    <style>
        .layui-form-switch em {
            width: auto;
        }

        .layui-form-item .checkbox {
            width: auto;
        }
    </style>
    <script id="opt" type="text/html">
        <a href="/payment/orderInfo?id=@{{d.id}}" class="layui-btn layui-btn-sm view">查看</a>
      
        @{{#if(d.status == '0'){ }}
            <a onclick="updateOrderStatus(@{{d.id}})" class="layui-btn layui-btn-xs layui-btn-diy">付款</a>
            <a onclick="delOrder(@{{d.id}})" class="layui-btn layui-btn-xs  layui-btn-danger">作废</a>
        @{{#} }}
 
    </script>
    <script>
        function updateOrderStatus(id){
            layer.open({
                title: '温馨提示'
                ,content: '确认修改订单为已支付状态吗？'
                ,btn: ['确定', '取消', ]
                ,yes: function(index, layero){
                    $.get('/payment/updateOrderStatus?id='+id,function(data){
                        layer.msg(data.msg)
                        location.reload()
                    })

                }
            });
        }
        function delOrder(id){
            layer.open({
                title: '温馨提示'
                ,content: '确认将该订单作废吗？'
                ,btn: ['确定', '取消', ]
                ,yes: function(index, layero){
                    $.get('/payment/removeOrder?id='+id,function(data){
                        layer.msg(data.msg)
                        location.reload()
                    })

                }
            });
        }
        function cancelOrder(){
            layer.open({
                title: '温馨提示'
                ,content: '确认将下单时间超过24小时的所有订单设为作废吗？'
                ,btn: ['确定', '取消', ]
                ,yes: function(index, layero){
                    $.get('/payment/cancelOrder',function(data){
                        layer.msg(data.msg)
                        location.reload()
                    })

                }
            });
        }
        
        function deleteAllOrder(){
            layer.open({
                title: '温馨提示'
                ,content: '确认将下单时间超过30天的所有订单删除吗？'
                ,btn: ['确定', '取消', ]
                ,yes: function(index, layero){
                    $.get('/payment/deleteAllOrder',function(data){
                        layer.msg(data.msg)
                        location.reload()
                    })

                }
            });
        }
    </script>
    <script id="status" type="text/html">
        @{{#if(d.status == '1'){ }}
            <span style="color:green;">支付成功</span>
        @{{#}else if(d.status == '-1'){ }}
            <span style="color:#FF5722;">订单作废</span>
        @{{#}else{ }}
            <span style="color:#1E9FFF;">待支付</span>
        @{{#} }}

    </script>
    <script>
        function exportWord(){
            $.get("/payment/viewDetail",$("form").serialize(),function(data1){
            var url = data1.data; //回调函数，返回值是地址，data
            window.location.href=url;
            });
        }
    </script>
    <div class="layui-row">
        <div class="layui-col-xs12">
            <form class="layui-form rewrite" eventType="eventForm" action="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-inline">
                            <label class="layui-form-label">订单日期</label>
                            <div class="layui-input-inline">
                                <input type="text" name="start_time"  id="start_time" placeholder=" - "  value="{{$start_time}}" lay-verify="required" eventType="event-query" autocomplete="off" class="layui-input test-item">
                            </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=" - "  value="{{$end_time}}" eventType="event-query" lay-verify="required" autocomplete="off" class="layui-input test-item">
                            </div>
                        </div>

                        <div class="layui-inline" style="width: 280px">
                            <label class="layui-form-label">{{ trans('pay_orders.order_no') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="order_no" id="order_no" eventType="event-query"
                                       value="{{$order_no}}" lay-verify="required" autocomplete="off"
                                       class="layui-input" style="width: 200px">
                            </div>
                            <!-- <div class="layui-input-inline checkbox">
                                <input type="checkbox" name="sureblur" id="sureblur" lay-skin="switch" lay-text="精确|模糊"
                                       checked>
                            </div> -->
                        </div>
                        <div class="layui-inline" style="width: 280px">
                            <label class="layui-form-label">{{ trans('pay_orders.payer') }}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="payer" id="payer" eventType="event-query"
                                       value="{{$payer}}" lay-verify="required" autocomplete="off"
                                       class="layui-input" style="width: 200px">
                            </div>
                            <!-- <div class="layui-input-inline checkbox">
                                <input type="checkbox" name="sureblur" id="sureblur" lay-skin="switch" lay-text="精确|模糊"
                                       checked>
                            </div> -->
                        </div>
                        <div class="layui-inline" style="width: 280px">
                            <label class="layui-form-label">{{ trans('pay_orders.status') }}</label>
                            <div class="layui-input-inline" style="width: 200px">
                                <select name="status" id="form_statuss" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
                                    <option value="-2">请选择订单状态</option>
                                    @foreach(trans('status.pay_orders.status') as $k=>$v):
                                        @if($status==$k))
                                            <option value="{{$k}}" selected="selected">{{$v}}</option>
                                        @else
                                            <option value="{{$k}}">{{$v}}</option>
                                        @endif
                                    @endforeach
                                </select>
                            </div>
                        </div>
                
                        <div class="layui-inline" style="width: 280px">
                            <label class="layui-form-label">{{ trans('pay_orders.gateway_name') }}</label>
                            <div class="layui-input-inline" style="width: 200px">
                                <select name="gateway_id" id="form_statuss" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
                                    <option value="">选择网关</option>
                                    @foreach($gateways_list as $k=>$v):
                                        @if($gateway_id==$v->id))
                                            <option value="{{$v->id}}" selected="selected">{{$v->id}}:{{$v->gateway_name}}</option>
                                        @else
                                            <option value="{{$v->id}}">{{$v->id}}:{{$v->gateway_name}}</option>
                                        @endif
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline" style="width: 280px">
                            <label class="layui-form-label">{{ trans('pay_orders.channel_name') }}</label>
                            <div class="layui-input-inline" style="width: 200px">
                                <select name="channel_id" id="form_statuss" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
                                    <option value="">选择通道</option>
                                    @foreach($channel_list as $k=>$v):
                                        @if($channel_id==$v->id))
                                            <option value="{{$v->id}}" selected="selected">{{$v->channel_name}}</option>
                                        @else
                                            <option value="{{$v->id}}">{{$v->channel_name}}</option>
                                        @endif
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline" style="width: 280px">
                            <label class="layui-form-label">{{trans('pay_orders.typename')}}</label>
                            <div class="layui-input-inline" style="width: 200px">
                                <select name="gateway_type_id" id="gateway_type_id" lay-vgateway_type_iderify="" autocomplete="off" class="layui-input" eventType=event-query>
                                    <option value="">选择网关类别</option>
                                    @foreach($gateway_type_list as $k=>$v)
                                        <option value="{{$v->id}}"
                                                @if($gateway_type_id==$v->id) selected @endif>{{$v->typename}}</option>
                                    @endforeach
                                </select>
                            </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;"><i class="layui-icon">ဂ</i></a>
                           
                                <!-- <a href="/payment/gatewayAdd" class="layui-btn layui-btn-sm ">添加</a> -->
                           <a  class="layui-btn layui-btn-sm" data-type="reload" style="opacity: 1; pointer-events: auto;" onclick="exportWord()">导出</a>
                           <a href="javascript:;" class="layui-btn layui-btn-sm  layui-btn-danger backwater" onclick="cancelOrder()">一键作废超过24小时未支付订单</a>
                           <a href="javascript:;" class="layui-btn layui-btn-sm  layui-btn-danger backwater" onclick="deleteAllOrder()">一键删除超过30天的所有订单</a>
                   
                        </div>
                        <br/>
                        <span>该搜索条件总成功条数：<span style="color:red;">{{$success_total_count}}</span>条，总成功金额：<span style="color:red;">￥{{$success_total_price}}</span>元</span>
                    </div>
                </div>
            </form>
        </div>
    </div>


    @include('vip.datatable')
    <link rel="stylesheet" href="{{ asset('/css/untablelist.css') }}"/>
@endsection
