cloudroam
2024-12-26 7d7ac69a8af85ab9e67c1dc2c6f52b03d27669e4
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
package com.mzl.flower.service.impl.report;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.dto.request.report.QueryAppSupplierDTO;
import com.mzl.flower.dto.request.report.QueryOrderDTO;
import com.mzl.flower.dto.request.report.QueryPartnerOrderDTO;
import com.mzl.flower.dto.request.report.QuerySupplierDTO;
import com.mzl.flower.dto.response.report.*;
import com.mzl.flower.dto.response.report.OrderDetailReportResultVO;
import com.mzl.flower.dto.response.report.OrderPartnerReportResultVO;
import com.mzl.flower.dto.response.report.OrderReportCalendarBO;
import com.mzl.flower.dto.response.report.OrderReportResultVO;
import com.mzl.flower.mapper.report.OrderReportMapper;
import com.mzl.flower.service.BaseService;
import com.mzl.flower.service.calendar.CalendarService;
import com.mzl.flower.service.report.OrderReportService;
import com.mzl.flower.utils.ExcelExportUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hpsf.Decimal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
 
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
@Slf4j
@Service
public class OrderReportServiceImpl extends BaseService implements OrderReportService {
 
    @Autowired
    private CalendarService calendarService;
 
    @Autowired
    private OrderReportMapper orderReportMapper;
 
 
 
    @Override
    public Page<OrderReportResultVO> getSalePage(Page page, QueryOrderDTO dto) {
 
        List<OrderReportCalendarBO> calendarBOList= calendarService.getOrderDatePage(page,dto);
 
        final List<OrderReportResultVO> list = calendarBOList.stream().map(calendarBO -> {
            if(null!=dto.getPartnerId()) calendarBO.setPartnerId(dto.getPartnerId());
            OrderReportResultVO vo2=orderReportMapper.getOrderDateReport(calendarBO);
            if(null==vo2) vo2=new OrderReportResultVO();
            vo2.setOrderDate(calendarBO.getCalDate());
 
            return vo2;
        }).collect(Collectors.toList());
 
        page.setRecords(list);
        return page;
    }
 
    @Override
    public Page<OrderDetailReportResultVO> getOrderDetailPage(Page page, QueryOrderDTO dto) {
        OrderReportCalendarBO orderReportCalendarBO = new OrderReportCalendarBO();
        if (StringUtils.isEmpty(dto.getCalDate())) {
            throw new ValidationException("日期不能为空");
        }
        LocalDateTime orderTime = dto.getCalDate().atStartOfDay();
        orderReportCalendarBO.setPartnerId(dto.getPartnerId());
        orderReportCalendarBO.setStartDate(calculateStartTime(orderTime));
        orderReportCalendarBO.setEndDate(calculateEndTime(orderTime));
        List<OrderDetailReportResultVO> list = orderReportMapper.getOrderDetailReport(orderReportCalendarBO, page);
        page.setRecords(list);
        return page;
    }
 
    @Override
    public OrderReportResultVO getSaleStatis(QueryOrderDTO dto) {
        // 计算开始时间和结束时间
 
        OrderReportCalendarBO bo=new OrderReportCalendarBO();
        if(null!=dto.getPartnerId()) bo.setPartnerId(dto.getPartnerId());
        bo.setStartDate(calculateStartTime(dto.getStartDate()));
        bo.setEndDate(calculateEndTime(dto.getEndDate()));
        OrderReportResultVO vo2=orderReportMapper.getOrderDateReport(bo);
 
        return vo2;
    }
 
    @Override
    public void exportSalesList(HttpServletResponse response, QueryOrderDTO dto) {
 
        List<OrderReportCalendarBO> calendarBOList= calendarService.getOrderDateList(dto);
        final List<OrderReportResultVO> list = calendarBOList.stream().map(calendarBO -> {
            if(null!=dto.getPartnerId()) calendarBO.setPartnerId(dto.getPartnerId());
            OrderReportResultVO vo2=orderReportMapper.getOrderDateReport(calendarBO);
            if(null==vo2) vo2=new OrderReportResultVO();
            vo2.setOrderDate(calendarBO.getCalDate());
 
            return vo2;
        }).collect(Collectors.toList());
 
        String[] rowsName = new String[]{"序号","下单日期", "销售额(原订单)","销售额(实付)", "花农底价", "平台区间加价", "平台加价", "平台区域加价"
                , "合伙人加价", "合伙人区间加价","优惠合计", "会员折扣","优惠券",
                "质检总扣款","降级扣款","缺货扣款","补货扣款",
                "售后总扣款","售后供应商扣款","售后平台扣款","售后合伙人扣款","售后打包扣款","售后质检扣款","售后物流扣款","售后打包运费扣款",
                "总包干费","总销售扎数","实际销售扎数","缺货扎数","降级扎数","补货扎数","利润","结算状态",};
        List<Object[]> dataList = new ArrayList<>();
        int sn = 1;
        for (OrderReportResultVO o : list) {
            Object[] objs = new Object[rowsName.length];
            int a = 0;
            objs[a++] = sn; // 序号
            objs[a++] = format(o.getOrderDate(), "yyyy-MM-dd"); // 下单日期
            objs[a++] = o.getOrderTotal(); // 销售额(原订单)
            objs[a++] = o.getTotalAmount(); // 销售额(实付)
            objs[a++] = o.getOrderSupplierPriceAmount(); // 花农底价
            objs[a++] = o.getOrderMarkupOneAmount(); // 平台区间加价
            objs[a++] = o.getOrderMarkupTwoAmount(); // 平台加价
            objs[a++] = o.getPlatformAreaFeeAmount(); //平台区域加价
            objs[a++] = o.getOrderMarkupPartnerAmount(); //合伙人加价
            objs[a++] = o.getPartnerSectionFeeAmount(); //合伙人区间加价
 
            objs[a++] = o.getOrderDiscountTotalFee();//优惠合计
            objs[a++] = o.getOrderPriceDiscountAmount();//会员折扣
            objs[a++] = o.getOrderCouponAmountTotal(); // 优惠券
 
            objs[a++] = o.getOrderCheckTotalFee();//质检总扣款
            objs[a++] = o.getOrderCheckFee();//降级扣款
            objs[a++] = o.getOrderLackFeeSupplier(); //缺货扣款
            objs[a++] = o.getOrderReplaceFee(); //补货扣款
 
 
            objs[a++] = o.getOrderTotalFee(); //售后总扣款
            objs[a++] = o.getOrderFeeSupplier(); //售后供应商扣款
            objs[a++] = o.getOrderFeePlatform(); //售后平台扣款
            objs[a++] = o.getOrderFeePartner(); //售后合伙人扣款
            objs[a++] = o.getOrderFeePlatformPack(); //售后打包扣款
            objs[a++] = o.getOrderFeePlatformCheck(); // 售后质检扣款
            objs[a++] = o.getOrderFeePlatformTransport(); //售后物流扣款
            objs[a++] = o.getOrderFeePackingTransport(); //售后打包运费扣款
 
 
            objs[a++] = o.getPartnerTotalFeeAmount(); // 总包干费
            objs[a++] = o.getOrderNum(); // 总销售扎数
            objs[a++] = o.getRealSaleNum(); // 实际销售扎数
            objs[a++] = o.getOrderLackNum(); // 缺货扎数
            objs[a++] = o.getOrderReduceNum(); // 降级扎数
            objs[a++] = o.getOrderReplaceNum(); // 补货扎数
 
            objs[a++] = o.getProfitFeeAmount(); //利润
            objs[a++] = o.getSettleStatus(); // 结算状态
            dataList.add(objs);
            sn++;
        }
 
        ExcelExportUtil excelExportUtil = new ExcelExportUtil("财务报表", rowsName, dataList, response);
        try {
            response.addHeader("filename", URLEncoder.encode("财务报表.xls", "UTF-8"));
            response.addHeader("Access-Control-Expose-Headers", "filename");
            excelExportUtil.export();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
 
    @Override
    public void exportOrderDetail(HttpServletResponse response, QueryOrderDTO dto) {
 
        if (StringUtils.isEmpty(dto.getCalDate())) {
            throw new ValidationException("日期不能为空");
        }
        OrderReportCalendarBO orderReportCalendarBO = new OrderReportCalendarBO();
        LocalDateTime orderTime = dto.getCalDate().atStartOfDay();
        orderReportCalendarBO.setPartnerId(dto.getPartnerId());
        orderReportCalendarBO.setStartDate(calculateStartTime(orderTime));
        orderReportCalendarBO.setEndDate(calculateEndTime(orderTime));
        List<OrderDetailReportResultVO> odrs = orderReportMapper.getOrderDetailReport(orderReportCalendarBO, null);
        String[] rowsName = new String[]{"序号","订单号", "下单用户", "收货人地址", "合伙人", "下单时间", "订单金额","订单金额(实付)"
                , "花农底价", "平台区间加价", "平台加价", "平台区域加价", "合伙人加价", "合伙人区间加价",
                "优惠合计","会员折扣", "优惠券",
                "质检总扣款","降级扣款", "缺货扣款", "补货扣款",
                "售后总扣款","售后供应商扣款","售后平台扣款","售后合伙人扣款","售后打包扣款","售后质检扣款","售后物流扣款","售后打包运费扣款",
                "总包干费","总销售扎数","实际销售扎数","缺货扎数","降级扎数","补货扎数","利润","结算状态",};
        List<Object[]> dataList = new ArrayList<>();
        int sn = 1;
        for (OrderDetailReportResultVO o : odrs) {
            Object[] objs = new Object[rowsName.length];
            int a = 0;
            objs[a++] = sn;
            objs[a++] = o.getOrderNo();
            objs[a++] = o.getCustomer();
            objs[a++] = o.getAddress();
            objs[a++] = o.getPartnerName();
            objs[a++] = o.getOrderDate();
            objs[a++] = o.getOrderTotal();
            objs[a++] = o.getTotalAmount();
 
            objs[a++] = o.getOrderSupplierPriceAmount();
            objs[a++] = o.getOrderMarkupOneAmount();
            objs[a++] = o.getOrderMarkupTwoAmount();
            objs[a++] = o.getPlatformAreaFeeAmount();
            objs[a++] = o.getOrderMarkupPartnerAmount();
            objs[a++] = o.getPartnerSectionFeeAmount();
 
            objs[a++] = o.getOrderDiscountTotalFee();//优惠合计
            objs[a++] = o.getOrderPriceDiscountAmount();
            objs[a++] = o.getOrderCouponAmountTotal();
 
            objs[a++] = o.getOrderCheckTotalFee();//质检总扣款
            objs[a++] = o.getOrderCheckFee();
            objs[a++] = o.getOrderLackFeeSupplier();
            objs[a++] = o.getOrderReplaceFee();
 
            objs[a++] = o.getOrderTotalFee(); //售后总扣款
            objs[a++] = o.getOrderFeeSupplier(); //售后供应商扣款
            objs[a++] = o.getOrderFeePlatform(); //售后平台扣款
            objs[a++] = o.getOrderFeePartner(); //售后合伙人扣款
            objs[a++] = o.getOrderFeePlatformPack(); //售后打包扣款
            objs[a++] = o.getOrderFeePlatformCheck(); // 售后质检扣款
            objs[a++] = o.getOrderFeePlatformTransport(); //售后物流扣款
            objs[a++] = o.getOrderFeePackingTransport(); //售后打包运费扣款
 
            objs[a++] = o.getPartnerTotalFeeAmount(); // 总包干费
            objs[a++] = o.getOrderNum(); // 总销售扎数
            objs[a++] = o.getRealSaleNum(); // 实际销售扎数
            objs[a++] = o.getOrderLackNum(); // 缺货扎数
            objs[a++] = o.getOrderReduceNum(); // 降级扎数
            objs[a++] = o.getOrderReplaceNum(); // 补货扎数
 
            objs[a++] = o.getProfitFeeAmount();
            objs[a++] = o.getSettleStatus();
            dataList.add(objs);
 
            sn++;
        }
        ExcelExportUtil excelExportUtil = new ExcelExportUtil("订单结算明细", rowsName, dataList, response);
        try {
            response.addHeader("filename", URLEncoder.encode("订单结算明细.xls", "UTF-8"));
            response.addHeader("Access-Control-Expose-Headers", "filename");
            excelExportUtil.export();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
 
    }
 
    @Override
    public Page<OrderPartnerReportResultVO> getPartnerSalePage(Page page, QueryPartnerOrderDTO dto) {
 
        if(null!=dto.getPaymentDateStart())
            dto.setStartDate(calculateStartTime(dto.getPaymentDateStart()));
        if(null!=dto.getPaymentDateEnd())
            dto.setEndDate(calculateEndTime(dto.getPaymentDateEnd()));
        Page<OrderPartnerReportResultVO> result=orderReportMapper.getPartnerOrderDateReportPage(page,dto);
        return result;
    }
 
    @Override
    public OrderPartnerReportResultVO getPartnerSaleStatis(QueryPartnerOrderDTO dto) {
        if(null!=dto.getPaymentDateStart())
            dto.setStartDate(calculateStartTime(dto.getPaymentDateStart()));
        if(null!=dto.getPaymentDateEnd())
            dto.setEndDate(calculateEndTime(dto.getPaymentDateEnd()));
        OrderPartnerReportResultVO vo2=orderReportMapper.getPartnerOrderDateReportStatis(dto);
        return vo2;
    }
 
    @Override
    public void exportPartnerSalesList(HttpServletResponse response, QueryPartnerOrderDTO dto) {
 
        if(null!=dto.getPaymentDateStart())
            dto.setStartDate(calculateStartTime(dto.getPaymentDateStart()));
        if(null!=dto.getPaymentDateEnd())
            dto.setEndDate(calculateEndTime(dto.getPaymentDateEnd()));
 
        List<OrderPartnerReportResultVO> list = orderReportMapper.getPartnerOrderDateReportList(dto);
 
 
        String[] rowsName = new String[]{"序号","下单日期", "合伙人ID", "合伙人","底价"
                , "合伙人加价",  "会员折扣","优惠券","售后扣合伙人款","总包干费"
                ,"总售扎数","实际销售扎数","缺货扎数","降级扎数","补货扎数"
        };
        List<Object[]> dataList = new ArrayList<>();
        int sn = 1;
        for (OrderPartnerReportResultVO o : list) {
            Object[] objs = new Object[rowsName.length];
            int a = 0;
            objs[a++] = sn; // 序号
            objs[a++] = o.getOrderDate(); // 下单日期
            objs[a++] = o.getPartnerId(); // 合伙人ID
            objs[a++] = o.getPartnerName(); // 合伙人
            objs[a++] = o.getOrderPartnerPriceAmount(); // 合伙人底价
            objs[a++] = o.getOrderMarkupPartnerAmount(); //合伙人加价
            objs[a++] = o.getOrderPriceDiscountAmount();//会员折扣
            objs[a++] = o.getOrderCouponAmountTotal(); // 优惠券
            objs[a++] = o.getOrderFeePartner(); //售后扣合伙人款
            objs[a++] = o.getPartnerTotalFeeAmount(); // 总包干费
 
            objs[a++] = o.getOrderNum(); // 总售扎数
            objs[a++] = o.getRealSaleNum(); // 实际销售扎数
            objs[a++] = o.getOrderLackNum(); // 缺货扎数
            objs[a++] = o.getOrderReduceNum(); // 降级扎数
            objs[a++] = o.getOrderReplaceNum(); // 补货扎数
 
            dataList.add(objs);
            sn++;
        }
 
        ExcelExportUtil excelExportUtil = new ExcelExportUtil("合伙人财务报表", rowsName, dataList, response);
        try {
            response.addHeader("filename", URLEncoder.encode("合伙人财务报表.xls", "UTF-8"));
            response.addHeader("Access-Control-Expose-Headers", "filename");
            excelExportUtil.export();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
 
    @Override
    public Page<OrderSupplierReportResultVO> getOrderSupplierPage(Page page, QuerySupplierDTO dto) {
        SupplierReportCalendarBO supplierReportCalendarBO = new SupplierReportCalendarBO();
        if (StringUtils.isEmpty(dto.getStartDate()) || StringUtils.isEmpty(dto.getEndDate())) {
            throw new ValidationException("日期不能为空");
        }
        supplierReportCalendarBO.setSupplierId(dto.getSupplierId());
        supplierReportCalendarBO.setStartDate(calculateStartTime(dto.getStartDate().atStartOfDay()));
        supplierReportCalendarBO.setEndDate(calculateEndTime(dto.getEndDate().atStartOfDay()));
        List<OrderSupplierReportResultVO> list = orderReportMapper.getOrderSupplierPageReport(supplierReportCalendarBO, page);
        page.setRecords(list);
        return page;
    }
 
    @Override
    public OrderSupplierReportResultVO getOrderSupplierClout(QuerySupplierDTO dto) {
        SupplierReportCalendarBO supplierReportCalendarBO = new SupplierReportCalendarBO();
        if (StringUtils.isEmpty(dto.getStartDate()) || StringUtils.isEmpty(dto.getEndDate())) {
            throw new ValidationException("日期不能为空");
        }
        supplierReportCalendarBO.setSupplierId(dto.getSupplierId());
        supplierReportCalendarBO.setStartDate(calculateStartTime(dto.getStartDate().atStartOfDay()));
        supplierReportCalendarBO.setEndDate(calculateEndTime(dto.getEndDate().atStartOfDay()));
        OrderSupplierReportResultVO orderSupplierCountReport = orderReportMapper.getOrderSupplierCountReport(supplierReportCalendarBO);
        return orderSupplierCountReport;
    }
 
 
    @Override
    public void exportSupplierList(HttpServletResponse response, QuerySupplierDTO dto) {
        SupplierReportCalendarBO supplierReportCalendarBO = new SupplierReportCalendarBO();
        if (StringUtils.isEmpty(dto.getStartDate()) || StringUtils.isEmpty(dto.getEndDate())) {
            throw new ValidationException("日期不能为空");
        }
        supplierReportCalendarBO.setSupplierId(dto.getSupplierId());
        supplierReportCalendarBO.setStartDate(calculateStartTime(dto.getStartDate().atStartOfDay()));
        supplierReportCalendarBO.setEndDate(calculateEndTime(dto.getEndDate().atStartOfDay()));
        List<OrderSupplierReportResultVO> list = orderReportMapper.getOrderSupplierReport(supplierReportCalendarBO);
 
        String[] rowsName = new String[]{"序号","日期", "供应商ID", "供应商","花农底价"
                , "降级扣款",  "缺货扣款(缺货+补货)","售后扣花农款",
                "总销售扎数","实际销售扎数","缺货扎数","降级扎数","补货扎数","结算费用","订单状态"};
        List<Object[]> dataList = new ArrayList<>();
        int sn = 1;
        for (OrderSupplierReportResultVO o : list) {
            if(!ObjectUtils.isEmpty(o)) {
                Object[] objs = new Object[rowsName.length];
                int a = 0;
                objs[a++] = sn; // 序号
                objs[a++] = format(o.getDateinfo(), "yyyy-MM-dd"); // 日期
                objs[a++] = o.getSupplierId(); // 供应商ID
                objs[a++] = o.getSupplierName(); // 供应商
                objs[a++] = o.getOrderSupplierPriceAmount(); // 花农底价
                objs[a++] = o.getOrderCheckFee(); //降级扣款
                objs[a++] = o.getOrderLackFeeSupplier();//缺货扣款
                objs[a++] = o.getSalesFeeSupplier(); // 售后扣花农款
 
                objs[a++] = o.getOrderNum(); // 总销售扎数
                objs[a++] = o.getRealSaleNum(); // 实际销售扎数
                objs[a++] = o.getOrderLackNum(); // 缺货扎数
                objs[a++] = o.getOrderReduceNum(); // 降级扎数
                objs[a++] = o.getOrderReplaceNum(); // 补货扎数
 
                objs[a++] = o.getProfitFeeAmount(); // 结算费用
                objs[a++] = o.getSettleStatus(); // 订单状态
                dataList.add(objs);
                sn++;
            }
        }
 
        ExcelExportUtil excelExportUtil = new ExcelExportUtil("花农结算报表", rowsName, dataList, response);
        try {
            response.addHeader("filename", URLEncoder.encode("花农结算报表.xls", "UTF-8"));
            response.addHeader("Access-Control-Expose-Headers", "filename");
            excelExportUtil.export();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
 
    @Override
    public AppSupplierStatisticsVO getAppSupplierStatistics(QueryAppSupplierDTO dto) {
 
 
 
        // 总成交:花农售卖全部的底价合计,
        // 本月成交:本月售卖的底价合计,
        // 上月成交:上月售卖的底价合计,
        // 今日成交:今日售卖的底价合计,
        // 近30天成交扎数:最近30天扎数合计(已有),
        // 今日成交扎数(已有)
        // 缺货(本月):本月质检缺货,并且web端审核通过的数量合计,
        // 缺货(上月):上月质检缺货,并且web端审核通过的数量合计,
        // 降级(本月):本月质检降级,并且web端审核通过的数量合计,
        // 降级(上月):上月质检降级,并且web端审核通过的数量合计,
        // 补货(本月):本月质检补货,并且web端审核通过的数量合计,
        // 补货(上月):上月质检补货,并且web端审核通过的数量合计,
 
        // 当天的开始时间
        dto.setStartDateTime(getCurDayStartTime());
        // 当天的结束时间
        dto.setEndDateTime(getCurDayEndTime());
 
        return orderReportMapper.getAppSupplierAmountStatistics(dto);
    }
 
    // 计算 startDate 的前一天 17:00:00
    public static LocalDateTime calculateStartTime(LocalDateTime startDateTime) {
        // 获取 LocalDate 部分
        LocalDateTime previousDay = startDateTime.minusDays(1).with(LocalTime.of(17, 0, 0));
        return previousDay;
    }
 
    // 计算 endDate 当天的 17:00:00
    public static LocalDateTime calculateEndTime(LocalDateTime endDateTime) {
        // 将时间部分固定为 17:00:00
        LocalDateTime endOfDay = endDateTime.with(LocalTime.of(17, 0, 0));
        return endOfDay;
    }
 
 
    // 计算 startDate 前一天的 17:00:00
    public static LocalDateTime calculateStartTime(LocalDate startDate) {
        // 获取前一天的日期,并将时间设为 17:00:00
        LocalDateTime previousDay = startDate.minusDays(1).atTime(LocalTime.of(17, 0, 0));
        return previousDay;
    }
 
    // 计算 endDate 当天的 17:00:00
    public static LocalDateTime calculateEndTime(LocalDate endDate) {
        // 将时间部分固定为 17:00:00
        LocalDateTime endOfDay = endDate.atTime(LocalTime.of(17, 0, 0));
        return endOfDay;
    }
 
    // 获取当天的开始时间
    public static LocalDateTime getCurDayStartTime() {
        LocalDateTime now = LocalDateTime.now();
        LocalTime cutoffTime = LocalTime.of(17, 0);
 
        if (now.toLocalTime().isAfter(cutoffTime)) {
            // 当前时间大于17:00
            return LocalDateTime.of(now.toLocalDate(), cutoffTime);
        } else {
            // 当前时间小于等于17:00
            return LocalDateTime.of(now.minusDays(1).toLocalDate(), cutoffTime);
        }
    }
 
    // 获取当天的结束时间
    public static LocalDateTime getCurDayEndTime() {
        LocalDateTime now = LocalDateTime.now();
        LocalTime cutoffTime = LocalTime.of(17, 0);
 
        if (now.toLocalTime().isAfter(cutoffTime)) {
            // 当前时间大于17:00,结束时间为明天17:00
            return LocalDateTime.of(now.plusDays(1).toLocalDate(), cutoffTime);
        } else {
            // 当前时间小于等于17:00,结束时间为当天17:00
            return LocalDateTime.of(now.toLocalDate(), cutoffTime);
        }
    }
 
}