Commit 70dbf446 by 朱继来

退款列表导出

parent 26b2088d
......@@ -157,11 +157,18 @@ class RefundController extends Controller
return $info;
}
// 退款导出
// 联营退款导出
public function refundExport(Request $request)
{
$refundModel = new OrderRefundModel();
$refundModel->export($request);
return $refundModel->jointExport($request);
}
// 自营退款导出
public function refundSelfExport(Request $request)
{
$refundModel = new OrderRefundModel();
return $refundModel->selfExport($request);
}
// 退货详情
......
......@@ -114,6 +114,7 @@ Route::group(['middleware' => 'web'], function () {
Route::get('/refund_self_order', 'RefundController@selfRefundList');
Route::post('/ajax/cancelSelfRefund', 'RefundController@cancelSelfRefund');
Route::get('/refund_self_export', 'RefundController@refundSelfExport');
});
// 不需要登陆态
......
......@@ -20,8 +20,8 @@ class OrderRefundModel extends Model
return $this->hasMany('App\Model\OrderRefundItemsModel', 'refund_id', 'refund_id');
}
// 订单导出
public function export($request, $type=1) // type: 1-联营,2-自营
// 联营订单导出
public function jointExport($request)
{
set_time_limit(0);
ini_set('memory_limit', '512M');
......@@ -36,8 +36,8 @@ class OrderRefundModel extends Model
$map['apply_status'] = $request->input('apply_status', '');
$list = $this->from('lie_order_refund_items as it')
->leftJoin('lie_order_refund as r', function($join) use ($type) {
$join->on('it.refund_id', '=', 'r.refund_id')->where('r.refund_type', '=', 2)->where('r.order_goods_type', '=', $type);
->leftJoin('lie_order_refund as r', function($join) {
$join->on('it.refund_id', '=', 'r.refund_id')->where('r.refund_type', '=', 2)->where('r.order_goods_type', '=', 1);
})
->leftJoin('lie_user_main as u', 'r.create_uid', '=', 'u.user_id')
->where(function ($query) use ($map) {
......@@ -83,7 +83,7 @@ class OrderRefundModel extends Model
array_unshift($cellData, $headerCell);
$fileName = $type == 1 ? '联营退货订单导出'.date('_YmdHis') : '自营退货订单导出'.date('_YmdHis');
$fileName = '联营退货订单导出'.date('_YmdHis');
Excel::create($fileName, function($excel) use ($cellData){
$excel->sheet('退货订单导出', function($sheet) use ($cellData){
......@@ -153,4 +153,116 @@ class OrderRefundModel extends Model
return $tmp;
}
// 获取自营商品型号
public function getGoodsName($goods_id)
{
$goods_info = json_decode(Redis::hget('Self_SelfGoods', $goods_id), true);
return $goods_info['goods_name'];
}
// 自营订单导出
public function selfExport($request)
{
set_time_limit(0);
ini_set('memory_limit', '512M');
$map = array();
// 页面参数
$map['order_sn'] = $request->input('order_sn', '');
$map['sku_name'] = $request->input('sku_name', '');
$map['time_start'] = $request->input('time_start', '');
$map['time_end'] = $request->input('time_end', '');
$map['apply_status'] = $request->input('apply_status', '');
$list = $this->from('lie_order_refund as r')
->leftJoin('lie_user_main as u', 'r.create_uid', '=', 'u.user_id')
->where('r.refund_type', '=', 1)
->where('r.order_goods_type', '=', 2)
->where(function ($query) use ($map) {
// 订单编号
if (!empty($map['order_sn'])) {
$query->where('r.order_sn', '=', $map['order_sn']);
}
})
->where(function ($query) use ($map) {
// 创建时间
if (!empty($map['time_start']) && !empty($map['time_end'])) {
$query->whereBetween('r.create_time', [$map['time_start'], $map['time_end']]);
} else if (!empty($map['time_start'])) {
$query->where('r.create_time', '>', $map['time_start']);
} else if (!empty($map['time_end'])) {
$query->where('r.create_time', '<', $map['time_end']);
}
})
->where(function ($query) use ($map) {
// 订单状态
if (!empty($map['apply_status'])) {
$query->whereIn('r.status', explode(',', $map['apply_status']));
}
})
->select('r.order_id', 'r.order_sn', 'r.order_goods_type', 'r.currency', 'r.pay_amount', 'r.price_fall', 'r.create_uid', 'r.status', 'r.refund_reason', 'r.create_time', 'r.refund_time', 'u.mobile', 'u.email')
->orderBy('r.create_time', 'DESC')
->get()
->toArray();
if (!empty($list)) {
// 订单数据处理
$cellData = $this->selfExportList($list);
// 标题
$headerCell = ['订单ID', '订单编号', '会员账号', '退货原因', '后台操作人', '创建时间', '退货处理状态', '退货处理时间'];
array_unshift($cellData, $headerCell);
$fileName = '自营退货订单导出'.date('_YmdHis');
Excel::create($fileName, function($excel) use ($cellData){
$excel->sheet('退货订单导出', function($sheet) use ($cellData){
$sheet->rows($cellData);
});
})->export('xls');
} else {
return redirect('/prompt')->with(['message'=>"数据为空无法导出!",'url'=>$_SERVER['HTTP_REFERER'], 'jumpTime'=>3,'status'=>false]);
}
}
/**
* 导出数据处理
* @param [type] $order [查询出的订单数据]
* @return [type] [description]
*/
public function selfExportList($order)
{
// 订单类型
$apply_status = array(
'-1' => '已拒绝',
'1' => '待处理',
'10' => '已处理',
);
$tmp = array();
for ($i = 0; $i < count($order); $i++) {
// 推送人
if ($order[$i]['create_uid']) {
$sales = DB::table('user_info')->where(['userId' => $order[$i]['create_uid']])->select('name')->first();
}
$tmp[$i]['order_id'] = $order[$i]['order_id'];
$tmp[$i]['order_sn'] = "\t".$order[$i]['order_sn']."\t";
$tmp[$i]['user_account'] = $order[$i]['mobile'] ? $order[$i]['mobile'] : $order[$i]['email'];
$tmp[$i]['refund_reason'] = $order[$i]['refund_reason'];
$tmp[$i]['sale_name'] = isset($sales) ? $sales->name : ''; // 推送业务员
$tmp[$i]['create_time'] = date('Y-m-d H:i:s', $order[$i]['create_time']);
$tmp[$i]['status'] = $apply_status[$order[$i]['status']];
$tmp[$i]['refund_time'] = $order[$i]['refund_time'] ? date('Y-m-d H:i:s', $order[$i]['refund_time']) : '';
unset($sales);
}
return $tmp;
}
}
\ No newline at end of file
......@@ -68,7 +68,7 @@
time_end = $('input[name="time_end"]').val(),
order_goods_type = $('input[name="order_goods_type"]').val();
if (url == '/refund_export') {
if (url == '/refund_export' || url == '/refund_self_export') {
if (!order_sn && !sku_name && !apply_status && !order_payment_mode && !time_start && !time_end) {
layer.msg('请选择筛选条件,再导出!');
return false;
......@@ -123,7 +123,13 @@
// 导出订单
$('.refund_order_export').click(function() {
refundCommon('/refund_export');
var order_goods_type = $('input[name="order_goods_type"]').val();
if (order_goods_type == 1) {
refundCommon('/refund_export');
} else {
refundCommon('/refund_self_export');
}
})
// // 钱包退款
......
......@@ -14,13 +14,15 @@
<input type="text" id="order_sn" name="order_sn" value="{{$condition['order_sn']}}" placeholder="请输入订单编号">
</dd>
</dl>
@if ($condition['order_goods_type'] == 1)
<dl>
<dt>SKU名称:</dt>
<dd>
<input type="text" id="sku_name" name="sku_name" value="{{$condition['sku_name']}}" placeholder="请输入SKU名称">
</dd>
</dl>
@endif
<dl>
<dt>支付方式:</dt>
......@@ -64,7 +66,7 @@
<input type="hidden" name="order_goods_type" value="{{$condition['order_goods_type']}}">
<div class="search-btn">
<button class="nbtn search_refund_order">搜索</button>
<!-- <button class="nbtn refund_order_export" style="margin-left: 20px; background: #23c6c8 !important;">导出</button> -->
<button class="nbtn refund_order_export" style="margin-left: 20px; background: #23c6c8 !important;">导出</button>
</div>
</div>
</div>
......
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