예제 #1
0
 private function canSendPresent($patientId, $presentId = 0)
 {
     /*{{{*/
     $result = true;
     $msg = '';
     if ($presentId) {
         $present = DAL::get()->find('Present', $presentId, true);
         if ($present->isNull() || false == $present->isValid()) {
             $result = false;
             $msg = "礼物无效!";
         }
     }
     if ($result && $patientId) {
         $patient = DAL::get()->find('patient', $patientId);
         if ($this->user->id != $patient->user->id) {
             $result = false;
             $msg = "您不能给{$this->space->name}医生送礼物!";
         }
     }
     if ($result) {
         $sentCount = PresentClient::getInstance()->getTodaySentCount4Patient($patientId, $this->space->id, $this->user->id);
         if (PresentOrder::patientSendLimit($sentCount)) {
             $result = false;
             $msg = "您今天已经赠送了太多的礼物给" . $this->space->name . "医生!";
         }
     }
     return array($result, $msg);
 }