|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+package com.water.revenue;
|
|
|
2
|
+
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
4
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
5
|
+import com.water.revenue.entity.PaymentChannel;
|
|
|
6
|
+import com.water.revenue.entity.PaymentRecord;
|
|
|
7
|
+import com.water.revenue.entity.WaterBill;
|
|
|
8
|
+import com.water.revenue.mapper.PaymentChannelMapper;
|
|
|
9
|
+import com.water.revenue.mapper.PaymentRecordMapper;
|
|
|
10
|
+import com.water.revenue.mapper.WaterBillMapper;
|
|
|
11
|
+import com.water.revenue.service.BillService;
|
|
|
12
|
+import com.water.revenue.service.PaymentQueryService;
|
|
|
13
|
+import com.water.revenue.service.PaymentService;
|
|
|
14
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
15
|
+import org.junit.jupiter.api.DisplayName;
|
|
|
16
|
+import org.junit.jupiter.api.Nested;
|
|
|
17
|
+import org.junit.jupiter.api.Test;
|
|
|
18
|
+import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
19
|
+import org.mockito.ArgumentCaptor;
|
|
|
20
|
+import org.mockito.Mock;
|
|
|
21
|
+import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
22
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
23
|
+
|
|
|
24
|
+import java.math.BigDecimal;
|
|
|
25
|
+import java.time.LocalDate;
|
|
|
26
|
+import java.time.LocalDateTime;
|
|
|
27
|
+import java.util.*;
|
|
|
28
|
+
|
|
|
29
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
30
|
+import static org.mockito.ArgumentMatchers.*;
|
|
|
31
|
+import static org.mockito.Mockito.*;
|
|
|
32
|
+
|
|
|
33
|
+@ExtendWith(MockitoExtension.class)
|
|
|
34
|
+@DisplayName("账单与收费模块测试")
|
|
|
35
|
+class BillPaymentTest {
|
|
|
36
|
+
|
|
|
37
|
+ @Mock
|
|
|
38
|
+ private WaterBillMapper waterBillMapper;
|
|
|
39
|
+ @Mock
|
|
|
40
|
+ private PaymentRecordMapper paymentRecordMapper;
|
|
|
41
|
+ @Mock
|
|
|
42
|
+ private PaymentChannelMapper paymentChannelMapper;
|
|
|
43
|
+ @Mock
|
|
|
44
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
45
|
+
|
|
|
46
|
+ private BillService billService;
|
|
|
47
|
+ private PaymentService paymentService;
|
|
|
48
|
+ private PaymentQueryService paymentQueryService;
|
|
|
49
|
+
|
|
|
50
|
+ @BeforeEach
|
|
|
51
|
+ void setUp() {
|
|
|
52
|
+ billService = new BillService(waterBillMapper, jdbcTemplate);
|
|
|
53
|
+ paymentService = new PaymentService(paymentRecordMapper, paymentChannelMapper, waterBillMapper);
|
|
|
54
|
+ paymentQueryService = new PaymentQueryService(paymentRecordMapper, jdbcTemplate);
|
|
|
55
|
+ }
|
|
|
56
|
+
|
|
|
57
|
+ // ========== 账单服务测试 ==========
|
|
|
58
|
+
|
|
|
59
|
+ @Nested
|
|
|
60
|
+ @DisplayName("BillService - 账单生成测试")
|
|
|
61
|
+ class BillGenerationTests {
|
|
|
62
|
+
|
|
|
63
|
+ @Test
|
|
|
64
|
+ @DisplayName("自动生成账单 - 正常周期")
|
|
|
65
|
+ void autoGenerateBills_normalPeriod() {
|
|
|
66
|
+ // 模拟抄表记录
|
|
|
67
|
+ Map<String, Object> reading = new HashMap<>();
|
|
|
68
|
+ reading.put("reading_id", 1L);
|
|
|
69
|
+ reading.put("consumption", new BigDecimal("15.5"));
|
|
|
70
|
+ reading.put("prev_reading", new BigDecimal("100"));
|
|
|
71
|
+ reading.put("curr_reading", new BigDecimal("115.5"));
|
|
|
72
|
+ reading.put("reading_period", "2026-06");
|
|
|
73
|
+ reading.put("meter_no", "M001");
|
|
|
74
|
+ reading.put("customer_id", 100L);
|
|
|
75
|
+ reading.put("customer_no", "C001");
|
|
|
76
|
+ reading.put("customer_name", "张三");
|
|
|
77
|
+ reading.put("customer_type", "residential");
|
|
|
78
|
+
|
|
|
79
|
+ when(jdbcTemplate.queryForList(anyString(), eq("2026-06"), eq("2026-06")))
|
|
|
80
|
+ .thenReturn(List.of(reading));
|
|
|
81
|
+ when(jdbcTemplate.queryForObject(contains("water_price"), eq(BigDecimal.class), eq("residential")))
|
|
|
82
|
+ .thenReturn(new BigDecimal("3.50"));
|
|
|
83
|
+ when(waterBillMapper.insert(any(WaterBill.class))).thenReturn(1);
|
|
|
84
|
+
|
|
|
85
|
+ Map<String, Object> result = billService.autoGenerateBills("2026-06");
|
|
|
86
|
+
|
|
|
87
|
+ assertNotNull(result);
|
|
|
88
|
+ assertEquals("2026-06", result.get("period"));
|
|
|
89
|
+ assertEquals(1, result.get("generatedCount"));
|
|
|
90
|
+ verify(waterBillMapper, times(1)).insert(any(WaterBill.class));
|
|
|
91
|
+ }
|
|
|
92
|
+
|
|
|
93
|
+ @Test
|
|
|
94
|
+ @DisplayName("手动生成账单 - 已存在时抛异常")
|
|
|
95
|
+ void manualGenerateBill_alreadyExists() {
|
|
|
96
|
+ when(jdbcTemplate.queryForMap(anyString(), eq(1L))).thenReturn(mockReadingMap());
|
|
|
97
|
+ when(waterBillMapper.selectCount(any(LambdaQueryWrapper.class))).thenReturn(1L);
|
|
|
98
|
+
|
|
|
99
|
+ assertThrows(RuntimeException.class, () -> billService.manualGenerateBill(1L));
|
|
|
100
|
+ }
|
|
|
101
|
+
|
|
|
102
|
+ @Test
|
|
|
103
|
+ @DisplayName("手动生成账单 - 正常生成")
|
|
|
104
|
+ void manualGenerateBill_success() {
|
|
|
105
|
+ when(jdbcTemplate.queryForMap(anyString(), eq(1L))).thenReturn(mockReadingMap());
|
|
|
106
|
+ when(waterBillMapper.selectCount(any(LambdaQueryWrapper.class))).thenReturn(0L);
|
|
|
107
|
+ when(jdbcTemplate.queryForObject(anyString(), eq(BigDecimal.class), anyString()))
|
|
|
108
|
+ .thenReturn(new BigDecimal("4.20"));
|
|
|
109
|
+ when(waterBillMapper.insert(any(WaterBill.class))).thenAnswer(inv -> {
|
|
|
110
|
+ WaterBill bill = inv.getArgument(0);
|
|
|
111
|
+ bill.setId(1L);
|
|
|
112
|
+ return 1;
|
|
|
113
|
+ });
|
|
|
114
|
+
|
|
|
115
|
+ WaterBill result = billService.manualGenerateBill(1L);
|
|
|
116
|
+ assertNotNull(result);
|
|
|
117
|
+ assertEquals("C001", result.getCustomerNo());
|
|
|
118
|
+ assertTrue(result.getTotalAmount().compareTo(BigDecimal.ZERO) > 0);
|
|
|
119
|
+ }
|
|
|
120
|
+
|
|
|
121
|
+ @Test
|
|
|
122
|
+ @DisplayName("账单明细查询 - 包含缴费记录")
|
|
|
123
|
+ void getBillDetail_withPayments() {
|
|
|
124
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), new BigDecimal("50"));
|
|
|
125
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
126
|
+
|
|
|
127
|
+ List<Map<String, Object>> payments = List.of(
|
|
|
128
|
+ Map.of("payment_no", "PAY-001", "amount", new BigDecimal("50"), "channel", "counter")
|
|
|
129
|
+ );
|
|
|
130
|
+ when(jdbcTemplate.queryForList(anyString(), eq(1L))).thenReturn(payments);
|
|
|
131
|
+
|
|
|
132
|
+ Map<String, Object> detail = billService.getBillDetail(1L);
|
|
|
133
|
+ assertNotNull(detail);
|
|
|
134
|
+ assertEquals(bill, detail.get("bill"));
|
|
|
135
|
+ assertEquals(1, ((List<?>) detail.get("payments")).size());
|
|
|
136
|
+ assertEquals(new BigDecimal("50"), detail.get("remainingAmount"));
|
|
|
137
|
+ }
|
|
|
138
|
+
|
|
|
139
|
+ @Test
|
|
|
140
|
+ @DisplayName("作废账单 - pending状态可作废")
|
|
|
141
|
+ void cancelBill_pending_success() {
|
|
|
142
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), BigDecimal.ZERO);
|
|
|
143
|
+ bill.setStatus("pending");
|
|
|
144
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
145
|
+ when(waterBillMapper.updateById(any(WaterBill.class))).thenReturn(1);
|
|
|
146
|
+
|
|
|
147
|
+ billService.cancelBill(1L);
|
|
|
148
|
+
|
|
|
149
|
+ ArgumentCaptor<WaterBill> captor = ArgumentCaptor.forClass(WaterBill.class);
|
|
|
150
|
+ verify(waterBillMapper).updateById(captor.capture());
|
|
|
151
|
+ assertEquals("cancelled", captor.getValue().getStatus());
|
|
|
152
|
+ }
|
|
|
153
|
+
|
|
|
154
|
+ @Test
|
|
|
155
|
+ @DisplayName("作废账单 - 非pending状态抛异常")
|
|
|
156
|
+ void cancelBill_notPending_throwsException() {
|
|
|
157
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), new BigDecimal("100"));
|
|
|
158
|
+ bill.setStatus("paid");
|
|
|
159
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
160
|
+
|
|
|
161
|
+ assertThrows(RuntimeException.class, () -> billService.cancelBill(1L));
|
|
|
162
|
+ }
|
|
|
163
|
+ }
|
|
|
164
|
+
|
|
|
165
|
+ // ========== 支付服务测试 ==========
|
|
|
166
|
+
|
|
|
167
|
+ @Nested
|
|
|
168
|
+ @DisplayName("PaymentService - 收费测试")
|
|
|
169
|
+ class PaymentTests {
|
|
|
170
|
+
|
|
|
171
|
+ @Test
|
|
|
172
|
+ @DisplayName("柜台收费 - 全额支付")
|
|
|
173
|
+ void payByCounter_fullPayment() {
|
|
|
174
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), BigDecimal.ZERO);
|
|
|
175
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
176
|
+ when(paymentRecordMapper.insert(any(PaymentRecord.class))).thenAnswer(inv -> {
|
|
|
177
|
+ PaymentRecord r = inv.getArgument(0);
|
|
|
178
|
+ r.setId(1L);
|
|
|
179
|
+ return 1;
|
|
|
180
|
+ });
|
|
|
181
|
+ when(waterBillMapper.updateById(any(WaterBill.class))).thenReturn(1);
|
|
|
182
|
+
|
|
|
183
|
+ PaymentRecord result = paymentService.payByCounter(1L, new BigDecimal("100"), 10L, "操作员A");
|
|
|
184
|
+
|
|
|
185
|
+ assertNotNull(result);
|
|
|
186
|
+ assertEquals("counter", result.getChannel());
|
|
|
187
|
+ assertEquals("success", result.getStatus());
|
|
|
188
|
+ assertEquals(new BigDecimal("100"), result.getAmount());
|
|
|
189
|
+ }
|
|
|
190
|
+
|
|
|
191
|
+ @Test
|
|
|
192
|
+ @DisplayName("柜台收费 - 部分支付")
|
|
|
193
|
+ void payByCounter_partialPayment() {
|
|
|
194
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), BigDecimal.ZERO);
|
|
|
195
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
196
|
+ when(paymentRecordMapper.insert(any(PaymentRecord.class))).thenReturn(1);
|
|
|
197
|
+ when(waterBillMapper.updateById(any(WaterBill.class))).thenReturn(1);
|
|
|
198
|
+
|
|
|
199
|
+ PaymentRecord result = paymentService.payByCounter(1L, new BigDecimal("50"), 10L, "操作员A");
|
|
|
200
|
+
|
|
|
201
|
+ assertNotNull(result);
|
|
|
202
|
+ ArgumentCaptor<WaterBill> captor = ArgumentCaptor.forClass(WaterBill.class);
|
|
|
203
|
+ verify(waterBillMapper).updateById(captor.capture());
|
|
|
204
|
+ assertEquals("partial", captor.getValue().getStatus());
|
|
|
205
|
+ }
|
|
|
206
|
+
|
|
|
207
|
+ @Test
|
|
|
208
|
+ @DisplayName("超额支付 - 抛出异常")
|
|
|
209
|
+ void payByCounter_overAmount_throwsException() {
|
|
|
210
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), BigDecimal.ZERO);
|
|
|
211
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
212
|
+
|
|
|
213
|
+ assertThrows(RuntimeException.class,
|
|
|
214
|
+ () -> paymentService.payByCounter(1L, new BigDecimal("200"), 10L, "操作员A"));
|
|
|
215
|
+ }
|
|
|
216
|
+
|
|
|
217
|
+ @Test
|
|
|
218
|
+ @DisplayName("支付宝下单 - 返回支付信息")
|
|
|
219
|
+ void payByAlipay_returnsPayInfo() {
|
|
|
220
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), BigDecimal.ZERO);
|
|
|
221
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
222
|
+ when(paymentRecordMapper.insert(any(PaymentRecord.class))).thenReturn(1);
|
|
|
223
|
+ when(waterBillMapper.updateById(any(WaterBill.class))).thenReturn(1);
|
|
|
224
|
+
|
|
|
225
|
+ Map<String, Object> result = paymentService.payByAlipay(1L, new BigDecimal("100"));
|
|
|
226
|
+
|
|
|
227
|
+ assertNotNull(result);
|
|
|
228
|
+ assertNotNull(result.get("payForm"));
|
|
|
229
|
+ assertNotNull(result.get("tradeNo"));
|
|
|
230
|
+ }
|
|
|
231
|
+
|
|
|
232
|
+ @Test
|
|
|
233
|
+ @DisplayName("微信下单 - 返回prepay信息")
|
|
|
234
|
+ void payByWechat_returnsPrepayInfo() {
|
|
|
235
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), BigDecimal.ZERO);
|
|
|
236
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
237
|
+ when(paymentRecordMapper.insert(any(PaymentRecord.class))).thenReturn(1);
|
|
|
238
|
+ when(waterBillMapper.updateById(any(WaterBill.class))).thenReturn(1);
|
|
|
239
|
+
|
|
|
240
|
+ Map<String, Object> result = paymentService.payByWechat(1L, new BigDecimal("100"));
|
|
|
241
|
+
|
|
|
242
|
+ assertNotNull(result);
|
|
|
243
|
+ assertNotNull(result.get("prepayId"));
|
|
|
244
|
+ assertNotNull(result.get("codeUrl"));
|
|
|
245
|
+ }
|
|
|
246
|
+
|
|
|
247
|
+ @Test
|
|
|
248
|
+ @DisplayName("支付宝回调 - 成功")
|
|
|
249
|
+ void alipayCallback_success() {
|
|
|
250
|
+ PaymentRecord record = new PaymentRecord();
|
|
|
251
|
+ record.setId(1L);
|
|
|
252
|
+ record.setPaymentNo("PAY-001");
|
|
|
253
|
+ record.setBillId(1L);
|
|
|
254
|
+ record.setAmount(new BigDecimal("100"));
|
|
|
255
|
+ record.setStatus("pending");
|
|
|
256
|
+
|
|
|
257
|
+ when(paymentRecordMapper.selectOne(any(LambdaQueryWrapper.class))).thenReturn(record);
|
|
|
258
|
+ when(paymentRecordMapper.updateById(any(PaymentRecord.class))).thenReturn(1);
|
|
|
259
|
+
|
|
|
260
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), BigDecimal.ZERO);
|
|
|
261
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
262
|
+ when(waterBillMapper.updateById(any(WaterBill.class))).thenReturn(1);
|
|
|
263
|
+
|
|
|
264
|
+ String result = paymentService.alipayCallback("PAY-001", "ALI123", "TRADE_SUCCESS");
|
|
|
265
|
+ assertEquals("success", result);
|
|
|
266
|
+ }
|
|
|
267
|
+
|
|
|
268
|
+ @Test
|
|
|
269
|
+ @DisplayName("退费 - 正常退费")
|
|
|
270
|
+ void refund_success() {
|
|
|
271
|
+ PaymentRecord original = new PaymentRecord();
|
|
|
272
|
+ original.setId(1L);
|
|
|
273
|
+ original.setPaymentNo("PAY-001");
|
|
|
274
|
+ original.setBillId(1L);
|
|
|
275
|
+ original.setBillNo("BILL-001");
|
|
|
276
|
+ original.setCustomerNo("C001");
|
|
|
277
|
+ original.setCustomerName("张三");
|
|
|
278
|
+ original.setAmount(new BigDecimal("100"));
|
|
|
279
|
+ original.setChannel("counter");
|
|
|
280
|
+ original.setChannelName("柜台现金");
|
|
|
281
|
+ original.setStatus("success");
|
|
|
282
|
+
|
|
|
283
|
+ when(paymentRecordMapper.selectById(1L)).thenReturn(original);
|
|
|
284
|
+ when(paymentRecordMapper.insert(any(PaymentRecord.class))).thenReturn(1);
|
|
|
285
|
+ when(paymentRecordMapper.updateById(any(PaymentRecord.class))).thenReturn(1);
|
|
|
286
|
+
|
|
|
287
|
+ WaterBill bill = createMockBill(1L, "BILL-001", "C001", new BigDecimal("100"), new BigDecimal("100"));
|
|
|
288
|
+ when(waterBillMapper.selectById(1L)).thenReturn(bill);
|
|
|
289
|
+ when(waterBillMapper.updateById(any(WaterBill.class))).thenReturn(1);
|
|
|
290
|
+
|
|
|
291
|
+ PaymentRecord result = paymentService.refund(1L, new BigDecimal("50"), 10L, "操作员B");
|
|
|
292
|
+
|
|
|
293
|
+ assertNotNull(result);
|
|
|
294
|
+ assertEquals("refunded", result.getStatus());
|
|
|
295
|
+ assertEquals(new BigDecimal("-50"), result.getAmount());
|
|
|
296
|
+ }
|
|
|
297
|
+
|
|
|
298
|
+ @Test
|
|
|
299
|
+ @DisplayName("退费 - 金额超限抛异常")
|
|
|
300
|
+ void refund_overAmount_throwsException() {
|
|
|
301
|
+ PaymentRecord original = new PaymentRecord();
|
|
|
302
|
+ original.setId(1L);
|
|
|
303
|
+ original.setAmount(new BigDecimal("100"));
|
|
|
304
|
+ original.setStatus("success");
|
|
|
305
|
+
|
|
|
306
|
+ when(paymentRecordMapper.selectById(1L)).thenReturn(original);
|
|
|
307
|
+
|
|
|
308
|
+ assertThrows(RuntimeException.class,
|
|
|
309
|
+ () -> paymentService.refund(1L, new BigDecimal("200"), 10L, "操作员B"));
|
|
|
310
|
+ }
|
|
|
311
|
+ }
|
|
|
312
|
+
|
|
|
313
|
+ // ========== 支付查询服务测试 ==========
|
|
|
314
|
+
|
|
|
315
|
+ @Nested
|
|
|
316
|
+ @DisplayName("PaymentQueryService - 查询测试")
|
|
|
317
|
+ class PaymentQueryTests {
|
|
|
318
|
+
|
|
|
319
|
+ @Test
|
|
|
320
|
+ @DisplayName("按渠道统计")
|
|
|
321
|
+ void statsByChannel_returnsStats() {
|
|
|
322
|
+ List<Map<String, Object>> mockStats = List.of(
|
|
|
323
|
+ Map.of("channel", "counter", "count", 10L, "total_amount", new BigDecimal("5000")),
|
|
|
324
|
+ Map.of("channel", "alipay", "count", 20L, "total_amount", new BigDecimal("8000"))
|
|
|
325
|
+ );
|
|
|
326
|
+ when(jdbcTemplate.queryForList(anyString())).thenReturn(mockStats);
|
|
|
327
|
+
|
|
|
328
|
+ List<Map<String, Object>> result = paymentQueryService.statsByChannel();
|
|
|
329
|
+ assertEquals(2, result.size());
|
|
|
330
|
+ }
|
|
|
331
|
+
|
|
|
332
|
+ @Test
|
|
|
333
|
+ @DisplayName("收费汇总")
|
|
|
334
|
+ void summary_returnsCorrectData() {
|
|
|
335
|
+ Map<String, Object> mockSummary = new HashMap<>();
|
|
|
336
|
+ mockSummary.put("total_count", 30L);
|
|
|
337
|
+ mockSummary.put("total_income", new BigDecimal("13000"));
|
|
|
338
|
+ mockSummary.put("total_refund", new BigDecimal("500"));
|
|
|
339
|
+ mockSummary.put("customer_count", 15L);
|
|
|
340
|
+
|
|
|
341
|
+ when(jdbcTemplate.queryForMap(anyString(), any(), any())).thenReturn(mockSummary);
|
|
|
342
|
+
|
|
|
343
|
+ Map<String, Object> result = paymentQueryService.summary(
|
|
|
344
|
+ LocalDate.of(2026, 6, 1), LocalDate.of(2026, 6, 30));
|
|
|
345
|
+
|
|
|
346
|
+ assertNotNull(result);
|
|
|
347
|
+ assertEquals(30L, result.get("total_count"));
|
|
|
348
|
+ assertEquals("2026-06-01", result.get("startDate"));
|
|
|
349
|
+ assertEquals("2026-06-30", result.get("endDate"));
|
|
|
350
|
+ }
|
|
|
351
|
+ }
|
|
|
352
|
+
|
|
|
353
|
+ // ========== Helper Methods ==========
|
|
|
354
|
+
|
|
|
355
|
+ private WaterBill createMockBill(Long id, String billNo, String customerNo,
|
|
|
356
|
+ BigDecimal totalAmount, BigDecimal paidAmount) {
|
|
|
357
|
+ WaterBill bill = new WaterBill();
|
|
|
358
|
+ bill.setId(id);
|
|
|
359
|
+ bill.setBillNo(billNo);
|
|
|
360
|
+ bill.setCustomerNo(customerNo);
|
|
|
361
|
+ bill.setCustomerName("测试客户");
|
|
|
362
|
+ bill.setBillPeriod("2026-06");
|
|
|
363
|
+ bill.setWaterUsage(new BigDecimal("30"));
|
|
|
364
|
+ bill.setUnitPrice(new BigDecimal("3.50"));
|
|
|
365
|
+ bill.setTotalAmount(totalAmount);
|
|
|
366
|
+ bill.setPaidAmount(paidAmount);
|
|
|
367
|
+ bill.setStatus("pending");
|
|
|
368
|
+ bill.setIssueDate(LocalDate.now());
|
|
|
369
|
+ bill.setDueDate(LocalDate.now().plusDays(30));
|
|
|
370
|
+ bill.setCreatedAt(LocalDateTime.now());
|
|
|
371
|
+ bill.setUpdatedAt(LocalDateTime.now());
|
|
|
372
|
+ return bill;
|
|
|
373
|
+ }
|
|
|
374
|
+
|
|
|
375
|
+ private Map<String, Object> mockReadingMap() {
|
|
|
376
|
+ Map<String, Object> reading = new HashMap<>();
|
|
|
377
|
+ reading.put("reading_id", 1L);
|
|
|
378
|
+ reading.put("consumption", new BigDecimal("20"));
|
|
|
379
|
+ reading.put("prev_reading", new BigDecimal("100"));
|
|
|
380
|
+ reading.put("curr_reading", new BigDecimal("120"));
|
|
|
381
|
+ reading.put("reading_period", "2026-06");
|
|
|
382
|
+ reading.put("meter_no", "M001");
|
|
|
383
|
+ reading.put("customer_id", 100L);
|
|
|
384
|
+ reading.put("customer_no", "C001");
|
|
|
385
|
+ reading.put("customer_name", "张三");
|
|
|
386
|
+ reading.put("customer_type", "residential");
|
|
|
387
|
+ return reading;
|
|
|
388
|
+ }
|
|
|
389
|
+}
|