package cn.pluss.platform.merchant;

import cn.pluss.platform.entity.JftMercPaymentChannel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;

/**
 * <p>
 * 银盛一码多户的商户进件记录 服务类
 * </p>
 *
 * @author Djh
 * @since 2022-06-15
 */
public interface JftMercPaymentChannelService extends IService<JftMercPaymentChannel> {

    /**
     * 根据用户id获得实体类
     *
     * @param userId 用户id
     * @return 数据
     */
    default JftMercPaymentChannel getByUserId(Object userId) {
        LambdaQueryWrapper<JftMercPaymentChannel> qWrapper = Wrappers.lambdaQuery();
        qWrapper.eq(JftMercPaymentChannel::getUserId, userId);
        return getBaseMapper().selectOne(qWrapper);
    }

    /**
     * 根据用户id获得实体类
     *
     * @param merchantCode 商户编号
     * @return 数据
     */
    default JftMercPaymentChannel getByMerchantCode(String merchantCode) {
        LambdaQueryWrapper<JftMercPaymentChannel> qWrapper = Wrappers.lambdaQuery();
        qWrapper.eq(JftMercPaymentChannel::getMerchantCode, merchantCode);
        return getBaseMapper().selectOne(qWrapper);
    }

    /**
     * 根据用户id获得实体类
     *
     * @param merchantId 通道商编，这里特指银盛商编
     * @return 数据
     */
    default JftMercPaymentChannel getByMerchantId(String merchantId) {
        LambdaQueryWrapper<JftMercPaymentChannel> qWrapper = Wrappers.lambdaQuery();
        qWrapper.eq(JftMercPaymentChannel::getMerchantId, merchantId);
        return getBaseMapper().selectOne(qWrapper);
    }

    /**
     * 根据用户id获得实体类
     *
     * @param applicationId 发起进件的事务id
     * @return 数据
     */
    default JftMercPaymentChannel getByApplicationId(String applicationId) {
        LambdaQueryWrapper<JftMercPaymentChannel> qWrapper = Wrappers.lambdaQuery();
        qWrapper.eq(JftMercPaymentChannel::getApplicationId, applicationId);
        return getBaseMapper().selectOne(qWrapper);
    }
}
