package cn.pluss.platform.mapper;

import cn.pluss.platform.entity.MerchantChannelStatus;
import cn.pluss.platform.vo.MerchantChannelStatusVO;
import cn.pluss.platform.vo.UserNumVO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MerchantChannelStatusMapper extends BaseMapper<MerchantChannelStatus> {

    MerchantChannelStatus selectByChangeFlowId(@Param("changeFlowId") String changeFlowId);

    MerchantChannelStatus selectBySysFlowId(@Param("sysFlowId") String sysFlowId);

    List<MerchantChannelStatusVO> selectListByMerchantCode(@Param("merchantCodeList") List<String> merchantCodeList);

    MerchantChannelStatus getByIdLock(@Param("id") Integer id);

    default MerchantChannelStatus getByMerchantCode(@Param("merchantCode") String merchantCode) {
       return getByMerchantCode(merchantCode, 1) ;
    }

    MerchantChannelStatus getByMerchantCode(@Param("merchantCode") String merchantCode, @Param("channel") Integer channel);

    /**
     * 获取未实名认证、瑞银信通道进件的商户
     * @return 商户进件信息列表
     */
    List<MerchantChannelStatus> getRyxNoCertMerchant();

    List<MerchantChannelStatus> selectListWithUserId(@Param(Constants.WRAPPER) Wrapper<MerchantChannelStatus> queryWrapper);

    @Select("SELECT * FROM tb_pluss_merchant_channel_status WHERE merchantId = #{merchantId} FOR UPDATE ")
    MerchantChannelStatus getByMerchantIdLock(@Param("merchantId") String merchantId);

    /**
     * 当前用户指定时间段 进件商户数量
     * @date: 2022/1/24 22:43
     * @param userId:
     * @param date:
     * @param dateType:
     * @return java.util.Map<java.lang.String,java.lang.Integer>
     */
    UserNumVO getUserNumInfo(@Param("userId") Long userId, @Param("date")String date, @Param("dateType")Integer dateType);
}
