From 4c2fa71f0e2d78b14765a185c8693b0747dd48d0 Mon Sep 17 00:00:00 2001 From: liuyu <33367671@qq.com> Date: Fri, 8 Jul 2022 17:31:22 +0800 Subject: [PATCH] export_wait_deliver_goods_tids xlsx --- control/index.php | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) 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(); + } }