request->input('order_id'); $refundLockKey = ApiRedisKey::refundLock($this->userId); if (0 == ($this->redis->addLock($refundLockKey))){ throw new ErrException('请勿重复点击'); } $orderInfo = $this->orderModel->getInfoById($orderId); if ($orderInfo->user_id != $this->userId) throw new ErrException('该订单不是您的订单,请勿操作'); if ($orderInfo->status != OrderCode::PAYED) throw new ErrException('该订单状态已变更,请勿重复操作,刷新后无法退款请联系客服'); try { $orderId = (int)$this->request->input('order_id'); $service = new FullRefundOrderService(); $service->orderId = $orderId; $service->reason = '用户主动退款订单'; $service->type = RefundCode::FULL_GOOD_REFUND; $service->handle(); }catch (Exception $e) { throw new ErrException($e->getMessage()); } $this->redis->delLock($refundLockKey); return $this->return->success(); } }