Commit 1e36785a by 朱继来

调整导出

parent 16873165
Showing with 25 additions and 56 deletions
...@@ -34,14 +34,6 @@ class OrderModel extends Model ...@@ -34,14 +34,6 @@ class OrderModel extends Model
->join('lie_order_items as it', 'o.order_id', '=', 'it.order_id') ->join('lie_order_items as it', 'o.order_id', '=', 'it.order_id')
->leftJoin('lie_order_invoice as i', 'o.order_id', '=', 'i.order_id') ->leftJoin('lie_order_invoice as i', 'o.order_id', '=', 'i.order_id')
->leftJoin('lie_order_extend as oe', 'o.order_id', '=', 'oe.order_id') ->leftJoin('lie_order_extend as oe', 'o.order_id', '=', 'oe.order_id')
// ->leftJoin('lie_order_address as a', function($join) {
// $join->on('o.order_id', '=', 'a.order_id')->where('a.address_type', '=', 1);
// })
// ->leftJoin('lie_order_shipping as s', function($join) {
// $join->on('o.order_id', '=', 's.order_id')->where('s.shipping_type', '=', 1);
// })
// ->leftJoin('lie_user_main as u', 'o.user_id', '=', 'u.user_id')
// ->leftJoin('lie_user_company as c', 'o.user_id', '=', 'c.user_id')
->where(function ($query) use ($map) { ->where(function ($query) use ($map) {
// 查询类型 // 查询类型
if (!empty($map['order_contain'])) { if (!empty($map['order_contain'])) {
...@@ -62,26 +54,22 @@ class OrderModel extends Model ...@@ -62,26 +54,22 @@ class OrderModel extends Model
$query->where('o.user_id', '=', $user_id); $query->where('o.user_id', '=', $user_id);
} }
} }
})
->where(function ($query) use ($map) {
// 订单编号 // 订单编号
if (!empty($map['order_sn'])) { if (!empty($map['order_sn'])) {
$query->where('o.order_sn', '=', $map['order_sn']); $query->where('o.order_sn', '=', $map['order_sn']);
} }
})
->where(function ($query) use ($map) {
// ERP订单编号 // ERP订单编号
if (!empty($map['erp_sn'])) { if (!empty($map['erp_sn'])) {
$query->where('oe.erp_sn', '=', $map['erp_sn']); $query->where('oe.erp_sn', '=', $map['erp_sn']);
} }
})
->where(function ($query) use ($map) {
// 型号 // 型号
if (!empty($map['goods_name'])) { if (!empty($map['goods_name'])) {
$query->where('it.goods_name', '=', $map['goods_name']); $query->where('it.goods_name', '=', $map['goods_name']);
} }
})
->where(function ($query) use ($map) {
// 创建时间 // 创建时间
if (!empty($map['time_start']) && !empty($map['time_end'])) { if (!empty($map['time_start']) && !empty($map['time_end'])) {
$query->whereBetween('o.create_time', [$map['time_start'], $map['time_end']]); $query->whereBetween('o.create_time', [$map['time_start'], $map['time_end']]);
...@@ -90,38 +78,32 @@ class OrderModel extends Model ...@@ -90,38 +78,32 @@ class OrderModel extends Model
} else if (!empty($map['time_end'])) { } else if (!empty($map['time_end'])) {
$query->where('o.create_time', '<', $map['time_end']); $query->where('o.create_time', '<', $map['time_end']);
} }
})
->where(function ($query) use ($map) {
// 订单状态 // 订单状态
if (!empty($map['order_status'])) { if (!empty($map['order_status'])) {
$query->whereIn('o.status', explode(',', $map['order_status'])); $query->whereIn('o.status', explode(',', $map['order_status']));
} }
})
->where(function ($query) use ($map) {
// 配送方式 // 配送方式
if (!empty($map['shipping_name'])) { if (!empty($map['shipping_name'])) {
$query->where('o.order_shipping_type', '=', $map['shipping_name']); $query->where('o.order_shipping_type', '=', $map['shipping_name']);
} }
})
->where(function ($query) use ($map) {
// 订单推送业务员 // 订单推送业务员
if (!empty($map['sale_id'])) { if (!empty($map['sale_id'])) {
$query->whereIn('o.sale_id', explode(',', $map['sale_id'])); $query->whereIn('o.sale_id', explode(',', $map['sale_id']));
} }
})
->where(function ($query) use ($map) {
// 订单类型 // 订单类型
if (!empty($map['order_pay_type'])) { if (!empty($map['order_pay_type'])) {
$query->where('o.order_pay_type', '=', $map['order_pay_type']); $query->where('o.order_pay_type', '=', $map['order_pay_type']);
} }
})
->where(function ($query) use ($map) {
// 测试订单 // 测试订单
if (empty($map['test_order'])) { if (empty($map['test_order'])) {
$query->whereNotIn('o.user_id', $map['testMobile']); $query->whereNotIn('o.user_id', $map['testMobile']);
} }
})
->where(function ($query) use ($map) {
// 订单来源 // 订单来源
if (!empty($map['order_source_pf'])) { if (!empty($map['order_source_pf'])) {
$order_source_pf = explode(',', $map['order_source_pf']); $order_source_pf = explode(',', $map['order_source_pf']);
...@@ -158,55 +140,48 @@ class OrderModel extends Model ...@@ -158,55 +140,48 @@ class OrderModel extends Model
// } // }
} }
})
->where(function ($query) use ($map) {
// adtags来源 // adtags来源
if (!empty($map['order_source_adtag'])) { if (!empty($map['order_source_adtag'])) {
$query->where('o.order_source', 'like', '%adtag='.$map['order_source_adtag'].'%'); $query->where('o.order_source', 'like', '%adtag='.$map['order_source_adtag'].'%');
} }
})
->where(function ($query) use ($map) {
// ptag来源 // ptag来源
if (!empty($map['order_source_ptag'])) { if (!empty($map['order_source_ptag'])) {
$query->where('o.order_source', 'like', '%ptag='.$map['order_source_ptag'].'%'); $query->where('o.order_source', 'like', '%ptag='.$map['order_source_ptag'].'%');
} }
})
// ->where(function ($query) use ($map) { //
// if ($map['order_type_filter']) { // 自营获取线上、京东、象牙宝订单 // if ($map['order_type_filter']) { // 自营获取线上、京东、象牙宝订单
// $query->whereIn('o.order_type', $map['order_type_filter']); // $query->whereIn('o.order_type', $map['order_type_filter']);
// } // }
// }) //
->where(function ($query) use ($map) {
// 交货地 // 交货地
if (!empty($map['delivery_place'])) { if (!empty($map['delivery_place'])) {
$query->where('o.delivery_place', $map['delivery_place']); $query->where('o.delivery_place', $map['delivery_place']);
} }
})
->where(function ($query) use ($map) {
// 同步状态 // 同步状态
if (!empty($map['erp_order_id'])) { if (!empty($map['erp_order_id'])) {
$query->where('o.erp_order_id', '<>', ''); $query->where('o.erp_order_id', '<>', '');
} }
})
->where(function ($query) use ($map) {
// 订单类型 // 订单类型
if (isset($map['order_type_extend'])) { if (isset($map['order_type_extend'])) {
$query->where('o.order_type_extend', '=', $map['order_type_extend']); $query->where('o.order_type_extend', '=', $map['order_type_extend']);
} }
})
->where(function ($query) use ($map) {
// 团购状态 // 团购状态
if (isset($map['status_extend'])) { if (isset($map['status_extend'])) {
$query->where('o.status_extend', '=', $map['status_extend']); $query->where('o.status_extend', '=', $map['status_extend']);
} }
})
->where(function ($query) use ($map) {
// 主管审核 // 主管审核
if (!empty($map['is_manager_audit'])) { if (!empty($map['is_manager_audit'])) {
$query->whereIn('oe.is_manager_audit', explode(',', $map['is_manager_audit'])); $query->whereIn('oe.is_manager_audit', explode(',', $map['is_manager_audit']));
} }
})
->where(function ($query) use ($map) {
// 竞调数据 // 竞调数据
if (isset($map['is_fake'])) { if (isset($map['is_fake'])) {
$query->where('o.is_type', '=', $map['is_fake']); $query->where('o.is_type', '=', $map['is_fake']);
...@@ -243,26 +218,24 @@ class OrderModel extends Model ...@@ -243,26 +218,24 @@ class OrderModel extends Model
if (!empty($map['order_invoice_status'])) { if (!empty($map['order_invoice_status'])) {
$query->where('i.inv_type', '=', $map['order_invoice_status']); $query->where('i.inv_type', '=', $map['order_invoice_status']);
} }
})
// ->where(function ($query) use ($map) { // ->where(function ($query) use ($map) {
// // 是否为新用户 // // 是否为新用户
// if ($map['is_new'] != '') { // if ($map['is_new'] != '') {
// $query->where('u.is_new', '=', $map['is_new']); // $query->where('u.is_new', '=', $map['is_new']);
// } // }
// }) // })
->where(function ($query) use ($map) {
// 是否新订单 // 是否新订单
if ($map['is_new_order'] != '') { if ($map['is_new_order'] != '') {
$query->where('oe.is_new', '=', $map['is_new_order']); $query->where('oe.is_new', '=', $map['is_new_order']);
} }
})
->where(function ($query) use ($map) {
// 自营其他业务类型 // 自营其他业务类型
if ($map['business_type'] != '') { if ($map['business_type'] != '') {
$query->whereIn('oe.business_type', explode(',', $map['business_type'])); $query->whereIn('oe.business_type', explode(',', $map['business_type']));
} }
})
->where(function ($query) use ($map) {
// 销售类型 // 销售类型
if ($map['sale_type'] != '') { if ($map['sale_type'] != '') {
$query->where('o.sale_type', '=', $map['sale_type']); $query->where('o.sale_type', '=', $map['sale_type']);
...@@ -273,16 +246,12 @@ class OrderModel extends Model ...@@ -273,16 +246,12 @@ class OrderModel extends Model
->select('o.order_id', 'o.order_sn', 'o.user_id', 'o.order_type', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.sale_type', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'o.advance_pay_time', 'o.pay_time', 'it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'it.self_supplier_type', 'it.extra_price', 'it.goods_discount_amount', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'oe.erp_sn', 'oe.order_type as extend_order_type', 'oe.send_remark', 'oe.is_new as is_new_order', 'oe.business_type', 'oe.jd_order_id', 'oe.exchange_rate') ->select('o.order_id', 'o.order_sn', 'o.user_id', 'o.order_type', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.sale_type', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'o.advance_pay_time', 'o.pay_time', 'it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'it.self_supplier_type', 'it.extra_price', 'it.goods_discount_amount', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'oe.erp_sn', 'oe.order_type as extend_order_type', 'oe.send_remark', 'oe.is_new as is_new_order', 'oe.business_type', 'oe.jd_order_id', 'oe.exchange_rate')
->groupBy('it.rec_id') ->groupBy('it.rec_id')
->orderBy('o.create_time', 'DESC') ->orderBy('o.create_time', 'DESC')
// ->get()
// ->toArray();
->paginate($map['limit'], ['*'], 'p', $map['p'])->toArray(); ->paginate($map['limit'], ['*'], 'p', $map['p'])->toArray();
if (!empty($list['data'])) { if (!empty($list['data'])) {
$list['data'] = $this->exportList($list['data']); // 订单数据处理 $list['data'] = $this->exportList($list['data']); // 订单数据处理
} }
// 'u.user_id', 'u.mobile', 'u.email', 'u.client_source', 'u.is_new', 'u.is_test',
return $list; return $list;
// dump($list->getBindings()); // dump($list->getBindings());
// dump($list->toSql()); // dump($list->toSql());
......
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