package com.tourguide.modules.order.payment; import com.tourguide.modules.order.entity.TourOrder; import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.UUID; /** 当前未接入真实支付渠道,本地实现仅生成模拟退款流水号。 */ @Component public class LocalPaymentRefundGateway implements PaymentRefundGateway { @Override public String refund(TourOrder order, BigDecimal amount) { if (order.getPaymentOrderNo() == null || !order.getPaymentOrderNo().startsWith("LOCAL")) { throw new IllegalStateException("真实支付退款渠道尚未接入"); } String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); return "LOCALRF" + time + UUID.randomUUID().toString().replace("-", "") .substring(0, 6).toUpperCase(); } }