<?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.slodon.b2b2c.dao.write.seller.StoreWithdrawalWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.seller.pojo.StoreWithdrawal">
    <id column="withdrawal_id" property="withdrawalId" />
    <result column="store_id" property="storeId" />
    <result column="vendor_id" property="vendorId" />
    <result column="withdrawal_sn" property="withdrawalSn" />
    <result column="amount" property="amount" />
    <result column="bank_account_name" property="bankAccountName" />
    <result column="bank_account_number" property="bankAccountNumber" />
    <result column="bank_id" property="bankId" />
    <result column="bank_name" property="bankName" />
    <result column="branch_name" property="branchName" />
    <result column="create_time" property="createTime" />
    <result column="deal_time" property="dealTime" />
    <result column="state" property="state" />
    <result column="fail_reason" property="failReason" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="vendorId != null">
        `vendor_id`,
      </if>
      <if test="withdrawalSn != null">
        `withdrawal_sn`,
      </if>
      <if test="amount != null">
        `amount`,
      </if>
      <if test="bankAccountName != null">
        `bank_account_name`,
      </if>
      <if test="bankAccountNumber != null">
        `bank_account_number`,
      </if>
      <if test="bankId != null">
        `bank_id`,
      </if>
      <if test="bankName != null">
        `bank_name`,
      </if>
      <if test="branchName != null">
        `branch_name`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="dealTime != null">
        `deal_time`,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="failReason != null">
        `fail_reason`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `withdrawal_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.withdrawalIdNotEquals != null">
          AND `withdrawal_id` != #{example.withdrawalIdNotEquals}
        </if>
        <if test="example.withdrawalIdIn != null">
          AND `withdrawal_id` in (${example.withdrawalIdIn})
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.vendorId != null">
          AND `vendor_id` = #{example.vendorId}
        </if>
        <if test="example.withdrawalSn != null">
          AND `withdrawal_sn` = #{example.withdrawalSn}
        </if>
        <if test="example.withdrawalSnLike != null">
          AND `withdrawal_sn` like concat('%',#{example.withdrawalSnLike},'%')
        </if>
        <if test="example.amount != null">
          AND `amount` = #{example.amount}
        </if>
        <if test="example.bankAccountName != null">
          AND `bank_account_name` = #{example.bankAccountName}
        </if>
        <if test="example.bankAccountNameLike != null">
          AND `bank_account_name` like concat('%',#{example.bankAccountNameLike},'%')
        </if>
        <if test="example.bankAccountNumber != null">
          AND `bank_account_number` = #{example.bankAccountNumber}
        </if>
        <if test="example.bankId != null">
          AND `bank_id` = #{example.bankId}
        </if>
        <if test="example.bankName != null">
          AND `bank_name` = #{example.bankName}
        </if>
        <if test="example.bankNameLike != null">
          AND `bank_name` like concat('%',#{example.bankNameLike},'%')
        </if>
        <if test="example.branchName != null">
          AND `branch_name` = #{example.branchName}
        </if>
        <if test="example.branchNameLike != null">
          AND `branch_name` like concat('%',#{example.branchNameLike},'%')
        </if>
        <if test="example.createTimeAfter != null">
          AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
        </if>
        <if test="example.createTimeBefore != null">
          AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
        </if>
        <if test="example.dealTimeAfter != null">
          AND `deal_time` <![CDATA[ >= ]]> #{example.dealTimeAfter}
        </if>
        <if test="example.dealTimeBefore != null">
          AND `deal_time` <![CDATA[ <= ]]> #{example.dealTimeBefore}
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.stateIn != null">
          AND `state` in (${example.stateIn})
        </if>
        <if test="example.stateNotIn != null">
          AND `state` not in (${example.stateNotIn})
        </if>
        <if test="example.stateNotEquals != null">
          AND `state` != #{example.stateNotEquals}
        </if>
        <if test="example.failReason != null">
          AND `fail_reason` = #{example.failReason}
        </if>
        <if test="example.failReasonLike != null">
          AND `fail_reason` like concat('%',#{example.failReasonLike},'%')
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `withdrawal_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.seller.example.StoreWithdrawalExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `store_withdrawal`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `store_withdrawal`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `store_withdrawal`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `store_withdrawal`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `store_withdrawal`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `store_withdrawal`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `store_withdrawal`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `store_withdrawal`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="withdrawal_id" keyProperty="withdrawalId" parameterType="com.slodon.b2b2c.seller.pojo.StoreWithdrawal" useGeneratedKeys="true">
    INSERT INTO `store_withdrawal`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="vendorId != null">
        #{vendorId},
      </if>
      <if test="withdrawalSn != null">
        #{withdrawalSn},
      </if>
      <if test="amount != null">
        #{amount},
      </if>
      <if test="bankAccountName != null">
        #{bankAccountName},
      </if>
      <if test="bankAccountNumber != null">
        #{bankAccountNumber},
      </if>
      <if test="bankId != null">
        #{bankId},
      </if>
      <if test="bankName != null">
        #{bankName},
      </if>
      <if test="branchName != null">
        #{branchName},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="dealTime != null">
        #{dealTime},
      </if>
      <if test="state != null">
        #{state},
      </if>
      <if test="failReason != null">
        #{failReason},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `store_withdrawal`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.vendorId != null">
        `vendor_id` = #{record.vendorId},
      </if>
      <if test="record.withdrawalSn != null">
        `withdrawal_sn` = #{record.withdrawalSn},
      </if>
      <if test="record.amount != null">
        `amount` = #{record.amount},
      </if>
      <if test="record.bankAccountName != null">
        `bank_account_name` = #{record.bankAccountName},
      </if>
      <if test="record.bankAccountNumber != null">
        `bank_account_number` = #{record.bankAccountNumber},
      </if>
      <if test="record.bankId != null">
        `bank_id` = #{record.bankId},
      </if>
      <if test="record.bankName != null">
        `bank_name` = #{record.bankName},
      </if>
      <if test="record.branchName != null">
        `branch_name` = #{record.branchName},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.dealTime != null">
        `deal_time` = #{record.dealTime},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
      <if test="record.failReason != null">
        `fail_reason` = #{record.failReason},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `store_withdrawal`
    <trim prefix="SET" suffixOverrides=",">
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="vendorId != null">
        `vendor_id` = #{vendorId},
      </if>
      <if test="withdrawalSn != null">
        `withdrawal_sn` = #{withdrawalSn},
      </if>
      <if test="amount != null">
        `amount` = #{amount},
      </if>
      <if test="bankAccountName != null">
        `bank_account_name` = #{bankAccountName},
      </if>
      <if test="bankAccountNumber != null">
        `bank_account_number` = #{bankAccountNumber},
      </if>
      <if test="bankId != null">
        `bank_id` = #{bankId},
      </if>
      <if test="bankName != null">
        `bank_name` = #{bankName},
      </if>
      <if test="branchName != null">
        `branch_name` = #{branchName},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="dealTime != null">
        `deal_time` = #{dealTime},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
      <if test="failReason != null">
        `fail_reason` = #{failReason},
      </if>
    </trim>
    WHERE `withdrawal_id` = #{withdrawalId}
  </update>
</mapper>