<?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.PresellOrderExtendReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.promotion.pojo.PresellOrderExtend">
    <id column="extend_id" property="extendId" />
    <result column="presell_id" property="presellId" />
    <result column="order_sn" property="orderSn" />
    <result column="deposit_pay_sn" property="depositPaySn" />
    <result column="remain_pay_sn" property="remainPaySn" />
    <result column="order_sub_state" property="orderSubState" />
    <result column="goods_id" property="goodsId" />
    <result column="product_id" property="productId" />
    <result column="product_num" property="productNum" />
    <result column="presell_price" property="presellPrice" />
    <result column="first_expand" property="firstExpand" />
    <result column="deposit_amount" property="depositAmount" />
    <result column="remain_amount" property="remainAmount" />
    <result column="is_all_pay" property="isAllPay" />
    <result column="deposit_end_time" property="depositEndTime" />
    <result column="remain_start_time" property="remainStartTime" />
    <result column="remain_end_time" property="remainEndTime" />
    <result column="deliver_time" property="deliverTime" />
    <result column="member_id" property="memberId" />
    <result column="store_id" property="storeId" />
    <result column="create_time" property="createTime" />
    <result column="is_compensation" property="isCompensation" />
    <result column="is_remind_member" property="isRemindMember" />
    <result column="is_remind_store" property="isRemindStore" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `extend_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.extendIdNotEquals != null">
          AND `extend_id` != #{example.extendIdNotEquals}
        </if>
        <if test="example.extendIdIn != null">
          AND `extend_id` in (${example.extendIdIn})
        </if>
        <if test="example.presellId != null">
          AND `presell_id` = #{example.presellId}
        </if>
        <if test="example.orderSn != null">
          AND `order_sn` = #{example.orderSn}
        </if>
        <if test="example.orderSnLike != null">
          AND `order_sn` like concat('%',#{example.orderSnLike},'%')
        </if>
        <if test="example.orderSnIn != null">
          AND `order_sn` in (${example.orderSnIn})
        </if>
        <if test="example.depositPaySn != null">
          AND `deposit_pay_sn` = #{example.depositPaySn}
        </if>
        <if test="example.depositPaySnLike != null">
          AND `deposit_pay_sn` like concat('%',#{example.depositPaySnLike},'%')
        </if>
        <if test="example.remainPaySn != null">
          AND `remain_pay_sn` = #{example.remainPaySn}
        </if>
        <if test="example.remainPaySnLike != null">
          AND `remain_pay_sn` like concat('%',#{example.remainPaySnLike},'%')
        </if>
        <if test="example.orderSubState != null">
          AND `order_sub_state` = #{example.orderSubState}
        </if>
        <if test="example.orderSubStateIn != null">
          AND `order_sub_state` in (${example.orderSubStateIn})
        </if>
        <if test="example.orderSubStateNotIn != null">
          AND `order_sub_state` not in (${example.orderSubStateNotIn})
        </if>
        <if test="example.orderSubStateNotEquals != null">
          AND `order_sub_state` != #{example.orderSubStateNotEquals}
        </if>
        <if test="example.goodsId != null">
          AND `goods_id` = #{example.goodsId}
        </if>
        <if test="example.productId != null">
          AND `product_id` = #{example.productId}
        </if>
        <if test="example.presellPrice != null">
          AND `presell_price` = #{example.presellPrice}
        </if>
        <if test="example.firstExpand != null">
          AND `first_expand` = #{example.firstExpand}
        </if>
        <if test="example.depositAmount != null">
          AND `deposit_amount` = #{example.depositAmount}
        </if>
        <if test="example.remainAmount != null">
          AND `remain_amount` = #{example.remainAmount}
        </if>
        <if test="example.isAllPay != null">
          AND `is_all_pay` = #{example.isAllPay}
        </if>
        <if test="example.depositEndTimeAfter != null">
          AND `deposit_end_time` <![CDATA[ >= ]]> #{example.depositEndTimeAfter}
        </if>
        <if test="example.depositEndTimeBefore != null">
          AND `deposit_end_time` <![CDATA[ <= ]]> #{example.depositEndTimeBefore}
        </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.deliverTimeAfter != null">
          AND `deliver_time` <![CDATA[ >= ]]> #{example.deliverTimeAfter}
        </if>
        <if test="example.deliverTimeBefore != null">
          AND `deliver_time` <![CDATA[ <= ]]> #{example.deliverTimeBefore}
        </if>
        <if test="example.memberId != null">
          AND `member_id` = #{example.memberId}
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </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.isCompensation != null">
          AND `is_compensation` = #{example.isCompensation}
        </if>
        <if test="example.isRemindMember != null">
          AND `is_remind_member` = #{example.isRemindMember}
        </if>
        <if test="example.isRemindStore != null">
          AND `is_remind_store` = #{example.isRemindStore}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `extend_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.PresellOrderExtendExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `promotion_presell_order_extend`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_presell_order_extend`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `promotion_presell_order_extend`
    <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_order_extend`
    <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_order_extend`
    <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_order_extend`
    <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>