package com.yc.ship.module.trade.service.refund;


import com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO;
import com.yc.ship.module.trade.dal.dataobject.order.TradeOrderPayDO;
import com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO;
import com.yc.ship.module.trade.dal.dataobject.refund.*;
import com.yc.ship.module.trade.enums.RefundStatusEnum;
import com.yc.ship.module.trade.enums.VoucherStatusEnum;
import com.yc.ship.module.trade.service.order.bo.TradeOrderDetailBaseBO;
import com.yc.ship.module.trade.service.refund.bo.TradeRefundBO;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * &#064;Description ：退款数据服务
 * &#064;Author ：qsl
 * &#064;Date ：2025/7/22 16:18
 */

public interface TradeRefundRepositoryService{

    void saveRefund(TradeRefundBO tradeRefundBO);

    void updateOrderRefunding(TradeRefundBO tradeRefundBO);

    void updateRefundStatus(Long refundId, RefundStatusEnum refundStatusEnum);

    @Transactional(rollbackFor = Exception.class)
    void updateRefundStatusAndAmount(Long refundId, BigDecimal refundAmount, RefundStatusEnum refundStatusEnum);

    RefundDO getById(Long refundId);

    void saveRefundAudit( RefundAuditDO refundAuditDO);

    void recoveryStatus(RefundDO refundDO);

    void saveRefundRecordAndUpdatePayOrder(List<RefundRecordDO> recordDOList, List<TradeOrderPayDO> updatePayList);

    List<RefundDetailDO> getRefundDetailList(Long refundId);
    List<RefundDetailBaseDO> getRefundDetailBaseList(Long refundDetailId);

    void updateRefundRecord(RefundRecordDO refundRecordDO);

    void updateOrderDetailStatusByRefundId(Long refundId, VoucherStatusEnum refundStatus);

    @Transactional(rollbackFor = Exception.class)
    void updateOrderDetailBaseStatusByRefundId(Long refundId, VoucherStatusEnum refundStatus);

    BigDecimal getRefundRecordAmount(Long refundId);
    RefundRecordDO getRecordById(Long recordId);

    Map<String,Long> getRefundRecordFailCount(Long refundId);

    void saveRefundRecord(RefundRecordDO refundRecordDO);

    RefundDO getRefundByOatNoAndOrder(String otaRefundNo, Long orderId);

    RefundRecordDO getRecordByIdIgnoreTenant(Long recordId);
    void updateRefundSupplierStatus(Long refundId, RefundStatusEnum refundSupplierStatusEnum);

    RefundAuditDO getRefundAuditById(Long auditId);

    List<Map<String,Object>> getRefundOrderProduct(Long refundId);

    List<Map<String, Object>> getRefundOrderProductV2(Long refundId, List<String> noContainSpecList);

    BigDecimal getOrderRefundAmount(Long orderId);

    BigDecimal getOrderRefundFee(Long orderId);

    List<TradeOrderDetailBaseBO> getProductBaseByRefund(Long refundId);

    List<TradeOrderDetailBaseBO> getProjectCountByRefund(Long refundId,Long orderId);

    void updateRefundStatusById(Long id, Integer refundStatus);

    BigDecimal getOrderApplyRefundAmount(Long orderId);

    BigDecimal getMarketRefundAmount(Long orderId);

    RefundDO getChangeOrderRefund(Long orderId);

    List<TradeVisitorDO> getBoatVisitorListByRefund(Long refundId, Date useDate);

    BigDecimal getMarketRefundAmount(Long orderId, Long changeOrderId);

    List<Map<String,Object>> getTradeDetailStatusByRefund(Long refundId);

    BigDecimal getOrderOriginRefundAmount(Long orderId);

    void saveRefundAmountApply(RefundAmountApplyDO refundAmountApplyDO);

    void updateRefundAmountApply(Long id, RefundStatusEnum refundStatusEnum);

    RefundAmountApplyDO getRefundAmountApply(Long id);

    List<RefundRecordDO> getMarketRefundRecordList(Long orderId, Long changeOrderId);

    List<RefundRecordDO> getRefundRecordList(Long refundId);

    BigDecimal getRefundAmountByOriginOrderNo(String originOrderNo);

    List<RefundDO> getByOrderId(Long orderId);

    List<RefundDO> getAllByOrderId(Long orderId);

    BigDecimal getRefundAmountFromOrderDetail(Long orderId);

    @Transactional(rollbackFor = Exception.class)
    void justUpdateRefundStatus(Long refundId, RefundStatusEnum refundStatusEnum);

    TradeOrderDO getOrderByGuideRefundId(Long refundId);

    boolean hasGuideRefundInnerOrder(String orderNo, List<Long> detailIdList);

    boolean hasGuideRefundOrder(Long orderId, List<Long> detailIdList);
    Map<String,Long> getSupplierRefundCountBySupplierOrderId(Long supplierOrderId);

    Map<String,Long> getSupplierRefundCount(Long refundId);


}
