<?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.MerchantSplitSettingMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.MerchantSplitSetting">
        <id column="id" property="id" />
        <result column="chieMerchantCode" property="chieMerchantCode" />
        <result column="chieMerchantId" property="chieMerchantId" />
        <result column="isDivistion" property="isDivistion" />
        <result column="divisionMode" property="divisionMode" />
        <result column="diviMerchantCode" property="diviMerchantCode" />
        <result column="diviMerchantId" property="diviMerchantId" />
        <result column="divAmt" property="divAmt" />
        <result column="divRatio" property="divRatio" />
        <result column="isChargeFee" property="isChargeFee" />
        <result column="createTime" property="createTime" />
        <result column="status" property="status" />
    </resultMap>

    <sql id="sql_field">
        id,chieMerchantCode,chieMerchantId,isDivistion,divisionMode,diviMerchantCode,diviMerchantId,divAmt,divRatio,isChargeFee,createTime,status
    </sql>

    <select id="pageInfo" resultType = "cn.pluss.platform.vo.MerchantSplitSettingVO">
        SELECT a.*,b.alias as chieMerchantName,c.alias as diviMerchantName from tb_pluss_merchant_split_setting a
            left join tb_pluss_merchant_base_info b on a.chieMerchantCode = b.merchantCode
            left join tb_pluss_merchant_base_info c on a.diviMerchantCode = c.merchantCode
        <where>
              <if test="vo.chieMerchantCode != null and vo.chieMerchantCode != ''">
                and a.chieMerchantCode = #{vo.chieMerchantCode}
              </if>
            <if test="vo.chieMerchantName != null and vo.chieMerchantName != ''">
                and b.chieMerchantName like CONCAT('%',#{vo.chieMerchantName},'%')
            </if>
            <if test="vo.chieMerchantId != null and vo.chieMerchantId != ''">
                 and a.chieMerchantId = #{vo.chieMerchantId}
            </if>
            <if test="vo.isDivistion != null and vo.isDivistion != ''">
                and a.isDivistion = #{vo.isDivistion}
            </if>
            <if test="vo.divisionMode != null and vo.divisionMode != ''">
                and a.divisionMode = #{vo.divisionMode}
            </if>
            <if test="vo.diviMerchantCode != null and vo.diviMerchantCode != ''">
                and a.diviMerchantCode = #{vo.diviMerchantCode}
            </if>
            <if test="vo.diviMerchantName != null and vo.diviMerchantName != ''">
                and c.diviMerchantName like CONCAT('%',#{vo.diviMerchantName},'%')
            </if>
            <if test="vo.diviMerchantId != null and vo.diviMerchantId != ''">
                and a.diviMerchantId = #{vo.diviMerchantId}
            </if>
            <if test="vo.status != null ">
                and a.status = #{vo.status}
            </if>
        </where>
        order by a.createTime desc
    </select>
</mapper>
