public function buyAction(Request $request, $id) { $course = $this->getCourseService()->getCourse($id); $user = $this->getCurrentUser(); if (!$user->isLogin()) { throw $this->createAccessDeniedException(); } $remainingStudentNum = $this->getRemainStudentNum($course); $previewAs = $request->query->get('previewAs'); $member = $user ? $this->getCourseService()->getCourseMember($course['id'], $user['id']) : null; $member = $this->previewAsMember($previewAs, $member, $course); $courseSetting = $this->getSettingService()->get('course', array()); $userInfo = $this->getUserService()->getUserProfile($user['id']); $userInfo['approvalStatus'] = $user['approvalStatus']; $account = $this->getCashAccountService()->getAccountByUserId($user['id'], true); if (empty($account)) { $this->getCashAccountService()->createAccount($user['id']); } if (isset($account['cash'])) { $account['cash'] = intval($account['cash']); } $amount = $this->getOrderService()->analysisAmount(array('userId' => $user->id, 'status' => 'paid')); $amount += $this->getCashOrdersService()->analysisAmount(array('userId' => $user->id, 'status' => 'paid')); $course = $this->getCourseService()->getCourse($id); $userFields = $this->getUserFieldService()->getAllFieldsOrderBySeqAndEnabled(); for ($i = 0; $i < count($userFields); $i++) { if (strstr($userFields[$i]['fieldName'], "textField")) { $userFields[$i]['type'] = "text"; } if (strstr($userFields[$i]['fieldName'], "varcharField")) { $userFields[$i]['type'] = "varchar"; } if (strstr($userFields[$i]['fieldName'], "intField")) { $userFields[$i]['type'] = "int"; } if (strstr($userFields[$i]['fieldName'], "floatField")) { $userFields[$i]['type'] = "float"; } if (strstr($userFields[$i]['fieldName'], "dateField")) { $userFields[$i]['type'] = "date"; } } if ($course['approval'] == 1 && $userInfo['approvalStatus'] != 'approved') { return $this->render('TopxiaWebBundle:CourseOrder:approve-modal.html.twig', array('course' => $course)); } if ($remainingStudentNum <= 0 && $course['type'] == 'live') { return $this->render('TopxiaWebBundle:CourseOrder:remainless-modal.html.twig', array('course' => $course)); } //判断用户是否为VIP $vipStatus = $courseVip = null; if ($this->isPluginInstalled('Vip') && $this->setting('vip.enabled')) { $courseVip = $course['vipLevelId'] > 0 ? $this->getLevelService()->getLevel($course['vipLevelId']) : null; if ($courseVip) { $vipStatus = $this->getVipService()->checkUserInMemberLevel($user['id'], $courseVip['id']); } } return $this->render('TopxiaWebBundle:CourseOrder:buy-modal.html.twig', array('course' => $course, 'payments' => $this->getEnabledPayments(), 'user' => $userInfo, 'noVerifiedMobile' => strlen($user['verifiedMobile']) == 0, 'verifiedMobile' => strlen($user['verifiedMobile']) > 0 ? $user['verifiedMobile'] : '', 'avatarAlert' => AvatarAlert::alertJoinCourse($user), 'courseSetting' => $courseSetting, 'member' => $member, 'userFields' => $userFields, 'account' => $account, 'amount' => $amount, 'vipStatus' => $vipStatus)); }
public function buyAction(Request $request, $id) { $course = $this->getCourseService()->getCourse($id); $user = $this->getCurrentUser(); if (!$user->isLogin()) { throw $this->createAccessDeniedException(); } $remainingStudentNum = $this->getRemainStudentNum($course); $previewAs = $request->query->get('previewAs'); $member = $user ? $this->getCourseService()->getCourseMember($course['id'], $user['id']) : null; $member = $this->previewAsMember($previewAs, $member, $course); $courseSetting = $this->getSettingService()->get('course', array()); $userInfo = $this->getUserService()->getUserProfile($user['id']); $userInfo['approvalStatus'] = $user['approvalStatus']; $course = $this->getCourseService()->getCourse($id); $userFields = $this->getUserFieldService()->getAllFieldsOrderBySeqAndEnabled(); for ($i = 0; $i < count($userFields); $i++) { if (strstr($userFields[$i]['fieldName'], "textField")) { $userFields[$i]['type'] = "text"; } if (strstr($userFields[$i]['fieldName'], "varcharField")) { $userFields[$i]['type'] = "varchar"; } if (strstr($userFields[$i]['fieldName'], "intField")) { $userFields[$i]['type'] = "int"; } if (strstr($userFields[$i]['fieldName'], "floatField")) { $userFields[$i]['type'] = "float"; } if (strstr($userFields[$i]['fieldName'], "dateField")) { $userFields[$i]['type'] = "date"; } } if ($remainingStudentNum == 0 && $course['type'] == 'live') { return $this->render('TopxiaWebBundle:CourseOrder:remainless-modal.html.twig', array('course' => $course)); } else { return $this->render('TopxiaWebBundle:CourseOrder:buy-modal.html.twig', array('course' => $course, 'payments' => $this->getEnabledPayments(), 'user' => $userInfo, 'avatarAlert' => AvatarAlert::alertJoinCourse($user), 'courseSetting' => $courseSetting, 'member' => $member, 'userFields' => $userFields)); } }
public function avatarAlertAction() { $user = $this->getCurrentUser(); return $this->render('TopxiaWebBundle:My:avatar-alert.html.twig', array('avatarAlert' => AvatarAlert::alertInMyCenter($user))); }