Commit f0bb5e86 by 朱继来

调整售后弹窗

parent c44ea657
......@@ -1517,6 +1517,25 @@ Class OrderController extends Controller
return view('changeInvoice', $info);
}
// 订单售后检测是否能原路返回
public function orderServiceCheck(Request $request)
{
if($request->isMethod('post')){
$data['data'] = $request->input();
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$data['operator_id'] = $request->user->userId;
$data['operator_name'] = $request->user->name;
$update_url = Config('website.api_domain').'service/checkTurnBack';
$res = json_decode(curlApi($update_url, $data, 'POST'), true);
return array('errcode'=>$res['err_code'], 'errmsg'=>'', 'data'=>$res['data']);
}
}
// 订单售后
public function orderServiceApply(Request $request)
{
......
......@@ -86,6 +86,7 @@ Route::group(['middleware' => 'web'], function () {
// Route::post('/ajaxInputCancelReason', 'OrderController@ajaxInputCancelReason');
Route::post('/ajax/shipping', 'OrderController@shipping');
Route::post('/ajax/orderServiceCheck', 'OrderController@orderServiceCheck');
Route::post('/ajax/orderServiceApply', 'OrderController@orderServiceApply');
Route::get('/add_order', 'AddOrderController@addOrder');
......
......@@ -8,6 +8,19 @@ return [
3 => '审核通过',
],
// 售后类型
'service_type' => [
1 => '未出库取消',
2 => '已出库退货',
],
// 退款方式
'refund_type' => [
1 => '原路返回',
2 => '支付宝',
3 => '银行',
],
// 退款状态
'refund_status' => [
1 => '待生成',
......
......@@ -11,45 +11,107 @@
// 弹出提示
layer.open({
type: 1,
area: ['1000px', '600px'],
area: ['1200px', '700px'],
title: '售后申请',
content: $('.order_service_info'),
btn:['确定', '取消'],
yes: function(index, layero){
var apply_reason = $('.apply_reason').val();
var remark = $('.remark').val();
var is_all_num_empty = false; // 校验全部申请数量是否为空
var is_all_price_empty = false; // 校验全部单价是否为空
var service_type = $('.service_type').val();
var refund_type = $('.refund_type').val();
if (!apply_reason) {
layer.tips('请选择申请原因', $('.apply_reason'));
if (!service_type) {
layer.tips('请选择售后类型', $('.service_type'));
return false;
}
if (!remark) {
layer.tips('请填写备注', $('.remark'));
if (!refund_type) {
layer.tips('请选择退款方式', $('.refund_type'));
return false;
}
var is_one_empty = false; // 同一行的售后数量或单价中一个为空
$('.order-service-table').find('tbody tr').each(function() {
var goods_number = $(this).find('.adjust_number').val();
var goods_price = $(this).find('.adjust_price').val();
if (refund_type == 2) { // 支付宝
var ali_customer_name = $('.ali_customer_name').val();
var ali_refund_account = $('.ali_refund_account').val();
if (!ali_customer_name) {
layer.tips('请填写客户/公司', $('.ali_customer_name'));
return false;
}
if (!ali_refund_account) {
layer.tips('请填写支付账户', $('.ali_refund_account'));
return false;
}
} else if (refund_type == 3) { // 银行
var bank_customer_name = $('.bank_customer_name').val();
var bank_refund_account = $('.bank_refund_account').val();
var bank_name = $('.bank_name').val();
var bank_sub_name = $('.bank_sub_name').val();
if (!bank_customer_name) {
layer.tips('请填写客户/公司', $('.bank_customer_name'));
return false;
}
if (!bank_refund_account) {
layer.tips('请填写银行账号', $('.bank_refund_account'));
return false;
}
if (!goods_number && goods_price) {
layer.tips('请填写数量', $(this).find('.adjust_number'));
is_one_empty = true;
if (!bank_name) {
layer.tips('请填写银行名称', $('.bank_name'));
return false;
}
if (goods_number && !goods_price) {
layer.tips('请填写单价', $(this).find('.adjust_price'));
is_one_empty = true;
if (!bank_sub_name) {
layer.tips('请填写银行支行', $('.bank_sub_name'));
return false;
}
}
var is_all_num_empty = false; // 校验全部申请数量是否为空
var is_all_price_empty = false; // 校验全部单价是否为空
var is_all_reason_empty = false; // 校验全部申请原因是否为空
var is_all_remark_empty = false; // 校验全部备注是否为空
var is_one_empty = false; // 同一行的售后数量或单价中一个为空
$('.order-service-table').find('tbody tr').each(function() {
var goods_number = $(this).find('.adjust_number').val();
var goods_price = $(this).find('.adjust_price').val();
var apply_reason = $(this).find('.apply_reason').val();
var remark = $(this).find('.remark').val();
if (goods_number) is_all_num_empty = true;
if (goods_price) is_all_price_empty = true;
if (apply_reason) is_all_reason_empty = true;
if (remark) is_all_remark_empty = true;
// 单行任意一个存在,则该行所有输入框必填
if (goods_number || goods_price || apply_reason || remark) {
if (!goods_number) {
layer.tips('请填写数量', $(this).find('.adjust_number'));
is_one_empty = true;
return false;
}
if (!goods_price) {
layer.tips('请填写单价', $(this).find('.adjust_price'));
is_one_empty = true;
return false;
}
if (!apply_reason) {
layer.tips('请选择申请原因', $(this).find('.apply_reason'));
is_one_empty = true;
return false;
}
if (!remark) {
layer.tips('请填写原因备注', $(this).find('.remark'));
is_one_empty = true;
return false;
}
}
})
if (is_one_empty) return false;
......@@ -64,33 +126,57 @@
return false;
}
if (!is_all_reason_empty) {
layer.msg('请选择申请原因');
return false;
}
if (!is_all_remark_empty) {
layer.msg('请填写原因备注');
return false;
}
var datax = $('.orderServiceForm').serialize() + '&order_id=' + order_id;
$.ajax({
url : '/ajax/orderServiceApply',
url : '/ajax/orderServiceCheck',
type: 'post',
data: datax,
dataType: 'json',
success: function (resp) {
if(resp.errcode === 0){
layer.msg(resp.errmsg || '操作成功');
setTimeout(function(){
location.reload();
}, 1000);
var data = resp.data;
if (refund_type == 1 && !data) { // 退款方式为原路返回,且系统不满足原路返回
layer.msg('不满足原路返回条件,请更改退款方式');
return false;
}
layer.alert(resp.errmsg || '网络异常', function() {
location.reload();
});
return false;
if (refund_type != 1 && data) { // 退款方式非原路返回,且系统满足原路返回
layer.confirm('此售后单满足系统自动原路返回,是否需要原路返回?', {
title: '导出数据'
,btn: ['需要', '否,我要手工写单']
}, function(){ // 确定
layer.closeAll('dialog'); // 确定时关闭弹框
datax = datax + '&refund_type=1'; // 退款方式更新为原路返回
order_service(datax);
}, function() { // 取消
layer.closeAll('dialog'); // 确定时关闭弹框
order_service(datax);
});
return false;
}
order_service(datax); // 以上条件不满足时调用
},
error: function (res) {
console.log(res);
}
})
layer.msg('申请中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
})
},
btn2: function(index, layero){
layer.close(index);
......@@ -98,16 +184,46 @@
});
})
function order_service(datax)
{
$.ajax({
url : '/ajax/orderServiceApply',
type: 'post',
data: datax,
dataType: 'json',
success: function (resp) {
if(resp.errcode === 0){
layer.msg(resp.errmsg || '操作成功');
setTimeout(function(){
location.reload();
}, 1000);
return false;
}
layer.alert(resp.errmsg || '网络异常', function() {
location.reload();
});
return false;
},
error: function (res) {
console.log(res);
}
})
layer.msg('申请中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
}
// 全退
$('.orderServiceForm').find('.select-all').click(function() {
$('.order-service-table').find('tbody tr').each(function() {
var goods_number = parseInt($(this).find('.origin-goods-number').html());
var goods_number = parseInt($(this).find('.origin-goods-number').html());
var service_goods_number = parseInt($(this).find('.service-goods-number').html()) || 0;
var goods_price = $(this).find('.origin-goods-price').html();
var allow_num = (goods_number - service_goods_number) || '';
var single_pre_price = $(this).find('.single_pre_price').html();
var allow_num = (goods_number - service_goods_number) || '';
$(this).find('.adjust_number').val(allow_num);
$(this).find('.adjust_price').val(goods_price);
$(this).find('.adjust_price').val(single_pre_price);
})
})
......@@ -123,13 +239,13 @@
return false;
}
var goods_price = parseFloat($(this).parents('tr').find('.origin-goods-price').html()); // 原订单单价
var goods_number = parseInt($(this).parents('tr').find('.origin-goods-number').html()); // 原订单数量
var single_pre_price = parseFloat($(this).parents('tr').find('.single_pre_price').html()); // 原订单均摊单价
var goods_number = parseInt($(this).parents('tr').find('.origin-goods-number').html()); // 原订单数量
var service_goods_number = parseInt($(this).parents('tr').find('.service-goods-number').html()) || 0; // 已售后数量
var origin_amount = goods_price * (goods_number - service_goods_number); // 商品可退金额
var origin_amount = single_pre_price * (goods_number - service_goods_number); // 商品可退金额
if (val > (goods_number - service_goods_number)) {
layer.tips('不能超过订单数量', $(this));
layer.tips('不能超过订单可退数量', $(this));
$(this).val('');
return false;
}
......@@ -137,7 +253,7 @@
var adjust_price = $(this).parents('tr').find('.adjust_price').val();
var adjust_amount = adjust_price * val;
if (adjust_amount > origin_amount) {
if (parseFloat(adjust_amount) > parseFloat(origin_amount)) {
layer.tips('不能超过该条商品可退金额', $(this));
$(this).val('');
return false;
......@@ -177,7 +293,7 @@
var single_pre_price = $(this).parents('tr').find('.single_pre_price').val();
if (val > single_pre_price) {
if (parseFloat(val) > parseFloat(single_pre_price)) {
layer.tips('不能超过均摊单价', $(this));
$(this).val('');
return false;
......@@ -197,15 +313,15 @@
return false;
}
var goods_price = parseFloat($(this).parents('tr').find('.origin-goods-price').html()); // 原订单单价
var goods_number = parseInt($(this).parents('tr').find('.origin-goods-number').html()); // 原订单数量
var single_pre_price = parseFloat($(this).parents('tr').find('.single_pre_price').html()); // 原订单均摊单价
var goods_number = parseInt($(this).parents('tr').find('.origin-goods-number').html()); // 原订单数量
var service_goods_number = parseInt($(this).parents('tr').find('.service-goods-number').html()) || 0; // 已售后数量
var origin_amount = goods_price * (goods_number - service_goods_number); // 商品可退金额
var origin_amount = single_pre_price * (goods_number - service_goods_number); // 商品可退金额
var adjust_number = $(this).parents('tr').find('.adjust_number').val();
var adjust_amount = adjust_number * val;
if (adjust_amount > origin_amount) {
if (parseFloat(adjust_amount) > parseFloat(origin_amount)) {
layer.tips('不能超过该条商品可退金额', $(this));
$(this).val('');
return false;
......@@ -213,6 +329,45 @@
})
// 退款方式
$('.refund_type').change(function() {
var val = $(this).val();
if (val == 2) {
$('.alipay-info').show();
$('.bank-info').hide();
} else if (val == 3) {
$('.alipay-info').hide();
$('.bank-info').show();
} else {
$('.alipay-info').hide();
$('.bank-info').hide();
}
})
// 批量选择申请原因
$('.batch_apply_reason').change(function() {
var val = $(this).val();
if (!val) return false;
$('.order-service-table').find('tbody tr').each(function() {
$(this).find('.apply_reason').val(val);
})
})
// 批量选择申请原因
$('.batch_remark').blur(function() {
var val = $(this).val();
if (!val) return false;
$('.order-service-table').find('tbody tr').each(function() {
$(this).find('.remark').val(val);
})
})
},
......
<style>
.order_service_info{ display: none; }
.orderServiceForm{ padding: 20px; }
.apply_reason{ width: 300px; }
.service_type, .refund_type{ width: 300px; }
.orderServiceForm textarea{ width: 300px; padding: 6px 5px; border: 1px solid #ccc; border-radius: 4px; resize: none; }
.orderServiceForm input{ width: 120px; height: 34px; }
.order-service-table input{ width: 100px; height: 34px; }
.order-service-table .apply_reason{ width: 120px; }
.alipay-info, .bank-info{ display: none; }
.alipay-info .label-prompt, .bank-info .label-prompt{ width: 120px !important; padding-top: 7px; }
</style>
<div class="order_service_info">
<form class="form-horizontal orderServiceForm">
<div class="form-group">
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 申请原因:</label>
<table class="table table-bordered">
<thead>
<tr>
<th width="20%">支付时间</th>
<th width="20%">支付单号</th>
<th width="20%">支付类型</th>
<th width="20%">支付方式</th>
<th width="20%">支付金额</th>
</tr>
</thead>
<tbody>
@if (!empty($order_pay_log))
@foreach ($order_pay_log as $v)
<tr>
<td>{{ date('Y-m-d H:i:s', $v['pay_time']) }}</td>
<td>{{ 'S-'.$v['order_sn'].'-'.$v['pay_type'] }}</td>
<td>{{ array_get(Config('params.pay_type'), $v['pay_type'], '') }}</td>
<td>{{ $v['pay_name'] }}</td>
<td>{{ $v['pay_amount'] }}</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 售后类型:</label>
<div class="col-sm-10">
<select class="form-control apply_reason" name="apply_reason">
<option value=""></option>
@if (Config('order_service.apply_reason'))
@foreach (Config('order_service.apply_reason') as $k=>$v)
<select class="form-control service_type" name="service_type">
<option value="">请选择</option>
@if (Config('order_service.service_type'))
@foreach (Config('order_service.service_type') as $k=>$v)
<option value="{{ $k }}">{{ $v }}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 原因备注</label>
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 退款方式</label>
<div class="col-sm-10">
<textarea class="form-control remark" name="remark" placeholder="请填写备注" cols="60" rows="3"></textarea>
<select class="form-control refund_type" name="refund_type">
<option value="">请选择</option>
@if (Config('order_service.refund_type'))
@foreach (Config('order_service.refund_type') as $k=>$v)
<option value="{{ $k }}">{{ $v }}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="form-group alipay-info">
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 客户/公司:</label>
<div class="col-sm-4">
<input class="form-control ali_customer_name" name="ali_customer_name" placeholder="请填写客户/公司">
</div>
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 支付账号:</label>
<div class="col-sm-4">
<input class="form-control ali_refund_account" name="ali_refund_account" placeholder="请填写支付账号">
</div>
</div>
<div class="bank-info">
<div class="form-group">
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 客户/公司:</label>
<div class="col-sm-4">
<input class="form-control bank_customer_name" name="bank_customer_name" placeholder="请填写客户/公司">
</div>
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 银行账号:</label>
<div class="col-sm-4">
<input class="form-control bank_refund_account" name="bank_refund_account" placeholder="请填写银行账号">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 银行名称:</label>
<div class="col-sm-4">
<input class="form-control bank_name" name="bank_name" placeholder="请填写银行名称">
</div>
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 银行支行:</label>
<div class="col-sm-4">
<input class="form-control bank_sub_name" name="bank_sub_name" placeholder="请填写银行支行">
</div>
</div>
</div>
<div class="form-group">
<a class="btn btn-info select-all">全退</a>
</div>
......@@ -33,15 +107,26 @@
<table class="table table-bordered order-service-table">
<thead>
<tr>
<th width="5%"></th>
<th width="20%">型号</th>
<th width="20%">品牌</th>
<th width="4%"></th>
<th width="18%">型号</th>
<th width="18%">品牌</th>
<th width="8%">订单数量</th>
<th width="8%">出库数量</th>
<th width="8%">单价</th>
<th width="8%">均摊单价</th>
<th width="10%">已售后数量</th>
<th width="8%">申请数量</th>
<th width="8%">售后单价</th>
<th width="8%">
<select class="form-control batch_apply_reason" name="batch_apply_reason">
<option value="">请选择</option>
@if (Config('order_service.apply_reason'))
@foreach (Config('order_service.apply_reason') as $key=>$val)
<option value="{{ $key }}">{{ $val }}</option>
@endforeach
@endif
</select>
</th>
<th width="8%"><input type="text" class="batch_remark" name="batch_remark" placeholder="原因备注"></th>
</tr>
</thead>
<tbody>
......@@ -62,7 +147,7 @@
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][supplier_id]" value="{{ $v['supplier_id'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][supplier_name]" value="{{ $v['supplier_name'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][goods_price]" value="{{ $v['goods_price'] }}">
<input type="hidden" class="single_pre_price" name="service_item[{{ $v['rec_id'] }}][single_pre_price]" value="{{ $v['single_pre_price'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][single_pre_price]" value="{{ $v['single_pre_price'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][goods_number]" value="{{ $v['goods_number'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][removal_number]" value="{{ $v['fqty'] }}">
<td>{{ $goods_count }}</td>
......@@ -70,10 +155,21 @@
<td>{{ $v['brand_name'] }}</td>
<td class="origin-goods-number">{{ $v['goods_number'] }}</td>
<td>{{ $v['fqty'] }}</td>
<td class="origin-goods-price">{{ $v['goods_price'] }}</td>
<td class="single_pre_price">{{ $v['single_pre_price'] }}</td>
<td class="service-goods-number">{{ App\Http\Controllers\getOrderServiceNum($v['order_id'], $v['goods_id']) }}</td>
<td><input type="text" class="adjust_number" name="service_item[{{ $v['rec_id'] }}][adjust_number]"></td>
<td><input type="text" class="adjust_price" name="service_item[{{ $v['rec_id'] }}][adjust_price]"></td>
<td>
<select class="form-control apply_reason" name="service_item[{{ $v['rec_id'] }}][apply_reason]">
<option value="">请选择</option>
@if (Config('order_service.apply_reason'))
@foreach (Config('order_service.apply_reason') as $key=>$val)
<option value="{{ $key }}">{{ $val }}</option>
@endforeach
@endif
</select>
</td>
<td><input type="text" class="remark" name="service_item[{{ $v['rec_id'] }}][remark]"></td>
</tr>
@endif
@endforeach
......
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