Commit ad0240d3 by 朱继来

调整售后编辑、详情页

parent f0bb5e86
......@@ -29,6 +29,7 @@ use App\Model\OrderServiceItemsModel;
use App\Model\OrderServiceLogModel;
use App\Model\OrderExtendModel;
use App\Model\PayLogModel;
use App\Model\OrderInvoiceModel;
class WebController extends Controller
{
......@@ -423,6 +424,10 @@ class WebController extends Controller
$PayLogModel = new PayLogModel;
$data['pay_log'] = $PayLogModel->where('order_id', $order_service->order_id)->orderBy('pay_log_id', 'desc')->get();
// 订单发票信息
$OrderInvoiceModel = new OrderInvoiceModel;
$data['order_invoice'] = $OrderInvoiceModel->where('order_id', $order_service->order_id)->first();
return view('web', $data);
}
......
......@@ -35,8 +35,9 @@ class OrderServiceItemsModel extends Model
continue;
}
$v['amount'] = number_format($v['adjust_number'] * $v['adjust_price'], 2);
$v['refund_amount'] = number_format($v['goods_number'] * $v['single_pre_price'], 2);
$v['amount'] = number_format($v['adjust_number'] * $v['adjust_price'], 2);
$v['refund_amount'] = number_format($v['goods_number'] * $v['single_pre_price'], 2);
$v['apply_reason_val'] = array_get(Config('order_service.apply_reason'), $v['apply_reason'], '');
}
return $data;
......
......@@ -192,10 +192,20 @@ class OrderServiceModel extends Model
$event = '编辑售后单';
$info = $this->find($id);
$event .= ',修改前---申请理由:'.array_get(Config('order_service.apply_reason'), $info['apply_reason'], '').',备注:'.$info['remark'];
$order_service['apply_reason'] = $request->input('apply_reason');
$order_service['remark'] = $request->input('remark');
$event .= ',修改前---售后类型:'.array_get(Config('order_service.service_type'), $info['service_type'], '').',退款方式:'.array_get(Config('order_service.refund_type'), $info['refund_type'], '');
$order_service['service_type'] = $request->input('service_type');
$order_service['refund_type'] = $request->input('refund_type');
if ($order_service['refund_type'] == 2) { // 支付宝
$order_service['customer_name'] = $request->input('ali_customer_name');
$order_service['refund_account'] = $request->input('ali_refund_account');
} else if ($order_service['refund_type'] == 3) { // 银行
$order_service['customer_name'] = $request->input('bank_customer_name');
$order_service['refund_account'] = $request->input('bank_refund_account');
$order_service['bank_name'] = $request->input('bank_name');
$order_service['bank_sub_name'] = $request->input('bank_sub_name');
}
$res = $this->where('id', $id)->update($order_service);
......@@ -208,7 +218,7 @@ class OrderServiceModel extends Model
$event .= ',售后明细:';
foreach ($service_items as $k=>$v) {
$item = $OrderServiceItemsModel->find($k);
$event .= '['.$item['goods_name'].' | '.$item['adjust_number'].' | '.$item['adjust_price'].'] ';
$event .= '['.$item['goods_name'].' | '.$item['adjust_number'].' | '.$item['adjust_price'].' | '.'申请原因:'.array_get(Config('order_service.apply_reason'), $item['apply_reason'], '').' | '.'备注:'.$item['remark'].'] ';
$v['update_time'] = time();
......
......@@ -141,5 +141,20 @@
3 => '尾款',
4 => '账期',
],
'order_inv_type' => [ // 订单发票类型
1 => '不开发票',
2 => '普通发票',
3 => '增值税专用发票',
4 => '增值税普通发票',
],
'order_invoice_status' => [ // 订单发票状态
-1 => '待确认',
1 => '已开票',
2 => '已发货',
3 => '已签收',
],
];
\ No newline at end of file
......@@ -16,8 +16,8 @@
content: $('.order_service_info'),
btn:['确定', '取消'],
yes: function(index, layero){
var service_type = $('.service_type').val();
var refund_type = $('.refund_type').val();
var service_type = $('.service_type').val();
var refund_type = $('.refund_type').val();
if (!service_type) {
layer.tips('请选择售后类型', $('.service_type'));
......@@ -291,7 +291,7 @@
$(this).val(val.slice(0, 12));
}
var single_pre_price = $(this).parents('tr').find('.single_pre_price').val();
var single_pre_price = $(this).parents('tr').find('.single_pre_price').text();
if (parseFloat(val) > parseFloat(single_pre_price)) {
layer.tips('不能超过均摊单价', $(this));
......
......@@ -25,6 +25,8 @@ layui.use(['form', 'table', 'element'], function(){
,{field: 'refund_amount', title: '可退款金额', width: 120}
,{field: 'removal_number', title: '已出库数量', width: 120}
,{field: 'put_warehouse_number', title: '退货入库数量', width: 120}
,{field: 'apply_reason_val', title: '申请原因', width: 120}
,{field: 'remark', title: '原因备注', width: 200}
]]
,limit: 10
,limits: [10, 20, 50,]
......
......@@ -87,40 +87,73 @@ layui.use(['form', 'table', 'laydate'], function(){
datax = {id: data.id};
} else if (layEvent === 'edit'){ // 编辑
type = 1;
area = ['1000px', '600px'];
area = ['1200px', '700px'];
title = '编辑申请';
content = $('.order_service_info');
// 填充内容
$('.apply_reason').val(data.apply_reason);
$('.remark').val(data.remark);
$('.service_type').val(data.service_type);
$('.refund_type').val(data.refund_type);
var html = '';
if (data.refund_type == 2) { // 支付宝
$('.alipay-info').show();
$('.ali_customer_name').val(data.customer_name);
$('.ali_refund_account').val(data.refund_account);
} else if (data.refund_type == 2) { // 银行
$('.bank-info').show();
$('.bank_customer_name').val(data.customer_name);
$('.bank_refund_account').val(data.refund_account);
$('.bank_name').val(data.bank_name);
$('.bank_sub_name').val(data.bank_sub_name);
}
var html = '';
var items = data.items;
var len = items.length;
var len = items.length;
for (var i = 0; i < len; i++) {
html += '<tr>\
<input type="hidden" class="single_pre_price" name="service_item['+items[i].id+'][single_pre_price]" value="'+ items[i].single_pre_price +'">\
<td>'+ (i + 1) +'</td>\
<td>'+ items[i].goods_name +'</td>\
<td>'+ items[i].brand_name +'</td>\
<td class="origin-goods-number">'+ items[i].goods_number +'</td>\
<td>'+ items[i].removal_number +'</td>\
<td class="origin-goods-price">'+ items[i].goods_price +'</td>\
<td class="single_pre_price">'+ items[i].single_pre_price +'</td>\
<td class="service-goods-number"></td>';
if (items[i].adjust_number != 0) {
html += '<td><input type="text" class="adjust_number" name="service_item['+items[i].id+'][adjust_number]" value="'+ items[i].adjust_number +'"></td>';
html += '<td><input type="text" class="form-control adjust_number" name="service_item['+items[i].id+'][adjust_number]" value="'+ items[i].adjust_number +'"></td>';
} else {
html += '<td><input type="text" class="adjust_number" name="service_item['+items[i].id+'][adjust_number]"></td>';
html += '<td><input type="text" class="form-control adjust_number" name="service_item['+items[i].id+'][adjust_number]"></td>';
}
if (items[i].adjust_price != 0.000000) {
html += '<td><input type="text" class="adjust_price" name="service_item['+items[i].id+'][adjust_price]" value="'+ items[i].adjust_price +'"></td>';
html += '<td><input type="text" class="form-control adjust_price" name="service_item['+items[i].id+'][adjust_price]" value="'+ items[i].adjust_price +'"></td>';
} else {
html += '<td><input type="text" class="adjust_price" name="service_item['+items[i].id+'][adjust_price]"></td>';
}
html += '<td><input type="text" class="form-control adjust_price" name="service_item['+items[i].id+'][adjust_price]"></td>';
}
// 申请原因
var str = '';
for (var j in apply_reason) {
if (j == items[i].apply_reason) {
str += '<option value="'+j+'" selected>'+apply_reason[j]+'</option>';
} else {
str += '<option value="'+j+'">'+apply_reason[j]+'</option>';
}
}
html += '<td>\
<select class="form-control apply_reason" name="service_item['+items[i].id+'][apply_reason]">\
<option value="">请选择</option>\
'+str+'\
</select>\
</td>';
html += '<td><input type="text" class="form-control remark" name="service_item['+items[i].id+'][remark]" value="'+ items[i].remark +'"></td>';
html += '</tr>';
}
......@@ -138,40 +171,102 @@ layui.use(['form', 'table', 'laydate'], function(){
btn: ['确认', '取消'],
yes: function(index) {
if (layEvent == 'edit') {
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;
......@@ -186,7 +281,62 @@ layui.use(['form', 'table', 'laydate'], function(){
return false;
}
datax = $('.orderServiceForm').serialize() + '&id=' + data.id;
if (!is_all_reason_empty) {
layer.msg('请选择申请原因');
return false;
}
if (!is_all_remark_empty) {
layer.msg('请填写原因备注');
return false;
}
datax = $('.orderServiceForm').serialize() + '&order_id=' + data.order_id + '&id=' + data.id;
$.ajax({
url : '/ajax/orderServiceCheck',
type: 'post',
data: datax,
dataType: 'json',
success: function (resp) {
var data = resp.data;
if (refund_type == 1 && !data) { // 退款方式为原路返回,且系统不满足原路返回
layer.msg('不满足原路返回条件,请更改退款方式');
return false;
}
if (refund_type != 1 && data) { // 退款方式非原路返回,且系统满足原路返回
layer.confirm('此售后单满足系统自动原路返回,是否需要原路返回?', {
title: '导出数据'
,btn: ['需要', '否,我要手工写单']
}, function(){ // 确定
layer.closeAll('dialog'); // 确定时关闭弹框
layer.close(index);
datax = datax + '&refund_type=1'; // 退款方式更新为原路返回
order_service(datax);
}, function() { // 取消
layer.closeAll('dialog'); // 确定时关闭弹框
layer.close(index);
order_service(datax);
});
return false;
}
layer.close(index);
order_service(datax); // 以上条件不满足时调用
},
error: function (res) {
console.log(res);
}
})
return false;
}
$.ajax({
......@@ -222,6 +372,34 @@ layui.use(['form', 'table', 'laydate'], function(){
})
});
function order_service(datax)
{
$.ajax({
url : '/api/ApiOrderServiceEdit',
type: 'post',
data: datax,
dataType: 'json',
success: function (resp) {
if(resp.errcode === 0){
layer.msg(resp.errmsg || '操作成功');
renderTable(); // 重新加载table
$('.search').trigger("click"); // 触发搜索按钮
return false;
}
layer.alert(resp.errmsg || '网络异常');
return false;
},
error: function (res) {
console.log(res);
}
})
layer.msg('编辑中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
}
// 导出
// $('.export').click(function() {
// var account = $('input[name=account]').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; }
.col-sm-2{ width: 14%; }
</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>
<label class="col-sm-2 control-label"><i class="text-danger">*</i> 售后类型</label>
<div class="col-sm-9">
<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-9">
<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 +81,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="form-control batch_remark" name="batch_remark" placeholder="原因备注"></th>
</tr>
</thead>
<tbody>
......
......@@ -37,10 +37,10 @@
<tr>
<td class="td-title">是否需要退货</td>
<td class="td-txt">{{ $order_service->is_return == 1 ? '是' : '否' }}</td>
<td class="td-title">申请原因</td>
<td class="td-txt">{{ array_get(Config('order_service.apply_reason'), $order_service->apply_reason, '') }}</td>
<td class="td-title">备注</td>
<td class="td-txt">{{ $order_service->remark }}</td>
<td class="td-title">售后类型</td>
<td class="td-txt">{{ array_get(Config('order_service.service_type'), $order_service->service_type, '') }}</td>
<td class="td-title">退款方式</td>
<td class="td-txt">{{ array_get(Config('order_service.refund_type'), $order_service->refund_type, '') }}</td>
</tr>
<tr>
<td class="td-title">关联销售单</td>
......@@ -82,6 +82,58 @@
</div>
<div class="layui-colla-item">
<h2 class="layui-colla-title">订单发票信息</h2>
<div class="layui-colla-content layui-show">
<table class="layui-table">
<tr>
<td width="20%">发票类型</td>
<td width="20%">发票抬头</td>
<td width="20%">公司地址</td>
<td width="20%">税务登记号</td>
<td width="20%">开票状态</td>
</tr>
@if ( $order_invoice->inv_type == 1)
<tr>
<td colspan="5">不开发票</td>
</tr>
@else
<tr>
<td>{{ array_get(Config('params.order_inv_type'), $order_invoice->inv_type, '') }}</td>
<td>{{ $order_invoice->tax_title }}</td>
<td>{{ $order_invoice->company_address }}</td>
<td>{{ $order_invoice->tax_no }}</td>
<td>{{ array_get(Config('params.order_invoice_status'), $order_invoice->invoice_status, '') }}</td>
</tr>
@endif
</table>
</div>
</div>
<div class="layui-colla-item">
<h2 class="layui-colla-title">退款信息</h2>
<div class="layui-colla-content layui-show">
<table class="layui-table">
<tr>
<td width="20%">退款类型</td>
<td width="20%">客户/公司</td>
<td width="20%">账号</td>
<td width="20%">银行名称</td>
<td width="20%">支行名称</td>
</tr>
<tr>
<td>{{ array_get(Config('order_service.refund_type'), $order_service->refund_type, '') }}</td>
<td>{{ $order_service->customer_name }}</td>
<td>{{ $order_service->refund_account }}</td>
<td>{{ $order_service->bank_name }}</td>
<td>{{ $order_service->bank_sub_name }}</td>
</tr>
</table>
</div>
</div>
<div class="layui-colla-item">
<h2 class="layui-colla-title">售后明细</h2>
<div class="layui-colla-content layui-show">
<table id="order-service-items" lay-filter="order-service-items"></table>
......
......@@ -134,4 +134,10 @@
@{{# } }}
</script>
<script>
var apply_reason = eval('('+'{!! json_encode(Config("order_service.apply_reason")) !!}'+')');
console.log(apply_reason)
console.log(apply_reason.length)
</script>
@include('common.order_service')
\ 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