<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.pluss.platform.mapper.JftMercPaymentChannelMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.JftMercPaymentChannel">
        <id column="id" property="id" />
        <result column="userId" property="userId" />
        <result column="merchantCode" property="merchantCode" />
        <result column="merchantId" property="merchantId" />
        <result column="status" property="status" />
        <result column="thirdStatus" property="thirdStatus" />
        <result column="remark" property="remark" />
        <result column="createTime" property="createTime" />
        <result column="passTime" property="passTime" />
        <result column="updateTime" property="updateTime" />
        <result column="applicationId" property="applicationId" />
        <result column="extra" property="extra" />
        <result column="mercName" property="mercName" />
    </resultMap>

    <select id="selectCountByCertNo" resultType="java.lang.Integer">
        SELECT count(mpc.id) FROM tb_pluss_jft_merc_payment_channel mpc
        LEFT JOIN tb_pluss_id_card ic ON mpc.userId = ic.userId AND ic.userType = '01'
        WHERE ic.certNo = #{certNo}
    </select>

    <select id="selectByChangeFlowId" resultType="cn.pluss.platform.entity.JftMercPaymentChannel">
        SELECT * FROM tb_pluss_jft_merc_payment_channel
        WHERE channel = 4 AND `status` = 3 AND (extra ->> '$.changeFlowId') = #{changeFlowId}
    </select>

    <select id="selectBySysFlowId" resultType="cn.pluss.platform.entity.JftMercPaymentChannel">
        SELECT * FROM tb_pluss_jft_merc_payment_channel
        WHERE channel = 4 AND `status` = 3 AND (extra ->> '$.sysFlowId') = #{sysFlowId}
    </select>
</mapper>
