<%@ page contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="renderer" content="webkit">
    <!-- 移动设备 viewport -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <jsp:include page="../../common.jsp"/>
</head>
<body>
<div class="row animated fadeInRight" style="margin: 0;">
    <div class="wrapper wrapper-content mt5 right-content ml5 mr5">
        <div class="toolbar-panel bdd">
            <div class="toolbar-box">
                <div class="toolbar-head clearfix lgraybg pt5 pl10 bdbd">
                    <!-- 顶部按钮 -->
                    <div class="fl">
                        查询条件
                    </div>
                    <div class="tools fr">
                        <a href="javascript:void(0);" class="collapse dblock f14 dgray mr5">
                            <i class="fa-2x fa fa-angle-double-up"></i>
                        </a>
                    </div>
                </div>
            </div>
            <!--搜索条件 -->
            <div class="toolbar-body">
                <form class="layui-form" id="form1" action="" style="margin-top: 10px;">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户ID</label>
                            <div class="layui-input-block">
                                <input type="text" name="userId" id="userId" placeholder="用户ID"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">订单号</label>
                            <div class="layui-input-block">
                                <input type="text" name="orderNumber" id="orderNumber" placeholder="订单号"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">商户名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="merchantName" id="merchantName" placeholder="商户名称"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">支付状态</label>
                            <div class="layui-input-block">
                               <select class="layui-select" name="status">
                                   <option value="">请选择</option>
                                   <option value="01">待支付</option>、
                                   <option value="02">已支付</option>
                               </select>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="mb50 mt10">
        <div class="whitebg pl10 pr10">
            <table class="layui-hide" id="jftOrder" lay-filter="jftOrder"></table>
        </div>
    </div>
</div>
<script type="text/html" id="leftBar">
    <a class="layui-btn layui-btn-sm" lay-event="search">
        <i class="layui-icon layui-icon-search"></i>查询
    </a>
</script>

<script>
    var table = null;
    var layer = null;
    layui.use(['table', 'layer'], function () {
        table = layui.table;
        layer = layui.layer;
        var tableIns = table.render({
            elem: '#jftOrder'
            , url: '${ctx}/jftOrder/page'
            , id: 'jftOrder'
            , response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                , countName: 'count' //数据总数的字段名称，默认：count
                , dataName: 'data' //默数据列表的字段名称，认：data
                , statusCode: 200
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.records //解析数据列表
                };
            }
            , toolbar: '#leftBar' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['filter']
            , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }]
            , title: '缴费通订单信息表'
            , cols: [[
                {type: 'checkbox', fixed: 'left', hidden: true}
                , {field: 'userId', title: '用户ID',width:80}
                , {
                    field: 'orderNumber', align: "center", title: '订单号', templet: function (d) {
                        return d.orderNumber + "<br/>" + d.transNo + "<br/>" + d.channelTransNo + "<br/>" + d.mercOrderNo;
                    }
                }
                , {field: 'merchantName', title: '商户名称'}
                , {field: 'amount', title: '订单金额',templet:function (d){
                        if(d.amount){
                            return d.amount.toFixed(2);
                        }
                        return "0.00";
                    }}
                , {field: 'channelFee', title: '通道手续费',templet:function (d){
                    if(d.channelFee){
                        return d.channelFee.toFixed(2);
                    }
                    return "0.00";
                }}
                , {field: 'mercFee', title: '商户手续费',templet:function (d){
                        if(d.mercFee){
                            return d.mercFee.toFixed(2);
                        }
                        return "0.00";
                    }}
                , {field: 'cashFee', title: '提现手续费',templet:function (d){
                        if(d.cashFee){
                            return d.cashFee.toFixed(2);
                        }
                        return "0.00";
                    }}
                , {field: 'profitFee', title: '收益金额',templet:function (d){
                        if(d.profitFee){
                            return d.profitFee.toFixed(2);
                        }
                        return "0.00";
                    }}
                , {field: 'rate', title: '费率(%)',templet:function (d){
                    if(d.rate){
                        return d.rate / 100 + "%";
                    }
                    return "-";
                }}
                , {field: 'payUserCity', title: '付款城市'}
                , {field: 'name', title: '输入项',templet: function (d){
                    let str = "";
                    if(d.name){
                        str = str + d.name + "-";
                    }
                    if(d.phone){
                        str = str + d.phone + "-";
                    }
                    if(d.goods){
                        str = str + d.goods + "-";
                    }
                    if(d.address){
                        str = str + d.address + "-";
                    }
                    if(str){
                        str = str.substring(0,str.length - 1)
                    }
                    return str;
                }}
                , {field: 'status', title: '交易状态',templet: function (d){
                    if(d.status === "02"){
                        return "<span style='color: green'>已支付</span>";
                    }else{
                        return "<span style='color: red'>待支付</span>";
                    }
                    }}
                , {
                    field: 'date',
                    title: '创建/交易时间',
                    width: 130,
                    templet:function (d){
                        let date = layui.util.toDateString(d.createTime,'yyyy-MM-dd HH:mm:ss');
                        if(d.transTime){
                            date = date + "<br/>" + layui.util.toDateString(d.transTime,'yyyy-MM-dd HH:mm:ss');
                        }
                        return date;
                    }
                }
            ]]
            , request: {
                pageName: 'current' //页码的参数名称，默认：page
                , limitName: 'size' //每页数据量的参数名，默认：limit
            }
            , page: true
        });
        //监听头工具栏事件
        table.on('toolbar(jftOrder)', function (obj) {
            switch (obj.event) {
                case 'add':
                    // 添加
                    toAdd();
                    break;
                case 'search':
                    var params = serialize($('#form1'));
                    table.reload('jftOrder', {
                        where: params
                        , page: {
                            size: 10
                            , current: 1
                        }
                    });
                    break;
            }
        });
    });
</script>
</body>
</html>
