Commit f3ef38ac by 朱继来

调整订单导出

parent d12b41c0
......@@ -434,9 +434,9 @@ Class OrderController extends Controller
);
// 非竞调账号,则查看真实数据
// if ($info['username'] != 'vpadmin@ichunt.com') {
// $map['is_fake'] = 0;
// }
if ($info['username'] != 'vpadmin@ichunt.com') {
$map['is_fake'] = 0;
}
$orderIds = array();
// 型号名称
......@@ -451,8 +451,17 @@ Class OrderController extends Controller
}
$list = DB::connection('order')
->table('lie_order as o')
->leftJoin('lie_user_main as u', 'o.user_id', '=', 'u.user_id')
->table('lie_order_items as it')
->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) {
// 查询类型
if (!empty($map['order_contain'])) {
......@@ -538,11 +547,12 @@ Class OrderController extends Controller
$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')
->get();
// 订单数据处理
$export = $this->exportList($list);
......@@ -613,68 +623,32 @@ Class OrderController extends Controller
$i = 0;
foreach ($order as $val) {
// 收货人
$address = DB::connection('order')
->table('lie_order_address')
->where(['order_id' => $val->order_id, 'address_type' => 1])
->first();
// 商品信息
$goods = DB::connection('order')
->table('lie_order_items')
->where('order_id', '=', $val->order_id)
->where('status', '<>', -1)
->get();
// // 推送人
// 推送人
if ($val->sale_id) {
$sales = DB::table('user_info')->where(['userId' => $val->sale_id])->select('name')->first();
}
// 公司信息
$company = DB::connection('order')
->table('lie_user_company')
->where(['user_id' => $val->user_id])
->select('com_name')
->first();
// 订单物流信息
$shipping = DB::connection('order')
->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]['consignee'] = isset($val->consignee) ? $val->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]['com_name'] = isset($val->com_name) ? $val->com_name : '';
$tmp[$i]['goods_name'] = $val->goods_name;
$tmp[$i]['goods_number'] = $val->goods_number;
$tmp[$i]['goods_price'] = $val->goods_price;
$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];
$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]['shipping_status'] = !empty($val->shipping_status) ? $shipping_status[$val->shipping_status] : '无发货信息';
$tmp[$i]['invoice_status'] = !empty($val->invoice_status) ? $invoice_status[$val->invoice_status] : '无发票信息'; // 发票状态
$tmp[$i]['company_name'] = $val->supplier_name;
$tmp[$i]['sale_name'] = isset($sales) ? $sales->name : ''; // 推送业务员
$i++;
}
}
}
if (!empty($tmp)) {
return $tmp;
......
......@@ -2,6 +2,7 @@
/** 公用函数 */
//导出数据
//导出数据
function exportExcel($expTitle, $expCellName, $expTableData)
{
$xlsTitle = iconv('utf-8', 'gb2312', $expTitle);//文件名称
......@@ -13,7 +14,6 @@
$objPHPExcel = new PHPExcel();
include_once(__DIR__."/../../vendor/PHPExcel/PHPExcel/IOFactory.php");
set_time_limit(0);//不对php(主要是写数据)执行时间做限制
ini_set("memory_limit", "1024M");//设置内存(防爆内存)
$cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized;//设置缓存策略(减少内存占用)
......@@ -37,9 +37,11 @@
}
header('pragma:public');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="'.$xlsTitle.'.xls"');
header("Content-Disposition:attachment;filename=$fileName.xls");//attachment新窗口打印inline本窗口打印
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="'.$xlsTitle.'.csv"');
header("Content-Disposition:attachment;filename=$fileName.csv");//attachment新窗口打印inline本窗口打印
//输出bom
print(chr(0xEF).chr(0xBB).chr(0xBF));
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save('php://output');
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