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()); } } }