1.mshd_orderlist.tpl
<form id="frm" method="GET" action="mshd_orderlist.php"> <input type="hidden" name="op" id="op" value="user_list"> <input type="submit" name="sub" value="导出秒杀名单" onClick="export_data()" /> </form> <script> function export_data() { $('#op').val('export'); $('#frm').submit(); } </script>
2.mshd_orderlist.php
if($op == 'export'){ $miaosha_list = $mshd_miaosha_member_obj -> getMemberList(false, $where_str, $order_by,'',"add_time,user_id,mobile,item_name,serial_number,payment_code,pay_price,out_trade_no,`status`"); $film_name = 'miaosha_list_' . date('Ymd') . '.xls'; header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment;filename=" . $film_name); echo iconv('utf-8', 'gbk', "用户ID 用户手机号 商品名称 兑换码 支付方式 价格 秒杀时间 订单外部交易号 支付状态"); foreach ($miaosha_list as $k => $v) { $time = date('Y-m-d H:i:s', $v['add_time']); $str = " " . $v['user_id']; $str .= " " . $v['mobile']; $str .= " " . $v['item_name']; $str .= " " . $v['serial_number']; $str .= " " . $v['payment_code']; $str .= " " . $v['pay_price']; $str .= " " . $time; $str .= " " . $v['out_trade_no']; $msg_info = ""; if($v['status'] == 1){ $msg_info = "已支付"; }else if($v['status'] == 2){ $msg_info = "无效"; }else if($v['status'] == 3){ $msg_info = "已退款"; }else{ $msg_info = "未支付"; } $str .= " " . $msg_info; echo iconv('utf-8', 'gbk', $str); } exit(); }