Commit 1dc17ce0 by 朱继来

Merge branch 'zjl_pay_refund_20190123'

parents ff3064c3 49e6a0a9
......@@ -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,43 @@ 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();
return $refundModel->jointExport($request);
}
$refundModel->export($request);
// 自营退款导出
public function refundSelfExport(Request $request)
{
$refundModel = new OrderRefundModel();
return $refundModel->selfExport($request);
}
// 退货详情
public function refundDetails(Request $request, $id)
{
$info = $this->getPageInfo($request);
$info['title'] = '订单退货详情';
$info['paths'] = [["title" => '联营订单', "href" => '#'], ["title" => '退款申请列表', "href" => '/refund_order'], ["title" => '订单退货详情', "href" => '#']];
$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);
}
......@@ -167,12 +198,12 @@ class RefundController extends Controller
public function walletRefund(Request $request, $id)
{
// 获取退款单
$refund = DB::connection('order')->table('lie_order_refund')->where('refund_id', $id)->first();
// $refund = DB::connection('order')->table('lie_order_refund')->where('refund_id', $id)->first();
if (!$refund) echo '未获取到退款单';
if (!$id) echo '未获取到退款单';
$data['order_id'] = $refund->order_id;
$data['refund_amount'] = number_format($refund->pay_amount - $refund->price_fall, 2, '.', '');
$data['refund_id'] = $id;
// $data['refund_amount'] = number_format($refund->pay_amount - $refund->price_fall, 2); // 最終退款金額
$data['pay_code'] = 'unionpay';
$url = Config('website.api_domain').'refund/recharge';
......@@ -187,4 +218,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' => '取消申请成功'];
}
}
......@@ -109,10 +109,14 @@ 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');
Route::get('/refund_self_export', 'RefundController@refundSelfExport');
});
// 不需要登陆态
......
......@@ -205,6 +205,7 @@ class OrderModel extends Model
case '6': $order_payment_mode[] = '京东支付';break;
case '7': $order_payment_mode[] = '交通银行';break;
case '8': $order_payment_mode[] = '恒生银行';break;
case '9': $order_payment_mode[] = '钱包支付';break;
}
}
......
<?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
......@@ -490,7 +490,7 @@
location.reload();
// layer.close();
} else {
layer.alert(resp.errmsg);
layer.alert(resp.errmsg || '网络异常');
}
},
error:function(){
......@@ -608,7 +608,7 @@
location.reload();
return false;
} else {
layer.alert(resp.errmsg);
layer.alert(resp.errmsg || '网络异常');
}
},
error:function(){
......@@ -686,7 +686,7 @@
location.reload();
return false;
} else {
layer.alert(resp.errmsg);
layer.alert(resp.errmsg || '网络异常');
}
},
error:function(){
......@@ -731,7 +731,7 @@
btn: [],
})
} else {
layer.alert(resp.errmsg || '网络异常')
layer.alert(resp.errmsg || '网络异常');
}
},
error: function(err) {
......@@ -781,7 +781,7 @@
if(resp.errcode == 0){
location.href = url;
} else {
layer.alert(resp.errmsg || '网络异常')
layer.alert(resp.errmsg || '网络异常');
}
}
});
......@@ -837,7 +837,7 @@
if(resp.errcode == 0){
location.href = url;
} else {
layer.alert(resp.errmsg || '网络异常')
layer.alert(resp.errmsg || '网络异常');
}
}
});
......@@ -917,7 +917,7 @@
if(resp.errcode == 0){
location.reload();
} else {
layer.msg(resp.errmsg || '网络异常');
layer.alert(resp.errmsg || '网络异常');
}
}
})
......@@ -992,7 +992,7 @@
location.reload();
return false;
} else {
layer.alert(resp.errmsg || '异常');
layer.alert(resp.errmsg || '网络异常');
}
}
});
......@@ -1028,9 +1028,7 @@
location.reload();
}, 1000);
} else {
layer.alert(resp.errmsg || '网络异常', function(){
location.reload();
});
layer.alert(resp.errmsg || '网络异常');
}
},
......@@ -1549,9 +1547,7 @@
location.href = url;
}, 1000);
} else {
layer.alert(resp.errmsg || '网络异常', function(){
location.reload();
});
layer.alert(resp.errmsg || '网络异常');
}
},
......@@ -1823,7 +1819,7 @@
location.reload();
return false;
} else {
layer.alert(resp.errmsg);
layer.alert(resp.errmsg || '网络异常');
}
},
error:function(){
......
......@@ -65,10 +65,10 @@
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 (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;
......@@ -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,12 +112,24 @@
// 搜索
$('.search_refund_order').click(function(){
var order_goods_type = $('input[name="order_goods_type"]').val();
if (order_goods_type == 1) {
refundCommon('/refund_order');
} else {
refundCommon('/refund_self_order');
}
})
// 导出订单
$('.refund_order_export').click(function() {
var order_goods_type = $('input[name="order_goods_type"]').val();
if (order_goods_type == 1) {
refundCommon('/refund_export');
} else {
refundCommon('/refund_self_export');
}
})
// // 钱包退款
......@@ -144,6 +156,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);
}
})
})
}
}
});
......
......@@ -6,15 +6,15 @@
<table class="table table-bordered order-express">
<tr>
<th width="10%">订单编号</th>
<td>{{$refund->order_sn}} <a href="/details/{{$refund->order_id}}" target="_blank" style="margin-left: 20px;">查看订单</a></td>
<td>{{$refund->order_sn}} <a href="/details/{{$refund->order_goods_type == 1 ? $refund->order_id : $refund->order_id.'?tags=self'}}" target="_blank" style="margin-left: 20px;">查看订单</a></td>
</tr>
<tr>
<th>用户账号</th>
<td>{{ App\Http\Controllers\getAccountName($refund->create_uid) }}</td>
<td>{{ App\Http\Controllers\getAccountName($refund->user_id) }}</td>
</tr>
<tr>
<th>申请时间</th>
<td>{{$refund->create_time ? date('Y-m-d H:i:s') : ''}}</td>
<td>{{$refund->create_time ? date('Y-m-d H:i:s', $refund->create_time) : ''}}</td>
</tr>
<tr>
<th>申请状态</th>
......@@ -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,13 @@
<th>最终退款总额</th>
<td>{{$currencySign.($refund->pay_amount - $refund->price_fall)}}</td>
</tr>
@endif
<tr>
<th>退款原因</th>
<td>{{$refund->refund_reason}}</td>
</tr>
<tr>
<th>退款型号</th>
<td>
......
......@@ -15,12 +15,14 @@
</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>
......@@ -61,6 +63,7 @@
</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>
......@@ -78,8 +81,12 @@
<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 +96,7 @@
@if (empty($list))
<tr>
<td class="text-center" colspan="9">没有查询到相关记录~</td>
<td class="text-center" colspan="8">没有查询到相关记录~</td>
</tr>
@else
<tbody>
......@@ -102,8 +109,12 @@
$currencySign = $v['currency'] == 1 ? '¥' : '$';
?>
<td class="show-list">{{$currencySign.$v['pay_amount']}}</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 +134,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