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
<?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.PaymentCompetitionMapper">
 
 
    <select id="queryMyCompetitionList" resultType="com.dsh.competition.model.CompetitionListVo">
        select
        a.id,
        b.`name`,
        b.coverDrawing,
        b.city as cityName,
        b.registerCondition,
        b.introduction,
        b.id as pId,
        DATE_FORMAT(b.registerEndTime, '%Y-%m-%d %H:%i') as registerEndTime,
        CONCAT(b.startAge, '-', b.endAge) as age,
        b.baseNumber as heat,
        if(a.payStatus = 3, 4, b.status) as status
        from t_payment_competition a
        left join t_competition b on (a.competitionId = b.id)
        where a.state = 1 and a.appUserId = #{uid} and a.payStatus != 1
        <!--1=未开始,2=进行中,3=已结束,4=已取消-->
        <if test="null != type and 1 == type">
            and b.status = 1 and a.payStatus = 2
        </if>
        <if test="null != type and 2 == type">
            and b.status = 2 and a.payStatus = 2
        </if>
        <if test="null != type and 3 == type">
            and b.status = 3 and a.payStatus = 2
        </if>
        <if test="null != type and 4 == type">
            and a.payStatus = 3
        </if>
        order by a.insertTime desc limit #{pageNo}, #{pageSize}
    </select>
    <select id="queryDatas" resultType="com.dsh.competition.feignclient.model.BillingRequest">
        SELECT DATE_FORMAT(insertTime, '%m-%d %H:%i')as `time`,
        amount
        from t_payment_competition
        where payStatus in (2,3) and payType in (1,2)
        <if test="null != monthStart and '' != monthStart and null != monthEnd and '' != monthEnd">
            and DATE_FORMAT(payTime, '%Y-%m-%d %H:%i:%s') between #{monthStart} and #{monthEnd}
        </if>
        <if test="null != appUserId and '' != appUserId ">
            and appUserId = #{appUserId}
        </if>
    </select>
    <select id="queryCancelDatas" resultType="com.dsh.competition.feignclient.model.BillingRequest">
        SELECT DATE_FORMAT(refundTime, '%m-%d %H:%i')as `time`,
        amount
        from t_payment_competition
        where payStatus = 3 and payType in (1,2)
        <if test="null != monthStart and '' != monthStart and null != monthEnd and '' != monthEnd">
            and DATE_FORMAT(refundTime, '%Y-%m-%d %H:%i:%s') between #{monthStart} and #{monthEnd}
        </if>
        <if test="null != appUserId and '' != appUserId ">
            and appUserId = #{appUserId}
        </if>
    </select>
    <select id="listAll" resultType="com.dsh.competition.entity.PaymentCompetition">
        select * from t_payment_competition t1
        <where>
            <if test="query.amount!=null and query.amount!= ''">
                and t1.amount &lt;= #{query.amount}
            </if>
            <if test="query.userIds != null and query.userIds.size()>0">
                AND t1.competitionId IN
                <foreach collection="query.userIds" separator="," item="id" open="(" close=")">
                    #{id}
                </foreach>
            </if>
            <if test="sTime !=null and sTime!= '' and eTime !=null and eTime!= ''">
                and t1.insertTime between #{sTime} and #{eTime}
            </if>
        </where>
    </select>
    <select id="queryBycode" resultType="java.lang.Integer">
        SELECT cp.storeId
        FROM t_course_package_payment py
                 LEFT JOIN t_course_package cp ON py.coursePackageId = cp.id
        WHERE py.code = #{code}
    </select>
    <select id="counts" resultType="java.lang.Integer">
        select  count(1)
        from t_user_competition where competitionId = #{id}
    </select>
</mapper>