diff --git a/control/index.php b/control/index.php index cf0bd34..7778d8f 100644 --- a/control/index.php +++ b/control/index.php @@ -84,24 +84,50 @@ class index extends publicBase { chown($filedir, 'nobody'); chgrp($filedir, 'nobody'); } - $filepath = $filedir."{$uid}_{$shop_id}_".date("YmdHis").".csv"; + $filepath = $filedir."{$uid}_{$shop_id}_".date("YmdHis").".xlsx"; - $file = fopen($filepath, 'w'); - fwrite($file, "订单号\t\n"); - fwrite($file, "order_sn\t\n"); + + ob_get_clean(); + ob_start(); + echo "订单号\t\n"; + echo "order_sn\t\n"; for ($page=1;;$page++) { $list = $obj->getOrderList($uid, $shop_id, ORDER_STATUS_WAIT_DELIVER_GOODS, REFUND_STATUS_NO_AFTER_SALES, $page, 1000); if (empty($list)) break; foreach ($list as $info) { - fwrite($file, $info['order_sn']."\t\n"); + echo $info['order_sn']."\t\n"; } } - fclose($file); + header('Content-Disposition: attachment; filename='.$shopinfo['name'].'_待发货订单.xlsx'); + header('Accept-Ranges:bytes'); + header('Content-Length:' . ob_get_length()); + header('Content-Type:application/vnd.ms-excel'); + ob_end_flush(); - $obj->downFileChunk($filepath, $shopinfo['name'].'_待发货订单.csv'); exit(); + + + // $filepath = $filedir."{$uid}_{$shop_id}_".date("YmdHis").".csv"; + + // $file = fopen($filepath, 'w'); + // fwrite($file, "订单号\t\n"); + // fwrite($file, "order_sn\t\n"); + + // for ($page=1;;$page++) { + // $list = $obj->getOrderList($uid, $shop_id, ORDER_STATUS_WAIT_DELIVER_GOODS, REFUND_STATUS_NO_AFTER_SALES, $page, 1000); + // if (empty($list)) break; + + // foreach ($list as $info) { + // fwrite($file, $info['order_sn']."\t\n"); + // } + // } + // fclose($file); + + // $obj->downFileChunk($filepath, $shopinfo['name'].'_待发货订单.csv'); + // exit(); + } }