package com.yn.bftl.thirdparty.common.repository;

import com.yn.bftl.common.modules.subaccount.entity.AllinpayMutual;
import com.yn.bftl.common.modules.subaccount.enums.DealStatus;
import com.yn.bftl.common.modules.subaccount.enums.DealType;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface AllinpayMutualRepository extends JpaRepository<AllinpayMutual, Long> {

    List<AllinpayMutual> findAllByCompanyIdAndUsersIdAndDealTypeAndDealStatusOrderById(Long companyId, Long userId, DealType dealType, DealStatus dealStatus);

    Page<AllinpayMutual> findAllByCompanyIdAndUsersIdAndDealTypeAndDealStatusOrderById(Long companyId, Long userId, DealType dealType, DealStatus dealStatus, Pageable pageable);

    Page<AllinpayMutual> findAllByCompanyIdAndDealStatusAndUpdatedOnBetweenOrderById(Long companyId, DealStatus dealStatus, LocalDateTime min, LocalDateTime max, Pageable pageable);

    AllinpayMutual findFirstByCompanyIdAndUsersIdAndBizOrderNo(Long companyId, Long userId, String BizOrderNo);

    AllinpayMutual findFirstByCustomerIdAndBizOrderNo(Long customerId, String BizOrderNo);

    AllinpayMutual findFirstByBizOrderNo(String BizOrderNo);
}