add
yj
2024-12-05 b9900893177c78fc559223521fe839aa21000017
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?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.iotechn.unimall.data.mapper.CouponUserMapper">
 
    <select id="getUserCoupons" resultType="com.iotechn.unimall.data.dto.CouponUserDTO">
        SELECT
            u.id,
            u.user_id AS userId,
            u.coupon_id AS couponId,
            u.gmt_update AS gmtUpdate,
            u.gmt_create AS gmtCreate,
            u.gmt_end AS gmtEnd,
            c.title,
            c.category_id AS categoryId,
            y.title AS categoryTitle,
            c.`min`,
            c.discount
        FROM
            unimall_coupon_user AS u,
            unimall_coupon AS c
            LEFT JOIN unimall_category AS y ON c.category_id = y.id
        WHERE
            u.coupon_id = c.id
            AND u.user_id = #{userId}
            AND u.gmt_used IS NULL
            AND unix_timestamp(u.gmt_start) &lt;= unix_timestamp(now())
            AND unix_timestamp(u.gmt_end) &gt; unix_timestamp(now())
    </select>
 
    <select id="getCouponUserById" resultType="com.iotechn.unimall.data.dto.CouponUserDTO">
        SELECT
            u.id,
            u.user_id AS userId,
            u.coupon_id AS couponId,
            u.gmt_update AS gmtUpdate,
            u.gmt_create AS gmtCreate,
            c.title,
            c.category_id AS categoryId,
            y.title AS categoryTitle,
            c.`min`,
            c.discount
        FROM
            unimall_coupon_user AS u,
            unimall_coupon AS c
            LEFT JOIN unimall_category AS y ON c.category_id = y.id
        WHERE
            u.id = #{userCouponId}
            AND u.coupon_id = c.id
            AND u.user_id = #{userId}
            AND u.gmt_used IS NULL
            AND unix_timestamp(u.gmt_start) &lt;= unix_timestamp(now())
            AND unix_timestamp(u.gmt_end) &gt; unix_timestamp(now())
    </select>
 
</mapper>