无关风月
2024-11-14 350067a73fc9ed0a35582b900533c2708d5b1212
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?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.stylefeng.guns.modular.system.dao.CouponMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Coupon">
        <id column="id" property="id" />
        <result column="couponName" property="couponName" />
        <result column="timeType" property="timeType" />
        <result column="grantType" property="grantType" />
        <result column="startTime" property="startTime" />
        <result column="endTime" property="endTime" />
        <result column="afterDay" property="afterDay" />
        <result column="needClockIn" property="needClockIn" />
        <result column="buyCourseId" property="buyCourseId" />
        <result column="money" property="money" />
        <result column="reduction" property="reduction" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, couponName, timeType, grantType, startTime, endTime, afterDay, needClockIn, buyCourseId, money, reduction
    </sql>
 
 
    <select id="couponReceive" resultType="com.stylefeng.guns.modular.system.vo.CouponReceiveVO">
        select t1.*,t2.name as userName,t2.phone
        from t_coupon_receive t1
        left join t_user t2 on t1.userId = t2.id
        <where>
            <if test="req.id !=null ">
                AND t1.couponId = #{req.id}
            </if>
            <if test="req.userName !=null and req.userName !='' ">
                AND t2.name LIKE concat('%',#{req.userName},'%')
            </if>
            <if test="req.phone !=null and req.phone !='' ">
                AND t2.phone LIKE concat('%',#{req.phone},'%')
            </if>
            <if test="req.receiveType !=null and req.receiveType == 1">
                and (t1.receiveType = 1 or t1.receiveType = 2)
            </if>
            <if test="req.receiveType !=null and req.receiveType == 2">
                and t1.receiveType = 3
            </if>
            <if test="req.state !=null and req.state == 1">
                and t1.state = 1
            </if>
            <if test="req.state !=null and req.state == 2">
                and t1.state = 2
            </if>
            <if test="req.state !=null and req.state == 3">
                and (t1.endTime &lt;= now() and t1.state!=2)
            </if>
        </where>
    </select>
 
    <select id="couponList" resultType="com.stylefeng.guns.modular.system.model.Coupon">
        select t1.* from t_coupon t1
        <where>
            <if test="name !=null and name!='' ">
                AND t1.couponName LIKE concat('%',#{name},'%')
            </if>
            <if test="time !=null">
                and t1.timeType = #{time}
            </if>
            <if test="grant !=null">
                and t1.grantType = #{grant}
            </if>
            and t1.isDelete  = 0
        </where>
        order by t1.id desc
    </select>
 
</mapper>