admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?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.yeshi.fanli.dao.mybatis.integral.IntegralTaskRecordMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.integral.IntegralTaskRecord">
        <id column="ir_id" property="id" jdbcType="BIGINT" />
        <result column="ir_cid" property="cid" jdbcType="BIGINT" />
        <result column="ir_task_id" property="taskId" jdbcType="BIGINT" />
        <result column="ir_uid" property="uid" jdbcType="BIGINT" />
        <result column="ir_gold_coin" property="goldCoin" jdbcType="INTEGER" />
        <result column="ir_state" property="state" jdbcType="INTEGER" />
        <result column="ir_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="ir_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="ir_end_time" property="endTime" jdbcType="TIMESTAMP"/>
 
        <result column="taskName" property="taskName" jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List">ir_id,ir_cid,ir_task_id,ir_uid,ir_gold_coin,ir_state,ir_create_time,ir_update_time,ir_end_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_integral_task_record where ir_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_integral_task_record where ir_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_task_record (ir_id,ir_cid,ir_task_id,ir_uid,ir_gold_coin,ir_state,ir_create_time,ir_update_time,ir_end_time) values (#{id,jdbcType=BIGINT},#{cid,jdbcType=BIGINT},#{taskId,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{goldCoin,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_task_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">ir_id,</if>
      <if test="cid != null">ir_cid,</if>
      <if test="taskId != null">ir_task_id,</if>
      <if test="uid != null">ir_uid,</if>
      <if test="goldCoin != null">ir_gold_coin,</if>
      <if test="state != null">ir_state,</if>
      <if test="createTime != null">ir_create_time,</if>
      <if test="updateTime != null">ir_update_time,</if>
      <if test="endTime != null">ir_end_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="cid != null">#{cid,jdbcType=BIGINT},</if>
      <if test="taskId != null">#{taskId,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="goldCoin != null">#{goldCoin,jdbcType=INTEGER},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord">update yeshi_ec_integral_task_record set ir_cid = #{cid,jdbcType=BIGINT},ir_task_id = #{taskId,jdbcType=BIGINT},ir_uid = #{uid,jdbcType=BIGINT},ir_gold_coin = #{goldCoin,jdbcType=INTEGER},ir_state = #{state,jdbcType=INTEGER},ir_create_time = #{createTime,jdbcType=TIMESTAMP},ir_update_time = #{updateTime,jdbcType=TIMESTAMP},ir_end_time = #{endTime,jdbcType=TIMESTAMP} where ir_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.integral.IntegralTaskRecord">update yeshi_ec_integral_task_record
    <set>
      <if test="cid != null">ir_cid=#{cid,jdbcType=BIGINT},</if>
      <if test="taskId != null">ir_task_id=#{taskId,jdbcType=BIGINT},</if>
      <if test="uid != null">ir_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="goldCoin != null">ir_gold_coin=#{goldCoin,jdbcType=INTEGER},</if>
      <if test="state != null">ir_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">ir_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">ir_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">ir_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
    </set> where ir_id = #{id,jdbcType=BIGINT}
  </update>
 
 
    <update id="updateReceived" parameterType="Long">
        UPDATE
        yeshi_ec_integral_task_record SET ir_state = 1,ir_update_time = NOW()
        WHERE ir_state = 0 AND ir_uid = #{uid}
    </update>
    <update id="invalidGoldCoin">
        UPDATE yeshi_ec_integral_task_record SET ir_state = 2 
        WHERE ir_end_time <![CDATA[<]]> NOW() AND ir_state = 0
    </update>
 
    <select id="listNotReceived" resultMap="BaseResultMap">
        SELECT tc.`tc_name` AS
        taskName,d.* FROM yeshi_ec_integral_task_record d
        LEFT JOIN
        `yeshi_ec_integral_task_class` tc ON tc.`tc_id` = d.`ir_cid`
        WHERE
        d.`ir_uid` = #{uid} AND d.ir_state = 0
        ORDER BY d.ir_create_time
        LIMIT
        #{count}
    </select>
 
    <select id="listNotReceivedExcludeId" resultMap="BaseResultMap">
        SELECT tc.`tc_name` AS taskName,d.* FROM yeshi_ec_integral_task_record
        d
        LEFT JOIN `yeshi_ec_integral_task_class` tc ON tc.`tc_id` =
        d.`ir_cid`
        WHERE d.`ir_uid` = #{uid} AND d.ir_state = 0
        <if test="list != null">
            AND d.ir_id not in
            <foreach collection="list" item="item" open="(" separator=","
                close=")">
                ${item}
            </foreach>
        </if>
        ORDER BY d.ir_create_time
        LIMIT #{count}
    </select>
 
    <select id="getTotalGoldCoin" resultType="Integer">
        SELECT IFNULL(SUM(tr.`ir_gold_coin`),0) FROM
        yeshi_ec_integral_task_record tr
        WHERE tr.ir_uid = #{uid} AND
        tr.`ir_cid`=#{cid} <!-- tr.ir_state <![CDATA[<>]]>2 AND -->
        <if test="dateType == 1">
            AND TO_DAYS(tr.ir_create_time) = TO_DAYS(NOW())
        </if>
    </select>
 
    <select id="countFinished" resultType="Integer">
        SELECT IFNULL(COUNT(tr.`ir_id`),0) FROM yeshi_ec_integral_task_record
        tr
        WHERE tr.ir_uid = #{uid} AND tr.`ir_cid`=#{cid}
        <if test="dateType == 1">
            AND TO_DAYS(tr.ir_create_time) = TO_DAYS(NOW())
        </if>
    </select>
 
    <select id="listDaySignRecord" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_integral_task_record d
        WHERE d.`ir_uid` = #{uid}
        <if test="cid!=null">
            and d.ir_cid=#{cid}
        </if>
 
        AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <![CDATA[<=]]>
        DATE(d.ir_create_time)
        ORDER BY d.ir_create_time desc
    </select>
    
    
    <select id="listDateSignRecord" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_integral_task_record d
        WHERE d.`ir_uid` = #{uid}
        <if test="cid!=null">
            and d.ir_cid=#{cid}
        </if>
        ORDER BY d.ir_create_time desc
    </select>
 
    <select id="listSignRecordByDateTime" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_integral_task_record d
        WHERE d.`ir_uid` = #{uid}
        and d.ir_cid=#{cid}
        AND d.ir_create_time <![CDATA[<=]]>
        #{dateTime}
        ORDER BY d.ir_create_time desc
    </select>
 
    <select id="countTotalGoldCoin" resultType="Integer">
        SELECT
        IFNULL(SUM(d.`ir_gold_coin`),0) FROM `yeshi_ec_integral_task_record`
        d
        WHERE d.`ir_uid` = #{uid} AND d.`ir_state` = 0
    </select>
 
 
    <select id="countGetCountByTaskIdAndDay" resultType="Integer" flushCache="true" useCache="false">
        SELECT count(*) FROM `yeshi_ec_integral_task_record`
        d
        WHERE
        d.ir_task_id = #{taskId}
        <if test="uid!=null">
            and ir_uid=#{uid}
        </if>
 
        <if test="minTime!=null">
            and ir_create_time>=#{minTime}
        </if>
 
        <if test="maxTime!=null">
            and #{maxTime}>ir_create_time
        </if>
    </select>
 
    <select id="countByTaskIdTodayNum" resultType="Integer">
        SELECT IFNULL(COUNT(tr.`ir_id`),0) FROM yeshi_ec_integral_task_record tr
        WHERE tr.ir_uid = #{uid} AND tr.`ir_task_id`= #{tid}
              AND TO_DAYS(tr.ir_create_time) = TO_DAYS('${date}') AND tr.ir_id <![CDATA[<=]]> #{recordId}
    </select>
 
 
    <select id="listByCidAndUidAndCreateTime" resultMap="BaseResultMap">
        select * from yeshi_ec_integral_task_record where ir_cid=#{cid}
        <if test="uid!=null">
            and ir_uid=#{uid}
        </if>
        <if test="minTime!=null">
            and ir_create_time>=#{minTime}
        </if>
        <if test="maxTime!=null">
            and #{maxTime}>ir_create_time
        </if>
        limit #{start},#{count}
    </select>
    
    <select id="listByUidAndTaskId" resultMap="BaseResultMap">
        select * from yeshi_ec_integral_task_record where ir_task_id=#{taskId}
        <if test="uid!=null">
            and ir_uid=#{uid}
        </if>
        order by ir_id desc
        limit #{start},#{count}
    </select>
    
 
    <select id="countByCidAndUidAndCreateTime" resultType="java.lang.Long">
        select count(ir_id) from yeshi_ec_integral_task_record where
        ir_cid=#{cid}
        <if test="uid!=null">
            and ir_uid=#{uid}
        </if>
        <if test="minTime!=null">
            and ir_create_time>=#{minTime}
        </if>
 
        <if test="maxTime!=null">
            and #{maxTime}>ir_create_time
        </if>
    </select>
 
</mapper>