Commit d4eb98dd by 朱继来

添加售后详情

parent b1384976
......@@ -446,5 +446,12 @@ class ApiController extends Controller
$this->Export($OrderServiceModel->action($request));
}
// 售后单明细列表
public function ApiOrderServiceItemsList($request)
{
$OrderServiceItemsModel = new OrderServiceItemsModel;
$this->ExportLayui($OrderServiceItemsModel->lists($request));
}
}
......@@ -24,6 +24,11 @@ use DB;
use App\Model\UserMainModel;
use App\Model\UserInfoModel;
use App\Model\UserCompanyModel;
use App\Model\OrderServiceModel;
use App\Model\OrderServiceItemsModel;
use App\Model\OrderServiceLogModel;
use App\Model\OrderExtendModel;
use App\Model\PayLogModel;
class WebController extends Controller
{
......@@ -387,4 +392,38 @@ class WebController extends Controller
return view('web', $data);
}
// 售后单详情
public function orderServiceDetails($request, $data, $id)
{
$service_id = $request->input('id', 0);
if (!$service_id) return redirect('/web/orderServiceList');
$data['title'] = '售后单详情';
$OrderServiceModel = new OrderServiceModel;
$OrderServiceLogModel = new OrderServiceLogModel;
$order_service = $OrderServiceModel->find($service_id);
// 用户账号
$UserMainModel = new UserMainModel;
$user = $UserMainModel->getUserAccount($order_service->user_id);
$order_service->user_account = $user->mobile ? $user->mobile : $user->email;
// ERP单号
$OrderExtendModel = new OrderExtendModel;
$order_service->erp_sn = $OrderExtendModel->where('order_id', $order_service->order_id)->value('erp_sn');
$data['order_service'] = $order_service;
$data['order_service_log'] = $OrderServiceLogModel->where('service_id', $service_id)->get();
// 获取收款信息
$PayLogModel = new PayLogModel;
$data['pay_log'] = $PayLogModel->where('order_id', $order_service->order_id)->get();
return view('web', $data);
}
}
......@@ -11,4 +11,29 @@ class OrderServiceItemsModel extends Model
protected $primaryKey = 'id';
public $timestamps = false;
// 获取领取列表
public function lists($request, $export='')
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$list = $this->orderBy('id', 'desc')->paginate($limit, ['*'], 'page', $page)->toArray();
$data = $this->handle($list['data']);
return [0, '获取成功', $data, $list['total']];
}
// 处理数据
public function handle($data)
{
if (!$data) return false;
foreach ($data as &$v) {
$v['amount'] = number_format($v['adjust_number'] * $v['adjust_price'], 2);
$v['refund_amount'] = number_format($v['goods_number'] * $v['goods_price'], 2);
}
return $data;
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ class OrderServiceModel extends Model
protected $connection = 'order';
protected $table = 'lie_order_service';
protected $primaryKey = 'id';
protected $guarded = ['id'];
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
......@@ -78,7 +79,7 @@ class OrderServiceModel extends Model
$query->where('create_time', '<=', $map['end_time']);
}
})
->orderBy('id', 'asc');
->orderBy('id', 'desc');
// $tmp = str_replace('?', '"'.'%s'.'"', $list->toSql());
// $tmp = vsprintf($tmp, $list->getBindings());
// echo $tmp;exit;
......
......@@ -134,4 +134,12 @@
3 => '国产替代',
],
// 支付类型
'pay_type' => [
1 => '全额付款',
2 => '预付款',
3 => '尾款',
4 => '账期',
],
];
\ No newline at end of file
layui.use(['form', 'table', 'element'], function(){
var form = layui.form;
var table = layui.table;
var element = layui.element;
table.render({
id: 'list'
,elem: '#order-service-items'
,url: '/api/ApiOrderServiceItemsList' //数据接口
,where: {
service_id: service_id
}
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
,cols: [[ //表头
{title: '序号', type: 'numbers', fixed: 'left', width: 78}
,{field: 'goods_name', title: '型号', width: 240}
,{field: 'brand_name', title: '品牌', width: 240}
,{field: 'goods_number', title: '原数量', width: 120}
,{field: 'goods_price', title: '原单价', width: 120}
,{field: 'adjust_number', title: '申请数量', width: 120}
,{field: 'adjust_price', title: '售后单价', width: 120}
,{field: 'amount', title: '小计', width: 120}
,{field: 'refund_amount', title: '可退款金额', width: 120}
,{field: 'removal_number', title: '已出库数量', width: 120}
,{field: 'put_warehouse_number', title: '退货入库数量', width: 120}
]]
,limit: 10
,limits: [10, 20, 50,]
});
// tool操作
table.on('tool(list)', function(obj){ //注:tool是工具条事件名,test是table原始容器的属性lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var tr = obj.tr; //获得当前行 tr 的DOM对象
var title = '';
var content = '';
var url = '/api/ApiOrderServiceAction';
var datax = [];
if(layEvent === 'submit'){ // 提交
title = '提交申请';
content = '确定提交该申请吗?';
datax = {id: data.id, service_status: 2};
} else if(layEvent === 'audit'){ // 审核
title = '审核申请';
content = '确定审核该申请吗?';
datax = {id: data.id, service_status: 3};
}else if(layEvent === 'cancel'){ // 取消
title = '取消申请';
content = '确定取消该申请吗?';
datax = {id: data.id, service_status: -1};
}
layer.open({
title: title,
content: content,
btn: ['确认', '取消'],
yes: function(index) {
$.ajax({
url : url,
type: 'post',
data: datax,
dataType: 'json',
success: function(resp) {
console.log(resp)
if (resp.errcode == 0) {
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
$('.search').trigger("click"); // 触发搜索按钮
return false;
}
layer.alert(resp.errmsg);
},
error: function(err) {
console.log(err)
}
})
layer.msg(title+'中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
},
cancel: function(index) {
layer.close(index);
}
})
});
});
\ No newline at end of file
<style type="text/css">
.order-service .layui-colla-title{ margin-top: 0px; margin-bottom: 0px; }
table tr td{ text-align: center; }
.td-title{ width: 10%; font-weight: 700; background: #F2F2F2; }
.td-txt{ width: 20%; }
</style>
<div class="layui-collapse order-service">
<div class="layui-colla-item">
<h2 class="layui-colla-title">基本信息</h2>
<div class="layui-colla-content layui-show">
<table class="layui-table">
<tr>
<td class="td-title">售后单号</td>
<td class="td-txt">{{ $order_service->service_sn }}</td>
<td class="td-title">客户</td>
<td class="td-txt">{{ $order_service->user_account }}</td>
<td class="td-title">售后状态</td>
<td class="td-txt">{{ array_get(Config('order_service.service_status'), $order_service->service_status, '') }}</td>
</tr>
<tr>
<td class="td-title">创建时间</td>
<td class="td-txt">{{ $order_service->create_time }}</td>
<td class="td-title">申请人</td>
<td class="td-txt">{{ $order_service->apply_name }}</td>
<td class="td-title">退款状态</td>
<td class="td-txt">{{ array_get(Config('order_service.refund_status'), $order_service->refund_status, '') }}</td>
</tr>
<tr>
<td class="td-title">审核时间</td>
<td class="td-txt">{{ $order_service->auditor_time ? date('Y-m-d H:i:s', $order_service->auditor_time) : '' }}</td>
<td class="td-title">审核人</td>
<td class="td-txt">{{ $order_service->auditor_name }}</td>
<td class="td-title">退货状态</td>
<td class="td-txt">{{ array_get(Config('order_service.return_status'), $order_service->return_status, '') }}</td>
</tr>
<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>
</tr>
<tr>
<td class="td-title">关联销售单</td>
<td class="td-txt">{{ $order_service->order_sn }}</td>
<td class="td-title">关联ERP单号</td>
<td class="td-txt">{{ $order_service->erp_sn }}</td>
<td class="td-title">关联退款单</td>
<td class="td-txt">{{ $order_service->refund_sn }}</td>
</tr>
</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>
@if (!empty($pay_log))
@foreach ($pay_log as $k=>$v)
<tr>
<td>{{ $v->pay_time ? 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
</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>
</div>
</div>
@if ( $order_service->status == 1)
<div class="layui-btn-container" style="text-align: center; margin: 20px 0;">
<button lay-submit lay-filter="save" class="layui-btn layui-btn-normal save" data-type="1">保存</button>
<button lay-submit lay-filter="save" class="layui-btn layui-btn-info submit_audit" data-type="2">提交审核</button>
</div>
@endif
<!-- 操作日志 -->
@if (!empty($order_service_log))
<div class="layui-colla-item">
<h2 class="layui-colla-title">操作日志</h2>
<div class="layui-colla-content layui-show">
<table class="table table-bordered">
<thead>
<tr>
<th width="15%">操作时间</th>
<th width="15%">操作人</th>
<th>操作事件</th>
</tr>
</thead>
<tbody>
@foreach($order_service_log as $v_log)
<tr>
<td>{{date("Y-m-d H:i:s", $v_log['create_time'])}}</td>
<td>{{$v_log['operator_name']}}</td>
<td style="word-break: break-all;">{{$v_log['event']}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endif
</div>
<script>
var service_id = "{{ $order_service->id }}";
</script>
......@@ -118,7 +118,7 @@
</script>
<script type="text/html" id="list_action">
<a class="btn btn-xs btn-outline btn-info" href="/web/orderServiceDetails?user_id=@{{ d.user_id }}&id=@{{ d.id }}" target="_blank">详情</a>
<a class="btn btn-xs btn-outline btn-info" href="/web/orderServiceDetails?id=@{{ d.id }}" target="_blank">详情</a>
@{{# if (d.service_status == 1) { }}
<a class="btn btn-xs btn-outline btn-success" lay-event="submit">提交</a>
......
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