TdClSubCardInfoSMapper.xml
9.07 KB
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
<?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.zteits.bill.mapper.smapper.TdClSubCardInfoSMapper">
<resultMap id="BaseResultMap" type="com.zteits.bill.domain.TdClSubCardInfo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="card_no" jdbcType="VARCHAR" property="cardNo" />
<result column="card_name" jdbcType="VARCHAR" property="cardName" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="pl_name" jdbcType="VARCHAR" property="plName" />
<result column="effect_time" jdbcType="TIMESTAMP" property="effectTime" />
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
<result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
<result column="area_no" jdbcType="VARCHAR" property="areaNo" />
<result column="area_name" jdbcType="VARCHAR" property="areaName" />
<result column="data_status" jdbcType="INTEGER" property="dataStatus" />
<result column="customer_name" jdbcType="VARCHAR" property="customerName" />
<result column="card_status" jdbcType="INTEGER" property="cardStatus" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
<result column="phone_no" jdbcType="VARCHAR" property="phoneNo" />
<result column="push_state" jdbcType="INTEGER" property="pushState" />
<result column="record_no" jdbcType="VARCHAR" property="recordNo" />
<result column="card_buy_type" jdbcType="INTEGER" property="cardBuyType" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, card_no, card_name, pl_no, pl_name, effect_time, expire_time, customer_no, area_no,
area_name, data_status, customer_name, card_status, create_date, update_date
</sql>
<select id="selectDataByExample" parameterType="com.zteits.bill.domain.TdClSubCardInfoExample" resultMap="BaseResultMap">
SELECT
s.id,
s.card_no,
s.card_name,
s.pl_no,
s.pl_name,
s.effect_time,
s.expire_time,
s.customer_no,
IF
(
s.card_status = 0,
0,
IF
( now( ) <s.effect_time, 1, IF ( now( ) < s.expire_time, 2, 3 ) )
) card_status,
s.customer_name
FROM
td_cl_sub_card_info s
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectDataDtoByExample" parameterType="com.zteits.clouds.api.dto.bill.closecarpark.param.SubCardInfoManageInfoRequest"
resultType="com.zteits.clouds.api.dto.bill.closecarpark.dto.SubCardInfoDTO">
SELECT
s.id,
s.card_no cardNo,
s.card_name cardName,
s.pl_no plNo,
s.effect_time effectTime,
s.expire_time expireTime,
s.customer_no customerNo,
s.phone_no phoneNo,
IF
(
s.card_status = 0,
0,
IF
( now( ) <s.effect_time, 1, IF ( now( ) < s.expire_time, 2, 3 ) )
) cardStatus,
s.customer_name customerName,
s.push_state pushState,
s.record_no recordNo
FROM
td_cl_sub_card_info s
where 1=1
<if test="cardName != null and cardName != ''">
and s.card_name like concat('%',#{cardName,jdbcType=VARCHAR},'%')
</if>
<if test="cardNo != null and cardNo != ''">
and s.card_no like concat('%',#{cardNo,jdbcType=VARCHAR},'%')
</if>
<if test="plNo != null and plNo != ''">
and s.pl_no = #{plNo}
</if>
<if test="phoneNo != null and phoneNo != ''">
and s.phone_no like concat('%',#{phoneNo,jdbcType=VARCHAR},'%')
</if>
<if test="orgId != null and orgId != ''">
and s.org_id = #{orgId}
</if>
order by s.update_date desc
</select>
<select id="selectChargeByPrimaryKey" parameterType="java.lang.Long"
resultType="com.zteits.clouds.api.dto.bill.closecarpark.dto.SubCardChargeInfoDTO">
select
t.card_no cardNo,
t.card_name cardName,
t.pl_no plNo,
t.pl_name plName,
t.customer_no customerNo,
t.customer_name customerName,
t.org_id orgId,
c.card_rule_name cardRuleName,
c.unit_price unitPrice,
c.discount discount,
c.count count,
c.effect_time effectTime,
c.expire_time expireTime,
c.charge_type chargeType,
c.charge charge
from td_cl_sub_card_info t
left join td_cl_sub_charge_information c
on t.card_no = c.card_no
where t.id = #{id,jdbcType=BIGINT}
and t.data_status = 1
</select>
<!-- 查询未推送的子母车卡信息(用于定时任务下发到道闸) -->
<select id="queryNoPushSubCardInfo" resultType="com.zteits.clouds.api.dto.bill.closecarpark.dto.SubCardPushDTO">
SELECT
s.id,
s.card_no AS cardNo,
s.card_name AS cardName,
s.pl_no AS plNo,
s.customer_name AS customerName,
s.phone_no AS phoneNo,
s.effect_time AS effectTime,
s.expire_time AS expireTime,
s.push_state AS pushState,
s.record_no AS recordNo,
s.card_buy_type AS cardBuyType
FROM td_cl_sub_card_info s
WHERE s.push_state = 0
AND s.data_status = 1
AND s.effect_time <= NOW()
AND s.expire_time >= NOW()
AND s.card_status != 0
ORDER BY s.id
</select>
<!-- 更新子母车推送状态 -->
<update id="updateSubCardPushState">
UPDATE td_cl_sub_card_info
SET push_state = #{pushState},
record_no = #{recordNo},
update_date = NOW()
WHERE id = #{id}
AND card_no = #{cardNo}
</update>
</mapper>