Commit c69188f8 by 朱继来

fix conflict

parents 6ed37108 f3ef38ac
......@@ -338,7 +338,7 @@ Class OrderController extends Controller
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$data['p'] = $request->input('p', 1); // 当前页码
$data['map'] = $map;
$response = json_decode(curlApi($url, $data), true);
// 分页
......@@ -394,30 +394,10 @@ Class OrderController extends Controller
$map['test_order'] = $request->input('test_order', '');
$map['order_pay_type'] = $request->input('order_pay_type', '');
$map['order_type_a'] = $request->input('order_type_a', '');
// $map['order_pay_status'] = $request->input('order_pay_status', '');
$map['order_source_pf'] = $request->input('order_source_pf', '');
$map['order_source_adtag'] = $request->input('order_source_adtag', '');
}
// 订单查看权限
// switch ($info['role']) {
// case 2:
// // 经理:若没有'查看线下订单'权限,则仅查看线上订单
// if (!in_array('check_offline_order', $info['userPerms'])) {
// $map['online_order'] = 1;
// }
// break;
// case 3:
// // 交易员: 若没有'查看线下订单'权限,则仅查看线上订单
// if (!in_array('check_offline_order', $info['userPerms'])) {
// $map['online_order'] = 1;
// }
// // 筛选自己的订单
// $data['sale_id'] = $request->user->userId;
// break;
// }
// 若没有'查看线下订单'权限,则仅查看线上订单
if (!in_array('check_offline_order', $info['userPerms'])) {
$map['online_order'] = 1;
......@@ -426,12 +406,6 @@ Class OrderController extends Controller
/* 临时添加 所有人只能查看线上订单 */
$map['online_order'] = 1;
// 订单查看权限---交易员
if ($info['role'] == 3) {
// 筛选自己的订单
$data['sale_id'] = $request->user->userId;
}
// 格式
$xlsCell = array(
array('order_id', '订单ID'),
......@@ -457,26 +431,226 @@ Class OrderController extends Controller
if ($info['username'] != 'vpadmin@ichunt.com') {
$map['is_fake'] = 0;
}
$orderIds = array();
// 型号名称
if ($map['order_type'] == 2) {
$goods = DB::connection('order')->table('lie_order_items')->where('goods_name', '=', $map['order_contain'])->select('order_id')->get();
if ($goods) {
foreach ($goods as $v) {
$orderIds[] = $v->order_id;
}
}
}
//获取订单列表
$url = Config('website.api_domain').'order/getAllOrder';
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$data['map'] = $map;
$data['export'] = 1; // 导出数据
$response = json_decode(curlApi($url, $data), true);
if(is_array($response['data'])){
$list = DB::connection('order')
->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'])) {
if ($map['order_type'] == 1) { // 订单编号
$query->where('o.order_sn', '=', $map['order_contain']);
} else if ($map['order_type'] == 2) { // 型号名称
$query->whereIn('o.order_id', $orderIds);
} else { // 会员账号
if (preg_match('/@/', $map['order_contain'])) {
$query->where('u.email', '=', $map['order_contain']);
} else {
$query->where('u.mobile', '=', $map['order_contain']);
}
}
}
})
->where(function ($query) use ($map) {
// 创建时间
if (!empty($map['time_start']) && !empty($map['time_end'])) {
$query->whereBetween('o.create_time', [$map['time_start'], $map['time_end']]);
} else if (!empty($map['time_start'])) {
$query->where('o.create_time', '>', $map['time_start']);
} else if (!empty($map['time_end'])) {
$query->where('o.create_time', '<', $map['time_end']);
}
})
->where(function ($query) use ($map) {
// 订单状态
if (!empty($map['order_status'])) {
$query->where('o.status', '=', $map['order_status']);
}
})
->where(function ($query) use ($map) {
// 配送方式
if (!empty($map['shipping_name'])) {
$query->where('o.order_shipping_type', '=', $map['shipping_name']);
}
})
->where(function ($query) use ($map) {
// 订单推送业务员
if (!empty($map['order_send'])) {
$query->where('o.sale_id', '=', $map['order_send']);
}
})
->where(function ($query) use ($map) {
// 订单类型
if (!empty($map['order_pay_type'])) {
$query->where('o.order_pay_type', '=', $map['order_pay_type']);
}
})
->where(function ($query) use ($map) {
// 测试订单
if (empty($map['test_order'])) {
$query->whereNotIn('o.user_id', $this->testMobile());
}
})
->where(function ($query) use ($map) {
// 订单来源
if (!empty($map['order_source_pf'])) {
if ($map['order_source_pf'] == 1) {
$query->whereRaw("FIND_IN_SET('pf=1', o.order_source)");
} else {
$query->whereRaw("FIND_IN_SET('pf=2', o.order_source)");
}
}
})
->where(function ($query) use ($map) {
// adtags来源
if (!empty($map['order_source_adtag'])) {
$query->whereRaw('FIND_IN_SET("adtag='.$map['order_source_adtag'].'", o.order_source)');
}
})
->where(function ($query) use ($map) {
// 线上订单
if (isset($map['online_order'])) {
$query->where('o.order_type', '=', $map['online_order']);
}
})
->where(function ($query) use ($map) {
// 竞调数据
if (isset($map['is_fake'])) {
$query->where('o.is_type', '=', $map['is_fake']);
}
})
->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);
if($export){
$xlsName = '订单数据导出';
$xlslist = exportExcel($xlsName, $xlsCell, $response['data']);
$xlslist = exportExcel($xlsName, $xlsCell, $export);
$this->$xlslist;
} else {
return redirect('/prompt')->with(['message'=>"数据为空无法导出!",'url' =>$_SERVER['HTTP_REFERER'], 'jumpTime'=>3,'status'=>false]);
}
}
// 测试帐号
public function testMobile()
{
$testId = array();
$user = DB::connection('order')->table('lie_user_main')->select('user_id')->where(['is_test' => 1])->get();
foreach ($user as $k => $v) {
$testId[$k] = $v->user_id;
}
return $testId;
}
/**
* 导出到Excel
* @param [type] $order [查询出的订单数据]
* @return [type] [description]
*/
public function exportList($order)
{
// 订单类型
$order_type = array(
'1' => '全款',
'2' => '预付款',
'3' => '账期支付',
);
// 订单状态
$order_status = array(
'-1' => '已取消',
'1' => '待审核',
'2' => '待付款',
'3' => '待付尾款',
'4' => '待发货',
'7' => '部分发货',
'8' => '待收货',
'10' => '交易成功',
);
// 订单发货状态
$shipping_status = array(
'-1' => '未配送',
'1' => '配送中',
'2' => '已签',
);
// 发票状态
$invoice_status = array(
'-1' => '待确认',
'1' => '已开票',
'2' => '已发货',
'3' => '已签收',
);
$i = 0;
foreach ($order as $val) {
// 推送人
if ($val->sale_id) {
$sales = DB::table('user_info')->where(['userId' => $val->sale_id])->select('name')->first();
}
$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($val->consignee) ? $val->consignee : '';
$tmp[$i]['create_time'] = date('Y-m-d H:i:s', $val->create_time);
$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($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;
} else {
return false;
}
}
// 详情页
public function details(Request $request, $id)
{
......
......@@ -2,6 +2,7 @@
/** 公用函数 */
//导出数据
//导出数据
function exportExcel($expTitle, $expCellName, $expTableData)
{
$xlsTitle = iconv('utf-8', 'gb2312', $expTitle);//文件名称
......@@ -13,6 +14,13 @@
$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;//设置缓存策略(减少内存占用)
//判断缓存策略是否可用
if (!\PHPExcel_Settings::setCacheStorageMethod($cacheMethod)) {
die($cacheMethod . " 缓存方法不可用" . EOL);
}
$cellName = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ');
//显示导出名称和导出时间
......@@ -29,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