<?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.system.BillAccountWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.system.pojo.BillAccount">
    <id column="account_id" property="accountId" />
    <result column="store_id" property="storeId" />
    <result column="store_name" property="storeName" />
    <result column="account_type" property="accountType" />
    <result column="alipay_name" property="alipayName" />
    <result column="alipay_account" property="alipayAccount" />
    <result column="bank_account_name" property="bankAccountName" />
    <result column="bank_account_number" property="bankAccountNumber" />
    <result column="bank_branch" property="bankBranch" />
    <result column="province_code" property="provinceCode" />
    <result column="city_code" property="cityCode" />
    <result column="district_code" property="districtCode" />
    <result column="address_all" property="addressAll" />
    <result column="is_default" property="isDefault" />
    <result column="create_vendor_id" property="createVendorId" />
    <result column="create_time" property="createTime" />
    <result column="update_time" property="updateTime" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="storeName != null">
        `store_name`,
      </if>
      <if test="accountType != null">
        `account_type`,
      </if>
      <if test="alipayName != null">
        `alipay_name`,
      </if>
      <if test="alipayAccount != null">
        `alipay_account`,
      </if>
      <if test="bankAccountName != null">
        `bank_account_name`,
      </if>
      <if test="bankAccountNumber != null">
        `bank_account_number`,
      </if>
      <if test="bankBranch != null">
        `bank_branch`,
      </if>
      <if test="provinceCode != null">
        `province_code`,
      </if>
      <if test="cityCode != null">
        `city_code`,
      </if>
      <if test="districtCode != null">
        `district_code`,
      </if>
      <if test="addressAll != null">
        `address_all`,
      </if>
      <if test="isDefault != null">
        `is_default`,
      </if>
      <if test="createVendorId != null">
        `create_vendor_id`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="updateTime != null">
        `update_time`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `account_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.accountIdNotEquals != null">
          AND `account_id` != #{example.accountIdNotEquals}
        </if>
        <if test="example.accountIdIn != null">
          AND `account_id` in (${example.accountIdIn})
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.storeName != null">
          AND `store_name` = #{example.storeName}
        </if>
        <if test="example.storeNameLike != null">
          AND `store_name` like concat('%',#{example.storeNameLike},'%')
        </if>
        <if test="example.accountType != null">
          AND `account_type` = #{example.accountType}
        </if>
        <if test="example.alipayName != null">
          AND `alipay_name` = #{example.alipayName}
        </if>
        <if test="example.alipayNameLike != null">
          AND `alipay_name` like concat('%',#{example.alipayNameLike},'%')
        </if>
        <if test="example.alipayAccount != null">
          AND `alipay_account` = #{example.alipayAccount}
        </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.bankBranch != null">
          AND `bank_branch` = #{example.bankBranch}
        </if>
        <if test="example.provinceCode != null">
          AND `province_code` = #{example.provinceCode}
        </if>
        <if test="example.cityCode != null">
          AND `city_code` = #{example.cityCode}
        </if>
        <if test="example.districtCode != null">
          AND `district_code` = #{example.districtCode}
        </if>
        <if test="example.addressAll != null">
          AND `address_all` = #{example.addressAll}
        </if>
        <if test="example.isDefault != null">
          AND `is_default` = #{example.isDefault}
        </if>
        <if test="example.createVendorId != null">
          AND `create_vendor_id` = #{example.createVendorId}
        </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.updateTimeAfter != null">
          AND `update_time` <![CDATA[ >= ]]> #{example.updateTimeAfter}
        </if>
        <if test="example.updateTimeBefore != null">
          AND `update_time` <![CDATA[ <= ]]> #{example.updateTimeBefore}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `account_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.system.example.BillAccountExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `sys_bill_account`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `sys_bill_account`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `sys_bill_account`
    <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 `sys_bill_account`
    <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 `sys_bill_account`
    <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 `sys_bill_account`
    <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 `sys_bill_account`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `sys_bill_account`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="account_id" keyProperty="accountId" parameterType="com.slodon.b2b2c.system.pojo.BillAccount" useGeneratedKeys="true">
    INSERT INTO `sys_bill_account`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="storeName != null">
        #{storeName},
      </if>
      <if test="accountType != null">
        #{accountType},
      </if>
      <if test="alipayName != null">
        #{alipayName},
      </if>
      <if test="alipayAccount != null">
        #{alipayAccount},
      </if>
      <if test="bankAccountName != null">
        #{bankAccountName},
      </if>
      <if test="bankAccountNumber != null">
        #{bankAccountNumber},
      </if>
      <if test="bankBranch != null">
        #{bankBranch},
      </if>
      <if test="provinceCode != null">
        #{provinceCode},
      </if>
      <if test="cityCode != null">
        #{cityCode},
      </if>
      <if test="districtCode != null">
        #{districtCode},
      </if>
      <if test="addressAll != null">
        #{addressAll},
      </if>
      <if test="isDefault != null">
        #{isDefault},
      </if>
      <if test="createVendorId != null">
        #{createVendorId},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="updateTime != null">
        #{updateTime},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `sys_bill_account`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.storeName != null">
        `store_name` = #{record.storeName},
      </if>
      <if test="record.accountType != null">
        `account_type` = #{record.accountType},
      </if>
      <if test="record.alipayName != null">
        `alipay_name` = #{record.alipayName},
      </if>
      <if test="record.alipayAccount != null">
        `alipay_account` = #{record.alipayAccount},
      </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.bankBranch != null">
        `bank_branch` = #{record.bankBranch},
      </if>
      <if test="record.provinceCode != null">
        `province_code` = #{record.provinceCode},
      </if>
      <if test="record.cityCode != null">
        `city_code` = #{record.cityCode},
      </if>
      <if test="record.districtCode != null">
        `district_code` = #{record.districtCode},
      </if>
      <if test="record.addressAll != null">
        `address_all` = #{record.addressAll},
      </if>
      <if test="record.isDefault != null">
        `is_default` = #{record.isDefault},
      </if>
      <if test="record.createVendorId != null">
        `create_vendor_id` = #{record.createVendorId},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.updateTime != null">
        `update_time` = #{record.updateTime},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `sys_bill_account`
    <trim prefix="SET" suffixOverrides=",">
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="storeName != null">
        `store_name` = #{storeName},
      </if>
      <if test="accountType != null">
        `account_type` = #{accountType},
      </if>
      <if test="alipayName != null">
        `alipay_name` = #{alipayName},
      </if>
      <if test="alipayAccount != null">
        `alipay_account` = #{alipayAccount},
      </if>
      <if test="bankAccountName != null">
        `bank_account_name` = #{bankAccountName},
      </if>
      <if test="bankAccountNumber != null">
        `bank_account_number` = #{bankAccountNumber},
      </if>
      <if test="bankBranch != null">
        `bank_branch` = #{bankBranch},
      </if>
      <if test="provinceCode != null">
        `province_code` = #{provinceCode},
      </if>
      <if test="cityCode != null">
        `city_code` = #{cityCode},
      </if>
      <if test="districtCode != null">
        `district_code` = #{districtCode},
      </if>
      <if test="addressAll != null">
        `address_all` = #{addressAll},
      </if>
      <if test="isDefault != null">
        `is_default` = #{isDefault},
      </if>
      <if test="createVendorId != null">
        `create_vendor_id` = #{createVendorId},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="updateTime != null">
        `update_time` = #{updateTime},
      </if>
    </trim>
    WHERE `account_id` = #{accountId}
  </update>
</mapper>