123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?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.kmall.api.dao.ApiCouponMapper">
- <!-- 可根据自己的需求,是否要使用 -->
- <resultMap type="com.kmall.api.entity.CouponVo" id="couponMap">
- <result property="id" column="id"/>
- <result property="name" column="name"/>
- <result property="type_money" column="type_money"/>
- <result property="send_type" column="send_type"/>
- <result property="min_amount" column="min_amount"/>
- <result property="max_amount" column="max_amount"/>
- <result property="send_start_date" column="send_start_date"/>
- <result property="send_end_date" column="send_end_date"/>
- <result property="use_start_date" column="use_start_date"/>
- <result property="use_end_date" column="use_end_date"/>
- <result property="coupon_txt" column="coupon_txt"/>
- <result property="user_id" column="user_id"/>
- <result property="coupon_number" column="coupon_number"/>
- <result property="show_state" column="show_state"/>
- <result property="pic_url" column="pic_url"/>
- <result property="isAll" column="is_all"/>
- <result property="couponUrl" column="coupon_url"/>
- </resultMap>
- <select id="queryObject" resultMap="couponMap">
- select * from mall_coupon where id = #{value}
- </select>
- <select id="queryList" resultMap="couponMap">
- select * from mall_coupon a
- where 1 = 1
- <if test="store_id != null">
- and a.`store_id` = #{store_id}
- </if>
- <if test="send_types != null">
- and send_type in
- <foreach item="item" collection="send_types" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="enabled != null and enabled == true">
- and a.use_end_date >= now()
- and now() >= a.use_start_date
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by a.id desc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
- <select id="queryTotal" resultType="int">
- select count(*) from mall_coupon a
- where 1 = 1
- <if test="send_types != null">
- and send_type in
- <foreach item="item" collection="send_types" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="store_id != null">
- and a.`store_id` = #{store_id}
- </if>
- <if test="enabled != null and enabled == true">
- and a.use_end_date >= now()
- and now() >= a.use_start_date
- </if>
- </select>
- <select id="queryMaxUserEnableCoupon" resultMap="couponMap">
- select a.*
- from mall_coupon a
- where 1 = 1
- and a.use_end_date >= now()
- and now() >= a.use_start_date
- <if test="send_type != null">
- and a.send_type = #{send_type}
- </if>
- <if test="send_types != null">
- and a.send_type in
- <foreach item="item" collection="send_types" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="filterCouponIds != null">
- and a.`id` not in
- <foreach item="item" collection="filterCouponIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- order by type_money desc
- limit 1
- </select>
- </mapper>
|