コード例 #1
0
 public function cancelRefundAction(Request $request, $id)
 {
     $order = $this->getOrderService()->getOrder($id);
     $processor = OrderRefundProcessorFactory::create($order['targetType']);
     $processor->cancelRefundOrder($id);
     return $this->createJsonResponse(true);
 }
コード例 #2
0
 public function cancelRefundAction(Request $request, $id)
 {
     $targetType = $request->query->get("targetType");
     if (!in_array($targetType, array("course", "classroom"))) {
         throw $this->createAccessDeniedException('参数不对。');
     }
     $processor = OrderRefundProcessorFactory::create($targetType);
     $target = $processor->getTarget($id);
     if (empty($target)) {
         throw $this->createNotFoundException();
     }
     $user = $this->getCurrentUser();
     if (empty($user)) {
         throw $this->createAccessDeniedException();
     }
     $member = $processor->getTargetMember($target['id'], $user['id']);
     if (empty($member) || empty($member['orderId'])) {
         throw $this->createAccessDeniedException('您不是学员或尚未购买,不能取消退款。');
     }
     $processor->cancelRefundOrder($member['orderId']);
     return $this->createJsonResponse(true);
 }
コード例 #3
0
 public function unLearn()
 {
     $classRoomId = $this->getParam("classRoomId");
     $targetType = $this->getParam("targetType");
     if (!in_array($targetType, array("course", "classroom"))) {
         throw $this->createErrorResponse('error', '退出学习失败');
     }
     $processor = OrderRefundProcessorFactory::create($targetType);
     $target = $processor->getTarget($classRoomId);
     $user = $this->controller->getUserByToken($this->request);
     if (!$user->isLogin()) {
         return $this->createErrorResponse('not_login', "您尚未登录,不能学习班级!");
     }
     $member = $processor->getTargetMember($classRoomId, $user["id"]);
     if (empty($member) || empty($member['orderId'])) {
         return $this->exitClassRoom($classRoomId, $user);
     }
     $order = $this->getOrderService()->getOrder($member['orderId']);
     if (empty($order)) {
         return $this->createErrorResponse('error', '您尚未购买,不能退学。');
     }
     $data = $this->request->request->all();
     $reason = empty($data['reason']) ? array() : $data['reason'];
     $amount = empty($data['applyRefund']) ? 0 : null;
     try {
         if (isset($data["applyRefund"]) && $data["applyRefund"]) {
             $refund = $processor->applyRefundOrder($member['orderId'], $amount, $reason, $this->container);
         } else {
             $processor->removeStudent($order['targetId'], $user['id']);
         }
     } catch (\Exception $e) {
         return $this->createErrorResponse('error', $e->getMessage());
     }
     return true;
 }
コード例 #4
0
 protected function getOrderRefundProcessor($targetType)
 {
     return OrderRefundProcessorFactory::create($targetType);
 }