function testCancelFavor() { $date = TimeUtils::getCurrentDate(); $userId = $_SESSION['user']->userId; $meal = MealAction::getTodayMeal($date); $favorite = MealAction::cancelFavor($userId, $meal->mealId); if ($favorite === MealAction::$CANCEL_FAVOR_FAIL) { $result = new Response(false, "cancel favor failed"); return $result; } elseif ($favorite === MealAction::$CANCEL_FAVOR_NOT_ORDER_MEAL) { $result = new Response(false, "you haven't ordered yet"); return $result; } elseif ($favorite === MealAction::$CANCEL_FAVOR_NOT_FAVOR_BEFORE) { $result = new Response(false, "you haven't liked it "); return $result; } elseif ($favorite === true) { $result = new Response(true); return $result; } return new Response(false, "服务器错误"); }
function testFavor($arr) { $date = TimeUtils::getCurrentDate(); $userId = $_SESSION['user']->userId; $meal = MealAction::getTodayMeal($date); $favorite = MealAction::favor($userId, $meal->mealId); if ($favorite === MealAction::$FAVOR_FAIL) { $result = new Response(false, "favor failed"); return $result; } elseif ($favorite === MealAction::$FAVOR_NOT_FOUND_MEAL_ID) { $result = new Response(false, "can't find this meal"); return $result; } elseif ($favorite === MealAction::$FAVOR_NOT_ORDER_MEAL) { $result = new Response(false, "can't find this order"); return $result; } elseif ($favorite === MealAction::$FAVOR_DUPLICATE) { $result = new Response(false, "you have favorited this meal"); return $result; } elseif ($favorite === true) { $result = new Response(true); return $result; } return new Response(false, "服务器故障"); }