public function askPost($request, $response) {/*{{{*/ $preHostpital = $request->getRequest('case_prehospital', ''). " ".$request->getRequest('case_prekeshi', ''); $isLogin = UserClient::getInstance()->isLogin(); if (false == $isLogin) { $username = $request->patient['mobileOrEmail']; $password = $request->password; $this->_newUser = UserClient::getInstance()->register($username, $password); User::sendRegisterMsg($this->_newUser->id); $this->_newUser = UserClient::getInstance()->login($username, $password, false); } if ($this->_newUser->isNull()) { throw new BizException('对不起,您的密码输入有误。建议您到好大夫在线取回密码'); } $spaceUserId = $request->getRequest('host_user_id', 0); $askSpace = DAL::get()->find('space', $spaceUserId); if ($askSpace->isNull()) { $askSpace = DAL::get()->find('space', 0); } $options = array(); $options['title'] = $request->getRequest('case_title', ''); $options['disease'] = $request->getRequest('case_disease_tag', ''); $options['prehospital'] = $preHostpital; $options['ExpireAction'] = $request->getRequest('case_expire_action'); //post content; for unity $contents = ""; foreach(IntentionContentsFix::$postRule as $id => $item) { $textAreaName =IntentionContentsFix::$textAreaNames[$id]; $contents .= IntentionContentsFix::$postRule[$id]."\n".$request->$textAreaName; } $options['content'] = $contents; $options['allowSpaceReplyCount'] = '3'; $options['attachmentIds'] = $request->getRequest('post_patient_attachment_ids', ''); $caseTypeId = 0; $options['facultyId'] = $request->getRequest('host_user_faculty_id', 0); $out = array(); $res = $this->_userIsAllowAsk($askSpace, $out, $response); if (false === $res) { return false; } $user = $this->_newUser; $patients = $user->patients; $patientInfos = array_shift($patients); if ($patientInfos == null || $patientInfos->isNull()) { $patient = $request->patient; if (empty($patient)) { throw new BizException('系统忙,请重试'); } $patient['birthday'] = $request->dateyear."-".$request->datemonth."-".$request->dateday; $params = array( 'name' => $patient['name'], 'sex' => $patient['sex'], 'relation' => $patient['relation'], 'province' => $patient['province'], 'birthday' => $patient['birthday'], 'city' => $patient['city'], 'mobile' => $patient['mobileOrEmail'], ); $patient = PatientClient::getInstance()->add($user, $params); } else { $patient = $patientInfos; } if ($this->_newUser->isNull()) { error_log(print_r(debug_backtrace(), true), 3, '/tmp/ask_user_null.log'); throw new BizException('系统忙,请重试'); } $src = $_SERVER['HTTP_HOST']; $hospital = $options['prehospital']; $disease = $options['disease']; $content = $options['content']; $title = $options['title']; $attachmentIds = explode(',', $options['attachmentIds']); $askSpace = $askSpace; $intention = IntentionClient::getInstance()->add4ThreadFromWap($patient, $askSpace, $src, $hospital, $content, $attachmentIds, $disease, $title); if (false == $intention->isNull()) { $response->setRedirect($response->router->urlfor('hzhospitalthread/askcomplete', array('id'=>$intention->id))); } else { throw new BizException('提交咨询出错,请重试'); } }/*}}}*/
/** * addOrder * * @param mixed $request * @param mixed $response * @author mq <*****@*****.**> * @access public * @return void */ public function addOrder($request, $response) { /*{{{*/ $request->convertToGBK(); $mobile = $request->buyerPhone; $product = DAL::get()->find('Product', $request->saId); DBC::requireFalse($product->isNull(), "产品不能为空"); $user = $this->user; $patientId = 0; $patientId = $request->curPatientId4Tel; if (empty($patientId) && isset($request->patient['id'])) { $patientId = $request->patient['id']; } $rand = 0; //患者不存在情况,需创建患者 if (empty($patientId)) { //用户不存在,则创建user并且登录 if ($user->isNull()) { $rand = 1; setcookie("MyRand", "1", 0); $res = UserClient::getInstance()->createRandUser($mobile); $user = $res['user']; User::sendRegisterMsg($user->id); //自动登录 UserClient::getInstance()->login($res['user']->name, $res['password']); } $patientInfo = array(); $birthday = "{$request->dateyear}-{$request->datemonth}-{$request->dateday}"; $patientInfo['name'] = $request->patient['name']; $patientInfo['sex'] = $request->patient['sex']; $patientInfo['province'] = $request->patient['province']; $patientInfo['city'] = $request->patient['city']; $patientInfo['birthday'] = $birthday; $patientInfo['relation'] = $request->patient['relation']; $patientInfo['mobile'] = $mobile; $params = $patientInfo; $patient = PatientClient::getInstance()->add($user, $params); } else { //用户不存在,则创建user并且登录 $modifyPatientInfo = array(); $existedPatientId = $request->existedPatientId; if (false == empty($existedPatientId)) { $modifyPatientInfo['name'] = $request->patient['name']; $modifyPatientInfo['sex'] = $request->patient['sex']; $modifyPatientInfo['province'] = $request->patient['province']; $modifyPatientInfo['city'] = $request->patient['city']; $birthday = "{$request->dateyear}-{$request->datemonth}-{$request->dateday}"; $modifyPatientInfo['birthday'] = $birthday; $modifyPatientInfo['relation'] = $request->patient['relation']; } $modifyPatientInfo['mobile'] = $mobile; $patient = DAL::get()->find('patient', $patientId); PatientClient::getInstance()->modifyInfo($patient->id, $modifyPatientInfo); } //期望时间 $expectedtimes = ''; if ($request->expectedtime == 'other') { $expectedtimes = $request->expectedtimeInput; } else { $expectedtimes = $request->expectTimes; } $expectedtimeStr = ""; if (false == empty($expectedtimes)) { foreach ($expectedtimes as $expectedtime) { $expectedtimeStr .= $expectedtime . ' '; } } $inconvenientTime = $request->inconvenientTime; if (false == empty($inconvenientTime)) { $expectedtimeStr .= '方便时间为:' . $request->inconvenientTime; } $src = Intention::SRC_WEB; $intention = IntentionClient::getInstance()->add4Tel($product, $patient, $expectedtimeStr, $request->diseaseDescription, $src, $request->disease); if ($intention->needPay()) { $response->setRedirect($response->router->urlfor('payment/showpaytype', array('sourceId' => $intention->id, 'sourceType' => "intention", 'rand' => $rand))); } else { $response->setRedirect($intention->getUrl()); } return parent::DIRECT_OUTPUT; }
public function newRegisterUser($mobile, $password, $key, $os = '', $app = '') {/*{{{*/ if(!User::validKeyForRegister($mobile, $key)) { $this->setErrorCode(118); return 0; } $request = new Request(); $info['mobile'] = $mobile; $info['password'] = $password; $tf = $this->_checkUserInfos($info); if ($tf > 0) { $this->setErrorCode($tf); return 0; } $userName = $mobile; $user = DAL::get()->find_by_name('user', $userName, true); if (false == $user->isNull()) { $this->setErrorCode(104); return 0; } $user = UserClient::getInstance()->register($userName, $password, array('mobile' => $mobile)); User::sendRegisterMsg($user->id); if ($user->isNull() || $user->name != $userName) { $this->setErrorCode(105); return 0; } //积分部分功能推迟 self::recordWapUser($user, $app, $os); UserClient::getInstance()->login($userName, $password); ScoreClient::getInstance()->reg($user->id); $this->content = array('_s' => self::userData($user)); }/*}}}*/
public function doRegister($request, $response) {/*{{{*/ $mobile = $request->mobile; $password1 = $request->password1; $password2 = $request->password2; $key = $request->key; if(User::validKeyForRegister($mobile, $key)) { $user = UserClient::getInstance()->register($mobile, $password1, array('mobile' => $mobile)); User::sendRegisterMsg($user->id); $user = UserClient::getInstance()->login($mobile, $password1); $forward = ($request->forward) ? $request->forward : $response->router->urlfor('user/index'); $results = array('res' => 'success', 'msg' => '', 'next' => $forward); } else { $results = array('res' => 'failure', 'msg' => mb_convert_encoding('短信验证码不正确', 'UTF-8', 'GBK'), 'next' => ''); } echo json_encode($results); return self::DIRECT_OUTPUT; }/*}}}*/
public function add($request, $response) {/*{{{*/ $this->breakIfLessMessage($request, $response); if ($response->isQQ) { $this->checkLogin($request, $response); } $isLogin = UserClient::getInstance()->isLogin(); if ($isLogin == true) { $curUser = $this->_newUser; } else { $username = $request->username; $password = $request->password; $curUser = UserClient::getInstance()->register($username, $password); User::sendRegisterMsg($curUser->id); $curUser = UserClient::getInstance()->login($username, $password, false, null, $this->partnerDomain); } if ($curUser->isNull()) { throw new BizException('该邮箱已被注册!');; } if (false == $curUser->allowQuestion()) { throw new BizException('不允许提问'); } $patient = $this->getPatient($request, $curUser); $space = DAL::get()->find('space', $request->host_id); $ip = RequestDelegate::getIp(); $diseaseDto = BingLiDto::createDiseaseDto(XString::convertToGbk($request->case_disease_tag), $patient->id); $titleDto = BingLiDto::createTitleDto(XString::convertToGbk($request->case_title), $patient->id); $hospitalDto = BingLiDto::createHospitalDto(XString::convertToGbk($request->case_prehospital), XString::convertToGbk($request->case_prekeshi), $patient->id); $hopeHelpDto = BingLiDto::createHopeHelpDto(XString::convertToGbk($request->post_help), $patient->id); $content = "检查及化验:\n".XString::convertToGbk($request->post_content). "\n治疗情况(当前用药或近期手术):\n".XString::convertToGbk($request->post_effects). "\n病史:\n".XString::convertToGbk($request->post_history); if(XString::getLengthOfGBKString(XString::getLengthOfGBKString($content)>1000)) { throw new BizException('请精简您所填写的病情信息'); } $contentDto = BingLiDto::createConditionDescDto($content, $patient->id); $realBingLiDtos = NodeClient::getInstance()->addBingLis(array( $diseaseDto, $titleDto, $hospitalDto, $hopeHelpDto, $contentDto, ), NodeObj::SOURCE_PATIENT); if(false == $space->isNull()) { $product = ProductClient::getInstance()->getFirstFlowProduct($space); } else { $product = FirstFlowPoolVirtualProduct::fetch(); } SpaceClient::getInstance()->ensureAllowAskRule($curUser, $space); $src = $_SERVER['HTTP_HOST']; $intention = IntentionClient::getInstance()->createWithProduct($patient, $product, $src, $realBingLiDtos, $ip); $response->setRedirect('http://'.$_SERVER['HTTP_HOST'].$response->router->urlfor('thread/finish', array('threadId' => $intention->id))); }/*}}}*/