| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Module\Pet\Services;
- use App\Module\Pet\Logic\PetStealLogic;
- use App\Module\Pet\Dtos\StealResultDto;
- /**
- * 宠物偷菜服务类
- *
- * 提供宠物偷菜功能的对外接口
- */
- class PetStealService
- {
- /**
- * 执行偷菜操作
- *
- * @param int $stealerId 偷菜者用户ID
- * @param int $targetUserId 被偷者用户ID
- * @param int $plantId 作物ID
- * @param int $petId 宠物ID
- * @return StealResultDto 偷菜结果
- * @throws \Exception 偷菜失败时抛出异常
- */
- public static function stealCrop(int $stealerId, int $targetUserId, int $plantId, int $petId): StealResultDto
- {
- return PetStealLogic::stealCrop($stealerId, $targetUserId, $plantId, $petId);
- }
- /**
- * 检查是否可以偷菜
- *
- * @param int $stealerId 偷菜者用户ID
- * @param int $targetUserId 被偷者用户ID
- * @param int $landId 土地ID
- * @return array 检查结果 ['can_steal' => bool, 'reason' => string]
- */
- public static function canSteal(int $stealerId, int $targetUserId, int $landId): array
- {
- return PetStealLogic::canSteal($stealerId, $targetUserId, $landId);
- }
- /**
- * 获取土地的偷菜信息
- *
- * @param int $landId 土地ID
- * @return array 偷菜信息
- */
- public static function getStealInfo(int $landId): array
- {
- return PetStealLogic::getStealInfo($landId);
- }
- /**
- * 获取用户的偷菜统计
- *
- * @param int $userId 用户ID
- * @return array 偷菜统计信息
- */
- public static function getStealStats(int $userId): array
- {
- return PetStealLogic::getStealStats($userId);
- }
- }
|