无关风月
2025-05-08 9486766c806fe1d9e082b2fd02ea1cc558f1b443
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
<?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.competition.mapper.CompetitionMapper">
 
    <delete id="deleteTenMinutes">
        delete from t_user_competition
 
        where paymentCompetitionId in
        <foreach collection="pays" item="pay" separator="," open="(" close=")">
            #{pay}
        </foreach>
    </delete>
 
 
    <select id="queryCompetitionList" resultType="com.dsh.competition.model.CompetitionListVo">
        select
        aa.id,
        aa.name,
        aa.coverDrawing,
        aa.cityName,
        aa.registerCondition,
        aa.introduction,
        aa.registerEndTime,
        aa.age,
        aa.status,
        aa.heat
        from (
        SELECT
        a.id,
        a.`name`,
        a.coverDrawing,
        a.city AS cityName,
        a.registerCondition,
        a.introduction,
        a.baseNumber as heat,
        DATE_FORMAT(a.registerEndTime, '%Y-%m-%d %H:%i') AS registerEndTime,
        CONCAT(a.startAge, '-', a.endAge) AS age,
        a.baseNumber,
        CASE
        WHEN NOW() &lt; a.startTime THEN 1 -- 未开始
        WHEN now() between a.startTime and a.endTime THEN 2 -- 进行中
        ELSE 3 -- 已结束
        END AS status
        FROM
        t_competition a
        WHERE
        a.auditStatus = 2 and a.status != 4
        AND a.state = 1
        <if test="null != cityCode and '' != cityCode">
            and a.cityCode = #{cityCode}
        </if>
        <if test="null != content and '' != content">
            and a.name like CONCAT('%', #{content}, '%')
        </if>
        <if test="null != registerCondition">
            and a.registerCondition = #{registerCondition}
        </if>
        GROUP BY a.id
        order by a.insertTime desc
        ) as aa
        <if test="null != heat and '' != heat">
            order by aa.heat ${heat}
        </if>
    </select>
    <select id="counts" resultType="java.lang.Integer">
            select  count(1)
            from t_user_competition where competitionId = #{id}
    </select>
 
 
    <update id="taskSetStatusStart">
        update t_competition set status = 2 where status = 1 and state = 1 and auditStatus = 2 and now() between startTime and endTime
    </update>
 
 
    <update id="taskSetStatusEnd">
        update t_competition set status = 3 where status = 2 and state = 1 and auditStatus = 2 and now() >= endTime
    </update>
</mapper>