xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
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
<?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.TTaxiCardPaymentMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TTaxiCardPayment">
        <id column="id" property="id" />
        <result column="userId" property="userId" />
        <result column="taxiCardId" property="taxiCardId" />
        <result column="payType" property="payType" />
        <result column="payStatus" property="payStatus" />
        <result column="payTime" property="payTime" />
        <result column="payMoney" property="payMoney" />
        <result column="orderNo" property="orderNo" />
        <result column="createTime" property="createTime" />
        <result column="type" property="type" />
        <result column="companyCityId" property="companyCityId" />
        <result column="content" property="content" />
        <result column="companyId" property="companyId" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, userId, taxiCardId, payType, payStatus, payTime, payMoney, orderNo, createTime, type, companyCityId, content, companyId
    </sql>
    <select  id="getList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        select
        p.id,
        p.createTime,
        u.nickName,
        u.phone,
        c.name cardName,
        p.payMoney,p.payType,
                CASE WHEN p.type=1 THEN '打折次数卡' WHEN
        p.type=1 THEN '优惠卡' WHEN
        p.type=1 THEN '次数卡' WHEN
        p.type=1 THEN '打折天数卡' WHEN
        p.type=1 THEN '物流打折卡' ELSE '物流优惠包' END typeName
                from t_taxi_card_payment p
                left join t_user u
                on p.userId = u.id
                left join t_taxi_card c
                on p.taxiCardId = c.id
        <where>
            1=1 and p.payStatus=2 and p.companyId=#{companyId}
            <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
                AND (p.createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            </if>
            <if test="userId != null and userId != ''">
                and find_in_set(p.userId, #{userId})
            </if>
            <if test="type != null and type != ''">
                and p.type=#{type}
            </if>
            <if test="phone != null and phone != ''">
                and u.phone  LIKE CONCAT('%',#{phone},'%')
            </if>
            <if test="name != null and name != ''">
                and u.nickName  LIKE CONCAT('%',#{name},'%')
            </if>
            <if test="id != null and id != ''">
                and p.id  LIKE CONCAT('%',#{id},'%')
            </if>
            <if test="cardName != null and cardName != ''">
                and c.name  LIKE CONCAT('%',#{cardName},'%')
            </if>
        </where>
        ORDER BY p.createTime DESC
    </select>
    <select  id="getListEx" resultType="map">
        select
        p.id,
        p.createTime,
        u.nickName,
        u.phone,
        c.name cardName,
        p.payMoney,p.payType,
        CASE WHEN p.type=1 THEN '打折次数卡' WHEN
        p.type=1 THEN '优惠卡' WHEN
        p.type=1 THEN '次数卡' WHEN
        p.type=1 THEN '打折天数卡' WHEN
        p.type=1 THEN '物流打折卡' ELSE '物流优惠包' END typeName
        from t_taxi_card_payment p
        left join t_user u
        on p.userId = u.id
        left join t_taxi_card c
        on p.taxiCardId = c.id
        <where>
            1=1 and p.payStatus=2 and p.companyId=#{companyId}
            <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
                AND (p.createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            </if>
            <if test="userId != null and userId != ''">
                and find_in_set(p.userId, #{userId})
            </if>
            <if test="type != null and type != ''">
                and p.type=#{type}
            </if>
            <if test="phone != null and phone != ''">
                and u.phone  LIKE CONCAT('%',#{phone},'%')
            </if>
            <if test="name != null and name != ''">
                and u.nickName  LIKE CONCAT('%',#{name},'%')
            </if>
            <if test="id != null and id != ''">
                and p.id  LIKE CONCAT('%',#{id},'%')
            </if>
            <if test="cardName != null and cardName != ''">
                and c.name  LIKE CONCAT('%',#{cardName},'%')
            </if>
        </where>
    </select>
    <select id="getSumMoney" resultType="java.lang.Double">
        SELECT SUM(payMoney) FROM t_taxi_card_payment p
        left join t_user u
        on p.userId = u.id
        left join t_taxi_card c
        on p.taxiCardId = c.id
        <where>
            1=1 and p.payStatus=2 and p.companyId=#{companyId}
            <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
                AND (p.createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            </if>
            <if test="userId != null and userId != ''">
                and find_in_set(p.userId, #{userId})
            </if>
            <if test="type != null and type != ''">
                and p.type=#{type}
            </if>
            <if test="phone != null and phone != ''">
                and u.phone  LIKE CONCAT('%',#{phone},'%')
            </if>
            <if test="name != null and name != ''">
                and u.nickName  LIKE CONCAT('%',#{name},'%')
            </if>
            <if test="id != null and id != ''">
                and p.id  LIKE CONCAT('%',#{id},'%')
            </if>
            <if test="cardName != null and cardName != ''">
                and c.name  LIKE CONCAT('%',#{cardName},'%')
            </if>
        </where>
    </select>
</mapper>