package com.fs.live.mapper;


import com.fs.live.domain.LiveOrderPayment;
import com.fs.live.vo.LiveOrderPaymentVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


/**
 * 支付明细Mapper接口
 *
 * @author fs
 * @date 2025-08-07
 */
public interface LiveOrderPaymentMapper {
    /**
     * 查询支付明细
     *
     * @param paymentId 支付明细主键
     * @return 支付明细
     */
    LiveOrderPayment selectLiveOrderPaymentByPaymentId(Long paymentId);

    /**
     * 查询支付明细列表
     *
     * @param liveOrderPayment 支付明细
     * @return 支付明细集合
     */
    List<LiveOrderPayment> selectLiveOrderPaymentList(LiveOrderPayment liveOrderPayment);

    /**
     * 新增支付明细
     *
     * @param liveOrderPayment 支付明细
     * @return 结果
     */
    int insertLiveOrderPayment(LiveOrderPayment liveOrderPayment);

    /**
     * 修改支付明细
     *
     * @param liveOrderPayment 支付明细
     * @return 结果
     */
    int updateLiveOrderPayment(LiveOrderPayment liveOrderPayment);

    /**
     * 删除支付明细
     *
     * @param paymentId 支付明细主键
     * @return 结果
     */
    int deleteLiveOrderPaymentByPaymentId(Long paymentId);

    /**
     * 批量删除支付明细
     *
     * @param paymentIds 需要删除的数据主键集合
     * @return 结果
     */
    int deleteLiveOrderPaymentByPaymentIds(Long[] paymentIds);

    @Select("select * from live_order_payment where pay_code=#{payCode}")
    LiveOrderPayment selectLiveOrderPaymentByPaymentCode(String payCode);

    @Select("select * from live_order_payment where business_type=#{type} and  business_id=#{businessId} and status=1")
    List<LiveOrderPayment> selectLiveOrderPaymentByPay(@Param("type")int type, @Param("businessId") Long businessId);

    @Select("select * from live_order_payment where   business_id=#{businessId} and status=1")
    LiveOrderPayment selectByBuissnessId(@Param("businessId") Long businessId);

    List<LiveOrderPaymentVo> selectLiveOrderPaymentVoList(LiveOrderPaymentVo liveOrderPayment);

    LiveOrderPaymentVo selectLiveOrderPaymentByPaymentIdNew(@Param("paymentId") Long paymentId);

    @Select("select * from live_order_payment where business_id= #{orderId}")
    List<LiveOrderPayment> selectLiveOrderPaymentByOrderId(@Param("orderId") Long orderId);

    @Select("select * from live_order_payment where business_id= #{orderId} and status=1 order by create_time desc limit 1")
    LiveOrderPayment selectLiveOrderLatestPayByOrderId(@Param("orderId") Long orderId);

    @MapKey("businessId")
    @Select("select business_id,bank_transaction_id from live_order_payment where bank_transaction_id is not null")
    Map<String, LiveOrderPayment> selectAllPayments();

}
