public function ajaxApplyPresent($request, $response) { /*{{{*/ $patientId = $request->patientid; $response->patientId = $patientId; if ($this->user->isNull()) { $errorUrl = User::getLogOutUrl(); $response->setRedirect($errorUrl); return; } if (false == $this->isAllowSendPresent($response)) { return 'notsend'; } $patient = DAL::get()->find('patient', $patientId); $presentId = $request->presentid; $response->presentId = $presentId; $present = DAL::get()->find('Present', $presentId); if ($present->status == 0) { $errorUrl = Present::sentPresentUrl($patientId, $this->space->user->name); $response->setRedirect($errorUrl); return; } $response->present = $present; $response->wish = mb_convert_encoding($request->getRequest('wish', ''), 'gbk', 'utf-8'); list($canSend, $errorMsg) = $this->canSendPresent($patientId, $presentId); $response->canSend = $canSend; $response->errorMsg = $errorMsg; if (false == $canSend) { if ('礼物无效!' == $errorMsg) { //礼物无效直接跳到选择礼物页面 $url = Present::sentPresentUrl($patientId, $this->space->user->name); $response->setRedirect($url); } return; } list($featAmount, $heartImgHtml) = ScoreClient::getInstance()->showFlagsforPage($this->space->user->id); //爱心图片 $response->heartImgHtml = $heartImgHtml; //爱心值 $response->featAmount = $featAmount; $response->otherDoctorFlows = array(); if (false == $this->user->isNull()) { $response->otherDoctorFlows = FlowClient::getInstance()->getFlowListByUser($this->user->id, array('status' => DoctorPatientRef::STATUS_INIT, 'filterSpace' => $this->space->id), true); } $userId = empty($patientId) ? $this->user->id : $patient->user->id; $response->leftAmount = ScoreClient::getInstance()->getIntegralAmount($userId); $response->presentOrder = DAL::get()->find_by_spaceid_and_patientid_and_status('presentOrder', $this->space->id, $patientId, PresentOrder::AUDITED_NO); }
public function ajaxApplyPresent($request, $response) {/*{{{*/ $patientId = $request->patientid; $response->patientId = $patientId; if($this->_newUser->isNull()) { $errorUrl = "http://".URL_PREFIX."passport.haodf.com/user/login"; $response->setRedirect($errorUrl); return; } $isAllowSend = $this->isAllowSendPresent($request, $response); if(false == $isAllowSend) { return 'notsend'; } $patient = DAL::get()->find('patient', $patientId); $presentId = $request->presentid; $response->presentId = $presentId; $present = DAL::get()->find('Present', $presentId); if($present->status == 0) { $errorUrl = "/api/present/ajaxshowpresent?patientid=".$patientId."&uname=".$this->_newSpace->userName; $response->setRedirect($errorUrl); return; } $response->present = $present; $response->wish = mb_convert_encoding($request->getRequest('wish', ''), 'gbk', 'utf-8'); list($canSend, $errorMsg) = $this->canSendPresent($patientId, $presentId); $response->canSend = $canSend; $response->errorMsg = $errorMsg; if(false == $canSend) { if('礼物无效!' == $errorMsg) {//礼物无效直接跳到选择礼物页面 $url = Present::sentPresentUrl($patientId, $this->_newSpace->userName); $response->setRedirect($url); } return; } //爱心图片 list($featAmount,$heartImgHtml) = ScoreClient::getInstance()->showFlagsforPage($this->_newSpace->user->id); $response->heartImgHtml = $heartImgHtml; //爱心值 $response->featAmount = $featAmount; $response->otherDoctorFlows = array(); if(false == $this->_newUser->isNull()) { $response->otherDoctorFlows = FlowClient::getInstance()->getFlowListByUser($this->_newUser->id, array('status' => DoctorPatientRef::STATUS_INIT, 'filterSpace' => $this->_newSpace->id), true); } $userId = empty($patientId) ? $this->_newUser->id : $patient->user->id; $response->leftAmount = ScoreClient::getInstance()->getIntegralAmount($userId); $response->presentOrder = DAL::get()->find_by_spaceid_and_patientid_and_status('presentOrder', $this->_newSpace->id, $patientId, PresentOrder::AUDITED_NO); //是否有符合条件的代金券 $response->canUseCoupon = $this->_newUser->canUseCoupon4Present($present->getAmount()); }/*}}}*/