<?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.fzm.mall.server.front.user.mapper.CouponMapper">
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.front.goods.model.vo.CouponVo">
        <result column="coupon_id" jdbcType="VARCHAR" property="couponId" />
        <result column="type" jdbcType="INTEGER" property="type" />
        <result column="name" jdbcType="VARCHAR" property="name" />
        <result column="remark" jdbcType="VARCHAR" property="remark" />
        <result column="scope" jdbcType="INTEGER" property="scope" />
        <result column="condition_val" jdbcType="DECIMAL" property="conditionVal" />
        <result column="coupon_val" jdbcType="DECIMAL" property="couponVal" />
        <result column="circulation" jdbcType="BIGINT" property="circulation" />
        <result column="amt" jdbcType="BIGINT" property="amt" />
        <result column="start_time" jdbcType="BIGINT" property="startTime" />
        <result column="end_time" jdbcType="BIGINT" property="endTime" />
        <result column="status" jdbcType="INTEGER" property="status" />
        <result column="range_type" jdbcType="INTEGER" property="rangeType" />
        <result column="merchant_id" jdbcType="VARCHAR" property="merchantId" />
        <result column="create_time" jdbcType="BIGINT" property="createTime" />
        <result column="update_time" jdbcType="BIGINT" property="updateTime" />
            <!--一对多，方式一-->
            <collection property="marketingCouponSkus" ofType = "com.fzm.mall.server.front.goods.model.MarketingCouponSku" >
                <result column="sku_id" jdbcType="VARCHAR" property="skuId" />
            </collection>
            <collection property="marketingCouponCategories" ofType="com.fzm.mall.server.front.goods.model.MarketingCouponCategory" >
                  <result column="category_id" jdbcType="VARCHAR" property="categoryId" />
            </collection>
        </resultMap>
    <select id="getAll" resultMap="BaseResultMap">
        select * from marketing_coupon a left join marketing_coupon_category b on a.coupon_id = b.coupon_id left join marketing_coupon_sku c on a.coupon_id = c.coupon_id where a.status = 1 and a.start_time &lt;= #{time} and a.end_time &gt;= #{time} and a.coupon_id = #{couponId} and a.type in (1,#{type}) and (c.status = 1 or c.status is null)
    </select>

  <!--  <select id="getTest" resultMap="BaseResultMap">
            select * from user_coupon a
            left join marketing_coupon b on a.coupon_id = b.coupon_id
            left join marketing_coupon_sku c on a.coupon_id = c.coupon_id
            left join marketing_coupon_category d on a.coupon_id = d.coupon_id
            where a.uid = #{uid} and a.status = 1 and b.status = 1 and b.start_time &lt;=#{time} and b.end_time &gt;= #{time}
            and b.type in (1,#{type})
            and (a.range_type=1 and a.merchant_id in (#{merchantId}))
            or (a.range_type = 2 and d.category_id in(#{categoryId}))
            or (a.range_type = 3 and c.sku_id in (#{skuId}))
    </select>-->
</mapper>
