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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?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.CouponMapper">
    <update id="updateType">
        update t_user_coupon set status = 2 where id =#{id}
    </update>
 
    <select id="queryConponRuleOfJson" resultType="java.util.Map">
        SELECT JSON_EXTRACT(content, "$.conditionalAmount") as conditionalAmount,
        JSON_EXTRACT(content, "$.deductionAmount") as deductionAmount,
        JSON_EXTRACT(content, "$.experienceName") as experienceName
        FROM t_coupon
        where 1=1
        <if test="id != null">
            and `id` = #{id}
        </if>
    </select>
    <select id="queryCouponListOfSearch" resultType="java.util.Map">
        SELECT id,
        `name`,
        useScope,
        `type`,
        distributionMethod,
        date_format(startTime ,'%Y-%m-%d') as startTime,
        date_format(endTime ,'%Y-%m-%d') as endTime,
        userPopulation,
        quantityIssued,
        pickUpQuantity,
        `status`,
        state,
        illustrate,
        auditStatus,
        publisherType
        from t_coupon
        where 1=1
        <if test="objType == 3">
            and cityManagerId = #{operatorId}
        </if>
 
        <if test="cityCode != null">
            and id in(
            SELECT DISTINCT couponId FROM
 
            (SELECT DISTINCT couponId
            from t_coupon_store
            WHERE storeId = #{storeId}
            UNION ALL
            SELECT DISTINCT couponId
 
            from t_coupon_city
            WHERE provinceCode = #{cityCode}) o)
        </if>
        <if test="name != null and name!=''">
            and `name` like concat('%', #{name}, '%')
        </if>
        <if test="type != null">
            and type = #{type}
        </if>
        <if test="distributionMethod != null">
            and distributionMethod = #{distributionMethod}
        </if>
        <if test="userPopulation != null">
            and userPopulation = #{userPopulation}
        </if>
        <if test="status !=null">
            and `status` = #{status}
        </if>
        <if test="state != null">
            and `state` = #{state}
        </if>
        and auditStatus = 2
        order by insertTime desc
    </select>
    <select id="queryCouponListOfSearch1" resultType="java.util.Map">
        SELECT id,
        `name`,
        useScope,
        `type`,
        distributionMethod,
        date_format(startTime ,'%Y-%m-%d') as startTime,
        date_format(endTime ,'%Y-%m-%d') as endTime,
        userPopulation,
        quantityIssued,
        pickUpQuantity,
        `status`,
        state,
        illustrate
        from t_coupon
        where 1 = 1 and distributionMethod = 4
        and auditStatus = 2
        and startTime &lt; now()
          and state= 1
        <if test="cityCode != null">
            and id in(
            SELECT DISTINCT couponId FROM
            (SELECT DISTINCT couponId
            from t_coupon_store
            WHERE storeId = #{storeId}
            UNION ALL
            SELECT DISTINCT couponId
            from t_coupon_city
            WHERE cityCode = #{cityCode}) o)
        </if>
        <if test="name != null">
            and `name` like concat('%', #{name}, '%')
        </if>
        <if test="type != null">
            and type = #{type}
        </if>
 
        <if test="userPopulation != null">
            and userPopulation = #{userPopulation}
        </if>
        <if test="status !=null">
            and `status` = #{status}
        </if>
        <if test="state != null">
            and `state` = #{state}
        </if>
        union all
        SELECT id,
        `name`,
        useScope,
        `type`,
        distributionMethod,
        date_format(startTime ,'%Y-%m-%d') as startTime,
        date_format(endTime ,'%Y-%m-%d') as endTime,
        userPopulation,
        quantityIssued,
        pickUpQuantity,
        `status`,
        state,
        illustrate
        from t_coupon
        where 1 = 1 and distributionMethod = 4 and useScope = 1
        and auditStatus = 2
        and state= 1
        and startTime &lt; now()
        <if test="name != null">
            and `name` like concat('%', #{name}, '%')
        </if>
 
 
    </select>
    <select id="queryCouponExamineList" resultType="java.util.Map">
        SELECT id,
        `name`,
        useScope,
        `type`,
        distributionMethod,
        date_format(startTime ,'%Y-%m-%d') as startTime,
        date_format(endTime ,'%Y-%m-%d') as endTime,
        userPopulation,
        quantityIssued,
        pickUpQuantity,
        auditStatus,
        publisherType,
        cityManagerId
        from t_coupon
        where auditStatus != 2
        <if test="name != null">
            and `name` like concat('%', #{name}, '%')
        </if>
        <if test="type != null">
            and type = #{type}
        </if>
        <if test="distributionMethod != null">
            and distributionMethod = #{distributionMethod}
        </if>
        <if test="userPopulation != null">
            and userPopulation = #{userPopulation}
        </if>
        <if test="auditStatus != null">
            and auditStatus = #{auditStatus}
        </if>
        order by insertTime desc
    </select>
    <select id="listRecord" resultType="java.util.Map">
        select id,userId,status from t_user_coupon where couponId =#{id}
        and userId in
        <foreach collection="ids" separator="," open="(" item="i" close=")">
            #{i}
        </foreach>
        <if test="type !=null">
            and status =#{type}
        </if>
    </select>
 
 
</mapper>