package com.erp.finance.service;

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

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 付款记录服务接口
 */
public interface PaymentService {

    /**
     * 创建付款记录
     */
    PaymentRecord createPaymentRecord(PaymentCreateRequest request);

    /**
     * 确认付款
     */
    PaymentRecord confirmPayment(Long id, String operator);

    /**
     * 取消付款
     */
    void cancelPayment(Long id, String reason, String operator);

    /**
     * 查询付款记录
     */
    IPage<PaymentRecord> query(PaymentQueryRequest request);

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

    /**
     * 根据付款单号查询
     */
    PaymentRecord getByPaymentNo(String paymentNo);

    /**
     * 统计已付款总额
     */
    BigDecimal sumCompletedPaymentAmount(LocalDateTime startTime, LocalDateTime endTime);

    // ========== 请求体 ==========
    @lombok.Data
    @lombok.NoArgsConstructor
    @lombok.AllArgsConstructor
    class PaymentCreateRequest {
        private String apNo;
        private Long apId;
        private String purchaseOrderNo;
        private Long supplierId;
        private String supplierName;
        private BigDecimal amount;
        private String paymentMethod;
        private String fromAccount;
        private String toAccount;
        private String purpose;
        private Long relatedId;
        private String relatedType;
        private String operator;
        private String remark;
    }
}
