// @param taskPreconditionInfo 任务前置条件信息<参考TaskPreconditionInfo> // @return boolean public function getResult($userTaskInfo, $taskPreconditionInfo){ // 用户基本信息比较 if (!is_null($userTaskInfo ->baseInfo)){ if ($this ->compare($taskPreconditionInfo ->age, $userTaskInfo ->baseInfo ->age)) return true; if ($this ->compare($taskPreconditionInfo ->sex, $userTaskInfo ->baseInfo ->sex)) return true; if ($this ->compare($taskPreconditionInfo ->time, $userTaskInfo ->baseInfo ->time)) return true; if ($this ->compare($taskPreconditionInfo ->ulevel, $userTaskInfo ->baseInfo ->ulevel)) return true; if ($this ->compare($taskPreconditionInfo ->place, $userTaskInfo ->baseInfo ->place)) return true; if ($this ->compare($taskPreconditionInfo ->weather, $userTaskInfo ->baseInfo ->weather)) return true; // todo } // 任务生理数据前置条件信息比较 if (!is_null($userTaskInfo ->taskPhysicalDataPInfo)){ if ($this ->compare($taskPreconditionInfo ->isLikeSports, $userTaskInfo ->baseInfo ->isLikeSports)) return true; if ($this ->compare($taskPreconditionInfo ->isHypertension, $userTaskInfo ->baseInfo ->isHypertension)) return true; if ($this ->compare($taskPreconditionInfo ->isHeartAttack, $userTaskInfo ->baseInfo ->isHeartAttack)) return true; if ($this ->compare($taskPreconditionInfo ->isAgile, $userTaskInfo ->baseInfo ->isAgile)) return true; if ($this ->compare($taskPreconditionInfo ->isHardBody, $userTaskInfo ->baseInfo ->isHardBody)) return true; // todo } return false; } // @function 是否是任务条件信息 // // @param value 值 // @return boolean private function isTaskCondtionInfo($value) { if ($value instanceof TaskCondtionInfo) return true; return false; } // @function 比较 // // @param value1 值1 // @param value2 值2 // @return boolean private function compare($value1,$value2) { if (true == $this ->isTaskCondtionInfo($value1)) { if (true == $this ->isEmpty($value1 ->equalValue)){ return $value2 == $value1 ->equalValue; } if (true == $this ->isEmpty($value1 ->minValue) && true == $this ->isEmpty($value1 ->maxValue)){ return ($value2 > $value1 ->minValue && $value2 <= $value1 ->maxValue); } if (true == $this ->isEmpty($value1 ->minValue)){ return $value2 >= $value1 ->minValue; } if (true == $this ->isEmpty($value1 ->maxValue)){ return $value2 <= $value1 ->maxValue; } }else { return $value1 == $value2; } } // @function 是否为空 // // @param value 值 // @return boolean private function isEmpty($value){ if (!is_null($value) && !empty($value)){ return true; } return false; } }