Commit dd356d7b by 朱继来

退货单审核

parent c465c8a1
...@@ -175,5 +175,13 @@ class ReturnController extends Controller ...@@ -175,5 +175,13 @@ class ReturnController extends Controller
return view('returnDetails', $info); return view('returnDetails', $info);
} }
// 退货单审核
public function returnCheck(Request $request)
{
if ($request->isMethod('post')) {
$OrderReturnModel = new OrderReturnModel();
return $OrderReturnModel->check($request);
}
}
} }
...@@ -127,6 +127,7 @@ Route::group(['middleware' => 'web'], function () { ...@@ -127,6 +127,7 @@ Route::group(['middleware' => 'web'], function () {
Route::get('/self_return_list', 'ReturnController@selfReturnList'); Route::get('/self_return_list', 'ReturnController@selfReturnList');
Route::get('/return_details/{id}', 'ReturnController@returnDetails'); Route::get('/return_details/{id}', 'ReturnController@returnDetails');
Route::post('/ajax/returnCheck', 'ReturnController@returnCheck');
}); });
// 不需要登陆态 // 不需要登陆态
......
...@@ -13,4 +13,24 @@ class OrderReturnLogModel extends Model ...@@ -13,4 +13,24 @@ class OrderReturnLogModel extends Model
protected $primaryKey = 'return_log_id'; protected $primaryKey = 'return_log_id';
public $timestamps = false; public $timestamps = false;
/**
* 创建退货记录
* @param [type] $return_id [退货单ID]
* @param [type] $operator_id [操作人ID]
* @param [type] $event [操作事件]
*/
public function addLog($return_id, $operator_id, $event)
{
$operator = DB::table('user_info')->where('userId', $operator_id)->select('name')->first(); // 操作人名称
$return_log['return_id'] = $return_id;
$return_log['operator_id'] = $operator_id;
$return_log['operator_name'] = $operator->name;
$return_log['event'] = $event;
$return_log['ip'] = get_client_ip(0, true);
$return_log['create_time'] = time();
return $this->insert($return_log);
}
} }
\ No newline at end of file
...@@ -23,7 +23,7 @@ class OrderReturnModel extends Model ...@@ -23,7 +23,7 @@ class OrderReturnModel extends Model
// 获取退货单记录 // 获取退货单记录
public function hasManyReturnLog() public function hasManyReturnLog()
{ {
return $this->hasMany('App\Model\OrderReturnLogModel', 'return_id', 'return_id'); return $this->hasMany('App\Model\OrderReturnLogModel', 'return_id', 'return_id')->orderBy('create_time', 'desc');
} }
// 联营订单导出 // 联营订单导出
...@@ -320,4 +320,41 @@ class OrderReturnModel extends Model ...@@ -320,4 +320,41 @@ class OrderReturnModel extends Model
return $tmp; return $tmp;
} }
// 审核
public function check($request)
{
$return_id = $request->input('return_id');
$type = $request->input('type');
$operator_id = $request->user->userId;
if ($type == 2) {
$update['syn_sign'] = 1; // 标记wms同步
$event = '审核通过退货单';
} else {
$update['refund_reason'] = $request->input('refund_reason');
$event = '驳回退货单,原因:'.$refund_reason;
}
$update['status'] = $type;
$update['audit_uid'] = $operator_id;
$update['audit_time'] = time();
try {
DB::connection('order')->beginTransaction(); // 开启事务
$OrderReturnLogModel = new OrderReturnLogModel();
$this->where('return_id', $return_id)->update($update);
$OrderReturnLogModel->addLog($return_id, $operator_id, $event);
DB::connection('order')->commit(); // 提交事务
return ['err_code'=>0, 'err_msg'=>'操作成功'];
} catch(Exception $e) {
DB::connection('order')->rollback(); // 回滚
return ['err_code'=>1, 'err_msg'=>'操作失败,原因:'.$e->getMessage()];
}
}
} }
\ No newline at end of file
...@@ -354,21 +354,53 @@ ...@@ -354,21 +354,53 @@
var type = $(this).data('type'); var type = $(this).data('type');
var title = ''; var title = '';
var content = ''; var content = '';
var data = {return_id: return_id, type: type};
if (type == 1) { // 审核通过 if (type == 2) { // 审核通过
title = '审核退货单'; title = '审核退货单';
content = '确定审核通过吗?'; content = '确定审核通过吗?';
} else { } else { // 驳回
title = '驳回退货单'; title = '驳回退货单';
content = '<div><textarea name="refuse_reason" id="refuse_reason" cols="30" rows="10"></textarea></div>'; content = '<div><textarea name="refuse_reason" class="form-control" id="refuse_reason" cols="30" rows="5" placeholder="填写驳回原因"></textarea></div>';
} }
layer.open({ layer.open({
title: title, title: title,
content: content, content: content,
btns: ['确定', '取消'], btn: ['确定', '取消'],
yes: function() { yes: function() {
if (type == -2) {
var refuse_reason = $('#refuse_reason').val();
if (!refuse_reason) {
layer.tips('驳回原因不能为空', $('#refuse_reason'));
return false;
}
data.refuse_reason = refuse_reason;
}
$.ajax({
url: '/ajax/returnCheck',
type: 'post',
data: data,
success: function(resp){
if (resp.err_code == 0) {
layer.msg(resp.err_msg);
setTimeout(function(){
location.reload();
}, 1000);
return false;
}
layer.alert(resp.err_msg);
},
error: function(err) {
console.log(err)
}
})
} }
}) })
}) })
......
...@@ -143,11 +143,11 @@ ...@@ -143,11 +143,11 @@
</div> </div>
</div> </div>
<!-- 管理员、经理、自营客服主管审核 --> <!-- 管理员、经理、自营客服主管审核 && 待审核状态 -->
@if (in_array($role, [1, 2, 10])) @if (in_array($role, [1, 2, 10]) && $return['status'] == 1)
<div class="text-center" style="margin-bottom: 10px;"> <div class="text-center" style="margin-bottom: 10px;">
<button class="btn btn-info return-check" style="margin-right: 10px;" data-type="1" data-id="{{ $return['return_id'] }}">审核通过</button> <button class="btn btn-info return-check" style="margin-right: 10px;" data-type="2" data-id="{{ $return['return_id'] }}">审核通过</button>
<button class="btn btn-danger return-check" data-type="-1" data-id="{{ $return['return_id'] }}">驳回</button> <button class="btn btn-danger return-check" data-type="-2" data-id="{{ $return['return_id'] }}">驳回</button>
</div> </div>
@endif @endif
</div> </div>
......
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