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


import com.yc.ship.framework.common.pojo.CommonResult;
import com.yc.ship.framework.security.core.LoginUser;
import com.yc.ship.module.trade.api.dto.*;
import com.yc.ship.module.trade.controller.admin.order.vo.refund.TradeRefundAmountReqVO;
import com.yc.ship.module.trade.dal.dataobject.order.TradeOrderPayDO;
import com.yc.ship.module.trade.service.refund.bo.MarketingPolicyRefundBO;
import com.yc.ship.module.trade.service.refund.bo.RefundAuditNotifyBO;

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

/**
 * &#064;Description 退款交易service接口
 * &#064;Author qsl
 * &#064;Date 2025/7/22 14:03
 */
public interface TradeRefundService {
    /**
     * 更新退款单锁
     */
    String UPDATE_REFUND_LOCK = "refund:update:lock:%d";
    String UPDATE_REFUND_RECORD_LOCK = "refundRecord:update:lock:%d";
    String UPDATE_REFUND_SUPPLIER_LOCK = "refundSupplier:update:lock:%d";
    String UPDATE_SUPPLIER_ORDER_LOCK = "supplier:update:lock:%d";
    String UPDATE_PAY_REFUND_ORDER_LOCK = "payAutoRefund:update:lock:%d";
    String BUILD_REFUND_RECORD_LOCK = "buildRefundRecord:update:lock:%d";
    String UPDATE_MARKETING_REFUND_ORDER_LOCK = "marketingRefund:update:lock:%d";
    String UPDATE_SERVICE_REFUND_ORDER_LOCK = "serviceRefund:update:lock:%d";
    String UPDATE_GUIDE_REFUND_ORDER_LOCK = "guideRefund:update:lock:%d";

    /**
     * 退款
     * @param refundCreateReqDTO
     * @return
     */
    CommonResult<TradeRefundRespDTO> refund(TradeRefundCreateReqDTO refundCreateReqDTO);
    CommonResult<TradeRefundRespDTO> minirefund(TradeRefundCreateReqDTO refundCreateReqDTO);

    /**
     * 退款审计
     * @param refundAuditReqDTO
     * @return
     */
    CommonResult<TradeRefundAuditRespDTO> refundAudit(TradeRefundAuditReqDTO refundAuditReqDTO);

    /**
     * 退款审计
     * @param cancelAuditReqDTO
     * @return
     */
    CommonResult<TradeCancelAuditRespDTO> cancelAudit(TradeCancelAuditReqDTO cancelAuditReqDTO);

    /**
     * 根据支付类型退款
     * @param refundId
     * @return
     */
    CommonResult<?> refundByPaymentType(Long refundId);

    /**
     * 接收MQ消息根据支付类型退款
     * @param refundId
     * @return
     */
    CommonResult<?> refundByPaymentTypeFromMq(Long refundId);

    /**
     * 处理退款通知（支付平台退款通知）
     * @param map
     * @return
     */
    CommonResult<?> handleRefundNotify( Map<String, Object> map);

    /**
     * 根据退款记录再次退款
     * @param refundRecordId
     * @return
     */
    CommonResult<?> refundByRecord(Long refundRecordId);

    /**
     * 退款查询
     * @param refundRecordId
     * @return
     */
    CommonResult<?> refundQuery(Long refundRecordId);

    /**
     * 重试供应商退款
     * @param refundId
     * @param supplierRefundId
     * @return
     */
    CommonResult<?> retrySupplierRefund(Long refundId,Long supplierRefundId);

    /**
     * 处理供应商退款审核
     * @param refundAuditNotifyBO
     * @return
     */
    CommonResult<?> handleSupplierRefundAuditNotify(RefundAuditNotifyBO refundAuditNotifyBO);

    /**
     * 计算退款金额
     * @param refundCreateReqDTO
     * @return
     */
    CommonResult<TradeRefundCalculateRespDTO> calculateRefundAmount(TradeRefundCreateReqDTO refundCreateReqDTO);

    CommonResult<?> autoRefundByPayOrder(Long payOrderId);

    void refundByMarketingPolicy(MarketingPolicyRefundBO marketingPolicyRefundBO);

    void refundByService(TradeRefundAmountReqVO tradeRefundAmountReqVO, LoginUser loginUser);

    void goOnAfterMarketingRefund(Long orderId);

    void refundBySuppTicket(TradeOrderPayDO payDO, BigDecimal refundAmount);

    CommonResult<?> cancelRefund(Long refundId);

    CommonResult<Boolean> refundByGuideRefund(Long orderId, Long guideRefundId, BigDecimal refundAmount,int refundType);
}
