<?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.freemud.manager.dao.OpenPlatformPartnerMerchantAccountDao" >
  <resultMap id="MerchantAccount" type="cn.freemud.entities.db.OpenPlatformPartnerMerchantAccount" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="indirect_id" property="indirectId" jdbcType="BIGINT" />
    <result column="account_name" property="accountName" jdbcType="VARCHAR" />
    <result column="account_card" property="accountCard" jdbcType="VARCHAR" />
    <result column="partner_id" property="partnerId" jdbcType="VARCHAR" />
    <result column="mch_id" property="mchId" jdbcType="VARCHAR" />
    <result column="platform" property="platform" jdbcType="VARCHAR" />
    <result column="platform_name" property="platformName" jdbcType="VARCHAR" />
    <result column="account_type" property="accountType" jdbcType="BIT" />
    <result column="pay_rate" property="payRate" jdbcType="VARCHAR" />
    <result column="pay_description" property="payDescription" jdbcType="VARCHAR" />
    <result column="gmt_created" property="gmtCreated" jdbcType="TIMESTAMP" />
    <result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP" />
  </resultMap>
    <resultMap id="MerchantAccountDtoMap" type="cn.freemud.entities.dto.OpenPlatformPartnerMerchantAccountDto" >
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="indirect_id" property="indirectId" jdbcType="BIGINT" />
        <result column="account_name" property="accountName" jdbcType="VARCHAR" />
        <result column="account_card" property="accountCard" jdbcType="VARCHAR" />
        <result column="partner_id" property="partnerId" jdbcType="VARCHAR" />
        <result column="mch_id" property="mchId" jdbcType="VARCHAR" />
        <result column="platform" property="platform" jdbcType="VARCHAR" />
        <result column="platform_name" property="platformName" jdbcType="VARCHAR" />
        <result column="account_type" property="accountType" jdbcType="BIT" />
        <result column="pay_rate" property="payRate" jdbcType="VARCHAR" />
        <result column="pay_description" property="payDescription" jdbcType="VARCHAR" />
        <result column="gmt_created" property="gmtCreated" jdbcType="TIMESTAMP" />
        <result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP" />
        <result column="fee_type" property="feeType" jdbcType="TIMESTAMP" />
    </resultMap>
  <select id="findMerchantAccountByPartnerIdAndMchId" resultMap="MerchantAccountDtoMap">
    SELECT
        a.id,
        a.indirect_id,
        a.account_name,
        a.account_card,
        a.partner_id,
        a.mch_id,
        a.platform,
        a.platform_name,
        a.account_type,
        a.pay_rate,
        a.pay_description,
        a.gmt_created,
        a.gmt_modified,
        i.fee_type
    FROM
        open_platform_partner_merchant_account a,
        open_platform_partner_merchant i,
        open_platform_partner_merchant_account_store s
    WHERE
        i.id = a.indirect_id
    AND a.id = s.account_id
    AND i.partner_id = #{merchantAccount.partnerId}
    AND i.mch_id = #{merchantAccount.mchId}
    AND s.store_id = #{merchantAccount.storeId}
  </select>
</mapper>