Commit 4e852a46 by 朱继来

添加自营退款列表

parent 1cebe9c9
......@@ -103,11 +103,27 @@ class RefundController extends Controller
return $data;
}
// 联营退款列表
public function jointRefundList(Request $request)
{
$info = $this->refundList($request, 1);
return view('refundlist', $info);
}
// 自营退款列表
public function selfRefundList(Request $request)
{
$info = $this->refundList($request, 2);
return view('refundlist', $info);
}
// 退款申请列表
public function refundList(Request $request)
public function refundList(Request $request, $type)
{
$info = $this->getPageInfo($request);
$info['title'] = '退款申请列表';
$info['title'] = $type == 1 ? '联营退款申请列表' : '自营退款申请列表';
$map['order_sn'] = $request->input('order_sn', '');
$map['sku_name'] = $request->input('sku_name', '');
......@@ -115,7 +131,7 @@ class RefundController extends Controller
$map['apply_status'] = $request->input('apply_status', '');
$map['time_start'] = $request->input('time_start', '');
$map['time_end'] = $request->input('time_end', '');
$map['order_goods_type'] = 1; // 联营退货
$map['order_goods_type'] = $type; // 类型
//获取订单列表
$url = Config('website.api_domain').'refund/getRefundOrderList';
......@@ -138,28 +154,36 @@ class RefundController extends Controller
$info['count'] = $response['data']['count'];
$info['page'] = $show;
return view('refundlist', $info);
return $info;
}
// 退款导出
public function refundExport(Request $request)
{
$refundModel = new RefundModel();
$refundModel = new OrderRefundModel();
$refundModel->export($request);
}
// 退货详情
public function refundDetails(Request $request, $id)
{
$info = $this->getPageInfo($request);
$info['title'] = '订单退货详情';
$info['paths'] = [["title" => '联营订单', "href" => '#'], ["title" => '退款申请列表', "href" => '/refund_order'], ["title" => '订单退货详情', "href" => '#']];
$info = $this->getPageInfo($request);
$OrderRefundModel = new OrderRefundModel();
$info['refund'] = $OrderRefundModel->find($id);
$info['refundItems'] = $OrderRefundModel->find($id)->hasManyRefundItems;
if ($info['refund']['order_goods_type'] == 1) {
$title = '联营订单';
$refund_url = '/refund_order';
} else {
$title = '自营订单';
$refund_url = '/refund_self_order';
}
$info['title'] = '订单退货详情';
$info['paths'] = [["title" => $title, "href" => '#'], ["title" => '退款申请列表', "href" => $refund_url], ["title" => '订单退货详情', "href" => '#']];
return view('refundDetails', $info);
}
......@@ -187,4 +211,16 @@ class RefundController extends Controller
echo $temp;
}
// 自营取消退款申请
public function cancelSelfRefund(Request $request)
{
$refund_id = $request->input('refund_id');
$update = DB::connection('order')->table('lie_order_refund')->where('refund_id', $refund_id)->update(['status' => -1]);
if (!$update) return ['errcode' => 1, 'errmsg' => '取消申请失败'];
return ['errcode' => 0, 'errmsg' => '取消申请成功'];
}
}
......@@ -107,10 +107,13 @@ Route::group(['middleware' => 'web'], function () {
Route::match(['get', 'post'], '/refund/{id}', 'OrderController@refund');
Route::get('/refund_order', 'RefundController@refundList');
Route::get('/refund_order', 'RefundController@jointRefundList');
Route::get('/refund_export', 'RefundController@refundExport');
Route::get('/refund_details/{id}', 'RefundController@refundDetails');
Route::match(['get', 'post'], '/wallet_refund/{id}', 'RefundController@walletRefund');
Route::get('/refund_self_order', 'RefundController@selfRefundList');
Route::post('/ajax/cancelSelfRefund', 'RefundController@cancelSelfRefund');
});
// 不需要登陆态
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Redis;
use Request;
use Excel;
use DB;
class OrderRefundModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_refund';
protected $primaryKey = 'refund_id';
public $timestamps = false;
// 获取联系人信息
public function hasManyRefundItems()
{
return $this->hasMany('App\Model\RefundItemsModel', 'refund_id', 'refund_id');
}
// 订单导出
public function export($request, $type=1) // type: 1-联营,2-自营
{
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_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_user_main as u', 'r.create_uid', '=', 'u.user_id')
->where(function ($query) use ($map) {
// 订单编号
if (!empty($map['order_sn'])) {
$query->where('r.order_sn', '=', $map['order_sn']);
}
})
->where(function ($query) use ($map) {
// sku名称
if (!empty($map['sku_name'])) {
$query->where('it.sku_name', '=', $map['sku_name']);
}
})
->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('it.refund_rec_id', 'it.refund_id', 'it.rec_id', 'it.goods_id', 'it.goods_name', 'it.brand_id', 'it.brand_name', 'it.supplier_id', 'it.supplier_name', 'it.sku_name', 'it.goods_price', 'it.single_pre_price', 'it.refund_num', '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')
->groupBy('it.refund_rec_id')
->orderBy('r.create_time', 'DESC')
->get()
->toArray();
if (!empty($list)) {
// 订单数据处理
$cellData = $this->exportList($list);
// 标题
$headerCell = ['订单ID', '订单编号', '会员账号', '商品型号', '制造商', '供应商', '币种', '退货数量', '原始单价', '均摊后单价', '小计', '退货总额', '手动差价', '实际退货总额', '退货原因', '后台操作人', '创建时间', '退货处理状态', '退货处理时间'];
array_unshift($cellData, $headerCell);
$fileName = $type == 1 ? '联营退货订单导出'.date('_YmdHis') : '自营退货订单导出'.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 exportList($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]['goods_name'] = $order[$i]['order_goods_type'] == 1 ? $order[$i]['goods_name'] : $this->getGoodsName($order[$i]['goods_id']);
$tmp[$i]['brand_name'] = $order[$i]['brand_name'];
$tmp[$i]['supplier_name'] = $order[$i]['supplier_name'];
$tmp[$i]['currency'] = $order[$i]['currency'] == 1 ? 'RMB' : 'USD';
$tmp[$i]['refund_num'] = $order[$i]['refund_num'];
$tmp[$i]['goods_price'] = $order[$i]['goods_price'];
$tmp[$i]['single_pre_price'] = $order[$i]['single_pre_price'];
$tmp[$i]['goods_amount'] = $order[$i]['refund_num'] * $order[$i]['single_pre_price'];
if ($i > 0 && $tmp[$i]['order_id'] == $tmp[$i-1]['order_id']) {
$tmp[$i]['pay_amount'] = $order[$i]['pay_amount'];
$tmp[$i]['price_fall'] = $order[$i]['price_fall'];
$tmp[$i]['final_amount'] = $order[$i]['pay_amount'] - $order[$i]['price_fall'];
} else {
$tmp[$i]['pay_amount'] = '';
$tmp[$i]['price_fall'] = '';
$tmp[$i]['final_amount'] = '';
}
$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
......@@ -65,8 +65,8 @@
apply_status = $('#apply_status').val() ? $('#apply_status').val() : '',
order_payment_mode = $('#order_payment_mode').val() ? $('#order_payment_mode').val() : '',
time_start = $('input[name="time_start"]').val(),
time_end = $('input[name="time_end"]').val();
time_end = $('input[name="time_end"]').val(),
order_goods_type = $('input[name="order_goods_type"]').val();
if (url == '/refund_export') {
if (!order_sn && !sku_name && !apply_status && !order_payment_mode && !time_start && !time_end) {
......@@ -104,7 +104,7 @@
}
if (!order_sn && !sku_name && !apply_status && !order_payment_mode && !time_start && !time_end) {
listUrl = '/refund_order';
listUrl = url;
}
location.href = listUrl;
......@@ -112,7 +112,13 @@
// 搜索
$('.search_refund_order').click(function(){
refundCommon('/refund_order');
var order_goods_type = $('input[name="order_goods_type"]').val();
if (order_goods_type == 1) {
refundCommon('/refund_order');
} else {
refundCommon('/refund_self_order');
}
})
// 导出订单
......@@ -144,6 +150,40 @@
// }
// })
// })
// 自营退款列表取消申请
$('.cancel-refund').click(function() {
var rid = $(this).data('rid');
layer.open({
title : '取消申请',
content: '确定取消退款申请吗?',
btn: ['确定', '取消'],
btn1: function () {
$.ajax({
url : 'ajax/cancelSelfRefund',
type: 'post',
data: {refund_id: rid},
dataType: 'json',
success: function (resp) {
if (resp.errcode == 0) {
location.reload();
return false;
}
layer.msg(resp.errmsg);
},
error: function (err) {
console.log(err)
}
})
},
btn2:function(index){
layer.close(index);
}
})
})
}
}
});
......
......@@ -41,6 +41,8 @@
<th>退款金额</th>
<td>{{$currencySign.$refund->pay_amount}}</td>
</tr>
@if ($refund->order_goods_type == 1)
<tr>
<th>手动差价</th>
<td>{{$currencySign.$refund->price_fall}}</td>
......@@ -49,10 +51,14 @@
<th>最终退款总额</th>
<td>{{$currencySign.($refund->pay_amount - $refund->price_fall)}}</td>
</tr>
@endif
<tr>
<th>退款原因</th>
<td>{{$refund->refund_reason}}</td>
</tr>
@if ($refund->order_goods_type == 1)
<tr>
<th>退款型号</th>
<td>
......@@ -81,6 +87,7 @@
@endif
</td>
</tr>
@endif
</table>
</div>
</div>
......
......@@ -61,9 +61,10 @@
</table>
<div class="text-center">
<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>
......@@ -78,8 +79,12 @@
<th class="pl30">会员账号</th>
<th class="pl30">订单编号</th>
<th class="pl30">退款金额</th>
<th class="pl30">手动差额</th>
<th class="pl30">最终退款总额</th>
<!-- 联营退款时显示 -->
@if ($condition['order_goods_type'] == 1)
<th class="pl30">手动差额</th>
<th class="pl30">最终退款总额</th>
@endif
<th class="pl30">申请状态</th>
<th class="pl30">支付方式</th>
<th class="pl30">处理时间</th>
......@@ -89,7 +94,7 @@
@if (empty($list))
<tr>
<td class="text-center" colspan="9">没有查询到相关记录~</td>
<td class="text-center" colspan="8">没有查询到相关记录~</td>
</tr>
@else
<tbody>
......@@ -102,8 +107,12 @@
$currencySign = $v['currency'] == 1 ? '¥' : '$';
?>
<td class="show-list">{{$currencySign.$v['pay_amount']}}</td>
<td class="show-list">{{$currencySign.$v['price_fall']}}</td>
<td class="show-list">{{$currencySign.number_format($v['pay_amount'] - $v['price_fall'], 2)}}</td>
@if ($condition['order_goods_type'] == 1)
<td class="show-list">{{$currencySign.$v['price_fall']}}</td>
<td class="show-list">{{$currencySign.number_format($v['pay_amount'] - $v['price_fall'], 2)}}</td>
@endif
<td class="show-list">
<?php
switch ($v['status']) {
......@@ -123,6 +132,10 @@
<!-- 退款申请已处理且为钱包支付 -->
@if ($v['status'] == 1 && strpos($pay_name, '钱包支付') !== false)
@if ($condition['order_goods_type'] == 2)
<a class="btn btn-danger cancel-refund" data-rid="{{$v['refund_id']}}">取消申请</a>
@endif
<!-- <a class="btn btn-info wallet-refund" data-oid="{{$v['order_id']}}" data-amount="{{number_format($v['pay_amount'] - $v['price_fall'], 2)}}" target="_blank">钱包退款</a> -->
<a class="btn btn-info" href="/wallet_refund/{{$v['refund_id']}}" target="_blank">钱包退款</a>
@endif
......
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