Commit 26e6ea13 authored by hujun's avatar hujun

删除退款

parent ca217be1
......@@ -2168,4 +2168,143 @@ class OfficePayLog extends Basic
$data['log'] = $m_refund_log->getListAll('operation_name,create_time,status', ['refund_id'=>$this->params['refund_id'], 'is_del'=>0]);
return $this->response($code, $msg, $data);
}
/**
* 退款审核
*
* @return \think\Response
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function checkRefund() {
$code = 101;
$msg = '';
if (empty($this->params['refund_id']) || empty($this->params['status'])) {
return $this->response($code, '参数错误');
}
$m_refund = new OfficeORefundModel();
$refund_where['id'] = $this->params['refund_id'];
// 0申请 1审核中 2退款成功 3已审核4驳回
switch ($this->params['status']) {
case 1 :
$refund_where['status'] = ['in', '0,1,4'];
break;
case 2 :
$refund_where['status'] = 3;
break;
}
$refund_where['is_del'] = $status = 0;
$refund_data = $m_refund->selectRefundByOrderNo('id,status,order_id', $refund_where);
if (empty($refund_data[0]['id'])) {
return $this->response($code, '没有该退款详情或审核完成');
}
if (($refund_data[0]['status'] == 4) && ($this->params['status'] == 4)) {
return $this->response($code, '该退款已驳回');
}
if (($refund_data[0]['status'] == 3) && ($this->params['status'] == 3)) {
return $this->response($code, '该退款已审核');
}
if (($refund_data[0]['status'] == 2) && ($this->params['status'] == 2)) {
return $this->response($code, '已退款');
}
$m_refund_log = new OfficeORefundLogModel();
$save_data['refund_id'] = $this->params['refund_id'];
$save_data['remark'] = trim($this->params['remark']);
$save_data['operation_id'] = $this->userId;
$save_data['operation_name'] = $this->userName;
$save_data['order_id'] = $refund_data[0]['order_id'];
$log_where['is_del'] = 0;
$log_where['refund_id'] = $this->params['refund_id'];
$num = 0;
switch ($this->params['status']) {
case 1 :
$log_where['status'] = 1;
$check_agent_id = $m_refund_log->getListAll('operation_id',$log_where);
foreach ($check_agent_id as $v) {
if ($v['operation_id'] == $this->userId) {
return $this->response(101, '你已审核过');
}
}
if (count($check_agent_id) >= 1) {
$status = 3; //已审核
}
$save_data['status'] = 1;
$num = $m_refund_log->insertData($save_data);
break;
case 2 :
$log_where['status'] = 1;
$check_num = $m_refund_log->getTotal($log_where);
$id = 0;
if ($check_num >= 2) {
$save_data['status'] = $status = 2; //已审核
$num = $id = $m_refund_log->insertData($save_data);
}
if ($id > 0 && is_array($this->params['img_arr'])) {
$m_img = new OfficeOImg();
$m_img->addImgAll($id, 4, $this->params['img_arr']);
}
break;
case 4 :
$save_data['status'] = $status = 4;
$m_refund_log->updateData(['is_del'=>1], ['refund_id'=>$this->params['refund_id'],'status'=>1,'is_del'=>0]);
$num = $m_refund_log->insertData($save_data);
}
if ($num) {
if ($status) {
$m_refund->updateData(['status'=> $status], ['id'=>$this->params['refund_id']]);
}
$code = 200;
} else {
$msg = '审核失败';
}
return $this->response($code, $msg);
}
/**
* 删除退款
*
* @return \think\Response
*/
public function delRefund() {
$code = 101;
if (empty($this->params['refund_id'])) {
return $this->response($code, '参数错误');
}
try {
$where['id'] = $this->params['refund_id'];
$where['status'] = ['<>', 2];
$m_refund = new OfficeORefundModel();
$m_refund_log = new OfficeORefundLogModel();
$data = $m_refund->getFind('id', $where);
if (empty($data['id'])) {
return $this->response($code, '退款信息错误');
}
$num = $m_refund->updateData(['is_del'=>1], ['id'=>$this->params['refund_id']]);
$msg = '删除失败';
if ($num) {
$m_refund_log->updateData(['is_del'=>1], ['refund_id'=>$this->params['refund_id']]);
$code = 200;
$msg = '删除成功';
}
} catch (\Exception $e) {
$msg = '内部错误:'.$e->getMessage();
}
return $this->response($code, $msg, []);
}
}
\ No newline at end of file
......@@ -1061,6 +1061,8 @@ Route::group('office_index', [
'getPayLogData' => ['index/officePayLog/getPayLogData', ['method' => 'GET']], //收款各种详情
'adjustmentList' => ['index/officePayLog/adjustmentList', ['method' => 'GET']], //调整列表
'refundDetail' => ['index/officePayLog/refundDetail', ['method' => 'GET']], //退款详情
'checkRefund' => ['index/officePayLog/checkRefund', ['method' => 'GET']], //退款审核
'delRefund' => ['index/officePayLog/delRefund', ['method' => 'GET']], //删除退款
'inspectionRecordOur/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 0]], //我的约带看
'inspectionRecordStore/:check_status' => ['index/OfficeReport/inspectionRecordAll', ['method' => 'GET'], ['check_status' => 1]], //门店约带看
......
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 to comment