<?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.liquidnet.service.candy.mapper.CandyCommonCouponMapper">

    <resultMap id="Rst_CommonCouponBasicDto" type="com.liquidnet.service.candy.dto.CandyCommonCouponBasicDto">
        <result column="coupon_id" jdbcType="VARCHAR" property="couponId"/>
        <!--        <result column="state" jdbcType="TINYINT" property="state"/>-->
        <result column="title" jdbcType="VARCHAR" property="title"/>
        <result column="label" jdbcType="VARCHAR" property="label"/>
        <result column="notice" jdbcType="VARCHAR" property="notice"/>
        <!--        <result column="exclusive" jdbcType="SMALLINT" property="exclusive"/>-->
        <result column="busi_type" jdbcType="SMALLINT" property="busiType"/>
        <result column="cou_type" jdbcType="SMALLINT" property="couType"/>
        <result column="bind_type" jdbcType="SMALLINT" property="bindType"/>
        <result column="discount" jdbcType="DECIMAL" property="discount"/>
        <result column="val_face" jdbcType="DECIMAL" property="valFace"/>
        <result column="val_over" jdbcType="DECIMAL" property="valOver"/>
        <result column="val_minus" jdbcType="DECIMAL" property="valMinus"/>
        <result column="overlay" jdbcType="TINYINT" property="overlay"/>
        <result column="overlay_level" jdbcType="TINYINT" property="overlayLevel"/>
        <result column="validity" jdbcType="INTEGER" property="validity"/>
        <result column="redeem_validity" jdbcType="INTEGER" property="redeemValidity"/>
        <result column="redeem_start" jdbcType="TIMESTAMP" property="redeemStart"/>
        <result column="redeem_stop" jdbcType="TIMESTAMP" property="redeemStop"/>
        <result column="effect_at" jdbcType="TIMESTAMP" property="effectAt"/>
        <result column="expire_at" jdbcType="TIMESTAMP" property="expireAt"/>
        <!--        <result column="operator" jdbcType="VARCHAR" property="operator" />-->
        <!--        <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />-->
        <!--        <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />-->
        <!--        <result column="comment" jdbcType="VARCHAR" property="comment" />-->

        <result column="ccoupon_id" jdbcType="VARCHAR" property="ccouponId"/>
        <result column="mcoupon_id" jdbcType="VARCHAR" property="mcouponId"/>
        <!--        <result column="coupon_id" jdbcType="VARCHAR" property="couponId" />-->
        <result column="exclusive" jdbcType="SMALLINT" property="exclusive"/>
        <result column="state" jdbcType="TINYINT" property="state"/>
        <result column="ranged" jdbcType="TINYINT" property="ranged"/>
        <!--        <result column="operator" jdbcType="VARCHAR" property="operator" />-->
        <result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
        <!--        <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />-->
        <!--        <result column="comment" jdbcType="VARCHAR" property="comment" />-->
    </resultMap>

    <sql id="Rst_CommonCouponBasicDto_Column_List">
        cc.coupon_id, cc.title, cc.`label`, cc.notice, cc.busi_type, cc.cou_type, cc.bind_type,
        cc.discount, cc.val_face, cc.val_over, cc.val_minus, cc.`overlay`, cc.overlay_level,
        cc.validity, cc.redeem_validity, cc.redeem_start, cc.redeem_stop, cc.effect_at, cc.expire_at,

        ccc.ccoupon_id, ccc.mcoupon_id, ccc.`exclusive`, ccc.`state`, ccc.ranged, ccc.created_at
    </sql>

    <select id="selectMultiForCommonCouponBasicDto" resultMap="Rst_CommonCouponBasicDto">
        SELECT
        <include refid="Rst_CommonCouponBasicDto_Column_List"/>
        FROM candy_common_coupon ccc
        LEFT JOIN candy_coupon cc ON ccc.coupon_id = cc.coupon_id
        WHERE ccc.state <![CDATA[<>]]> 2
        AND ccc.created_at <![CDATA[>=]]> #{ucreatedAt,jdbcType=TIMESTAMP}
    </select>
</mapper>
