TdCCustInvoiceHisSMapper.xml
16.4 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?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.pay.mapper.smapper.TdCCustInvoiceHisSMapper">
<resultMap id="BaseResultMap" type="com.zteits.pay.domain.TdCCustInvoiceHis">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="invoice_id" jdbcType="VARCHAR" property="invoiceId" />
<result column="invoice_code" jdbcType="VARCHAR" property="invoiceCode" />
<result column="invoice_number" jdbcType="VARCHAR" property="invoiceNumber" />
<result column="invoice_url" jdbcType="VARCHAR" property="invoiceUrl" />
<result column="cust_id" jdbcType="VARCHAR" property="custId" />
<result column="invoice_total_fee" jdbcType="DECIMAL" property="invoiceTotalFee" />
<result column="invoice_fee" jdbcType="DECIMAL" property="invoiceFee" />
<result column="invoice_tax_rate" jdbcType="DECIMAL" property="invoiceTaxRate" />
<result column="invoice_tax_fee" jdbcType="DECIMAL" property="invoiceTaxFee" />
<result column="invoice_state" jdbcType="VARCHAR" property="invoiceState" />
<result column="post_name_id" jdbcType="BIGINT" property="postNameId" />
<result column="post_name" jdbcType="VARCHAR" property="postName" />
<result column="post_date" jdbcType="TIMESTAMP" property="postDate" />
<result column="pryee" jdbcType="VARCHAR" property="pryee" />
<result column="checker" jdbcType="VARCHAR" property="checker" />
<result column="drawer_id" jdbcType="BIGINT" property="drawerId" />
<result column="drawer" jdbcType="VARCHAR" property="drawer" />
<result column="invoice_date" jdbcType="TIMESTAMP" property="invoiceDate" />
<result column="pdf_md5" jdbcType="VARCHAR" property="pdfMd5" />
<result column="msg" jdbcType="VARCHAR" property="msg" />
<result column="hjbhsje" jdbcType="VARCHAR" property="hjbhsje" />
<result column="kphjse" jdbcType="VARCHAR" property="kphjse" />
<result column="cust_name" jdbcType="VARCHAR" property="custName" />
<result column="invoice_type" jdbcType="VARCHAR" property="invoiceType" />
<result column="cust_taxID" jdbcType="VARCHAR" property="custTaxid" />
<result column="cust_bank_name" jdbcType="VARCHAR" property="custBankName" />
<result column="cust_card_no" jdbcType="VARCHAR" property="custCardNo" />
<result column="cust_address" jdbcType="VARCHAR" property="custAddress" />
<result column="cust_phone" jdbcType="VARCHAR" property="custPhone" />
<result column="cust_email" jdbcType="VARCHAR" property="custEmail" />
<result column="sale_name" jdbcType="VARCHAR" property="saleName" />
<result column="sale_taxID" jdbcType="VARCHAR" property="saleTaxid" />
<result column="sale_bank_name" jdbcType="VARCHAR" property="saleBankName" />
<result column="sale_card_no" jdbcType="VARCHAR" property="saleCardNo" />
<result column="sale_address" jdbcType="VARCHAR" property="saleAddress" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="modfiy_empid" jdbcType="VARCHAR" property="modfiyEmpid" />
<result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
<result column="apply_date" jdbcType="TIMESTAMP" property="applyDate" />
<result column="ticket_content" jdbcType="VARCHAR" property="ticketContent" />
<result column="recipients" jdbcType="VARCHAR" property="recipients" />
<result column="recipients_address" jdbcType="VARCHAR" property="recipientsAddress" />
<result column="fetch_ticket_way" jdbcType="INTEGER" property="fetchTicketWay" />
<result column="recipients_phone" jdbcType="VARCHAR" property="recipientsPhone" />
<result column="invoice_kind" jdbcType="VARCHAR" property="invoiceKind" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="car_numbers" jdbcType="VARCHAR" property="carNumbers" />
<result column="invoice_big_type" jdbcType="INTEGER" property="invoiceBigType" />
<result column="terminal_source" jdbcType="INTEGER" property="terminalSource"/>
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
</resultMap>
<sql id="Base_Column_List">
id, invoice_id, invoice_code, invoice_number, invoice_url, cust_id, invoice_total_fee,
invoice_fee, invoice_tax_rate, invoice_tax_fee, invoice_state, post_name_id, post_name,
post_date, pryee, checker, drawer_id, drawer, invoice_date, pdf_md5, msg, hjbhsje,
kphjse, cust_name, invoice_type, cust_taxID, cust_bank_name, cust_card_no, cust_address,
cust_phone, cust_email, sale_name, sale_taxID, sale_bank_name, sale_card_no, sale_address,
data_state, create_empid, create_date, modfiy_empid, modfiy_date, apply_date, ticket_content,
recipients, recipients_address, fetch_ticket_way, recipients_phone, invoice_kind,
pl_no, car_numbers, invoice_big_type,terminal_source, remark, org_id
</sql>
<select id="selectListByVO" parameterType="com.zteits.clouds.api.dto.pay.param.TdCCustInvoiceHisRequest"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from td_c_cust_invoice_his
where data_state = 1
<if test="carNumber != null and carNumber!=''">
AND car_numbers like concat('%',#{carNumber,jdbcType=VARCHAR},'%')
</if>
<if test="plNos != null and plNos.size>0">
AND pl_no in
<foreach collection="plNos" index="index" item="plNo" open="(" separator="," close=")">#{plNo}</foreach>
</if>
<if test="invoiceId != null">
and invoice_id = #{invoiceId,jdbcType=VARCHAR}
</if>
<if test="invoiceCode != null">
and invoice_code = #{invoiceCode,jdbcType=VARCHAR}
</if>
<if test="invoiceNumber != null">
and invoice_number = #{invoiceNumber,jdbcType=VARCHAR}
</if>
<if test="invoiceDate != null">
and invoice_date = #{invoiceDate,jdbcType=TIMESTAMP}
</if>
<if test="custId != null">
and cust_id = #{custId,jdbcType=VARCHAR}
</if>
<if test="invoiceTotalFee != null">
and invoice_total_fee = #{invoiceTotalFee,jdbcType=DECIMAL}
</if>
<if test="invoiceFee != null">
and invoice_fee = #{invoiceFee,jdbcType=DECIMAL}
</if>
<if test="invoiceTaxRate != null">
and invoice_tax_rate = #{invoiceTaxRate,jdbcType=DECIMAL}
</if>
<if test="invoiceTaxFee != null">
and invoice_tax_fee = #{invoiceTaxFee,jdbcType=DECIMAL}
</if>
<if test="invoiceState != null and '' != invoiceState">
and invoice_state = #{invoiceState,jdbcType=VARCHAR}
</if>
<if test="invoiceStates != null and invoiceStates.size > 0 ">
and invoice_state IN
<foreach collection="invoiceStates" open="(" close=")" index="index" item="iState" separator=",">
#{iState}
</foreach>
</if>
<if test="postDate != null">
and post_date = #{postDate,jdbcType=TIMESTAMP}
</if>
<if test="pryee != null">
and pryee = #{pryee,jdbcType=VARCHAR}
</if>
<if test="checker != null">
and checker = #{checker,jdbcType=VARCHAR}
</if>
<if test="drawer != null">
and drawer = #{drawer,jdbcType=VARCHAR}
</if>
<if test=" custName != null and '' !=custName">
and (cust_taxID LIKE concat('%',#{custName,jdbcType=VARCHAR},'%') OR cust_name LIKE
concat('%',#{custName,jdbcType=VARCHAR},'%'))
</if>
<if test="invoiceType != null">
and invoice_type = #{invoiceType,jdbcType=VARCHAR}
</if>
<if test="custBankName != null">
and cust_bank_name = #{custBankName,jdbcType=VARCHAR}
</if>
<if test="custCardNo != null">
and cust_card_no = #{custCardNo,jdbcType=VARCHAR}
</if>
<if test="custAddress != null">
and cust_address = #{custAddress,jdbcType=VARCHAR}
</if>
<if test="custPhone != null and '' != custPhone">
and recipients_phone like CONCAT('%',#{custPhone,jdbcType=VARCHAR},'%')
</if>
<if test="saleName != null">
and sale_name = #{saleName,jdbcType=VARCHAR}
</if>
<if test="saleTaxid != null">
and sale_taxID = #{saleTaxid,jdbcType=VARCHAR}
</if>
<if test="saleBankName != null">
and sale_bank_name = #{saleBankName,jdbcType=VARCHAR}
</if>
<if test="saleCardNo != null">
and sale_card_no = #{saleCardNo,jdbcType=VARCHAR}
</if>
<if test="saleAddress != null">
and sale_address = #{saleAddress,jdbcType=VARCHAR}
</if>
<if test="dataState != null">
and data_state = #{dataState,jdbcType=INTEGER}
</if>
<if test="createEmpid != null">
and create_empid = #{createEmpid,jdbcType=VARCHAR}
</if>
<if test="createDate != null">
and create_date = #{createDate,jdbcType=TIMESTAMP}
</if>
<if test="modfiyEmpid != null">
and modfiy_empid = #{modfiyEmpid,jdbcType=VARCHAR}
</if>
<if test="modfiyDate != null">
and modfiy_date = #{modfiyDate,jdbcType=TIMESTAMP}
</if>
<if test="applyDate != null">
and apply_date = #{applyDate,jdbcType=TIMESTAMP}
</if>
<if test="ticketContent != null">
and ticket_content = #{ticketContent,jdbcType=VARCHAR}
</if>
<if test="recipients != null">
and recipients = #{recipients,jdbcType=VARCHAR}
</if>
<if test="recipientsAddress != null">
and recipients_address = #{recipientsAddress,jdbcType=VARCHAR}
</if>
<if test="fetchTicketWay != null">
and fetch_ticket_way = #{fetchTicketWay,jdbcType=INTEGER}
</if>
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
order by create_date desc
</select>
<select id="selectListByOrderId" parameterType="com.zteits.clouds.api.dto.pay.param.TdCCustInvoiceHisRequest"
resultType="com.zteits.clouds.api.dto.pay.TdCCustInvoiceHisDTO">
select
a.id, a.invoice_id invoiceId, a.invoice_code invoiceCode, a.invoice_number invoiceNumber, a.invoice_url invoiceUrl, a.cust_id custId, a.invoice_total_fee invoiceTotalFee,
a.invoice_fee invoiceFee, a.invoice_tax_rate invoiceTaxRate, a.invoice_tax_fee invoiceTaxFee, a.invoice_state invoiceState, a.post_name_id postNameId, a.post_name postName ,
a.post_date postDate, a.pryee, a.checker, a.drawer_id drawerId, a.drawer, a.invoice_date invoiceDate, a.pdf_md5 pdfMd5, a.msg, a.hjbhsje,
a.kphjse, a.cust_name custName, a.invoice_type invoiceType, a.cust_taxID custTaxID, a.cust_bank_name custBankName, a.cust_card_no custCardNo, a.cust_address custAddress,
a.cust_phone, a.cust_email custEmail, a.sale_name, a.sale_taxID, a.sale_bank_name, a.sale_card_no, a.sale_address,
a.data_state dataState, a.create_empid createEmpid, a.create_date createDate, a.modfiy_empid modfiyEmpid, a.modfiy_date modfiyDate, a.apply_date applyDate, a.ticket_content ticketContent,
a.recipients, a.recipients_address recipientsAddress, a.fetch_ticket_way fetchTicketWay, a.recipients_phone recipientsPhone, a.invoice_kind invoiceKind,
a.pl_no plNo, a.car_numbers carNumbers,a.invoice_big_type invoiceBigType,a.terminal_source terminalSource, a.remark, a.org_id orgId
from td_c_cust_invoice_his a,
td_c_cust_invoice_his_detail b
where a.data_state = 1
and b.invoice_id = a.invoice_id
<if test="orderIds != null and orderIds.size>0">
AND b.order_id in
<foreach collection="orderIds" index="index" item="orderId" open="(" separator="," close=")">#{orderId}</foreach>
</if>
<if test="invoiceId != null">
and a.invoice_id = #{invoiceId,jdbcType=VARCHAR}
</if>
<if test="invoiceCode != null">
and a.invoice_code = #{invoiceCode,jdbcType=VARCHAR}
</if>
<if test="invoiceNumber != null">
and a.invoice_number = #{invoiceNumber,jdbcType=VARCHAR}
</if>
<if test="invoiceDate != null">
and a.invoice_date = #{invoiceDate,jdbcType=TIMESTAMP}
</if>
<if test="invoiceStates != null and invoiceStates.size > 0 ">
and a.invoice_state IN
<foreach collection="invoiceStates" open="(" close=")" index="index" item="iState" separator=",">
#{iState}
</foreach>
</if>
<if test="postDate != null">
and a.post_date = #{postDate,jdbcType=TIMESTAMP}
</if>
<if test="custPhone != null and '' != custPhone">
and a.recipients_phone like CONCAT('%',#{custPhone,jdbcType=VARCHAR},'%')
</if>
<if test="saleName != null">
and sale_name = #{saleName,jdbcType=VARCHAR}
</if>
<if test="orgId != null">
and a.org_id = #{orgId,jdbcType=BIGINT}
</if>
</select>
<!--按照税率分组查询明细-->
<select id="selectRateData" parameterType="com.zteits.clouds.api.dto.pay.param.InvoiceStatisticsRequest"
resultType="com.zteits.clouds.api.dto.pay.RateDataDTO">
select sum(invoice_fee) invoiceFee,
sum(invoice_tax_fee) invoiceTaxFee,
case invoice_tax_rate
when 3 then '3%'
when 6 then '6%'
when 10 then '10%'
when 16 then '16%'
else '其他'
end rate
from td_c_cust_invoice_his t1
where data_state = 1
<if test="saleName != null">
and sale_name = #{saleName,jdbcType=VARCHAR}
</if>
<if test="custName != null">
and cust_name = #{custName,jdbcType=VARCHAR}
</if>
<if test="startDate != null">
and invoice_date >= #{startDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate != null">
and invoice_date <= #{endDate,jdbcType=TIMESTAMP}
</if>
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
group by (case
when invoice_tax_rate = 3 then '3%'
when invoice_tax_rate = 6 then '6%'
when invoice_tax_rate = 10 then '10%'
when invoice_tax_rate = 16 then '16%'
else '其他' end);
</select>
<!--按照开票状态分组查询-->
<select id="selectStatisticsData" parameterType="com.zteits.clouds.api.dto.pay.param.InvoiceStatisticsRequest"
resultType="com.zteits.clouds.api.dto.pay.StatisticsDataDTO">
select cust_taxID custTaxID,
cust_name custName,
count(1) amount,
case invoice_state
when 1 then '未开票'
when 2 then '开票成功'
when 3 then '开票成功'
else '开票失败' end invoiceState
from td_c_cust_invoice_his
where data_state = 1
<if test="saleName != null">
and sale_name = #{saleName,jdbcType=VARCHAR}
</if>
<if test="custName != null">
and cust_name = #{custName,jdbcType=VARCHAR}
</if>
<if test="startDate != null">
and invoice_date >= #{startDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate != null">
and invoice_date <= #{endDate,jdbcType=TIMESTAMP}
</if>
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
group by (case
when invoice_state = 1 then '未开票'
when invoice_state in (2, 3) then '开票成功'
else '开票失败' end)
</select>
<select id="selectNuonuoPendingInvoiceList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
from td_c_cust_invoice_his
where data_state = 1
AND invoice_code IS NOT NULL
AND invoice_code != ''
AND (invoice_url IS NULL OR invoice_url = '')
</select>
</mapper>