<?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.mall.coupon.mapper.CouponMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.coupon.domain.entity.Coupon">
            <id column="id" property="id"/>
            <id column="coupon_type" property="couponType"/>
            <id column="coupon_img" property="couponImg"/>
            <id column="coupon_name" property="couponName"/>
            <id column="num" property="num"/>
            <id column="amount" property="amount"/>
            <id column="per_limit" property="perLimit"/>
            <id column="min_point" property="minPoint"/>
            <id column="start_time" property="startTime"/>
            <id column="end_time" property="endTime"/>
            <id column="use_type" property="useType"/>
            <id column="note" property="note"/>
            <id column="publish_count" property="publishCount"/>
            <id column="use_count" property="useCount"/>
            <id column="receive_count" property="receiveCount"/>
            <id column="enable_start_time" property="enableStartTime"/>
            <id column="enable_end_time" property="enableEndTime"/>
            <id column="code" property="code"/>
            <id column="member_level" property="memberLevel"/>
            <id column="publish" property="publish"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,coupon_type,coupon_img,coupon_name,num,amount,per_limit,min_point,start_time,end_time,use_type,note,publish_count,use_count,receive_count,enable_start_time,enable_end_time,code,member_level,publish
    </sql>

    <!-- 分页查询优惠券信息内容 -->
    <select id="selectListByPage" resultType="com.mall.coupon.domain.vo.CouponVo">
        select
        <include refid="Base_Column_List"/>
        from sms_coupon
        <where>
                <if test="dto.id != null and dto.id != ''">
                    and id like CONCAT('%',#{dto.id},'%')
                </if>
                <if test="dto.couponType != null and dto.couponType != ''">
                    and coupon_type like CONCAT('%',#{dto.couponType},'%')
                </if>
                <if test="dto.couponImg != null and dto.couponImg != ''">
                    and coupon_img like CONCAT('%',#{dto.couponImg},'%')
                </if>
                <if test="dto.couponName != null and dto.couponName != ''">
                    and coupon_name like CONCAT('%',#{dto.couponName},'%')
                </if>
                <if test="dto.num != null and dto.num != ''">
                    and num like CONCAT('%',#{dto.num},'%')
                </if>
                <if test="dto.amount != null and dto.amount != ''">
                    and amount like CONCAT('%',#{dto.amount},'%')
                </if>
                <if test="dto.perLimit != null and dto.perLimit != ''">
                    and per_limit like CONCAT('%',#{dto.perLimit},'%')
                </if>
                <if test="dto.minPoint != null and dto.minPoint != ''">
                    and min_point like CONCAT('%',#{dto.minPoint},'%')
                </if>
                <if test="dto.startTime != null and dto.startTime != ''">
                    and start_time like CONCAT('%',#{dto.startTime},'%')
                </if>
                <if test="dto.endTime != null and dto.endTime != ''">
                    and end_time like CONCAT('%',#{dto.endTime},'%')
                </if>
                <if test="dto.useType != null and dto.useType != ''">
                    and use_type like CONCAT('%',#{dto.useType},'%')
                </if>
                <if test="dto.note != null and dto.note != ''">
                    and note like CONCAT('%',#{dto.note},'%')
                </if>
                <if test="dto.publishCount != null and dto.publishCount != ''">
                    and publish_count like CONCAT('%',#{dto.publishCount},'%')
                </if>
                <if test="dto.useCount != null and dto.useCount != ''">
                    and use_count like CONCAT('%',#{dto.useCount},'%')
                </if>
                <if test="dto.receiveCount != null and dto.receiveCount != ''">
                    and receive_count like CONCAT('%',#{dto.receiveCount},'%')
                </if>
                <if test="dto.enableStartTime != null and dto.enableStartTime != ''">
                    and enable_start_time like CONCAT('%',#{dto.enableStartTime},'%')
                </if>
                <if test="dto.enableEndTime != null and dto.enableEndTime != ''">
                    and enable_end_time like CONCAT('%',#{dto.enableEndTime},'%')
                </if>
                <if test="dto.code != null and dto.code != ''">
                    and code like CONCAT('%',#{dto.code},'%')
                </if>
                <if test="dto.memberLevel != null and dto.memberLevel != ''">
                    and member_level like CONCAT('%',#{dto.memberLevel},'%')
                </if>
                <if test="dto.publish != null and dto.publish != ''">
                    and publish like CONCAT('%',#{dto.publish},'%')
                </if>
        </where>
    </select>

</mapper>
