Commit eeeb73eb by 朱继来

退货退款

parent 515cd2cd
......@@ -1018,6 +1018,48 @@ Class OrderController extends Controller
return view('detail', $info);
}
// 退货退款
public function refund(Request $request, $id)
{
if ($request->isMethod('post'))
{
$data['order_id'] = $request->input('order_id');
$data['refund_info'] = $request->input('refund_info');
$data['all_refund_amount'] = $request->input('all_refund_amount');
$data['price_fall'] = $request->input('price_fall');
$data['refund_reason'] = $request->input('refund_reason');
$data['operator_id'] = $request->user->userId;
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$url = Config('website.api_domain').'refund/refundGoods';
$temp = json_decode(curlApi($url, $data, 'POST'), true);
return array('errcode'=>$temp['err_code'], 'errmsg'=>$temp['err_msg']);
}
$info = $this->orderDetail($request, $id);
$this->pageHeader($request, $info, '退货申请', ["title" => '退货申请', "href" => '#']);
// 未发货明细
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$data['order_id'] = $id;
$url = Config('website.api_domain').'removal/getUnshippedItems';
$res = json_decode(curlApi($url, $data, 'POST'), true);
if ($res['err_code'] != 0)
return redirect('/prompt')->with(['message'=>'退货退款无法操作'.$res['err_msg'], 'url' =>$_SERVER['HTTP_REFERER'], 'jumpTime'=>3,'status'=>false]);
$info['unshippedItems'] = $res['data'];
return view('detail', $info);
}
//订单物流信息
public function changeShipping(Request $request, $id='')
{
......
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Model\OrderModel;
use App\Model\OrderRefundModel;
use App\Model\OrderRefundItemsModel;
use DB;
use App\Http\Page;
use App\Model\UserMainModel;
// 获取会员账号
function getUserName($user_id)
{
if (!$user_id) return false;
$userMainModel = new UserMainModel;
$user = $userMainModel->find($user_id);
if (!$user) return false;
return $user->mobile ? $user->mobile : $user->email;
}
// 获取订单金额
function getOrderAmount($order_id)
{
if (!$order_id) return false;
$OrderModel = new OrderModel;
$order = $OrderModel->find($order_id);
if (!$order) return false;
return $order->order_amount;
}
class RefundController extends Controller
{
// 页面用户、菜单信息
public function getPageInfo(Request $request)
{
$uri = '/' . $request->path();
if ($request->path() == '/') $uri = '/list';
$username = $request->user->email;
$useremail= $request->user->email;
// 菜单
$menuconfig = DB::table('config')->where('config_title', '订单系统')->first();
$menus = [];
if ($menuconfig && !($menus = json_decode($menuconfig->config_data)))
$menus = [];
$perm = new PermController;
// 用户角色
$role = $perm->getUserRole($request);
// 获取权限菜单
if ($role != 1) {
$menus = $perm->getPermMenu($menus, $request->user->userId);
}
$userPerms = $perm->getUserAllPerms($request->user->userId, $role); // 用户权限
$data = [
'header' => $request->user->header,
'uri' => $uri,
'username' => $username,
'useremail' => $useremail,
'menus' => $menus,
'userPerms' => $userPerms,
'role' => $role,
];
return $data;
}
// 退款申请列表
public function refundList(Request $request)
{
$info = $this->getPageInfo($request);
$info['title'] = '退款申请列表';
$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', '');
$map['order_goods_type'] = 1; // 联营退货
//获取订单列表
$url = Config('website.api_domain').'refund/getRefundOrderList';
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$data['p'] = $request->input('p', 1); // 当前页码
$data['size'] = 10; // 当前页条数
$data['map'] = $map;
$response = json_decode(curlApi($url, $data), true);
// 分页
$page = new Page($response['data']['count'], 10);
$page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
$show = $page->show();
$info['condition'] = $map;
$info['list'] = $response['data']['data'];
$info['count'] = $response['data']['count'];
$info['page'] = $show;
return view('refundlist', $info);
}
// 退款导出
public function refundExport(Request $request)
{
$refundModel = new RefundModel();
$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" => '#']];
$OrderRefundModel = new OrderRefundModel();
$info['refund'] = $OrderRefundModel->find($id);
$info['refundItems'] = $OrderRefundModel->find($id)->hasManyRefundItems;
return view('refundDetails', $info);
}
}
......@@ -105,6 +105,11 @@ Route::group(['middleware' => 'web'], function () {
Route::match(['get', 'post'],'/web/{key}', 'WebController@info');
Route::match(['get', 'post'],'/api/{key}', 'ApiController@Entrance');
Route::match(['get', 'post'], '/refund/{id}', 'OrderController@refund');
Route::get('/refund_order', 'RefundController@refundList');
Route::get('/refund_export', 'RefundController@refundExport');
Route::get('/refund_details/{id}', 'RefundController@refundDetails');
});
// 不需要登陆态
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use Excel;
use DB;
class OrderRefundItemsModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_refund_items';
protected $primaryKey = 'refund_rec_id';
public $timestamps = false;
}
\ No newline at end of file
<?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\OrderRefundItemsModel', '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
<?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
......@@ -340,6 +340,7 @@
case 2: title = '取消订单'; break;
case 3: title = '订单审核不通过'; break;
case 4: title = '填写订单取消原因'; break;
case 5: title = '填写退货退款原因'; break;
default: title = '填写订单取消原因'; break;
}
......@@ -382,7 +383,7 @@
title: title,
content: content,
btn:['确认', '取消'],
btn1:function(){
btn1:function(index){
var cancel_reason = $('input[name=cancel_reason]:checked').val();
var other_reason = $('textarea[name=input-other-reason]').val();
......@@ -398,6 +399,15 @@
}
}
// 退货退款弹出层
if (type == 5) {
self.siblings('.refund_reason').val(cancel_reason);
self.siblings('.refund_reason_val').empty().text(cancel_reason);
layer.close(index);
return false; // 阻止继续执行
}
$.ajax({
url:'/ajaxCancel',
data: {order_id: order_id, cancel_reason: cancel_reason, type: type},
......@@ -463,6 +473,9 @@
if(action_type=='changeOrder'){
self.changeOrder();
}
if(action_type=='refund'){
self.refund();
}
self.selfOrder();
self.cancelorder();
......@@ -1756,6 +1769,175 @@
})
},
// 退货退款
refund: function() {
// 正整数输入框限制
$('.int_num').off().on('keyup', function(){
var val = $(this).val();
if(!val) return false;
if (!(/^[1-9]\d*$/g.test(val))) {
layer.msg('只能是正整数');
$(this).val('');
}
if($(this).val().length > 9){
$(this).val($(this).val().slice(0, 9));
}
});
// 浮点数输入框限制
$('.float_num').off().on('keyup', function(){
var val = $(this).val();
if(!val) return false;
if(!(/^\d{0,7}(\.\d{0,4})?$/g.test(val))){//判断输入是否合法,不合法强制转换
if(isNaN(parseFloat(val))){
layer.msg('只能是数字');
$(this).val('');
}else{
$(this).val(parseFloat(val).toFixed(4));
}
}
if(val > 999999.9999){
$(this).val(999999.9999);
}
if(val.length > 11){
$(this).val(val.slice(0,11));
}
});
// 填写退货数量
$('.refund_num').keyup(function() {
var unshipped_num = parseInt($(this).parents('tr').find('.unshipped_num').val()); // 未发货数量
var single_pre_price = parseFloat($(this).parents('tr').find('.single_pre_price').val()); // 均摊单价
var val = $(this).val(); // 退货数量
if (val > unshipped_num) {
layer.msg('不能超过未发货数量');
$(this).val('');
}
// 退款小计
var single_amount = parseFloat(single_pre_price * val).toFixed(4);
$(this).parents('tr').find('.single_refund_amount').text(currency_sign + single_amount);
// 退款总额
var refund_total = 0;
$('.refund-table').find('tbody tr').each(function(){
var num = parseInt($(this).find('.refund_num').val()) || 0;
var price = parseFloat($(this).find('.single_pre_price').val()) || 0;
refund_total += parseFloat(num * price);
});
// 差价
var price_fall = $('.price_fall').val();
refund_amount = parseFloat(refund_total - price_fall).toFixed(2);
refund_total = refund_total.toFixed(2);
$('.all_refund_amount').val(refund_total);
$('.all_refund_amount_val').text(currency_sign + refund_total);
$('.refund_amount').text(currency_sign + refund_amount);
})
// 调整差价
$('.price_fall').keyup(function() {
var val = $(this).val();
var all_refund_amount = $('.all_refund_amount').val();
var refund_total = parseFloat(all_refund_amount - val).toFixed(2);
// 退款总额不存在,则差价设置为0
if (!all_refund_amount) {
$(this).val(0);
return false;
}
// 若差价大于或等于退款总额,则差价设置为0
if (parseFloat(val) >= parseFloat(all_refund_amount)) {
$(this).val(0);
$('.refund_amount').text(currency_sign + all_refund_amount);
return false;
}
$('.refund_amount').text(currency_sign + refund_total);
})
// 提交表单
$('.refundApply').click(function() {
var goods_count = 0; // 商品数量
var refund_eq_true = []; // 退货数量与未发货数量相等
var refund_empty = []; // 退货数量为空
// 表单退货数量
$('.refund-table').find('tbody tr').each(function(){
var num = parseInt($(this).find('.refund_num').val());
var unshipped_num = parseInt($(this).find('.unshipped_num').val());
// 为空标记
if (!num) refund_empty.push(0);
// 数量等于未发货数量标记
if (num == unshipped_num) refund_eq_true.push(1);
goods_count++;
});
if (refund_empty.length == goods_count) {
layer.msg('请填写退货数量');
return false;
}
if (refund_eq_true.length == goods_count) {
layer.msg('不能选择全部退货数量,请检查数量');
return false;
}
var order_id = $('input[name=order_id]').val();
var refund_reason = $('.refund_reason').val();
if (!refund_reason) {
layer.msg('请选择退货原因');
return false;
}
layer.open({
title: '提示信息',
content: '确认提交退货申请?',
btn: ['确认', '取消'],
yes: function(index, layero){
$.ajax({
url : '/refund/' + order_id,
type: 'post',
data: $('#refundForm').serialize(),
dataType: 'json',
success: function (resp) {
if(resp.errcode === 0){
layer.msg(resp.errmsg || '操作成功');
setTimeout(function(){
location.href = url;
}, 1000);
} else {
layer.alert(resp.errmsg || '网络异常');
}
},
error: function (res) {
console.log(res);
}
})
},
btn2: function(index, layero){
layer.close(index);
}
});
})
}
}
});
......
+(function($){
$.lie = $.lie || {version: "v1.0.0"};
$.extend($.lie, {
refund:{
index:function(){
$.lie.droplist($('.droplist'));
// 特殊字符编码
function specialCode(chr)
{
switch (chr) {
case '!': return '%21'; break;
case '"': return '%22'; break;
case '#': return '%23'; break;
case '$': return '%24'; break;
case '%': return '%25'; break;
case '&': return '%26'; break;
case '\'': return '%27'; break;
case '(': return '%28'; break;
case ')': return '%29'; break;
case '*': return '%2A'; break;
case '+': return '%2B'; break;
case ',': return '%2C'; break;
case '/': return '%2F'; break;
case ':': return '%3A'; break;
case ';': return '%3B'; break;
case '<': return '%3C'; break;
case '=': return '%3D'; break;
case '>': return '%3E'; break;
case '?': return '%3F'; break;
case '@': return '%40'; break;
case '[': return '%5B'; break;
case ']': return '%5D'; break;
case '\\': return '%5C'; break;
case '|': return '%7C'; break;
default: return ''; break;
}
}
// 查找特殊字符
function specialStr(str)
{
var reg = new RegExp("[!\"#$%&'()*+,/:;<=>?@\\[\\]\\|]");
var len = str.length;
var rs = '';
for (var i = 0; i < len; i++) {
var val = str.substr(i, 1);
if (reg.test(val)) {
rs = rs + specialCode(val);;
} else {
rs = rs + val;
}
}
return rs;
}
// 搜索、导出条件
function refundCommon(url) {
var order_sn = $('input[name="order_sn"]').val(),
sku_name = $('input[name="sku_name"]').val(),
time_start = $('input[name="time_start"]').val(),
time_end = $('input[name="time_end"]').val(),
apply_status = $('#apply_status').val() ? $('#apply_status').val() : '';
if (url == '/refund_export') {
if (!order_sn && !sku_name && !time_start && !time_end && !apply_status) {
layer.msg('请选择筛选条件,再导出!');
return false;
}
}
var listUrl = url;
listUrl += '?order_sn=' + order_sn;
if (sku_name) {
listUrl += '&sku_name=' + specialStr(sku_name);
}
if(time_start){
time_start = Date.parse(time_start) / 1000;
listUrl += '&time_start='+time_start;
}
if(time_end){
time_end = Date.parse(time_end) / 1000 + (24*60*60-1);
listUrl += '&time_end='+time_end;
}
if (apply_status) {
listUrl += '&apply_status=' + apply_status;
}
if (!order_sn && !sku_name && !time_start && !time_end && !apply_status) {
listUrl = '/refund_order';
}
location.href = listUrl;
}
// 搜索
$('.search_refund_order').click(function(){
refundCommon('/refund_order');
})
// 导出订单
$('.refund_order_export').click(function() {
refundCommon('/refund_export');
})
}
}
});
})(jQuery)
\ No newline at end of file
......@@ -588,6 +588,11 @@
<!--自营对账-->
@include('detail.selfCheckPay')
@endif
@if ($action_name == 'refund')
<!--自营对账-->
@include('detail.refund')
@endif
<!-- 人工审单时去掉操作按钮 -->
@if (!isset($_REQUEST['tags']) && $action_name != 'changeOrder' && $action_name != 'sendSales')
......@@ -615,6 +620,10 @@
@if (in_array($order_info['status'], array(4, 7, 8, 10)) && in_array('order_send', $userPerms))
<!-- <a href="{{URL('send', ['order_id'=>$order_info['order_id']])}}" class="btn btn-default">订单发货</a> -->
@endif
@if (in_array($order_info['status'], array(3, 4, 7)))
<a href="{{URL('refund', ['order_id'=>$order_info['order_id']])}}" class="btn btn-info">退货退款</a>
@endif
<!-- 已发货之后的状态 -->
@if ($order_info['status'] == 10)
......
<p style="padding-left: 5px;">退货申请</p>
<div class="tabs-box">
<div class="order-change-main">
<form id="refundForm" class="form-horizontal table-responsive">
<input type="hidden" name="order_id" value="{{$order_info['order_id']}}">
<input type="hidden" name="goods_amount" value="{{$order_price_info['goods_price']}}">
<input type="hidden" name="order_amount" value="{{$order_info['order_amount']}}">
<!-- 退款型号 -->
<p>退款型号</p>
<table class="table table-bordered table-hover refund-table">
<thead>
<!-- <th width="7%"><input type="checkbox" class="all-select" >全选</th> -->
<th width="20%">供应商</th>
<th>型号</th>
<th>未发货数量</th>
<th>均摊后单价</th>
<th>退货数量</th>
<th width="10%">小计</th>
</thead>
<tbody>
@foreach ($unshippedItems as $v)
<tr>
<!-- <td><input type="checkbox" name="refund_info[{{$v['rec_id']}}]" value="{{$v['rec_id']}}"></td> -->
<td>
<span>{{$v['supplier_name']}}</span>
</td>
<td>
<span>{{$v['goods_name']}}</span>
</td>
<td>
<input type="hidden" name="refund_info[{{$v['rec_id']}}][unshipped_num]" class="unshipped_num" value="{{ $v['goods_number'] }}">
<span>{{$v['goods_number']}}</span>
</td>
<td>
<input type="hidden" name="refund_info[{{$v['rec_id']}}][single_pre_price]" class="single_pre_price" value="{{ $v['single_pre_price'] }}">
<span>{{$v['single_pre_price_format']}}</span>
</td>
<td>
<input class="only_number int_num refund_num" name="refund_info[{{$v['rec_id']}}][refund_num]" value="">
</td>
<td>
<span class="single_refund_amount"></span>
</td>
</tr>
@endforeach
</tbody>
</table>
<hr/>
<table class="table table-bordered table-hover">
<tr>
<th width="20%">订单总额</th>
<td>
<p class="text-danger">{{$currency}}<span class="total">{{$order_info['order_amount']}}</span></p>
</td>
</tr>
<tr>
<th>退款小计</th>
<td>
<input type="hidden" name="all_refund_amount" class="all_refund_amount" value="">
<span class="all_refund_amount_val"></span>
</td>
</tr>
<tr>
<th>调整差价</th>
<td><input class="only_number float_num price_fall" name="price_fall" value="0"></td>
</tr>
<tr>
<th>退款总额</th>
<td><span class="refund_amount"></span></td>
</tr>
<tr>
<th>退款原因</th>
<td>
<input type="hidden" class="refund_reason" name="refund_reason" value="">
<a href="javascript:;" class="btn btn-default input-cancel-reason" data-oid="{{$order_info['order_id']}}" data-type="5">点击选择</a>
<span class="refund_reason_val"></span>
</td>
</tr>
</table>
<a class="btn btn-primary refundApply">提交</a>
</form>
</div>
</div>
<script>
var currency_sign = "{{$currency}}";
</script>
\ No newline at end of file
......@@ -11,3 +11,4 @@
<script src="/js/order.js"></script>
<script src="/js/orderamount.js"></script>
<script src="/js/plugins/DatePicker/WdatePicker.js"></script>
<script src="/js/refund.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单管理后台 | {{$title}}</title>
<script>document.domain="{{ Config::get('website.domain') }}";</script>
@include('orderlist.css')
@include('orderlist.js')
</head>
<body class="">
<div id="wrapper">
<!-- layouts.navigation -->
<?php $isPage = false; ?>
@include('layouts.navigation')
<div id="page-wrapper" class="gray-bg">
<div class="row">
@include('refundDetails.content')
</div>
</div>
</div>
</body>
<div class="wrapper">
@include('layouts.header')
<div class="page-content">
<div class="tabs-box table-responsive">
<table class="table table-bordered order-express">
<tr>
<td width="10%">订单编号</td>
<td>{{$refund->order_sn}} <a href="/details/{{$refund->order_id}}" target="_blank" style="margin-left: 20px;">查看订单</a></td>
</tr>
<tr>
<td>用户账号</td>
<td>{{ App\Http\Controllers\getUserName($refund->create_uid) }}</td>
</tr>
<tr>
<td>申请时间</td>
<td>{{$refund->create_time ? date('Y-m-d H:i:s') : ''}}</td>
</tr>
<tr>
<td>申请状态</td>
<td>
<?php
switch ($refund->status) {
case -1: echo '已拒绝'; break;
case 1: echo '待处理'; break;
case 10: echo '已处理'; break;
}
?>
</td>
</tr>
<?php
$currencySign = $refund->currency == 1 ? '¥' : '$';
?>
<tr>
<td>订单金额</td>
<td>{{$currencySign}} {{ App\Http\Controllers\getOrderAmount($refund->order_id) }}</td>
</tr>
<tr>
<td>退款金额</td>
<td>{{$currencySign.$refund->pay_amount}}</td>
</tr>
<tr>
<td>手动差价</td>
<td>{{$currencySign.$refund->price_fall}}</td>
</tr>
<tr>
<td>最终退款总额</td>
<td>{{$currencySign.($refund->pay_amount - $refund->price_fall)}}</td>
</tr>
<tr>
<td>退款原因</td>
<td>{{$refund->refund_reason}}</td>
</tr>
<tr>
<td>退款型号</td>
<td>
<?php
$str = '';
if ($refundItems) {
foreach ($refundItems as $v) {
$str .= $v->goods_name.', ';
}
echo rtrim($str, ', ');
}
?>
</td>
</tr>
</table>
</div>
</div>
</div>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单管理后台 | {{ $title }}</title>
<script>document.domain="{{ Config::get('website.domain') }}";</script>
@include('orderlist.css')
@include('orderlist.js')
</head>
<body class="">
<div id="wrapper">
@include('layouts.navigation')
<div id="page-wrapper" class="gray-bg">
<div class="row">
@include('refundlist.content')
</div>
</div>
</div>
</body>
<div class="wrapper">
@include('layouts.header')
<div class="page-content">
<div class="tabs-box">
<div class="row-fluid search-box">
<div class="span12">
<table style="width:100%">
<tr>
<td>
<dl>
<dt>订单编号:</dt>
<dd>
<input type="text" id="order_sn" name="order_sn" value="{{$condition['order_sn']}}" placeholder="请输入订单编号">
</dd>
</dl>
<dl>
<dt>SKU名称:</dt>
<dd>
<input type="text" id="sku_name" name="sku_name" value="{{$condition['sku_name']}}" placeholder="请输入SKU名称">
</dd>
</dl>
<dl>
<dt>创建日期: </dt>
<dd style="width:auto !important;">
<input type="text" name="time_start" value="{{ !empty($condition['time_start']) ? date('Y/m/d', $condition['time_start']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="开始时间" autocomplete="off" />
</dd>
<dd style="width:auto !important;">
<input type="text" name="time_end" value="{{ !empty($condition['time_end']) ? date('Y/m/d', $condition['time_end']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="结束时间" autocomplete="off" />
</dd>
</dl>
<dl>
<dt>处理状态:</dt>
<dd>
<select id="apply_status" name="apply_status" class="form-control apply_status selectpicker" title="全部" multiple>
<option value="-1">已拒绝</option>
<option value="1">待处理</option>
<option value="10">已处理</option>
</select>
</dd>
</dl>
</td>
</tr>
</table>
<div class="text-center">
<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>
</div>
</div>
</div>
</div>
</div>
<div class="row-fluid table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th class="pl30">创建时间</th>
<th class="pl30">会员账号</th>
<th class="pl30">订单编号</th>
<th class="pl30">退款金额</th>
<th class="pl30">申请状态</th>
<th class="pl30">处理时间</th>
<th class="pl30">操作</th>
</tr>
</thead>
@if (empty($list))
<tr>
<td class="text-center" colspan="7">没有查询到相关记录~</td>
</tr>
@else
<tbody>
@foreach ($list as $v)
<tr>
<td class="show-list">{{$v['create_time'] ? date('Y-m-d H:i:s', $v['create_time']) : ''}}</td>
<td class="show-list">{{$v['mobile'] ? $v['mobile'] : $v['email']}}</td>
<td class="show-list">{{$v['order_sn']}}</td>
<td class="show-list">
<?php
$currencySign = $v['currency'] == 1 ? '¥' : '$';
echo $currencySign.$v['pay_amount'];
?>
</td>
<td class="show-list">
<?php
switch ($v['status']) {
case -1: echo '<span class="list-text-cancel"><b>已拒绝</b></span>';break;
case 1: echo '<span class="list-text-checking"><b>待处理</b></span>';break;
case 10: echo '<span class="list-text-success"><b>已处理</b></span>';break;
}
?>
</td>
<td class="show-list">{{$v['refund_time'] ? date('Y-m-d H:i:s', $v['refund_time']) : ''}}</td>
<td>
<div class="btn-group btn-group-xs">
<a class="btn btn-primary" href="/refund_details/{{$v['refund_id']}}" target="_blank">查看申请</a>
</div>
</td>
</tr>
@endforeach
</tbody>
@endif
</table>
</div>
<div class="row-fluid pagination">
<?php echo $page; ?>
</div>
</div>
</div>
<script>
var apply_status = "{{$condition['apply_status']}}";
$(".apply_status").selectpicker({
actionsBox:true, //在下拉选项添加选中所有和取消选中的按钮
countSelectedText:"已选中{0}项",
selectedTextFormat:"count > 5",
selectAllText: '全选',
deselectAllText: '取消全选',
})
$('.apply_status').selectpicker('val', apply_status.split(',')).trigger("change");
$.lie.refund.index();
</script>
\ No newline at end of file
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