コード例 #1
0
 public function sendPresent($request, $response)
 {
     /*{{{*/
     $patient = DAL::get()->find('patient', $request->patientid);
     $space = DAL::get()->find('space', $request->spaceid);
     $cashCoupon = DAL::get()->find('cashcoupon', $request->couponid);
     $mes = "礼物无效或订单创建失败!请重试!";
     if ($cashCoupon->isNull()) {
         throw new BizException('代金券无效!');
     }
     //$presentId = (CashCoupon::PRICE_10 == $cashCoupon->price)?(Present::GEHL_PRESENT_ID):(Present::YDGS_PRESENT_ID);
     $presentId = CashCoupon::PRICE_10 == $cashCoupon->price ? Present::TEST_GNHL_PRESENT_ID : Present::TEST_YDGS_PRESENT_ID;
     $present = DAL::get()->find('Present', $presentId);
     $result = 4;
     if (false == $present->isNull()) {
         $presentOrder = PresentClient::getInstance()->createOrder($patient->user, $patient, $space, $present, "");
     }
     if (Account::PAY_RESULT_FAIL_COUPON == $result) {
         $mes = "代金券支付失败!";
     } else {
         if (Account::PAY_RESULT_SUCC == $result) {
             AsyncSendMessage::regAsyncMessage($presentOrder);
             //发送站内信
             $mes = "{$cashCoupon->price}元代金券使用成功!";
         }
     }
     $response->setRedirect($response->router->urlfor('present/showtelorder?message=' . $mes));
 }
コード例 #2
0
 public function ajaxBuyPresent($request, $response)
 {
     /*{{{*/
     $patientId = $request->patientid;
     $presentId = $request->presentid;
     list($canSend, $errorMsg) = $this->canSendPresent($patientId, $presentId);
     $response->canSend = $canSend;
     $response->errorMsg = $errorMsg;
     if ($this->user->isNull()) {
         return 'ajaxfailsent';
     }
     if (false == $canSend) {
         return 'ajaxfailsent';
     }
     $isAllowSend = $this->isAllowSendPresent($response);
     if (false == $isAllowSend) {
         return 'notsend';
     }
     //处理老订单还是新订单
     $present = DAL::get()->find('Present', $presentId);
     $patient = DAL::get()->find('patient', $patientId);
     $presentOrder = PresentClient::getInstance()->createOrder($this->user, $patient, $this->space, $present, $request->wish, $request->old);
     $response->presentOrder = $presentOrder;
     $result = Account::PAY_RESULT_FAIL;
     $url = '';
     $couponId = 0;
     if (false == $presentOrder->isNull()) {
         $result = ScoreClient::getInstance()->payForPresent($this->user->id, $this->space->id, $presentOrder->id);
         $url = Account::resultUrl($result, 'present', $presentOrder->id);
     }
     $errorMsg = '';
     if (Account::PAY_RESULT_FAIL == $result) {
         $errorMsg = '订单提交失败';
     } else {
         if (Account::PAY_RESULT_FAIL_COUPON == $result) {
             $errorMsg = '代金券支付失败!';
         } else {
             if (Account::PAY_RESULT_NEED_RECHARGE != $result && Account::PAY_RESULT_NEED_EXCHANGE != $result && Account::PAY_RESULT_SUCC != $result) {
                 $errorMsg = '积分处理流程失败!';
             } else {
                 $ref = DAL::get()->find_by_spaceid_and_patientid_and_status('doctorpatientref', $this->space->id, $patientId, DoctorPatientRef::STATUS_INIT);
                 $response->ref = $ref;
                 $response->url = $url;
                 $response->score = $present->price;
                 $response->heartValue = $present->heartValue;
                 if (Account::PAY_RESULT_SUCC == $result) {
                     AsyncSendMessage::regAsyncMessage($presentOrder);
                     //发送站内信
                     if ($ref instanceof DoctorPatientRef) {
                         //管理员给患者的提示信息失效
                         NfsClient::getInstance()->disablePatientNotice($ref->id);
                     }
                 }
                 if ($presentOrder->isAudited()) {
                     return 'ajaxsuccesssent';
                 } else {
                     return 'ajaxsuccesscustom';
                 }
             }
         }
     }
     $response->errorMsg = $errorMsg;
     $response->result = $result;
     return 'ajaxfailsent';
 }