package com.seer.teach.pay.api.refund;

import com.seer.teach.pay.api.refund.dto.RefundOrderRequestDTO;
import com.seer.teach.pay.api.refund.dto.RefundResponseDTO;
import com.seer.teach.pay.app.wallet.convert.RefundConvert;
import com.seer.teach.pay.app.refund.service.IAppRefundOrderService;
import com.seer.teach.pay.dto.RefundSubmitRespDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

/**
 * 退款订单服务API实现类
 * 作为Feign接口的实现，提供退款服务
 */
@Slf4j
@RestController
@RequiredArgsConstructor
public class RefundOrderServiceApiImpl implements RefundOrderServiceApi {

    private final IAppRefundOrderService appRefundOrderService;

    @Override
    public RefundResponseDTO submitRefund(RefundOrderRequestDTO refundRequest) {
        log.info("收到退款申请请求：{}", refundRequest);
        RefundSubmitRespDTO refundSubmitRespDTO = appRefundOrderService.refundOrder(refundRequest);
        return RefundConvert.INSTANCE.convert(refundSubmitRespDTO);
    }

    @Override
    public RefundResponseDTO queryRefundStatus(String refundSn) {
        log.info("收到查询退款状态请求，退款单号：{}", refundSn);
        RefundSubmitRespDTO refundSubmitRespDTO = appRefundOrderService.queryRefundStatus(refundSn);
        return RefundConvert.INSTANCE.convert(refundSubmitRespDTO);
    }
}