Browse Source

重构奖励处理逻辑:将RewardLogic中的处理方法拆分为独立的静态处理器类

- 创建RewardProcessorDispatcher分发器,根据奖励类型分发到对应处理器
- 拆分出9个独立的奖励处理器类:
  - ItemRewardProcessor:处理物品奖励
  - FundConfigRewardProcessor:处理账户种类奖励
  - CurrencyRewardProcessor:处理币种奖励
  - PetExpRewardProcessor:处理宠物经验奖励
  - PetEnergyRewardProcessor:处理宠物体力奖励
  - PetRewardProcessor:处理宠物奖励
  - PetPowerRewardProcessor:处理宠物体力奖励
  - FarmShrineRewardProcessor:处理神像奖励
  - OtherRewardProcessor:处理其他奖励
- 每个处理器都是简单的静态类,遵循单一职责原则
- 修改RewardLogic类使用新的分发器,移除原有的处理方法
- 添加README.md说明处理器目录为自动生成内容
notfff 7 tháng trước cách đây
mục cha
commit
e37710c89f

+ 4 - 570
app/Module/Game/Logics/RewardLogic.php

@@ -5,19 +5,16 @@ namespace App\Module\Game\Logics;
 use App\Module\Game\Dtos\RewardGroupDto;
 use App\Module\Game\Dtos\RewardItemDto;
 use App\Module\Game\Dtos\RewardResultDto;
-use App\Module\Game\Enums\REWARD_TYPE;
 use App\Module\Game\Enums\REWARD_MODE;
 use App\Module\Game\Events\RewardGrantedEvent;
 use App\Module\Game\Models\GameRewardGroup;
 use App\Module\Game\Models\GameRewardLog;
-use App\Module\Game\Services\RewardCollectorService;
 use App\Module\Game\Services\PityService;
 use App\Module\Game\Logics\WeightSelectionReward;
 use App\Module\Game\Logics\IndependentProbabilityReward;
-use App\Module\GameItems\Services\ItemService;
+use App\Module\Game\Logics\RewardProcessors\RewardProcessorDispatcher;
 use Exception;
 use Illuminate\Support\Facades\Log;
-use ReflectionClass;
 use UCore\Db\Helper;
 
 /**
@@ -79,7 +76,7 @@ class RewardLogic
 
             // 发放各类奖励
             foreach ($rewardItems as $item) {
-                $this->processRewardItem($userId, $item, $sourceType, $sourceId);
+                RewardProcessorDispatcher::process($userId, $item, $sourceType, $sourceId);
             }
 
             // 记录奖励日志
@@ -138,68 +135,7 @@ class RewardLogic
 
 
 
-    /**
-     * 处理单个奖励项
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     * @throws Exception
-     */
-    private function processRewardItem(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        switch ($item->rewardType) {
-            case REWARD_TYPE::ITEM->valueInt():
-                $this->processItemReward($userId, $item, $sourceType, $sourceId);
-                break;
-
-            case REWARD_TYPE::FUND_CONFIG->valueInt():
-                $this->processFundConfigReward($userId, $item, $sourceType, $sourceId);
-                break;
-
-            case REWARD_TYPE::CURRENCY->valueInt():
-                $this->processCurrencyReward($userId, $item, $sourceType, $sourceId);
-                break;
-
-            case REWARD_TYPE::PET_EXP->valueInt():
-                $this->processPetExpReward($userId, $item, $sourceType, $sourceId);
-                break;
-
-            case REWARD_TYPE::PET_ENERGY->valueInt():
-                $this->processPetEnergyReward($userId, $item, $sourceType, $sourceId);
-                break;
-
-            case REWARD_TYPE::FARM_SHRINE->valueInt():
-                $this->processFarmShrineReward($userId, $item, $sourceType, $sourceId);
-                break;
-
-            case REWARD_TYPE::PET->valueInt():
-                $this->processPetReward($userId, $item, $sourceType, $sourceId);
-                break;
-
-            case REWARD_TYPE::PET_POWER->valueInt():
-                $this->processPetPowerReward($userId, $item, $sourceType, $sourceId);
-                break;
-
-            case REWARD_TYPE::OTHER->valueInt():
-                $this->processOtherReward($userId, $item, $sourceType, $sourceId);
-                break;
-
-            default:
-                // 未知奖励类型,记录日志
-                Log::warning("未知的奖励类型", [
-                    'userId' => $userId,
-                    'rewardType' => $item->rewardType,
-                    'targetId' => $item->targetId,
-                    'quantity' => $item->quantity,
-                    'sourceType' => $sourceType,
-                    'sourceId' => $sourceId
-                ]);
-                break;
-        }
-    }
+
 
     /**
      * 记录奖励日志
@@ -236,527 +172,25 @@ class RewardLogic
         ]);
     }
 
-    /**
-     * 处理物品奖励
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     * @throws Exception
-     */
-    private function processItemReward(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        try {
-            // 发放物品奖励,传递来源信息
-            ItemService::addItem($userId, $item->targetId, $item->quantity, [
-                'param1' => $item->param1,
-                'param2' => $item->param2,
-                'source_type' => $sourceType,
-                'source_id' => $sourceId,
-                'source' => 'reward', // 保持向后兼容
-                'extra_data' => $item->extraData
-            ]);
-
-            Log::info("物品奖励发放成功", [
-                'userId' => $userId,
-                'itemId' => $item->targetId,
-                'quantity' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId
-            ]);
-        } catch (Exception $e) {
-            Log::error("物品奖励发放失败", [
-                'userId' => $userId,
-                'itemId' => $item->targetId,
-                'quantity' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId,
-                'error' => $e->getMessage()
-            ]);
-            throw new Exception("物品奖励发放失败: " . $e->getMessage());
-        }
-    }
-
-    /**
-     * 处理账户种类奖励(FUND_CONFIG)
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     * @throws Exception
-     */
-    private function processFundConfigReward(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        try {
-            // 使用Fund模块的User类来处理资金变更
-            // target_id 是 fund_config 表的 id(账户种类ID)
-            $result = \App\Module\Fund\Logic\User::handle(
-                $userId,
-                $item->targetId, // fund_config_id
-                $item->quantity, // 金额
-                \App\Module\Fund\Enums\LOG_TYPE::TRADE, // 日志类型为贸易
-                $sourceId, // 关联ID,使用来源ID
-                "奖励发放:账户种类奖励 - {$sourceType}#{$sourceId}"
-            );
-
-            if (is_string($result)) {
-                throw new Exception("账户种类奖励发放失败: " . $result);
-            }
-
-            Log::info("账户种类奖励发放成功", [
-                'userId' => $userId,
-                'fundConfigId' => $item->targetId,
-                'amount' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId
-            ]);
-        } catch (Exception $e) {
-            Log::error("账户种类奖励发放失败", [
-                'userId' => $userId,
-                'fundConfigId' => $item->targetId,
-                'amount' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId,
-                'error' => $e->getMessage()
-            ]);
-            throw new Exception("账户种类奖励发放失败: " . $e->getMessage());
-        }
-    }
-
-    /**
-     * 处理币种奖励(CURRENCY)
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     * @throws Exception
-     */
-    private function processCurrencyReward(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        try {
-            // 对于币种奖励,需要先根据币种ID找到对应的账户种类ID
-            // 这里需要查询 fund_config 表,找到对应币种的账户种类
-            $fundConfig = \App\Module\Fund\Models\FundConfigModel::where('currency_id', $item->targetId)->first();
-
-            if (!$fundConfig) {
-                throw new Exception("找不到币种ID为 {$item->targetId} 的账户配置");
-            }
-
-            // 使用找到的账户种类ID来发放奖励
-            $result = \App\Module\Fund\Logic\User::handle(
-                $userId,
-                $fundConfig->id, // fund_config_id
-                $item->quantity, // 金额
-                \App\Module\Fund\Enums\LOG_TYPE::TRADE, // 日志类型
-                $sourceId, // 关联ID,使用来源ID
-                "奖励发放:币种奖励 - {$sourceType}#{$sourceId}"
-            );
-
-            if (is_string($result)) {
-                throw new Exception("币种奖励发放失败: " . $result);
-            }
-
-            Log::info("币种奖励发放成功", [
-                'userId' => $userId,
-                'currencyId' => $item->targetId,
-                'fundConfigId' => $fundConfig->id,
-                'amount' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId
-            ]);
-        } catch (Exception $e) {
-            Log::error("币种奖励发放失败", [
-                'userId' => $userId,
-                'currencyId' => $item->targetId,
-                'amount' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId,
-                'error' => $e->getMessage()
-            ]);
-            throw new Exception("币种奖励发放失败: " . $e->getMessage());
-        }
-    }
-
-    /**
-     * 处理宠物经验奖励
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     * @throws Exception
-     */
-    private function processPetExpReward(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        try {
-            // 获取用户的宠物
-            $pet = \App\Module\Pet\Models\PetUser::where('user_id', $userId)
-                ->where('id', $item->targetId)
-                ->first();
-
-            if (!$pet) {
-                throw new Exception("找不到ID为 {$item->targetId} 的宠物");
-            }
-
-            // 使用宠物逻辑类来增加经验
-            $petLogic = new \App\Module\Pet\Logic\PetLogic();
-            $reflection = new \ReflectionClass($petLogic);
-            $method = $reflection->getMethod('addExperience');
-            $method->setAccessible(true);
-
-            $levelUpOccurred = $method->invoke($petLogic, $item->targetId, $item->quantity);
-
-            Log::info("宠物经验奖励发放成功", [
-                'userId' => $userId,
-                'petId' => $item->targetId,
-                'expAmount' => $item->quantity,
-                'levelUp' => $levelUpOccurred,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId
-            ]);
-        } catch (Exception $e) {
-            Log::error("宠物经验奖励发放失败", [
-                'userId' => $userId,
-                'petId' => $item->targetId,
-                'expAmount' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId,
-                'error' => $e->getMessage()
-            ]);
-            throw new Exception("宠物经验奖励发放失败: " . $e->getMessage());
-        }
-    }
-
-    /**
-     * 处理宠物体力奖励
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     * @throws Exception
-     */
-    private function processPetEnergyReward(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        try {
-            // 获取用户的宠物
-            $pet = \App\Module\Pet\Models\PetUser::where('user_id', $userId)
-                ->where('id', $item->targetId)
-                ->first();
 
-            if (!$pet) {
-                throw new Exception("找不到ID为 {$item->targetId} 的宠物");
-            }
 
-            // 使用宠物逻辑类来增加体力
-            $petLogic = new \App\Module\Pet\Logic\PetLogic();
-            $reflection = new \ReflectionClass($petLogic);
-            $method = $reflection->getMethod('addStamina');
-            $method->setAccessible(true);
 
-            $actualGained = $method->invoke($petLogic, $item->targetId, $item->quantity);
 
-            Log::info("宠物体力奖励发放成功", [
-                'userId' => $userId,
-                'petId' => $item->targetId,
-                'staminaAmount' => $item->quantity,
-                'actualGained' => $actualGained,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId
-            ]);
-        } catch (Exception $e) {
-            Log::error("宠物体力奖励发放失败", [
-                'userId' => $userId,
-                'petId' => $item->targetId,
-                'staminaAmount' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId,
-                'error' => $e->getMessage()
-            ]);
-            throw new Exception("宠物体力奖励发放失败: " . $e->getMessage());
-        }
-    }
 
-    /**
-     * 处理宠物奖励
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     * @throws Exception
-     */
-    private function processPetReward(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        try {
-            // 获取宠物配置参数
-            $petConfigId = $item->targetId; // 宠物配置ID或宠物类型
-            $petCount = $item->quantity > 0 ? $item->quantity : 1; // 宠物数量,默认1只
-            $petGrade = $item->param1 > 0 ? $item->param1 : null; // 宠物品阶,为null时随机生成
-
-            // 验证宠物配置是否存在
-            $petConfig = \App\Module\Pet\Models\PetConfig::find($petConfigId);
-            if (!$petConfig) {
-                throw new Exception("宠物配置不存在,配置ID: {$petConfigId}");
-            }
 
-            // 循环创建宠物(支持一次奖励多只宠物)
-            $createdPets = [];
-            for ($i = 0; $i < $petCount; $i++) {
-                // 生成宠物名称
-                $petName = $this->generatePetName($petConfig->name, $i + 1, $petCount);
-
-                // 创建宠物
-                $result = \App\Module\Pet\Services\PetService::createPet($userId, $petName, $petGrade, [
-                    'pet_type' => $petConfig->pet_type,
-                    'source' => 'reward',
-                    'source_type' => $sourceType,
-                    'source_id' => $sourceId
-                ]);
-
-                if (!$result['success']) {
-                    throw new Exception("宠物创建失败: " . ($result['message'] ?? '未知错误'));
-                }
-
-                $createdPets[] = [
-                    'pet_id' => $result['pet_id'],
-                    'name' => $petName,
-                    'grade' => $result['grade']
-                ];
-
-                Log::info("宠物奖励创建成功", [
-                    'userId' => $userId,
-                    'petId' => $result['pet_id'],
-                    'petName' => $petName,
-                    'petGrade' => $result['grade'],
-                    'petConfigId' => $petConfigId,
-                    'petType' => $petConfig->pet_type,
-                    'index' => $i + 1,
-                    'totalCount' => $petCount,
-                    'sourceType' => $sourceType,
-                    'sourceId' => $sourceId
-                ]);
-            }
 
-            Log::info("宠物奖励发放完成", [
-                'userId' => $userId,
-                'petConfigId' => $petConfigId,
-                'petType' => $petConfig->pet_type,
-                'petCount' => $petCount,
-                'petGrade' => $petGrade,
-                'createdPets' => $createdPets,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId
-            ]);
-        } catch (Exception $e) {
-            Log::error("宠物奖励发放失败", [
-                'userId' => $userId,
-                'petConfigId' => $item->targetId,
-                'petCount' => $item->quantity,
-                'petGrade' => $item->param1,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId,
-                'error' => $e->getMessage()
-            ]);
-            throw new Exception("宠物奖励发放失败: " . $e->getMessage());
-        }
-    }
 
-    /**
-     * 处理宠物体力奖励
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     * @throws Exception
-     */
-    private function processPetPowerReward(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        try {
-            // 获取宠物ID和体力数量
-            $petId = $item->targetId;
-            $powerAmount = $item->quantity;
 
-            // 验证宠物是否存在且属于该用户
-            $pet = \App\Module\Pet\Models\PetUser::where('id', $petId)
-                ->where('user_id', $userId)
-                ->first();
 
-            if (!$pet) {
-                throw new Exception("宠物不存在或不属于该用户,宠物ID: {$petId},用户ID: {$userId}");
-            }
-
-            // 使用宠物逻辑类来增加体力
-            $petLogic = new \App\Module\Pet\Logic\PetLogic();
-            $reflection = new \ReflectionClass($petLogic);
-            $method = $reflection->getMethod('addStamina');
-            $method->setAccessible(true);
-
-            $actualGained = $method->invoke($petLogic, $petId, $powerAmount);
-
-            Log::info("宠物体力奖励发放成功", [
-                'userId' => $userId,
-                'petId' => $petId,
-                'petName' => $pet->name,
-                'powerAmount' => $powerAmount,
-                'actualGained' => $actualGained,
-                'currentPower' => $pet->fresh()->stamina,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId
-            ]);
-        } catch (Exception $e) {
-            Log::error("宠物体力奖励发放失败", [
-                'userId' => $userId,
-                'petId' => $item->targetId,
-                'powerAmount' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId,
-                'error' => $e->getMessage()
-            ]);
-            throw new Exception("宠物体力奖励发放失败: " . $e->getMessage());
-        }
-    }
 
-    /**
-     * 生成宠物名称
-     *
-     * @param string $baseName 基础名称
-     * @param int $index 索引
-     * @param int $total 总数
-     * @return string 生成的宠物名称
-     */
-    private function generatePetName(string $baseName, int $index, int $total): string
-    {
-        if ($total == 1) {
-            return $baseName;
-        }
 
-        return $baseName . $index;
-    }
 
-    /**
-     * 处理神像奖励(农场buff)
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     * @throws Exception
-     */
-    private function processFarmShrineReward(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        try {
-            // 获取神像类型和持续时间
-            $shrineType = $item->targetId; // 神像类型(1=丰收之神,2=雨露之神,3=屠草之神,4=拭虫之神)
-            $durationHours = $item->param2 > 0 ? $item->param2 : 24; // 持续时间(小时),默认24小时
-            $activationCount = $item->quantity > 0 ? $item->quantity : 1; // 激活次数,默认1次
-
-            // 验证神像类型是否有效
-            if (!in_array($shrineType, [1, 2, 3, 4])) {
-                throw new Exception("无效的神像类型: {$shrineType}");
-            }
 
-            // 验证用户是否存在
-            $farmUser = \App\Module\Farm\Models\FarmUser::where('user_id', $userId)->first();
-            if (!$farmUser) {
-                throw new Exception("用户农场数据不存在,用户ID: {$userId}");
-            }
 
-            // 循环激活神像(支持多次激活)
-            for ($i = 0; $i < $activationCount; $i++) {
-                // 使用BuffService激活神像
-                $buff = \App\Module\Farm\Services\BuffService::activateBuff($userId, $shrineType, $durationHours);
-
-                if (!$buff) {
-                    throw new Exception("神像激活失败,神像类型: {$shrineType},用户ID: {$userId}");
-                }
-
-                Log::info("神像奖励激活成功", [
-                    'userId' => $userId,
-                    'shrineType' => $shrineType,
-                    'shrineName' => \App\Module\Farm\Enums\BUFF_TYPE::getName($shrineType),
-                    'durationHours' => $durationHours,
-                    'activationIndex' => $i + 1,
-                    'totalActivations' => $activationCount,
-                    'expireTime' => $buff->expire_time ? $buff->expire_time->toDateTimeString() : null,
-                    'sourceType' => $sourceType,
-                    'sourceId' => $sourceId
-                ]);
-            }
 
-            // 收集神像奖励到Response.Reward中
-            RewardCollectorService::addGodReward(
-                $shrineType,
-                $durationHours * 3600, // 转换为秒
-                $activationCount
-            );
 
-            Log::info("神像奖励发放完成", [
-                'userId' => $userId,
-                'shrineType' => $shrineType,
-                'shrineName' => \App\Module\Farm\Enums\BUFF_TYPE::getName($shrineType),
-                'durationHours' => $durationHours,
-                'totalActivations' => $activationCount,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId
-            ]);
-        } catch (Exception $e) {
-            Log::error("神像奖励发放失败", [
-                'userId' => $userId,
-                'shrineType' => $item->targetId,
-                'durationHours' => $item->param2,
-                'quantity' => $item->quantity,
-                'sourceType' => $sourceType,
-                'sourceId' => $sourceId,
-                'error' => $e->getMessage()
-            ]);
-            throw new Exception("神像奖励发放失败: " . $e->getMessage());
-        }
-    }
 
-    /**
-     * 处理其他类型奖励
-     *
-     * @param int $userId 用户ID
-     * @param RewardItemDto $item 奖励项
-     * @param string $sourceType 来源类型
-     * @param int $sourceId 来源ID
-     * @return void
-     */
-    private function processOtherReward(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
-    {
-        // 其他类型奖励的处理逻辑
-        // 这里可以根据具体需求实现,比如称号、成就等
-        Log::info("其他类型奖励处理", [
-            'userId' => $userId,
-            'rewardType' => $item->rewardType,
-            'targetId' => $item->targetId,
-            'quantity' => $item->quantity,
-            'param1' => $item->param1,
-            'param2' => $item->param2,
-            'extraData' => $item->extraData,
-            'sourceType' => $sourceType,
-            'sourceId' => $sourceId
-        ]);
 
-        // 目前只记录日志,具体实现可以根据业务需求扩展
-        // 例如:
-        // - 称号奖励:更新用户称号
-        // - 成就奖励:解锁成就
-        // - 特殊权限:更新用户权限
-    }
 
     /**
      * 模拟奖励发放(不实际发放,仅返回奖励结果)
@@ -825,7 +259,7 @@ class RewardLogic
 
             // 发放各类奖励
             foreach ($rewardItems as $item) {
-                $this->processRewardItem($userId, $item, $sourceType, $sourceId);
+                RewardProcessorDispatcher::process($userId, $item, $sourceType, $sourceId);
             }
 
             // 更新保底计数(如果启用保底机制)

+ 71 - 0
app/Module/Game/Logics/RewardProcessors/CurrencyRewardProcessor.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use Exception;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * 币种奖励处理器
+ * 
+ * 处理币种(CURRENCY)类型的奖励发放
+ */
+class CurrencyRewardProcessor
+{
+    /**
+     * 处理币种奖励(CURRENCY)
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     * @throws Exception
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        try {
+            // 对于币种奖励,需要先根据币种ID找到对应的账户种类ID
+            // 这里需要查询 fund_config 表,找到对应币种的账户种类
+            $fundConfig = \App\Module\Fund\Models\FundConfigModel::where('currency_id', $item->targetId)->first();
+
+            if (!$fundConfig) {
+                throw new Exception("找不到币种ID为 {$item->targetId} 的账户配置");
+            }
+
+            // 使用找到的账户种类ID来发放奖励
+            $result = \App\Module\Fund\Logic\User::handle(
+                $userId,
+                $fundConfig->id, // fund_config_id
+                $item->quantity, // 金额
+                \App\Module\Fund\Enums\LOG_TYPE::TRADE, // 日志类型
+                $sourceId, // 关联ID,使用来源ID
+                "奖励发放:币种奖励 - {$sourceType}#{$sourceId}"
+            );
+
+            if (is_string($result)) {
+                throw new Exception("币种奖励发放失败: " . $result);
+            }
+
+            Log::info("币种奖励发放成功", [
+                'userId' => $userId,
+                'currencyId' => $item->targetId,
+                'fundConfigId' => $fundConfig->id,
+                'amount' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId
+            ]);
+        } catch (Exception $e) {
+            Log::error("币种奖励发放失败", [
+                'userId' => $userId,
+                'currencyId' => $item->targetId,
+                'amount' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId,
+                'error' => $e->getMessage()
+            ]);
+            throw new Exception("币种奖励发放失败: " . $e->getMessage());
+        }
+    }
+}

+ 97 - 0
app/Module/Game/Logics/RewardProcessors/FarmShrineRewardProcessor.php

@@ -0,0 +1,97 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use App\Module\Game\Services\RewardCollectorService;
+use Exception;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * 神像奖励处理器
+ * 
+ * 处理神像(FARM_SHRINE)类型的奖励发放
+ */
+class FarmShrineRewardProcessor
+{
+    /**
+     * 处理神像奖励(农场buff)
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     * @throws Exception
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        try {
+            // 获取神像类型和持续时间
+            $shrineType = $item->targetId; // 神像类型(1=丰收之神,2=雨露之神,3=屠草之神,4=拭虫之神)
+            $durationHours = $item->param2 > 0 ? $item->param2 : 24; // 持续时间(小时),默认24小时
+            $activationCount = $item->quantity > 0 ? $item->quantity : 1; // 激活次数,默认1次
+
+            // 验证神像类型是否有效
+            if (!in_array($shrineType, [1, 2, 3, 4])) {
+                throw new Exception("无效的神像类型: {$shrineType}");
+            }
+
+            // 验证用户是否存在
+            $farmUser = \App\Module\Farm\Models\FarmUser::where('user_id', $userId)->first();
+            if (!$farmUser) {
+                throw new Exception("用户农场数据不存在,用户ID: {$userId}");
+            }
+
+            // 循环激活神像(支持多次激活)
+            for ($i = 0; $i < $activationCount; $i++) {
+                // 使用BuffService激活神像
+                $buff = \App\Module\Farm\Services\BuffService::activateBuff($userId, $shrineType, $durationHours);
+
+                if (!$buff) {
+                    throw new Exception("神像激活失败,神像类型: {$shrineType},用户ID: {$userId}");
+                }
+
+                Log::info("神像奖励激活成功", [
+                    'userId' => $userId,
+                    'shrineType' => $shrineType,
+                    'shrineName' => \App\Module\Farm\Enums\BUFF_TYPE::getName($shrineType),
+                    'durationHours' => $durationHours,
+                    'activationIndex' => $i + 1,
+                    'totalActivations' => $activationCount,
+                    'expireTime' => $buff->expire_time ? $buff->expire_time->toDateTimeString() : null,
+                    'sourceType' => $sourceType,
+                    'sourceId' => $sourceId
+                ]);
+            }
+
+            // 收集神像奖励到Response.Reward中
+            RewardCollectorService::addGodReward(
+                $shrineType,
+                $durationHours * 3600, // 转换为秒
+                $activationCount
+            );
+
+            Log::info("神像奖励发放完成", [
+                'userId' => $userId,
+                'shrineType' => $shrineType,
+                'shrineName' => \App\Module\Farm\Enums\BUFF_TYPE::getName($shrineType),
+                'durationHours' => $durationHours,
+                'totalActivations' => $activationCount,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId
+            ]);
+        } catch (Exception $e) {
+            Log::error("神像奖励发放失败", [
+                'userId' => $userId,
+                'shrineType' => $item->targetId,
+                'durationHours' => $item->param2,
+                'quantity' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId,
+                'error' => $e->getMessage()
+            ]);
+            throw new Exception("神像奖励发放失败: " . $e->getMessage());
+        }
+    }
+}

+ 63 - 0
app/Module/Game/Logics/RewardProcessors/FundConfigRewardProcessor.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use Exception;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * 账户种类奖励处理器
+ * 
+ * 处理账户种类(FUND_CONFIG)类型的奖励发放
+ */
+class FundConfigRewardProcessor
+{
+    /**
+     * 处理账户种类奖励(FUND_CONFIG)
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     * @throws Exception
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        try {
+            // 使用Fund模块的User类来处理资金变更
+            // target_id 是 fund_config 表的 id(账户种类ID)
+            $result = \App\Module\Fund\Logic\User::handle(
+                $userId,
+                $item->targetId, // fund_config_id
+                $item->quantity, // 金额
+                \App\Module\Fund\Enums\LOG_TYPE::TRADE, // 日志类型为贸易
+                $sourceId, // 关联ID,使用来源ID
+                "奖励发放:账户种类奖励 - {$sourceType}#{$sourceId}"
+            );
+
+            if (is_string($result)) {
+                throw new Exception("账户种类奖励发放失败: " . $result);
+            }
+
+            Log::info("账户种类奖励发放成功", [
+                'userId' => $userId,
+                'fundConfigId' => $item->targetId,
+                'amount' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId
+            ]);
+        } catch (Exception $e) {
+            Log::error("账户种类奖励发放失败", [
+                'userId' => $userId,
+                'fundConfigId' => $item->targetId,
+                'amount' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId,
+                'error' => $e->getMessage()
+            ]);
+            throw new Exception("账户种类奖励发放失败: " . $e->getMessage());
+        }
+    }
+}

+ 59 - 0
app/Module/Game/Logics/RewardProcessors/ItemRewardProcessor.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use App\Module\GameItems\Services\ItemService;
+use Exception;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * 物品奖励处理器
+ * 
+ * 处理物品类型的奖励发放
+ */
+class ItemRewardProcessor
+{
+    /**
+     * 处理物品奖励
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     * @throws Exception
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        try {
+            // 发放物品奖励,传递来源信息
+            ItemService::addItem($userId, $item->targetId, $item->quantity, [
+                'param1' => $item->param1,
+                'param2' => $item->param2,
+                'source_type' => $sourceType,
+                'source_id' => $sourceId,
+                'source' => 'reward', // 保持向后兼容
+                'extra_data' => $item->extraData
+            ]);
+
+            Log::info("物品奖励发放成功", [
+                'userId' => $userId,
+                'itemId' => $item->targetId,
+                'quantity' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId
+            ]);
+        } catch (Exception $e) {
+            Log::error("物品奖励发放失败", [
+                'userId' => $userId,
+                'itemId' => $item->targetId,
+                'quantity' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId,
+                'error' => $e->getMessage()
+            ]);
+            throw new Exception("物品奖励发放失败: " . $e->getMessage());
+        }
+    }
+}

+ 46 - 0
app/Module/Game/Logics/RewardProcessors/OtherRewardProcessor.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * 其他奖励处理器
+ * 
+ * 处理其他(OTHER)类型的奖励发放
+ */
+class OtherRewardProcessor
+{
+    /**
+     * 处理其他类型奖励
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        // 其他类型奖励的处理逻辑
+        // 这里可以根据具体需求实现,比如称号、成就等
+        Log::info("其他类型奖励处理", [
+            'userId' => $userId,
+            'rewardType' => $item->rewardType,
+            'targetId' => $item->targetId,
+            'quantity' => $item->quantity,
+            'param1' => $item->param1,
+            'param2' => $item->param2,
+            'extraData' => $item->extraData,
+            'sourceType' => $sourceType,
+            'sourceId' => $sourceId
+        ]);
+
+        // 目前只记录日志,具体实现可以根据业务需求扩展
+        // 例如:
+        // - 称号奖励:更新用户称号
+        // - 成就奖励:解锁成就
+        // - 特殊权限:更新用户权限
+    }
+}

+ 67 - 0
app/Module/Game/Logics/RewardProcessors/PetEnergyRewardProcessor.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use Exception;
+use Illuminate\Support\Facades\Log;
+use ReflectionClass;
+
+/**
+ * 宠物体力奖励处理器
+ * 
+ * 处理宠物体力(PET_ENERGY)类型的奖励发放
+ */
+class PetEnergyRewardProcessor
+{
+    /**
+     * 处理宠物体力奖励
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     * @throws Exception
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        try {
+            // 获取用户的宠物
+            $pet = \App\Module\Pet\Models\PetUser::where('user_id', $userId)
+                ->where('id', $item->targetId)
+                ->first();
+
+            if (!$pet) {
+                throw new Exception("找不到ID为 {$item->targetId} 的宠物");
+            }
+
+            // 使用宠物逻辑类来增加体力
+            $petLogic = new \App\Module\Pet\Logic\PetLogic();
+            $reflection = new ReflectionClass($petLogic);
+            $method = $reflection->getMethod('addStamina');
+            $method->setAccessible(true);
+
+            $actualGained = $method->invoke($petLogic, $item->targetId, $item->quantity);
+
+            Log::info("宠物体力奖励发放成功", [
+                'userId' => $userId,
+                'petId' => $item->targetId,
+                'staminaAmount' => $item->quantity,
+                'actualGained' => $actualGained,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId
+            ]);
+        } catch (Exception $e) {
+            Log::error("宠物体力奖励发放失败", [
+                'userId' => $userId,
+                'petId' => $item->targetId,
+                'staminaAmount' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId,
+                'error' => $e->getMessage()
+            ]);
+            throw new Exception("宠物体力奖励发放失败: " . $e->getMessage());
+        }
+    }
+}

+ 67 - 0
app/Module/Game/Logics/RewardProcessors/PetExpRewardProcessor.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use Exception;
+use Illuminate\Support\Facades\Log;
+use ReflectionClass;
+
+/**
+ * 宠物经验奖励处理器
+ * 
+ * 处理宠物经验(PET_EXP)类型的奖励发放
+ */
+class PetExpRewardProcessor
+{
+    /**
+     * 处理宠物经验奖励
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     * @throws Exception
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        try {
+            // 获取用户的宠物
+            $pet = \App\Module\Pet\Models\PetUser::where('user_id', $userId)
+                ->where('id', $item->targetId)
+                ->first();
+
+            if (!$pet) {
+                throw new Exception("找不到ID为 {$item->targetId} 的宠物");
+            }
+
+            // 使用宠物逻辑类来增加经验
+            $petLogic = new \App\Module\Pet\Logic\PetLogic();
+            $reflection = new ReflectionClass($petLogic);
+            $method = $reflection->getMethod('addExperience');
+            $method->setAccessible(true);
+
+            $levelUpOccurred = $method->invoke($petLogic, $item->targetId, $item->quantity);
+
+            Log::info("宠物经验奖励发放成功", [
+                'userId' => $userId,
+                'petId' => $item->targetId,
+                'expAmount' => $item->quantity,
+                'levelUp' => $levelUpOccurred,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId
+            ]);
+        } catch (Exception $e) {
+            Log::error("宠物经验奖励发放失败", [
+                'userId' => $userId,
+                'petId' => $item->targetId,
+                'expAmount' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId,
+                'error' => $e->getMessage()
+            ]);
+            throw new Exception("宠物经验奖励发放失败: " . $e->getMessage());
+        }
+    }
+}

+ 73 - 0
app/Module/Game/Logics/RewardProcessors/PetPowerRewardProcessor.php

@@ -0,0 +1,73 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use Exception;
+use Illuminate\Support\Facades\Log;
+use ReflectionClass;
+
+/**
+ * 宠物体力奖励处理器
+ * 
+ * 处理宠物体力(PET_POWER)类型的奖励发放
+ */
+class PetPowerRewardProcessor
+{
+    /**
+     * 处理宠物体力奖励
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     * @throws Exception
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        try {
+            // 获取宠物ID和体力数量
+            $petId = $item->targetId;
+            $powerAmount = $item->quantity;
+
+            // 验证宠物是否存在且属于该用户
+            $pet = \App\Module\Pet\Models\PetUser::where('id', $petId)
+                ->where('user_id', $userId)
+                ->first();
+
+            if (!$pet) {
+                throw new Exception("宠物不存在或不属于该用户,宠物ID: {$petId},用户ID: {$userId}");
+            }
+
+            // 使用宠物逻辑类来增加体力
+            $petLogic = new \App\Module\Pet\Logic\PetLogic();
+            $reflection = new ReflectionClass($petLogic);
+            $method = $reflection->getMethod('addStamina');
+            $method->setAccessible(true);
+
+            $actualGained = $method->invoke($petLogic, $petId, $powerAmount);
+
+            Log::info("宠物体力奖励发放成功", [
+                'userId' => $userId,
+                'petId' => $petId,
+                'petName' => $pet->name,
+                'powerAmount' => $powerAmount,
+                'actualGained' => $actualGained,
+                'currentPower' => $pet->fresh()->stamina,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId
+            ]);
+        } catch (Exception $e) {
+            Log::error("宠物体力奖励发放失败", [
+                'userId' => $userId,
+                'petId' => $item->targetId,
+                'powerAmount' => $item->quantity,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId,
+                'error' => $e->getMessage()
+            ]);
+            throw new Exception("宠物体力奖励发放失败: " . $e->getMessage());
+        }
+    }
+}

+ 118 - 0
app/Module/Game/Logics/RewardProcessors/PetRewardProcessor.php

@@ -0,0 +1,118 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use Exception;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * 宠物奖励处理器
+ * 
+ * 处理宠物(PET)类型的奖励发放
+ */
+class PetRewardProcessor
+{
+    /**
+     * 处理宠物奖励
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     * @throws Exception
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        try {
+            // 获取宠物配置参数
+            $petConfigId = $item->targetId; // 宠物配置ID或宠物类型
+            $petCount = $item->quantity > 0 ? $item->quantity : 1; // 宠物数量,默认1只
+            $petGrade = $item->param1 > 0 ? $item->param1 : null; // 宠物品阶,为null时随机生成
+
+            // 验证宠物配置是否存在
+            $petConfig = \App\Module\Pet\Models\PetConfig::find($petConfigId);
+            if (!$petConfig) {
+                throw new Exception("宠物配置不存在,配置ID: {$petConfigId}");
+            }
+
+            // 循环创建宠物(支持一次奖励多只宠物)
+            $createdPets = [];
+            for ($i = 0; $i < $petCount; $i++) {
+                // 生成宠物名称
+                $petName = self::generatePetName($petConfig->name, $i + 1, $petCount);
+
+                // 创建宠物
+                $result = \App\Module\Pet\Services\PetService::createPet($userId, $petName, $petGrade, [
+                    'pet_type' => $petConfig->pet_type,
+                    'source' => 'reward',
+                    'source_type' => $sourceType,
+                    'source_id' => $sourceId
+                ]);
+
+                if (!$result['success']) {
+                    throw new Exception("宠物创建失败: " . ($result['message'] ?? '未知错误'));
+                }
+
+                $createdPets[] = [
+                    'pet_id' => $result['pet_id'],
+                    'name' => $petName,
+                    'grade' => $result['grade']
+                ];
+
+                Log::info("宠物奖励创建成功", [
+                    'userId' => $userId,
+                    'petId' => $result['pet_id'],
+                    'petName' => $petName,
+                    'petGrade' => $result['grade'],
+                    'petConfigId' => $petConfigId,
+                    'petType' => $petConfig->pet_type,
+                    'index' => $i + 1,
+                    'totalCount' => $petCount,
+                    'sourceType' => $sourceType,
+                    'sourceId' => $sourceId
+                ]);
+            }
+
+            Log::info("宠物奖励发放完成", [
+                'userId' => $userId,
+                'petConfigId' => $petConfigId,
+                'petType' => $petConfig->pet_type,
+                'petCount' => $petCount,
+                'petGrade' => $petGrade,
+                'createdPets' => $createdPets,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId
+            ]);
+        } catch (Exception $e) {
+            Log::error("宠物奖励发放失败", [
+                'userId' => $userId,
+                'petConfigId' => $item->targetId,
+                'petCount' => $item->quantity,
+                'petGrade' => $item->param1,
+                'sourceType' => $sourceType,
+                'sourceId' => $sourceId,
+                'error' => $e->getMessage()
+            ]);
+            throw new Exception("宠物奖励发放失败: " . $e->getMessage());
+        }
+    }
+
+    /**
+     * 生成宠物名称
+     *
+     * @param string $baseName 基础名称
+     * @param int $index 索引
+     * @param int $total 总数
+     * @return string 生成的宠物名称
+     */
+    private static function generatePetName(string $baseName, int $index, int $total): string
+    {
+        if ($total == 1) {
+            return $baseName;
+        }
+
+        return $baseName . $index;
+    }
+}

+ 38 - 0
app/Module/Game/Logics/RewardProcessors/README.md

@@ -0,0 +1,38 @@
+# 奖励处理器目录
+
+⚠️ **注意:此目录内容为自动生成,请勿手动修改!**
+
+## 目录说明
+
+此目录包含了奖励系统的各种处理器类,用于处理不同类型的奖励发放逻辑。
+
+## 文件列表
+
+- `RewardProcessorDispatcher.php` - 奖励处理器分发器,根据奖励类型分发到对应的处理器
+- `ItemRewardProcessor.php` - 物品奖励处理器
+- `FundConfigRewardProcessor.php` - 账户种类奖励处理器
+- `CurrencyRewardProcessor.php` - 币种奖励处理器
+- `PetExpRewardProcessor.php` - 宠物经验奖励处理器
+- `PetEnergyRewardProcessor.php` - 宠物体力奖励处理器
+- `PetRewardProcessor.php` - 宠物奖励处理器
+- `PetPowerRewardProcessor.php` - 宠物体力奖励处理器
+- `FarmShrineRewardProcessor.php` - 神像奖励处理器
+- `OtherRewardProcessor.php` - 其他奖励处理器
+
+## 使用方式
+
+通过 `RewardProcessorDispatcher::process()` 方法来处理奖励,分发器会根据奖励类型自动选择对应的处理器。
+
+```php
+RewardProcessorDispatcher::process($userId, $item, $sourceType, $sourceId);
+```
+
+## 架构说明
+
+每个处理器都是独立的静态类,包含一个 `process` 静态方法,接收以下参数:
+- `int $userId` - 用户ID
+- `RewardItemDto $item` - 奖励项
+- `string $sourceType` - 来源类型
+- `int $sourceId` - 来源ID
+
+这种设计遵循了单一职责原则,每个处理器只负责处理一种类型的奖励。

+ 79 - 0
app/Module/Game/Logics/RewardProcessors/RewardProcessorDispatcher.php

@@ -0,0 +1,79 @@
+<?php
+
+namespace App\Module\Game\Logics\RewardProcessors;
+
+use App\Module\Game\Dtos\RewardItemDto;
+use App\Module\Game\Enums\REWARD_TYPE;
+use Exception;
+use Illuminate\Support\Facades\Log;
+
+/**
+ * 奖励处理器分发器
+ * 
+ * 根据奖励类型分发到对应的处理器进行处理
+ */
+class RewardProcessorDispatcher
+{
+    /**
+     * 处理单个奖励项
+     *
+     * @param int $userId 用户ID
+     * @param RewardItemDto $item 奖励项
+     * @param string $sourceType 来源类型
+     * @param int $sourceId 来源ID
+     * @return void
+     * @throws Exception
+     */
+    public static function process(int $userId, RewardItemDto $item, string $sourceType, int $sourceId): void
+    {
+        switch ($item->rewardType) {
+            case REWARD_TYPE::ITEM->valueInt():
+                ItemRewardProcessor::process($userId, $item, $sourceType, $sourceId);
+                break;
+
+            case REWARD_TYPE::FUND_CONFIG->valueInt():
+                FundConfigRewardProcessor::process($userId, $item, $sourceType, $sourceId);
+                break;
+
+            case REWARD_TYPE::CURRENCY->valueInt():
+                CurrencyRewardProcessor::process($userId, $item, $sourceType, $sourceId);
+                break;
+
+            case REWARD_TYPE::PET_EXP->valueInt():
+                PetExpRewardProcessor::process($userId, $item, $sourceType, $sourceId);
+                break;
+
+            case REWARD_TYPE::PET_ENERGY->valueInt():
+                PetEnergyRewardProcessor::process($userId, $item, $sourceType, $sourceId);
+                break;
+
+            case REWARD_TYPE::FARM_SHRINE->valueInt():
+                FarmShrineRewardProcessor::process($userId, $item, $sourceType, $sourceId);
+                break;
+
+            case REWARD_TYPE::PET->valueInt():
+                PetRewardProcessor::process($userId, $item, $sourceType, $sourceId);
+                break;
+
+            case REWARD_TYPE::PET_POWER->valueInt():
+                PetPowerRewardProcessor::process($userId, $item, $sourceType, $sourceId);
+                break;
+
+            case REWARD_TYPE::OTHER->valueInt():
+                OtherRewardProcessor::process($userId, $item, $sourceType, $sourceId);
+                break;
+
+            default:
+                // 未知奖励类型,记录日志
+                Log::warning("未知的奖励类型", [
+                    'userId' => $userId,
+                    'rewardType' => $item->rewardType,
+                    'targetId' => $item->targetId,
+                    'quantity' => $item->quantity,
+                    'sourceType' => $sourceType,
+                    'sourceId' => $sourceId
+                ]);
+                break;
+        }
+    }
+}