package com.erp.finance.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.erp.finance.dto.*;
import com.erp.finance.entity.RefundRecord;

/**
 * 退款记录服务接口
 */
public interface RefundService {

    /**
     * 创建退款记录（订单退款/售后退款）
     */
    RefundRecord createRefundRecord(RefundCreateRequest request);

    /**
     * 确认退款（财务确认发起退款）
     */
    RefundRecord confirmRefund(Long id, String operator);

    /**
     * 标记退款完成（外部支付渠道回调）
     */
    RefundRecord completeRefund(Long id, String externalRefundNo, String operator);

    /**
     * 退款失败
     */
    void failRefund(Long id, String reason);

    /**
     * 取消退款
     */
    void cancelRefund(Long id, String reason, String operator);

    /**
     * 查询退款记录
     */
    IPage<RefundRecord> query(RefundQueryRequest request);

    /**
     * 根据ID查询
     */
    RefundRecord getById(Long id);

    /**
     * 根据退款单号查询
     */
    RefundRecord getByRefundNo(String refundNo);

    /**
     * 获取待处理退款数量
     */
    long getPendingCount();

    /**
     * 统计退款金额
     */
    java.math.BigDecimal sumCompletedRefundAmount(java.time.LocalDateTime startTime, java.time.LocalDateTime endTime);

    // ========== 请求体 ==========
    @lombok.Data
    @lombok.NoArgsConstructor
    @lombok.AllArgsConstructor
    class RefundCreateRequest {
        private String orderNo;
        private String shortId;
        private java.math.BigDecimal refundAmount;
        private String refundReason;
        private java.time.LocalDateTime refundTime;
        private Long incomeRecordId;
        private java.math.BigDecimal originalAmount;
        private String refundMethod;
        private String refundAccount;
        private String type;
        private Long sourceId;
        private String source;
        private String operator;
        private String remark;
    }
}
