<?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.ym.mec.biz.dal.dao.SysAccountDao">
  <resultMap id="SysAccount" type="com.ym.mec.biz.dal.entity.SysAccount">
    <!--@Table sys_account-->
    <id column="id_" jdbcType="INTEGER" property="id" />
    <result column="mer_no_" jdbcType="VARCHAR" property="merNo" />
    <result column="max_receipt_" jdbcType="DECIMAL" property="maxReceipt" />
    <result column="has_receipt_" jdbcType="DECIMAL" property="hasReceipt" />
    <result column="channel_" jdbcType="VARCHAR" property="channel" />
    <result column="channel_type_" jdbcType="CHAR" property="channelType" />
    <result column="version" jdbcType="INTEGER" property="version" />
  </resultMap>
  <sql id="Base_Column_List">
    id_, mer_no_, max_receipt_, has_receipt_, channel_, channel_type_, version
  </sql>
  <select id="get" parameterType="java.lang.Integer" resultMap="SysAccount">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from sys_account
    where id_ = #{id,jdbcType=INTEGER}
  </select>
  <delete id="delete" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from sys_account
    where id_ = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SysAccount" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into sys_account
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="merNo != null">
        mer_no_,
      </if>
      <if test="maxReceipt != null">
        max_receipt_,
      </if>
      <if test="hasReceipt != null">
        has_receipt_,
      </if>
      <if test="channel != null">
        channel_,
      </if>
      <if test="channelType != null">
        channel_type_,
      </if>
      <if test="version != null">
        version,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="merNo != null">
        #{merNo,jdbcType=VARCHAR},
      </if>
      <if test="maxReceipt != null">
        #{maxReceipt,jdbcType=DECIMAL},
      </if>
      <if test="hasReceipt != null">
        #{hasReceipt,jdbcType=DECIMAL},
      </if>
      <if test="channel != null">
        #{channel,jdbcType=VARCHAR},
      </if>
      <if test="channelType != null">
        #{channelType,jdbcType=CHAR},
      </if>
      <if test="version != null">
        #{version,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysAccount">
    <!--@mbg.generated-->
    update sys_account
    <set>
      <if test="merNo != null">
        mer_no_ = #{merNo,jdbcType=VARCHAR},
      </if>
      <if test="maxReceipt != null">
        max_receipt_ = #{maxReceipt,jdbcType=DECIMAL},
      </if>
      <if test="hasReceipt != null">
        has_receipt_ = #{hasReceipt,jdbcType=DECIMAL},
      </if>
      <if test="channel != null">
        channel_ = #{channel,jdbcType=VARCHAR},
      </if>
      <if test="channelType != null">
        channel_type_ = #{channelType,jdbcType=CHAR},
      </if>
      <if test="version != null">
        version = version+1,
      </if>
    </set>
    where id_ = #{id,jdbcType=INTEGER} AND version =#{version}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ym.mec.biz.dal.entity.SysAccount">
    <!--@mbg.generated-->
    update sys_account
    set mer_no_ = #{merNo,jdbcType=VARCHAR},
      max_receipt_ = #{maxReceipt,jdbcType=DECIMAL},
      has_receipt_ = #{hasReceipt,jdbcType=DECIMAL},
      channel_ = #{channel,jdbcType=VARCHAR},
      channel_type_ = #{channelType,jdbcType=CHAR},
      version = #{version,jdbcType=INTEGER}
    where id_ = #{id,jdbcType=INTEGER}
  </update>
  <select id="find"></select>
  <!-- 获取一个私户账户 -->
  <select id="getPerAccount" resultMap="SysAccount">
    SELECT * FROM sys_account WHERE channel_ = 'YQPAY' AND channel_type_ = 'PER'
  </select>

  <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
    INSERT INTO sys_account (id_,mer_no_,channel_)
    VALUES
    <foreach collection="sysAccountList" item="data" separator=",">
      (#{data.id},#{data.merNo},#{data.channel})
    </foreach>
  </insert>
</mapper>