package com.izouma.nineth.repo;

import com.izouma.nineth.domain.WalletRenewOrder;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.Optional;

public interface WalletRenewOrderRepo extends JpaRepository<WalletRenewOrder,Long>, JpaSpecificationExecutor<WalletRenewOrder> {

    /**
     * 计数
     * @param orderNo
     * @return
     */
    Integer countByOrderNo(String orderNo);

    Optional<WalletRenewOrder> findByOrderNo(String orderNo);

    /**
     * 检查支付中的记录数量
     * @param userId
     * @return
     */
    @Query("select count(wro) from WalletRenewOrder wro where wro.status = com.izouma.nineth.enums.PayStatus.PENDING and wro.userId = ?1 ")
    Integer countPendingStatus(Long userId);


}
