Commit a43d4027 by 朱继来

申请售后单

parent 086298de
......@@ -25,6 +25,9 @@ use App\Model\BrandBlackListModel;
use App\Model\PayExtendModel;
use Illuminate\Support\Facades\Redis;
use App\Model\ShoppingCartModel;
use App\Model\OrderServiceModel;
use App\Model\OrderServiceItemsModel;
use App\Model\OrderServiceLogModel;
class ApiController extends Controller
{
......@@ -429,5 +432,12 @@ class ApiController extends Controller
$this->Export(0, '成功');
}
// 售后单列表
public function ApiOrderServiceList($request)
{
$OrderServiceModel = new OrderServiceModel;
$this->ExportLayui($OrderServiceModel->lists($request));
}
}
......@@ -1501,6 +1501,27 @@ Class OrderController extends Controller
return view('changeInvoice', $info);
}
// 订单售后
public function orderServiceApply(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/apply';
$update = json_decode(curlApi($update_url, $data, 'POST'), true);
if ($update['err_code'] != 0) return array('errcode'=>-1,'errmsg'=>'操作失败');
return array('errcode'=>0,'errmsg'=>'操作成功');
}
}
// 订单详情页面头部信息
public function pageHeader($request, &$info, $title, $addInfo=[])
{
......
......@@ -19,6 +19,7 @@ use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Controllers\PermController;
use DB;
use App\Model\UserMainModel;
use App\Model\UserInfoModel;
......@@ -375,4 +376,15 @@ class WebController extends Controller
return view('web', $data);
}
// 售后单列表
public function orderServiceList($request, $data, $id)
{
$data['title'] = '售后单列表';
$perm = new PermController;
$data['sale_list'] = $perm->getUserByDepartmentId(Config('perm_args.sales_department_id')); // 获取所有的销售
return view('web', $data);
}
}
......@@ -72,7 +72,6 @@ Route::group(['middleware' => 'web'], function () {
Route::post('/ajax/orderAmountInfoLoading', 'OrderCountController@orderAmountInfoLoading');
Route::match('post', '/ajaxDelayTime', 'OrderController@ajaxDelayTime');
Route::match('post', '/ajaxRejected', 'OrderController@ajaxRejected');
Route::get('/self_order', 'OrderController@selfOrder');
......@@ -87,6 +86,7 @@ Route::group(['middleware' => 'web'], function () {
// Route::post('/ajaxInputCancelReason', 'OrderController@ajaxInputCancelReason');
Route::post('/ajax/shipping', 'OrderController@shipping');
Route::post('/ajax/orderServiceApply', 'OrderController@orderServiceApply');
Route::get('/add_order', 'AddOrderController@addOrder');
Route::post('/ajax/getUserInfo', 'AddOrderController@getUserInfo');
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
class OrderServiceItemsModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_service_items';
protected $primaryKey = 'id';
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use App\Model\CmsModel;
class OrderServiceLogModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_service_log';
protected $primaryKey = 'id';
public $timestamps = false;
/**
* 操作记录
* @param [Integer] $service_id [售后单ID]
* @param [Integer] $operator_id [操作人]
* @param [string] $event [操作事件]
* @return [type] [description]
*/
static public function addLog($service_id, $operator_id, $event='')
{
$CmsModel = new CmsModel;
$log['service_id'] = $service_id;
$log['operator_id'] = $operator_id;
$log['operator_name'] = $CmsModel->getUserName($operator_id);
$log['event'] = $event;
$log['ip'] = get_client_ip(0, true);
$log['create_time'] = time();
$actionLog = $this->insert($log);
if (!$actionLog) return false;
return $actionLog;
}
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
use App\Model\UserMainModel;
class OrderServiceModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_service';
protected $primaryKey = 'id';
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
/** * @param \DateTime|int $value * @return false|int * @author dividez */
public function fromDateTime($value)
{
return strtotime(parent::fromDateTime($value));
}
// 获取领取列表
public function lists($request, $export='')
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$map['service_sn'] = $request->input('service_sn', ''); // 售后单号
$map['order_sn'] = $request->input('order_sn', ''); // 订单号
$map['apply_id'] = $request->input('apply_id', ''); // 申请人
$map['service_status'] = $request->input('service_status', ''); // 售后状态
$map['refund_status'] = $request->input('refund_status', ''); // 退款状态
$map['return_status'] = $request->input('return_status', ''); // 退货状态
$map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$list = $this->where(function($query) use ($map) {
// 售后单号
if ($map['service_sn']) {
$query->where('service_sn', '=', $map['service_sn']);
}
})->where(function($query) use ($map) {
// 订单号
if ($map['order_sn']) {
$query->where('order_sn', '=', $map['order_sn']);
}
})->where(function($query) use ($map) {
// 申请人
if ($map['apply_id']) {
$query->where('apply_id', '=', $map['apply_id']);
}
})->where(function($query) use ($map) {
// 售后状态
if ($map['service_status']) {
$query->where('service_status', '=', $map['service_status']);
}
})->where(function($query) use ($map) {
// 退款状态
if ($map['refund_status']) {
$query->where('refund_status', '=', $map['refund_status']);
}
})->where(function($query) use ($map) {
// 退货状态
if ($map['return_status']) {
$query->where('return_status', '=', $map['return_status']);
}
})->where(function($query) use ($map) {
// 创建时间
if(!empty($map['begin_time']) && !empty($map['end_time'])) {
$query->whereBetween('create_time', [$map['begin_time'], $map['end_time']]);
}
else if(!empty($map['begin_time'])) {
$query->where('create_time', '>=', $map['begin_time']);
}
else if(!empty($map['end_time'])) {
$query->where('create_time', '<=', $map['end_time']);
}
})
->orderBy('id', 'asc');
// $tmp = str_replace('?', '"'.'%s'.'"', $list->toSql());
// $tmp = vsprintf($tmp, $list->getBindings());
// echo $tmp;exit;
if ($export) {
$list = $list->get()->toArray();
$list = $this->handle($list);
if (empty($list)) {
echo '<script>alert("导出数据为空");history.go(-1);</script>';die;
}
return $list;
} else {
$list = $list->paginate($limit, ['*'], 'page', $page)->toArray();
$data = $this->handle($list['data']);
return [0, '获取成功', $data, $list['total']];
}
}
// 处理数据
public function handle($data)
{
if (!$data) return false;
$UserMainModel = new UserMainModel;
foreach ($data as &$v) {
$user = $UserMainModel->getUserAccount($v['user_id']);
$v['user_account'] = $user->mobile ? $user->mobile : $user->email;
$v['service_status_val'] = array_get(Config('order_service.service_status'), $v['service_status'], '');
$v['refund_status_val'] = array_get(Config('order_service.refund_status'), $v['refund_status'], '');
$v['return_status_val'] = array_get(Config('order_service.return_status'), $v['return_status'], '');
}
return $data;
}
}
\ No newline at end of file
<?php
return [
// 售后状态
'service_status' => [
-1 => '取消',
1 => '待提交',
2 => '待审核',
3 => '审核通过',
],
// 退款状态
'refund_status' => [
1 => '待生成',
2 => '待退款',
3 => '已退款',
],
// 退货状态
'return_status' => [
1 => '待生成',
2 => '待退款',
3 => '已退款',
],
// 退货状态
'apply_reason' => [
1 => '型号下错',
2 => '测试单',
],
];
+(function($){
$.lie = $.lie || {version: "v1.0.0"};
$.extend($.lie, {
order_service: {
index:function() {
// 售后申请
$('.order_service').click(function() {
var order_id = $(this).data('id');
// 弹出提示
layer.open({
type: 1,
area: ['1000px', '600px'],
title: '售后申请',
content: $('.order_service_info'),
btn:['确定', '取消'],
yes: function(index, layero){
var apply_reason = $('.apply_reason').val();
var remark = $('.remark').val();
var is_empty = false; // 校验申请数量、单价是否为空
if (!apply_reason) {
layer.tips('请选择申请原因', $('.apply_reason'));
return false;
}
if (!remark) {
layer.tips('请填写备注', $('.remark'));
return 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 (!goods_number) {
layer.tips('请填写申请数量', $(this).find('.adjust_number'));
is_empty = true;
return false;
}
if (!goods_price) {
layer.tips('请填写售后单价', $(this).find('.adjust_price'));
is_empty = true;
return false;
}
})
if (is_empty) return false;
var datax = $('.orderServiceForm').serialize() + '&order_id=' + order_id;
$.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}); // 阻止重复提交
},
btn2: function(index, layero){
layer.close(index);
}
});
})
// 全退
$('.orderServiceForm').find('.select-all').click(function() {
$('.order-service-table').find('tbody tr').each(function() {
var goods_number = $(this).find('.origin-goods-number').html();
var goods_price = $(this).find('.origin-goods-price').html();
$(this).find('.adjust_number').val(goods_number);
$(this).find('.adjust_price').val(goods_price);
})
})
// 数量输入校验
$('.adjust_number').keyup(function() {
var val = $(this).val();
if (!val) return false;
if (!(/\d/.test(val)) || val <= 0) {
layer.msg('只能是数字,且为正整数');
$(this).val('');
return false;
}
var goods_number = parseInt($(this).parents('tr').find('.origin-goods-number').html()); // 订单数量
if (val > goods_number) {
layer.msg('不能超过订单数量');
$(this).val('');
return false;
}
})
// 单价输入校验
$('.adjust_price').keyup(function() {
var val = $(this).val();
if (!val) return false;
if(!(/^\d{0,6}(\.\d{0,6})?$/g.test(val))){//判断输入是否合法,不合法强制转换
if(isNaN(parseFloat(val))){
layer.msg('只能是数字和小数组成');
$(this).val('');
}else{
$(this).val(parseFloat(val).toFixed(6));
}
}
if (val < 0) {
layer.msg('只能是正整数');
$(this).val('');
return false;
}
if(val > 999999.999999){
$(this).val(999999.999999);
}
if(val.length > 12){
$(this).val(val.slice(0, 12));
}
}).blur(function() {
var val = $(this).val();
if (!val) return false;
if (val == 0) {
layer.msg('单价不能为0');
$(this).val('');
return false;
}
})
},
}
})
})(jQuery)
\ No newline at end of file
layui.use(['form', 'table', 'laydate'], function(){
var form = layui.form;
var table = layui.table;
var laydate = layui.laydate;
laydate.render({
elem: '#begin_time' //指定元素
});
laydate.render({
elem: '#end_time' //指定元素
});
table.render({
id: 'list'
,elem: '#sample'
,url: '/api/ApiOrderServiceList' //数据接口
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
,cols: [[ //表头
{title: '序号', type: 'numbers', fixed: 'left', width: 80}
,{field: 'service_sn', title: '售后单号', width: 100}
,{field: 'order_sn', title: '订单编号', width: 150}
,{field: 'user_account', title: '用户账号', width: 100}
,{field: 'apply_name', title: '申请人', width: 120}
,{field: 'auditor_name', title: '审核人', width: 120}
,{field: 'service_status_val', title: '售后状态', width: 120}
,{field: 'refund_status_val', title: '退款状态', width: 120}
,{field: 'return_status_val', title: '退款状态', width: 120}
,{field: 'create_time', title: '申请时间', width: 180}
,{field: 'auditor_time', title: '审核时间', width: 180}
,{title: '操作', align:'center', fixed: 'right', toolbar: '#list_action', width: 200}
]]
,limit: 10
,limits: [10, 20, 50,]
});
form.on('submit(load)', function(data) {
//执行重载
table.reload('list', {
page: {
curr: 1
}
,where: data.field
});
return false;
});
// 导出
$('.export').click(function() {
var account = $('input[name=account]').val(),
goods_name = $('input[name=goods_name]').val(),
order_sn = $('input[name=order_sn]').val(),
begin_time = $('input[name=begin_time]').val(),
end_time = $('input[name=end_time]').val(),
url = '/export/selfSampleExport';
if (!account && !goods_name && !order_sn && !begin_time && !end_time) {
layer.msg('请选择筛选条件');
return false;
}
layer.confirm('确定导出数据吗?', {
title: '导出数据'
,btn: ['确定', '取消']
}, function(){
layer.closeAll('dialog'); // 确定时关闭弹框
window.location.href = url+'?account='+account+'&goods_name='+goods_name+'&order_sn='+order_sn+'&begin_time='+begin_time+'&end_time='+end_time;
});
})
// 工具尺邀约记录导出
$('.invite_export').click(function() {
var url = '/export/rulesInviteExport';
layer.confirm('确定导出数据吗?', {
title: '导出数据'
,btn: ['确定', '取消']
}, function(){
layer.closeAll('dialog'); // 确定时关闭弹框
window.location.href = url;
});
})
});
\ No newline at end of file
......@@ -210,6 +210,11 @@
<!-- <a href="{{URL('refund', ['order_id'=>$order_info['order_id']])}}" class="btn btn-info order_refund">退货退款</a> -->
@endif
<!-- 售后申请 -->
@if ($order_info['status'] > 2 && $order_info['status'] < 10)
<a class="btn btn-info order_service" data-id="{{$order_info['order_id']}}">售后申请</a>
@endif
<!-- 已发货之后的状态 -->
@if ($order_info['status'] == 10)
<a href="{{URL('invShipping', ['order_id'=>$order_info['order_id']])}}" class="btn btn-default">寄送发票</a>
......@@ -365,6 +370,8 @@
</script>
@endif
@include('detail.order_service')
<script>
// 退款申请已处理或已拒绝,则隐藏退款按钮
var refund = "{{!empty($order_refund_info) && ($order_refund_info['status'] == -1 || $order_refund_info['status'] == 10) ? false : true}}";
......@@ -383,5 +390,5 @@
$.lie.audit.index();
$.lie.send_mail.index();
$.lie.cancel.cancelorder();
$.lie.order_service.index();
</script>
\ No newline at end of file
......@@ -17,5 +17,6 @@
<script src="/js/order_cancel.js?v=<?= time() ?>"></script>
<script src="/js/order_send_email.js"></script>
<script src="/js/refund.js?v=<?= time() ?>"></script>
<script src="/js/order_service.js?v=<?= time() ?>"></script>
<style>
.order_service_info{ display: none; }
.orderServiceForm{ padding: 20px; }
.apply_reason{ width: 300px; }
.orderServiceForm textarea{ width: 300px; padding: 6px 5px; border: 1px solid #ccc; border-radius: 4px; resize: none; }
.orderServiceForm input{ width: 120px; height: 34px; }
</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>
<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)
<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>
<div class="col-sm-10">
<textarea class="form-control remark" name="remark" placeholder="请填写备注" cols="60" rows="3"></textarea>
</div>
</div>
<div class="form-group">
<a class="btn btn-info select-all">全退</a>
</div>
<div class="form-group">
<table class="table table-bordered order-service-table">
<thead>
<tr>
<th width="5%"></th>
<th width="20%">型号</th>
<th width="20%">品牌</th>
<th width="8%">订单数量</th>
<th width="8%">出库数量</th>
<th width="8%">原单价</th>
<th width="8%">申请数量</th>
<th width="8%">售后单价</th>
</tr>
</thead>
<tbody>
<!-- 目前仅支持联营商品退款 -->
<?php $goods_count = 0; ?>
@foreach ($order_items_info as $k => $v)
@if ($v['order_goods_type'] == 1)
<?php $goods_count++; ?>
<tr>
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][rec_id]" value="{{ $v['rec_id'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][goods_id]" value="{{ $v['goods_id'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][goods_name]" value="{{ $v['goods_name'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][brand_id]" value="{{ $v['brand_id'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][brand_name]" value="{{ $v['brand_name'] }}">
<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" 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>
<td>{{ $v['goods_name'] }}</td>
<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><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>
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
</form>
</div>
\ No newline at end of file
<form class="layui-form layui-box" method="post">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">售后单号</label>
<div class="layui-input-inline">
<input type="text" name="service_sn" placeholder="填写售后单号" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">订单编号</label>
<div class="layui-input-inline">
<input type="text" name="order_sn" placeholder="填写订单编号" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">申请人</label>
<div class="layui-input-inline">
<select name="apply_id" lay-verify="" lay-search>
<option value=""></option>
@if (isset($sale_list))
<optgroup label="在职">
@foreach ($sale_list as $k=>$v)
@if ($v->status == 0)
<option value="{{ $v->userId }}">{{ $v->name }}</option>
@endif
@endforeach
</optgroup>
<optgroup label="离职">
@foreach ($sale_list as $k=>$v)
@if ($v->status == 4)
<option value="{{ $v->userId }}">{{ $v->name }}</option>
@endif
@endforeach
</optgroup>
@endif
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">售后状态</label>
<div class="layui-input-inline">
<select name="service_status" lay-verify="" lay-search>
<option value=""></option>
@if (Config('order_service.service_status'))
@foreach (Config('order_service.service_status') as $k=>$v)
<option value="{{ $k }}">{{ $v }}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">退款状态</label>
<div class="layui-input-inline">
<select name="refund_status" lay-verify="" lay-search>
<option value=""></option>
@if (Config('order_service.refund_status'))
@foreach (Config('order_service.refund_status') as $k=>$v)
<option value="{{ $k }}">{{ $v }}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">退货状态</label>
<div class="layui-input-inline">
<select name="return_status" lay-verify="" lay-search>
<option value=""></option>
@if (Config('order_service.return_status'))
@foreach (Config('order_service.return_status') as $k=>$v)
<option value="{{ $k }}">{{ $v }}</option>
@endforeach
@endif
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">申请时间</label>
<div class="layui-input-inline">
<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-btn-container" style="text-align: center; margin-top: 10px;">
<button lay-submit lay-filter="load" class="layui-btn" data-type="search">搜索</button>
<!-- <button type="button" class="layui-btn layui-btn-normal export">导出</button> -->
</div>
</div>
</form>
<table id="sample" lay-filter="list"></table>
<script type="text/html" id="list_action">
<a class="btn btn-xs btn-info" href="/web/selfSampleLog?user_id=@{{ d.user_id }}" target="_blank">领取和邀约记录</a>
</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