package cn.pluss.platform.mapper;

import cn.pluss.platform.entity.BankCard;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 银行卡信息 Mapper 接口
 * </p>
 *
 * @author Djh
 * @since 2020-10-16
 */
public interface BankCardMapper extends BaseMapper<BankCard> {

    /**
     * 获取未关联结算信息的对私结算银行卡信息
     *
     * @param userId 用户id
     * @return 银行卡信息
     */
    @Select("SELECT * FROM tb_pluss_bank_card bc LEFT JOIN tb_pluss_account acc ON acc.userId = bc.userId AND acc.idCardId = bc.id WHERE acc.id IS NULL AND bc.userType = '01'")
    BankCard getUnusedBankCard(@Param("userId") String userId);
}
