<?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.qs.mp.admin.mapper.CouponPkgItemMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qs.mp.admin.domain.CouponPkgItem">
        <id column="id" property="id" />
        <result column="coupon_pkg_id" property="couponPkgId" />
        <result column="coupon_id" property="couponId" />
        <result column="created_time" property="createdTime" />
        <result column="updated_time" property="updatedTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, coupon_pkg_id, coupon_id, created_time, updated_time
    </sql>

    <select id="selectDetail" resultType="com.qs.mp.admin.domain.vo.CouponPkgItemVO">
        select t1.id,
            t1.coupon_pkg_id,
            t1.coupon_id,
            t1.coupon_num,
            t1.created_time,
            t1.updated_time,
            t2.title,
            t2.discount,
            t2.type,
            t2.due_days
        from mp_coupon_pkg_item t1
        left join mp_coupon t2 on t1.coupon_id = t2.coupon_id
        ${ew.customSqlSegment}
    </select>

    <select id="selectCouponList" resultType="com.qs.mp.admin.domain.Coupon">
        select t2.*
        from mp_coupon_pkg_item t1
        left join mp_coupon t2 on t1.coupon_id = t2.coupon_id
        ${ew.customSqlSegment}
    </select>
</mapper>