package com.yn.bftl.thirdparty.modules.business.repository;

import com.yn.bftl.common.modules.subaccount.entity.ChinaumsPayment;
import com.yn.bftl.common.modules.subaccount.enums.SubaccountType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 银联支付单Repository
 *
 * @author huabiao
 * @create 2022/12/16  15:16
 **/
@Repository
public interface ChinaumsPaymentRepository extends JpaRepository<ChinaumsPayment, Long> {

    /**
     * 银联支付单-根据订单查询
     *
     * @param orderId:订单ID
     * @return 银联支付单数组
     * @author huabiao
     * @create 2022/12/16  15:50
     */
    List<ChinaumsPayment> findAllByOrdersId(Long orderId);

    /**
     * 银联支付单-根据订单和平台账簿ID
     *
     * @param orderId:订单ID
     * @param recvBalanceAcctId:账簿ID
     * @return 银联支付单
     * @author huabiao
     * @create 2022/12/16  16:31
     */
    ChinaumsPayment findFirstByOrdersIdAndRecvBalanceAcctId(Long orderId, String recvBalanceAcctId);

    /**
     * 银联支付单-根据订单和分账类型查询
     *
     * @param orderId        订单ID
     * @param subaccountType 分账类型
     * @return 银联支付单
     * @author huabiao
     * @create 2023/1/4  17:29
     */
    ChinaumsPayment findFirstByOrdersIdAndSubaccountType(Long orderId, SubaccountType subaccountType);

    /**
     * 银联支付单-根据订单ID和状态
     *
     * @param orderId 订单ID
     * @param status  状态
     * @return 银联支付单列表
     * @author huabiao
     * @create 2023/3/1  2:29
     */
    List<ChinaumsPayment> findAllByOrdersIdAndStatus(Long orderId, String status);

    /**
     * 银联支付单-根据订单ID判断是否存在
     *
     * @param orderId 订单ID
     * @return true:存在;false:不存在
     * @author huabiao
     * @create 2023/6/13  9:07
     */
    Boolean existsByOrdersId(Long orderId);

    /**
     * 银联支付单-根据子订单系统订单号查询
     *
     * @param guaranteePaymentId 子订单系统订单号
     * @return 银联支付单
     * @author huabiao
     * @create 2023/9/8  16:38
     */
    // TODO 临时代码，后续删除
    ChinaumsPayment findFirstByGuaranteePaymentId(String guaranteePaymentId);
}