puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?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.dsh.activity.mapper.UserCouponMapper">
 
 
    <select id="queryAvailableCouponList" resultType="map">
        select
        a.id,
        b.`name`,
        b.type,
        b.content,
        DATE_FORMAT(b.startTime, '%Y-%m-%d') as startTime,
        DATE_FORMAT(b.endTime, '%Y-%m-%d') as endTime
        from t_user_coupon a
        left join t_coupon b on (a.couponId = b.id)
        where a.`status` = 1 and b.type != 3 and (now() between b.startTime and b.endTime) and a.userId = #{uid} and
              (
            b.useScope = 1 or (b.useScope = 2 and b.id IN (SELECT couponId FROM t_coupon_city  where provinceCode = #{provinceCode} and cityCode = #{cityCode}) )
                           or (b.useScope = 3 and b.id in (select couponId from t_coupon_store where storeId = #{storeId})))
    </select>
</mapper>