<?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.read.promotion.PresellReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.promotion.pojo.Presell">
    <id column="presell_id" property="presellId" />
    <result column="presell_name" property="presellName" />
    <result column="presell_label_id" property="presellLabelId" />
    <result column="presell_label_name" property="presellLabelName" />
    <result column="start_time" property="startTime" />
    <result column="end_time" property="endTime" />
    <result column="store_id" property="storeId" />
    <result column="store_name" property="storeName" />
    <result column="state" property="state" />
    <result column="type" property="type" />
    <result column="buy_limit" property="buyLimit" />
    <result column="deliver_time_type" property="deliverTimeType" />
    <result column="deliver_time" property="deliverTime" />
    <result column="remain_start_time" property="remainStartTime" />
    <result column="remain_end_time" property="remainEndTime" />
    <result column="deliver_start_time" property="deliverStartTime" />
    <result column="deposit_compensate" property="depositCompensate" />
    <result column="create_vendor_id" property="createVendorId" />
    <result column="create_time" property="createTime" />
    <result column="update_time" property="updateTime" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `presell_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.presellIdNotEquals != null">
          AND `presell_id` != #{example.presellIdNotEquals}
        </if>
        <if test="example.presellIdIn != null">
          AND `presell_id` in (${example.presellIdIn})
        </if>
        <if test="example.presellName != null">
          AND `presell_name` = #{example.presellName}
        </if>
        <if test="example.presellNameLike != null">
          AND `presell_name` like concat('%',#{example.presellNameLike},'%')
        </if>
        <if test="example.presellLabelId != null">
          AND `presell_label_id` = #{example.presellLabelId}
        </if>
        <if test="example.presellLabelName != null">
          AND `presell_label_name` = #{example.presellLabelName}
        </if>
        <if test="example.presellLabelNameLike != null">
          AND `presell_label_name` like concat('%',#{example.presellLabelNameLike},'%')
        </if>
        <if test="example.startTimeAfter != null">
          AND `start_time` <![CDATA[ >= ]]> #{example.startTimeAfter}
        </if>
        <if test="example.startTimeBefore != null">
          AND `start_time` <![CDATA[ <= ]]> #{example.startTimeBefore}
        </if>
        <if test="example.endTimeAfter != null">
          AND `end_time` <![CDATA[ >= ]]> #{example.endTimeAfter}
        </if>
        <if test="example.endTimeBefore != null">
          AND `end_time` <![CDATA[ <= ]]> #{example.endTimeBefore}
        </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.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.type != null">
          AND `type` = #{example.type}
        </if>
        <if test="example.buyLimit != null">
          AND `buy_limit` = #{example.buyLimit}
        </if>
        <if test="example.deliverTimeType != null">
          AND `deliver_time_type` = #{example.deliverTimeType}
        </if>
        <if test="example.deliverTimeAfter != null">
          AND `deliver_time` <![CDATA[ >= ]]> #{example.deliverTimeAfter}
        </if>
        <if test="example.deliverTimeBefore != null">
          AND `deliver_time` <![CDATA[ <= ]]> #{example.deliverTimeBefore}
        </if>
        <if test="example.remainStartTimeAfter != null">
          AND `remain_start_time` <![CDATA[ >= ]]> #{example.remainStartTimeAfter}
        </if>
        <if test="example.remainStartTimeBefore != null">
          AND `remain_start_time` <![CDATA[ <= ]]> #{example.remainStartTimeBefore}
        </if>
        <if test="example.remainEndTimeAfter != null">
          AND `remain_end_time` <![CDATA[ >= ]]> #{example.remainEndTimeAfter}
        </if>
        <if test="example.remainEndTimeBefore != null">
          AND `remain_end_time` <![CDATA[ <= ]]> #{example.remainEndTimeBefore}
        </if>
        <if test="example.deliverStartTime != null">
          AND `deliver_start_time` = #{example.deliverStartTime}
        </if>
        <if test="example.depositCompensate != null">
          AND `deposit_compensate` = #{example.depositCompensate}
        </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>
        <if test="example.stateNotEquals != null">
          AND `state` != #{example.stateNotEquals}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `presell_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.promotion.example.PresellExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `promotion_presell`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_presell`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_presell`
    <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 `promotion_presell`
    <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 `promotion_presell`
    <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 `promotion_presell`
    <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>
</mapper>