<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:88:"D:\wwwroot\127.0.0.1010\public/../application/simple\view\member\member_money_order.html";i:1591672596;s:65:"D:\wwwroot\127.0.0.1010\application\Simple\view\public\heard.html";i:1591672596;}*/ ?>
<!doctype html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>后台登录-X-admin2.2</title>
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link rel="stylesheet" href="/static/simple/css/font.css">
        <link rel="stylesheet" href="/static/simple/css/xadmin.css">
        <script src="/static/simple/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/static/simple/js/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>

    <body>
	     <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">会员中心</a>
                <a>
                    <cite>兑卡列表</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
								
							  <form class="layui-form layui-col-space5" >
							  <div class="layui-inline layui-show-xs-block" id="caoji" style="width: 100%;">
                                    <?php foreach($admin as $pp): ?>
									<button class="layui-btn layui-btn-normal" type="button" id="cao" lay-type="<?php echo $pp['id']; ?>" >指派给用户<?php echo $pp['user']; ?></button>
									<?php endforeach; ?>
                                </div>
							  <div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn layui-btn-danger" id="money"> 总兑换:￥0.00 </button>
									<button class="layui-btn layui-btn-danger" type="button" id="delAll"><i class="layui-icon"></i>批量删除</button>
									<button class="layui-btn layui-btn-normal" type="button" id="restall">批量重试</button>

                                </div>
								<div class="layui-inline layui-show-xs-block">
                                <input class="layui-input"  autocomplete="off" placeholder="开始日期" name="start" id="start">
								</div>
								<div class="layui-inline layui-show-xs-block">
									<input class="layui-input"  autocomplete="off" placeholder="截止日期" name="end" id="end">
								</div>
								<div class="layui-inline layui-show-xs-block">
								 <select name="type" id="selt" lay-skin="select">
									 <option value="uid">UID</option>
									 <option value="tmporder|orderno|fenlei">订单号</option>
									 <option value="money">提交面值</option>
									 <option value="settle_amt">成功面值</option>
									 <option value="card_no">卡号</option>
									 <option value="card_key">卡密</option>
								 </select>
                                </div>
								<div class="layui-inline layui-show-xs-block">
								<input type="hidden" id="typen" value="">
                                    <input type="text" name="username" placeholder="搜索内容" autocomplete="off" class="layui-input">
								</div>
								<div class="layui-inline layui-show-xs-block">
								 <select name="state" id="seltt" lay-skin="select">
								     <option value="0">全部订单</option>
									 <option value="3">处理中</option>
									 <option value="1">成功订单</option>
									 <option value="2">失败订单</option>
								 </select>
                                </div>
								
                                <div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn" type="button" lay-submit="" lay-filter="sreach" lay-skin="select" lay-filter="type">
                                        <i class="layui-icon">&#xe615;</i></button>
										<button class="layui-btn" type="button" id="printt">
                                        <i class="layui-icon">&#xe66d;</i></button>
                                </div>
								<div class="layui-inline layui-show-xs-block" id="mbutton">
								   <button class="layui-btn" style="margin-bottom:8px" type="button" id="moneyClick" lay-type="" >全 部</button>
								   <?php foreach($res as $v): ?>
                                    <button class="layui-btn layui-btn-primary" style="margin-bottom:8px" type="button" id="moneyClick" lay-type="<?php echo $v; ?>" ><?php echo $v; ?>元面值</button> 
                                   <?php endforeach; ?>									
                                </div>

								<div class="layui-inline layui-show-xs-block" id="allbutton">
								   <button class="layui-btn" style="margin-bottom:8px" type="button" id="typeClick" lay-type="" >全 部</button>
								<?php if(is_array($li) || $li instanceof \think\Collection || $li instanceof \think\Paginator): $i = 0; $__LIST__ = $li;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$p): $mod = ($i % 2 );++$i;?>
                                    <button class="layui-btn layui-btn-primary" style="margin-bottom:8px" type="button" id="typeClick" lay-type="<?php echo $p['type']; ?>" ><?php echo $p['name']; ?></button> 
                                <?php endforeach; endif; else: echo "" ;endif; ?>									
                                </div>
								</form>
								<input type="hidden" id="font-primary" >
                        </div>
						 
                        <div class="layui-card-body ">
                            <table class="layui-table" id="mlist" lay-filter="mlist">
                                <thead>
                                    <tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
	
	<script type="text/html" id="active">
	 {{#  if(d.state == 1){ }}
      <p class="layui-bg-red">结算成功</p>
	   {{# }else if(d.state==2){ }}
     <p class="layui-bg-blue">失败</p>
	 {{#  } else { }}
	 <p class="layui-bg-black">处理中</p>
	 {{#  } }}
    </script>
	<script type="text/html" id="haos">
	  <p style="color:red">{{d.haos}}</p>
	</script>
	<script type="text/html" id="number">
	   <p id="share" title="点击复制卡号卡密" lay-event="share">{{d.card_no}}</br>{{d.card_key}}</p>
	</script>
	<script type="text/html" id="caoz">
	<div class="layui-btn-group">
    <button class="layui-btn" onclick="xadmin.open('订单赔付','<?php echo U('simple/Member/memberPeifu'); ?>?id={{d.id}}')" >订单赔付</button>
	<button class="layui-btn layui-btn-normal"  lay-event="rest">查询</button>
    <button class="layui-btn layui-btn-danger"  lay-event="del">删除</button>
	</div>
   </script>
   <script type="text/html" id="idd">
     <p style="margin-right:5px">{{d.orderno}} </p><p>{{d.qian}}</p>
   </script>
   <script type="text/html" id="xit">
      {{d.xit}}
   </script>
   <script type="text/html" id="but">
   <p>{{d.uname}}</p>
	 <button class="layui-btn layui-btn-normal"  lay-event="butsucc">成功</button>
	 <button class="layui-btn "  lay-event="buterr">失败</button>
   </script>
   <script src="/static/simple/js/clipboard.min.js"></script>
    <script>
	layui.use(['table','form','laydate'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery,laydate = layui.laydate;
        tableIn = table.render({
            elem: '#mlist',
            url: "<?php echo U('simple/member/memberMoneyOrder'); ?>",
            method: 'post',
			page:true,
			totalRow:true,
			parseData: function(res){
			  $("#money").text("总兑换:￥"+res.money);
			},
            cols: [[
			    {type: 'checkbox',width:30,minWidth:30},
				{toolbar: '#idd',title:"订单号", align: 'center', sort: true,width:80},
				{toolbar: '#but',title:"商户信息", align: 'center', sort: true,width:135},
			    {field:'class',title: '运营商',align: 'center',width:110,totalRowText: '合计：'},
				{title: '卡号/卡密',toolbar:'#number',align: 'left',sort: true,width:150},
				{field:'money',title: '提交金额',align: 'center',totalRow: true,width:80,edit:'text'},
				{field:'settle_amt',title: '实际金额',align: 'center',totalRow: true,width:80},
				{field:'amount',title:'到账金额',style:"color:#e60040",align:'center',totalRow: true,width:80},
				{title:'系统金额',align:'center',style:'color:#04e600',toolbar:'#xit',width:80},
				{field:'create_time', align: 'center',title:'提交时间',width:150},
				{toolbar: '#haos', align: 'center',title:'耗时',width:65},
				{field:'state', title:'状态',align: 'center',toolbar: '#active',width:100,sort: true},
				{field:'oper', align: 'center',title:'通道',width:80},
                {field:'remarks', align: 'center',title:'备注',width:120},
				{field:'area', align: 'center',title:'地区',width:80},
				{align:'center',title:'操作',toolbar: '#caoz'}
            ]],
			limit:15,
			limits:[10,20,50,60]
        });	
        var nowTime=new Date();    
		var startTime=laydate.render({
			elem:'#start',
			type:'datetime',
			btns: ['confirm'],
			max:'nowTime',//默认最大值为当前日期
			done:function(value,date){
				endTime.config.min={    	    		
					year:date.year,
					month:date.month-1,//关键
					date:date.date,
					hours:date.hours,
					minutes:date.minutes,
					seconds:date.seconds
				};
				
			}
		})
		var endTime=laydate.render({
			elem:'#end',
			type:'datetime',
			btns: ['confirm'],
			max:'nowTime',
			done:function(value,date){   	   
				startTime.config.max={
						year:date.year,
						month:date.month-1,//关键
						date:date.date,
						hours:date.hours,
						minutes:date.minutes,
						seconds:date.seconds
				}
				
			}
		})				
		

		form.on('submit(sreach)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var name=$("input[name=username]").val();
			var kk=$("#selt").val(),st=$("#start").val(),se=$("#end").val();
			var state=$("#seltt").val(),cl=$("#typen").val();
			var index = layer.load(3, {
					  shade: [0.1,'#fff'] //0.1透明度的白色背景
					});
                 tableIn.reload({
					page:{curr:1
						 },
                     where:{
						 name:name,
						 kk:kk,
						 st:st,
						 se:se,
						 state:state,
						 classa:cl
                     }
                 });
				 layer.close(index);
        });
		table.on('edit(mlist)', function(obj){
         loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = obj.data.id,str = obj.value,field=obj.field;
            $.post('<?php echo U("simple/member/editMoney"); ?>',{'id':id,'count':str,'field':field},function (res) {
                layer.close(loading);
				if(res.code==1){
				  layer.msg(res.msg,{time:1000,icon:1});
				}else{
					layer.msg(res.msg,{time:1000,icon:2});
					return false;
				}
            })		  
		});
		
		table.on('tool(mlist)', function(obj){
            var data = obj.data;
			console.log(obj.event);
			switch(obj.event){
               case 'del':
                layer.confirm('您确定要删除该记录吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("<?php echo U('simple/member/orderDel'); ?>",{id:data.id,tab:'order'},function(res){
                        layer.close(loading);
                        if(res.code==1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
			  break;
			  case 'qiang':
			        var loading = layer.load(3, {shade: [0.1, '#fff']});
                    $.post("<?php echo U('simple/member/qiang'); ?>",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code==1){
                            layer.msg(res.msg,{time:1000,icon:1},function(){
                           tableIn.reload();
						});
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
						
                    });
			  break;
			  case 'rest':
			   var loading = layer.load(3, {shade: [0.1, '#fff']});
                    $.post("<?php echo U('simple/card/find'); ?>",{id:data.id,type:data.type},function(res){
                        layer.close(loading);
						tableIn.reload();
                        layer.msg(res.msg,{time:1000,icon:1});
                    });
			  break;
			  case 'share':
					  $("#font-primary").val(data.card_no+","+data.card_key);
			  break;
			  case 'butsucc':
					layer.confirm('您确定要执行成功操作吗？', function(index){
							var loading =layer.load(3, {shade: [0.1,'#fff']});
							$.post("<?php echo U('simple/card/dasucc'); ?>",{id:data.id,op:data.type,amt:data.money},function(res){
									layer.close(loading);
									if(res.code==1){
										layer.alert(res.msg,{icon:1},function(index){
											tableIn.reload();
											layer.closeAll();
										});
									}else{
									   layer.alert(res.msg,{icon:2});
									}
							})
						})
			  break;
			  case 'buterr':
					layer.confirm('您确定要执行失败操作吗？', function(index){
							var loading =layer.load(3, {shade: [0.1,'#fff']});
							$.post("<?php echo U('simple/card/daerr'); ?>",{id:data.id,op:data.type,amt:data.money},function(res){
									layer.close(loading);
									if(res.code==1){
										layer.alert(res.msg,{icon:1},function(index){
										  tableIn.reload();
										  layer.closeAll();
										})
									}else{
									   layer.alert(res.msg,{icon:2});
									}
							})
						})
			  break;
			  return false;
            }
        });
		var clipboard1 = new ClipboardJS('#share', {
						text: function(trigger) {
						console.log(trigger);
						return $("#font-primary").val();
					  }
					});

		clipboard1.on('success', function(e) {
			console.log(e);
			layer.msg((e.action=='copy'?'复制':'剪切')+'成功');
		});

		clipboard1.on('error', function(e) {
			layer.msg((e.action=='copy'?'复制':'剪切')+'失败');
		});
		$("#caoji").on("click","#cao",function(){
		   var e=$(this);
		   var id=e.attr('lay-type');
		   var checkStatus = table.checkStatus('mlist'); //test即为参数id设定的值
				console.log(checkStatus,table);
                var ids = [];
                $(checkStatus.data).each(function (i, o) {
                    ids.push(o.id);
                });
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("<?php echo U('simple/member/zhipai'); ?>", {ids: ids,uid:id}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1},function(){
                        tableIn.reload();
						});
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
		})
		$("#allbutton").on("click","#typeClick",function(){
		    var e=$(this);
			e.siblings().addClass("layui-btn-primary");
			e.removeClass("layui-btn-primary");
			$("#typen").val(e.attr('lay-type'));
			loading =layer.load(1, {shade: [0.1,'#fff']});
            var name=$("input[name=username]").val();
			var kk=$("#selt").val(),st=$("#start").val(),se=$("#end").val();
			var state=$("#seltt").val(),cl=$("#typen").val();
			var index = layer.load(3, {
					  shade: [0.1,'#fff'] //0.1透明度的白色背景
					});
                 tableIn.reload({
					page:{curr:1
						 },
                     where:{
						 name:name,
						 kk:kk,
						 st:st,
						 se:se,
						 state:state,
						 classa:cl
                     }
                 });
				 layer.close(index);
		});
		$("#mbutton").on("click","#moneyClick",function(){
		    var e=$(this);
			e.siblings().addClass("layui-btn-primary");
			e.removeClass("layui-btn-primary");
			$("#money").val(e.attr('lay-type'));
			loading =layer.load(1, {shade: [0.1,'#fff']});
            var name=$("input[name=username]").val();
			var kk=$("#selt").val(),st=$("#start").val(),se=$("#end").val();
			var state=$("#seltt").val(),cl=$("#typen").val(),money=$("#money").val();
			var index = layer.load(3, {
					  shade: [0.1,'#fff'] //0.1透明度的白色背景
					});
                 tableIn.reload({
					page:{curr:1
						 },
                     where:{
						 name:name,
						 kk:kk,
						 st:st,
						 se:se,
						 state:state,
						 classa:cl,
						 money:money
                     }
                 });
				 layer.close(index);
		});
		$("#printt").click(function(){
					var name=$("input[name=username]").val();
					var kk=$("#selt").val(),st=$("#start").val(),se=$("#end").val();
					var state=$("#seltt").val(),cl=$("#typen").val();
					location.href="/printt.html?name="+name+"&kk="+kk+"&st="+st+"&se="+se+"&state="+state+"&classa="+cl;
                    
		});
		$("#delAll").click(function(){
            layer.confirm('确认要删除选中信息吗？', {icon: 3}, function(index) {
                layer.close(index);
                var checkStatus = table.checkStatus('mlist'); //test即为参数id设定的值
				console.log(checkStatus,table);
                var ids = [];
                $(checkStatus.data).each(function (i, o) {
                    ids.push(o.id);
                });
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("<?php echo U('simple/member/orderDel'); ?>", {ids: ids,tab:'order'}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1},function(){
                        tableIn.reload();
						});
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
            });
        });
		
		$("#restall").click(function(){
                var checkStatus = table.checkStatus('mlist'); //test即为参数id设定的值
                var ids = [];
                $(checkStatus.data).each(function (i, o) {
                    ids.push(o.id);
                });
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("<?php echo U('simple/card/findlist'); ?>", {ids: ids}, function (data) {
                    layer.close(loading);

                    if (data.result == 1) {
                        layer.msg("本次成功处理"+data.snum+"张卡【消卡成功"+data.ok+"张|消卡失败"+data.err+"张】", {time: 1000, icon: 1},function(){
                        tableIn.reload();
						});
                    } else {
                        layer.msg(data.err!=""?data.err:"系统错误", {time: 1000, icon: 2});
                    }
                });

        });
      });
	  function tips(q,e){
		layer.tips(q, e, {
		  tips: [1, '#3595CC'],
		  time: 4000
		});
		}
    </script>
</html>