getRow(); // 只有有来源ID的记录才显示此操作 return !empty($row->source_id) && !empty($row->source_type); } /** * 处理请求 * * @param Request $request * @return mixed */ public function handle(Request $request) { $id = $this->getKey(); $profit = UrsProfit::find($id); if (!$profit) { return $this->response()->error('收益记录不存在'); } if (empty($profit->source_id) || empty($profit->source_type)) { return $this->response()->error('收益来源信息不完整'); } // 根据来源类型确定跳转URL $url = $this->getSourceUrl($profit->source_type, $profit->source_id); if (!$url) { return $this->response()->error('不支持的来源类型:' . $profit->source_type); } return $this->response()->redirect($url); } /** * 根据来源类型获取详情页面URL * * @param string $sourceType * @param int $sourceId * @return string|null */ private function getSourceUrl(string $sourceType, int $sourceId): ?string { switch ($sourceType) { case 'land_harvest': // 土地收获记录 return admin_url("land/harvest-logs/{$sourceId}"); case 'user_register': // 用户注册记录 return admin_url("users/{$sourceId}"); case 'promotion_reward': // 推广奖励记录 return admin_url("urs-promotion/profits/{$sourceId}"); case 'planting_reward': // 种植奖励记录 return admin_url("urs-promotion/profits/{$sourceId}"); default: return null; } } }