public function replenish($request, $response)
 {/*{{{*/
     $intention = DAL::get()->find('intention', $request->intentionid);
     $user = $this->user;
     DBC::requireEquals($this->user->id, $intention->user->id, '你不能操作别人的数据');
     if($intention->isFromThread() && $intention->hasSpace())
     {
         DBC::requireTrue($intention->space->isCaseOpen(), '医生已经关闭咨询区,不能补充意向了');
     }
     $content = $request->content;
     $attachmentIds = array_filter(explode(",", $request->attachmentIds));
     $patient = $intention->patient;
     $intention = IntentionClient::getInstance()->replenishFromIntention($intention, Intention::SRC_WEB, $content, $attachmentIds);
     $url = $intention->getUrl();
     $url .= "&fromReplenish=1";
     $response->setRedirect($url);
 }/*}}}*/
 public function deleteBingLi($request,$response)
 {/*{{{*/
     $patientAttachment = DAL::get()->find('PatientAttachment', $request->paid);
     DBC::requireEquals($this->user->id, $patientAttachment->user->id, '你不能删除别人的病历');
     $user = $this->user;
     $paId = $request->paid;
     $pageNum = $request->p;
     $pageNum = ($pageNum > 0) ? $pageNum : 1;
     $pageSize = 15;
     BingliClient::getInstance()->doDelete($paId);
     $res =  BingliClient::getInstance()->getAllAttachment($user->id, $request->patientid, $type='', $pageNum, $pageSize);
     if(empty($res['patientattachment']))
     {
         $pageNum = $pageNum-1;
     }
     $response->setRedirect($response->router->urlfor('mycase/binglilist',array('p'=>$pageNum,'patientid'=>$request->patientid)));
 }/*}}}*/
	public function receiveProofSMS($request, $response)
	{/*{{{*/
		$orderId = $request->id;
		$order = DAL::get()->find('BookingOrder', $orderId);
        $proposal = $order->notification->proposal;
		DBC::requireEquals($order->userid, $this->user->id, '您无权操作别人的订单!');
			
		$now = XDateTime::now("Y-m-d H:i:s");
		$before1Schedule = $order->schedule->addDay(-1)->setHour("16")->setMinute("00");
		$before2Schedule = $order->schedule->addDay(-2)->setHour("20")->setMinute("00");
		//在加号日期两天之前显示的内容
		if($now < $before2Schedule)
		{
			$response->message = "<div align='left'>暂时不能领取加号凭证,<br/>请您在".date('Y-m-d H:i', strtotime($before2Schedule))."至".date('Y-m-d H:i', strtotime($before1Schedule))."到此页面领取加号凭证短信,若操作有困难,也可在".date('Y-m-d', strtotime($before1Schedule))."日9点半至16点致电客服协助您完成操作,客服电话".BookingOrder::BU_PHONE_1."</div>";
			MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/proposal/showbookinglist', array('delay' => 10, 'button' => 'back'));
			exit();
		}
		$response->order = $order;
		$response->proposal = $proposal;

	}/*}}}*/
    public function showTelAccount($request, $response)
    {/*{{{*/

        /********开始:处理未支付的订单*******/
        $presentOrderId = $request->orderId;
        $response->orderId = $presentOrderId;
        $from = $request->from;

        $orderId4show = $request->orderId;
        if(Pay::ORDER_TYPE_FLOW == $from)
        {
            $orderId4show = $this->getFlowOrder($request, $response)->id;
        }
        $response->orderId4show = $orderId4show;

        $response->refId = 0; 
        $response->payType = 0; 
        $response->ceilPrice = null; 
        $response->from = ($from == self::FROM_TYPE_MSG) ? Pay::ORDER_TYPE_PRESENT : $from;
        $response->sourceType = $request->sourceType?$request->sourceType:0;
        $presentOrder = new NullEntity();
        $response->rechargePhone = $request->rechargePhone;
        $response->bankType = $request->getRequest('pay', PresentOrder::PAY_UNION_PAY);
        $response->isRecharge = (($presentOrderId == '' || $presentOrderId == 0 ) && $from == '')?true:false;
        $response->payType = $request->getRequest('pay', PresentOrder::PAY_UNION_PAY);

        if(Pay::ORDER_TYPE_FLOW != $from)
        {
            $cookie = new HdfCookie();
            $cookie->clear('rechargeSourceFlow');
        }

        if($from == Pay::ORDER_TYPE_PRESENT || $from == self::FROM_TYPE_MSG)
        {/*{{{*/
            if(false == empty($presentOrderId))
            {
                $presentOrder = DAL::get()->find_by_id_and_status('presentOrder', $presentOrderId, PresentOrder::STATUS_PAID_NO);
                if(($presentOrder->isNull() || $presentOrder->present->isValid() == false) && $from == self::FROM_TYPE_MSG)
                {
                    if (false == empty($presentOrder))
                    {
                        $presentOrder = DAL::get()->find_by_id('presentOrder', $presentOrderId);
                    }
                    $response->presentOrder = $presentOrder;
                    $response->space = $presentOrder->space;
                    $flow = new NullEntity();
                    if($presentOrder->patientid)
                    {
                        $flow = DAL::get()->find_by_patientid_and_spaceid('DoctorPatientRef', $presentOrder->patientid, $presentOrder->space->id);
                    }
                    $response->ref = $flow;
                    return 'notice';
                }
                DBC::requireEquals($presentOrder->user->id, $this->user->id, '您无权操作别人的订单!');
            }

            if($presentOrder->isNull())
            {
                $patientIds = array_keys($this->user->patients);
                $presentOrder = PresentClient::getInstance()->getOneUnpaidPresentOrderByPatientIds($patientIds);
            }

            if($presentOrder instanceof PresentOrder)
            {
                $response->presentOrder = $presentOrder;
                $response->present = $presentOrder->present;
                $response->space = $presentOrder->space;
                $response->price = $presentOrder->present->price;
                list($response->featAmount, $response->heartImgHtml) = ScoreClient::getInstance()->showFlagsforPage($presentOrder->space->user->id);
                $recycleTime = $presentOrder->getRecycleTime();
                $response->recycleTime = $recycleTime['recycleTime'];
                $response->countDown = (0 < $recycleTime['countDown'])?$recycleTime['countDown']:0;

                return 'payment';
            }
            /********结束:处理未支付的订单*******/
        }/*}}}*/
        if($from == Pay::ORDER_TYPE_FLOW)
        {/*{{{*/
           $price = 0;
           $response->refId = $presentOrderId; 
           if(false == empty($presentOrderId))
           {
               $ref = DAL::get()->find('DoctorPatientRef', $presentOrderId);
               DBC::requireEquals($ref->user->id, $this->user->id, '您无权操作别人的订单!');
               $product = ProductClient::getInstance()->getDoctorChargeFlowProduct($ref->space);
               $price = $product->salePrice;
               $response->space = $ref->space;
           }
           $response->price = $price;
           $response->countDown = 0;

           return 'payment';
        }/*}}}*/
        return 'default';
    }/*}}}*/
 public function receiveProofSMS($request, $response)
 {
     /*{{{*/
     $ref = DAL::get()->find('DoctorPatientRef', $request->refid);
     if ($ref->isNull()) {
         header('Location: ' . $this->space->url);
         return;
     }
     $orderId = $request->id;
     $order = DAL::get()->find('BookingOrder', $orderId);
     DBC::requireEquals($order->userid, $this->user->id, '您无权操作别人的订单!');
     $now = XDateTime::now("Y-m-d H:i:s");
     $beforeStartSchedule = $order->schedule->addDay(-1)->setHour("16")->setMinute("00");
     $beforeEndSchedule = $order->schedule->addDay(-2)->setHour("20")->setMinute("00");
     //在加号日期两天之前显示的内容
     if ($now < $beforeEndSchedule) {
         $response->message = "<div align='left'>暂时不能领取加号凭证,<br/>请您在" . date('Y-m-d H:i', strtotime($beforeEndSchedule)) . "至" . date('Y-m-d H:i', strtotime($beforeStartSchedule)) . "到此页面领取加号凭证短信,若操作有困难,也可在" . date('Y-m-d', strtotime($beforeStartSchedule)) . "日9点半至16点致电客服协助您完成操作,客服电话" . BookingOrder::BU_PHONE_1 . "</div>";
         $this->message($response->message, $response, array('url' => $ref->url));
     } else {
         $response->setRedirect($ref->url);
     }
 }
 public function replenish($request, $response)
 {/*{{{*/
     $proposal = DAL::get()->find('proposal', $request->proposalid);
     $user = $this->user;
      DBC::requireEquals($this->user->id, $proposal->user->id, '你不能操作别人的数据');
     $content = $request->content;
     $attachmentIds = array_filter(explode(",", $request->attachmentIds));
     $src = Intention::SRC_WEB;
     $intention = IntentionClient::getInstance()->replenishByProposal($proposal, $src, $content, $attachmentIds);
     $url = $intention->getUrl();
     $url .= "&fromReplenish=1";
     $response->setRedirect($url);
 }/*}}}*/
 public function paybank($request, $response)
 {/*{{{*/
     $response->title = "";
     $from = $request->getRequest("from", "");
     if ($from == Pay::ORDER_TYPE_FLOW)
     {
         $ref = DAL::get()->find('DoctorPatientRef', $request->orderid);
         DBC::requireEquals($ref->user->id, $this->user->id, '您无权操作别人的订单!');
         $response->order = $ref;
         $response->patientPhone = $ref->patient->mobile;
     }
     else
     {
         $order = $this->getPayable($request->orderid);
         if ($order->isNull())
         {
             $this->_exit404();
         }
         $response->order = $order;
         $response->patientPhone = $order->patient->mobile;
     }
     $response->from = $from;
 }/*}}}*/
    private function modifyPasswordForUser(User $user, $oldPassword, $newPassword, $newPasswordSure)
    {/*{{{*/
        $errorMsg = "";
        if((empty($oldPassword) && empty($newPassword) && empty($newPasswordSure)))
        {
			$errorMsg = "您并未修改密码但成功修改了邮箱";
        }
        else
        {
            DBC::requireNotEmptyString($newPassword, '新密码不能为空');
            DBC::requireNotEmptyString($newPasswordSure, '确认密码不能为空');
            DBC::requireEquals($newPasswordSure, $newPassword, '新密码和确认密码不一致');
            
            if(false == $user->validatePassword($oldPassword))
            {
                $errorMsg = "原登录密码输入错误,请重新输入";
            }    
        }
        if(empty($errorMsg))
        {
            UserClient::getInstance()->updatePassword($user->id, $newPassword);
            DAL::get()->cleanCache('user', $user->id);
            $errorMsg = "修改密码或邮箱成功";
        }
           return $errorMsg;
    }/*}}}*/