<?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="com.jsowell.pile.mapper.AdapayMemberAccountMapper">
  <resultMap id="BaseResultMap" type="com.jsowell.pile.domain.AdapayMemberAccount">
    <!--@mbg.generated-->
    <!--@Table adapay_member_account-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="status" jdbcType="VARCHAR" property="status" />
    <result column="merchant_id" jdbcType="VARCHAR" property="merchantId" />
    <result column="adapay_member_id" jdbcType="VARCHAR" property="adapayMemberId" />
    <result column="settle_account_id" jdbcType="VARCHAR" property="settleAccountId" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="del_flag" jdbcType="VARCHAR" property="delFlag" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, `status`, merchant_id, adapay_member_id, settle_account_id, remark, create_time, 
    create_by, update_time, update_by, del_flag
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from adapay_member_account
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from adapay_member_account
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into adapay_member_account (`status`, merchant_id, adapay_member_id, 
      settle_account_id, remark, create_time, 
      create_by, update_time, update_by, 
      del_flag)
    values (#{status,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, #{adapayMemberId,jdbcType=VARCHAR}, 
      #{settleAccountId,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{createBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, 
      #{delFlag,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into adapay_member_account
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="status != null">
        `status`,
      </if>
      <if test="merchantId != null">
        merchant_id,
      </if>
      <if test="adapayMemberId != null">
        adapay_member_id,
      </if>
      <if test="settleAccountId != null">
        settle_account_id,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="delFlag != null">
        del_flag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="status != null">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="merchantId != null">
        #{merchantId,jdbcType=VARCHAR},
      </if>
      <if test="adapayMemberId != null">
        #{adapayMemberId,jdbcType=VARCHAR},
      </if>
      <if test="settleAccountId != null">
        #{settleAccountId,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.jsowell.pile.domain.AdapayMemberAccount">
    <!--@mbg.generated-->
    update adapay_member_account
    <set>
      <if test="status != null">
        `status` = #{status,jdbcType=VARCHAR},
      </if>
      <if test="merchantId != null">
        merchant_id = #{merchantId,jdbcType=VARCHAR},
      </if>
      <if test="adapayMemberId != null">
        adapay_member_id = #{adapayMemberId,jdbcType=VARCHAR},
      </if>
      <if test="settleAccountId != null">
        settle_account_id = #{settleAccountId,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.jsowell.pile.domain.AdapayMemberAccount">
    <!--@mbg.generated-->
    update adapay_member_account
    set `status` = #{status,jdbcType=VARCHAR},
      merchant_id = #{merchantId,jdbcType=VARCHAR},
      adapay_member_id = #{adapayMemberId,jdbcType=VARCHAR},
      settle_account_id = #{settleAccountId,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_by = #{createBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      del_flag = #{delFlag,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update adapay_member_account
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="`status` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="merchant_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.merchantId,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="adapay_member_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.adapayMemberId,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="settle_account_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.settleAccountId,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.remark,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="create_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="create_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="update_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.updateTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="update_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.updateBy,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="del_flag = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.delFlag,jdbcType=VARCHAR}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=INTEGER}
    </foreach>
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into adapay_member_account
    (`status`, merchant_id, adapay_member_id, settle_account_id, remark, create_time, 
      create_by, update_time, update_by, del_flag)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.status,jdbcType=VARCHAR}, #{item.merchantId,jdbcType=VARCHAR}, #{item.adapayMemberId,jdbcType=VARCHAR}, 
        #{item.settleAccountId,jdbcType=VARCHAR}, #{item.remark,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
        #{item.createBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR}, 
        #{item.delFlag,jdbcType=VARCHAR})
    </foreach>
  </insert>
  <insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into adapay_member_account
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      `status`,
      merchant_id,
      adapay_member_id,
      settle_account_id,
      remark,
      create_time,
      create_by,
      update_time,
      update_by,
      del_flag,
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      #{status,jdbcType=VARCHAR},
      #{merchantId,jdbcType=VARCHAR},
      #{adapayMemberId,jdbcType=VARCHAR},
      #{settleAccountId,jdbcType=VARCHAR},
      #{remark,jdbcType=VARCHAR},
      #{createTime,jdbcType=TIMESTAMP},
      #{createBy,jdbcType=VARCHAR},
      #{updateTime,jdbcType=TIMESTAMP},
      #{updateBy,jdbcType=VARCHAR},
      #{delFlag,jdbcType=VARCHAR},
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      `status` = #{status,jdbcType=VARCHAR},
      merchant_id = #{merchantId,jdbcType=VARCHAR},
      adapay_member_id = #{adapayMemberId,jdbcType=VARCHAR},
      settle_account_id = #{settleAccountId,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_by = #{createBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      del_flag = #{delFlag,jdbcType=VARCHAR},
    </trim>
  </insert>
  <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into adapay_member_account
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="merchantId != null">
        merchant_id,
      </if>
      <if test="adapayMemberId != null">
        adapay_member_id,
      </if>
      <if test="settleAccountId != null">
        settle_account_id,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="delFlag != null">
        del_flag,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="merchantId != null">
        #{merchantId,jdbcType=VARCHAR},
      </if>
      <if test="adapayMemberId != null">
        #{adapayMemberId,jdbcType=VARCHAR},
      </if>
      <if test="settleAccountId != null">
        #{settleAccountId,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=VARCHAR},
      </if>
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=VARCHAR},
      </if>
      <if test="merchantId != null">
        merchant_id = #{merchantId,jdbcType=VARCHAR},
      </if>
      <if test="adapayMemberId != null">
        adapay_member_id = #{adapayMemberId,jdbcType=VARCHAR},
      </if>
      <if test="settleAccountId != null">
        settle_account_id = #{settleAccountId,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

    <resultMap id="AdapayMemberAccountResult" type="com.jsowell.pile.domain.AdapayMemberAccount">
        <result column="id" property="id" />
        <result column="status" property="status" />
        <result column="merchant_id" property="merchantId" />
        <result column="adapay_member_id" property="adapayMemberId" />
        <result column="settle_account_id" property="settleAccountId" />
        <result column="create_time" property="createTime" />
        <result column="create_by" property="createBy" />
        <result column="update_time" property="updateTime" />
        <result column="update_by" property="updateBy" />
        <result column="del_flag" property="delFlag" />
    </resultMap>

    <select id="selectAdapayMemberAccountList" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" resultMap="AdapayMemberAccountResult">
      select
      <include refid="Base_Column_List" />
      from adapay_member_account
        <where>
            <if test="merchantId != null  and merchantId != ''"> and merchant_id = #{merchantId}</if>
            <if test="adapayMemberId != null  and adapayMemberId != ''"> and adapay_member_id = #{adapayMemberId}</if>
            <if test="settleAccountId != null  and settleAccountId != ''"> and settle_account_id = #{settleAccountId}</if>
        </where>
    </select>

    <select id="selectAdapayMemberAccountById" parameterType="Long" resultMap="AdapayMemberAccountResult">
      select
      <include refid="Base_Column_List" />
      from adapay_member_account
        where id = #{id}
    </select>

    <insert id="insertAdapayMemberAccount" keyProperty="id" parameterType="com.jsowell.pile.domain.AdapayMemberAccount" useGeneratedKeys="true">
        insert into adapay_member_account
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="status != null">status,</if>
            <if test="merchantId != null">merchant_id,</if>
            <if test="adapayMemberId != null">adapay_member_id,</if>
            <if test="settleAccountId != null">settle_account_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="status != null">#{status},</if>
            <if test="merchantId != null">#{merchantId},</if>
            <if test="adapayMemberId != null">#{adapayMemberId},</if>
            <if test="settleAccountId != null">#{settleAccountId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
        </trim>
    </insert>

    <update id="updateAdapayMemberAccount" parameterType="com.jsowell.pile.domain.AdapayMemberAccount">
        update adapay_member_account
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null">status = #{status},</if>
            <if test="merchantId != null">merchant_id = #{merchantId},</if>
            <if test="adapayMemberId != null">adapay_member_id = #{adapayMemberId},</if>
            <if test="settleAccountId != null">settle_account_id = #{settleAccountId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateAdapayMemberAccountByMemberId" parameterType="com.jsowell.pile.domain.AdapayMemberAccount">
        update adapay_member_account
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null">status = #{status},</if>
            <if test="merchantId != null">merchant_id = #{merchantId},</if>
            <if test="adapayMemberId != null">adapay_member_id = #{adapayMemberId},</if>
            <if test="settleAccountId != null">settle_account_id = #{settleAccountId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where adapay_member_id = #{adapayMemberId,jdbcType=VARCHAR}
    </update>

    <delete id="deleteAdapayMemberAccountById" parameterType="Long">
        delete from adapay_member_account where id = #{id}
    </delete>

    <!--&lt;delete id="deleteAdapayMemberAccountByIds" parameterType="String"&gt;
        delete from adapay_member_account where id in
        &lt;foreach item="id" collection="array" open="(" separator="," close=")"&gt;
            #{id}
        &lt;/foreach&gt;
    &lt;/delete&gt;-->

    <update id="deleteAdapayMemberAccountByIds" parameterType="com.jsowell.pile.domain.AdapayMemberAccount">
        update adapay_member_account
        set del_flag = '1'
        where id in
        <foreach close=")" collection="list" item="id" open="(" separator=",">
            #{id}
        </foreach>
    </update>

    <select id="selectByMerchantId" resultMap="AdapayMemberAccountResult">
        select
        <include refid="Base_Column_List" />
        from adapay_member_account
        where del_flag = '0'
        and merchant_id = #{merchantId,jdbcType=VARCHAR}
    </select>

    <delete id="deleteByMemberId">
        delete from adapay_member_account where adapay_member_id = #{memberId,jdbcType=VARCHAR}
    </delete>

    <select id="selectByMemberId" resultMap="AdapayMemberAccountResult">
        select
        <include refid="Base_Column_List" />
        from adapay_member_account
        where del_flag = '0'
        and adapay_member_id = #{memberId,jdbcType=VARCHAR}
    </select>
</mapper>