Commit f3ef38ac by 朱继来

调整订单导出

parent d12b41c0
...@@ -434,9 +434,9 @@ Class OrderController extends Controller ...@@ -434,9 +434,9 @@ Class OrderController extends Controller
); );
// 非竞调账号,则查看真实数据 // 非竞调账号,则查看真实数据
// if ($info['username'] != 'vpadmin@ichunt.com') { if ($info['username'] != 'vpadmin@ichunt.com') {
// $map['is_fake'] = 0; $map['is_fake'] = 0;
// } }
$orderIds = array(); $orderIds = array();
// 型号名称 // 型号名称
...@@ -451,8 +451,17 @@ Class OrderController extends Controller ...@@ -451,8 +451,17 @@ Class OrderController extends Controller
} }
$list = DB::connection('order') $list = DB::connection('order')
->table('lie_order as o') ->table('lie_order_items as it')
->leftJoin('lie_user_main as u', 'o.user_id', '=', 'u.user_id') ->leftJoin('lie_order as o', 'it.order_id', '=', 'o.order_id')
->leftJoin('lie_order_invoice as i', 'it.order_id', '=', 'i.order_id')
->leftJoin('lie_order_address as a', function($join) {
$join->on('it.order_id', '=', 'a.order_id')->where('a.address_type', '=', 1);
})
->leftJoin('lie_order_shipping as s', function($join) {
$join->on('it.order_id', '=', 's.order_id')->where('s.shipping_type', '=', 1);
})
->leftJoin('lie_user_main as u', 'it.user_id', '=', 'u.user_id')
->leftJoin('lie_user_company as c', 'it.user_id', '=', 'c.user_id')
->where(function ($query) use ($map, $orderIds) { ->where(function ($query) use ($map, $orderIds) {
// 查询类型 // 查询类型
if (!empty($map['order_contain'])) { if (!empty($map['order_contain'])) {
...@@ -538,11 +547,12 @@ Class OrderController extends Controller ...@@ -538,11 +547,12 @@ Class OrderController extends Controller
$query->where('o.is_type', '=', $map['is_fake']); $query->where('o.is_type', '=', $map['is_fake']);
} }
}) })
->select('o.order_id', 'o.order_sn', 'o.order_pay_type', 'o.create_time', 'o.status', 'o.currency', 'o.sale_id', 'u.user_id', 'u.mobile', 'u.email') ->where('it.status', '<>', -1)
->select('it.goods_name', 'it.goods_number', 'it.goods_price', 'it.supplier_name', 'o.order_id', 'o.order_sn', 'o.order_pay_type', 'o.create_time', 'o.status', 'o.currency', 'o.sale_id', 'i.invoice_status', 'a.consignee', 's.status as shipping_status', 'u.user_id', 'u.mobile', 'u.email', 'c.com_name')
->groupBy('it.rec_id')
->orderBy('o.create_time', 'DESC') ->orderBy('o.create_time', 'DESC')
->get(); ->get();
// 订单数据处理 // 订单数据处理
$export = $this->exportList($list); $export = $this->exportList($list);
...@@ -613,67 +623,31 @@ Class OrderController extends Controller ...@@ -613,67 +623,31 @@ Class OrderController extends Controller
$i = 0; $i = 0;
foreach ($order as $val) { foreach ($order as $val) {
// 收货人 // 推送人
$address = DB::connection('order') if ($val->sale_id) {
->table('lie_order_address') $sales = DB::table('user_info')->where(['userId' => $val->sale_id])->select('name')->first();
->where(['order_id' => $val->order_id, 'address_type' => 1]) }
->first();
$tmp[$i]['order_id'] = $val->order_id;
// 商品信息 $tmp[$i]['order_sn'] = $val->order_sn;
$goods = DB::connection('order') $tmp[$i]['user_account'] = $val->mobile ? $val->mobile : $val->email;
->table('lie_order_items') $tmp[$i]['consignee'] = isset($val->consignee) ? $val->consignee : '';
->where('order_id', '=', $val->order_id) $tmp[$i]['create_time'] = date('Y-m-d H:i:s', $val->create_time);
->where('status', '<>', -1) $tmp[$i]['com_name'] = isset($val->com_name) ? $val->com_name : '';
->get(); $tmp[$i]['goods_name'] = $val->goods_name;
$tmp[$i]['goods_number'] = $val->goods_number;
// // 推送人 $tmp[$i]['goods_price'] = $val->goods_price;
$sales = DB::table('user_info')->where(['userId' => $val->sale_id])->select('name')->first(); $tmp[$i]['order_amount'] = $val->goods_number * $val->goods_price;
$tmp[$i]['currency'] = $val->currency == 1 ? 'RMB' : 'USD';
// 公司信息 $tmp[$i]['order_type'] = $order_type[$val->order_pay_type];
$company = DB::connection('order') $tmp[$i]['order_status'] = $order_status[$val->status];
->table('lie_user_company') // 发货状态
->where(['user_id' => $val->user_id]) $tmp[$i]['shipping_status'] = !empty($val->shipping_status) ? $shipping_status[$val->shipping_status] : '无发货信息';
->select('com_name') $tmp[$i]['invoice_status'] = !empty($val->invoice_status) ? $invoice_status[$val->invoice_status] : '无发票信息'; // 发票状态
->first(); $tmp[$i]['company_name'] = $val->supplier_name;
$tmp[$i]['sale_name'] = isset($sales) ? $sales->name : ''; // 推送业务员
// 订单物流信息
$shipping = DB::connection('order') $i++;
->table('lie_order_shipping')
->where(['order_id' => $val->order_id, 'shipping_type' => 1])
->select('status')
->first();
// 订单发票信息
$invoice = DB::connection('order')
->table('lie_order_invoice')
->where(['order_id' => $val->order_id])
->select('invoice_status')
->first();
if ($goods) {
foreach ($goods as $item) {
$tmp[$i]['order_id'] = $val->order_id;
$tmp[$i]['order_sn'] = $val->order_sn;
$tmp[$i]['user_account'] = $val->mobile ? $val->mobile : $val->email;
$tmp[$i]['consignee'] = isset($address) ? $address->consignee : '';
$tmp[$i]['create_time'] = date('Y-m-d H:i:s', $val->create_time);
$tmp[$i]['com_name'] = isset($company) ? $company->com_name : '';
$tmp[$i]['goods_name'] = $item->goods_name;
$tmp[$i]['goods_number'] = $item->goods_number;
$tmp[$i]['goods_price'] = $item->goods_price;
$tmp[$i]['order_amount'] = $item->goods_number * $item->goods_price;
$tmp[$i]['currency'] = $val->currency == 1 ? 'RMB' : 'USD';
$tmp[$i]['order_type'] = $order_type[$val->order_pay_type];
$tmp[$i]['order_status'] = $order_status[$val->status];
// 发货状态
$tmp[$i]['shipping_status'] = !empty($shipping) ? $shipping_status[$shipping->status] : '无发货信息';
$tmp[$i]['invoice_status'] = !empty($invoice) ? $invoice_status[$invoice->invoice_status] : '无发票信息'; // 发票状态
$tmp[$i]['company_name'] = $item->supplier_name;
$tmp[$i]['sale_name'] = isset($sales) ? $sales->name : ''; // 推送业务员
$i++;
}
}
} }
if (!empty($tmp)) { if (!empty($tmp)) {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/** 公用函数 */ /** 公用函数 */
//导出数据 //导出数据
//导出数据
function exportExcel($expTitle, $expCellName, $expTableData) function exportExcel($expTitle, $expCellName, $expTableData)
{ {
$xlsTitle = iconv('utf-8', 'gb2312', $expTitle);//文件名称 $xlsTitle = iconv('utf-8', 'gb2312', $expTitle);//文件名称
...@@ -13,7 +14,6 @@ ...@@ -13,7 +14,6 @@
$objPHPExcel = new PHPExcel(); $objPHPExcel = new PHPExcel();
include_once(__DIR__."/../../vendor/PHPExcel/PHPExcel/IOFactory.php"); include_once(__DIR__."/../../vendor/PHPExcel/PHPExcel/IOFactory.php");
set_time_limit(0);//不对php(主要是写数据)执行时间做限制 set_time_limit(0);//不对php(主要是写数据)执行时间做限制
ini_set("memory_limit", "1024M");//设置内存(防爆内存) ini_set("memory_limit", "1024M");//设置内存(防爆内存)
$cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized;//设置缓存策略(减少内存占用) $cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized;//设置缓存策略(减少内存占用)
...@@ -37,9 +37,11 @@ ...@@ -37,9 +37,11 @@
} }
header('pragma:public'); header('pragma:public');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="'.$xlsTitle.'.xls"'); header('Content-type:application/vnd.ms-excel;charset=utf-8;name="'.$xlsTitle.'.csv"');
header("Content-Disposition:attachment;filename=$fileName.xls");//attachment新窗口打印inline本窗口打印 header("Content-Disposition:attachment;filename=$fileName.csv");//attachment新窗口打印inline本窗口打印
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); //输出bom
print(chr(0xEF).chr(0xBB).chr(0xBF));
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save('php://output'); $objWriter->save('php://output');
exit; exit;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment