getLandId(); $itemId = $data->getItemId(); $userId = $this->user_id; // 验证土地是否存在且属于当前用户 // 获取用户所有土地 $landInfo = LandService::getUserLand($userId,$landId); if (!$landInfo) { throw new LogicException("土地不存在或不属于当前用户"); } // 验证用户是否拥有该物品 $hasItem = ItemService::checkItemQuantity($userId, $itemId ,1); if ($hasItem->error) { throw new LogicException("您没有该肥料物品"); } $item = ItemService::getItemInfo($itemId); // 调用施肥服务 $result = CropService::useFertilizer($userId, $landId,$crop_growth_time); if (!$result) { throw new LogicException("施肥失败,请检查土地状态或作物生长阶段"); } // 消耗物品 ItemService::consumeItem($userId, $itemId, null, 1, [ 'source_type' => 'land_fertilizer', 'source_id' => $landId, 'details' => [ 'land_id' => $landId ] ]); Log::info('用户施肥成功', [ 'user_id' => $userId, 'land_id' => $landId, 'item_id' => $itemId ]); return $response; } }