Commit f253c133fcc79cc29d6936aa2a642a7b98b2bf23
Merge branch 'master-jdk17' of https://github.com/YunaiV/ruoyi-vue-pro into master-jdk17
Showing
2 changed files
with
16 additions
and
2 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.common.util.date; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.date.DatePattern; |
| 5 | 5 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 6 | +import cn.hutool.core.date.TemporalAccessorUtil; | |
| 6 | 7 | import cn.hutool.core.lang.Assert; |
| 7 | 8 | import cn.hutool.core.util.StrUtil; |
| 8 | 9 | import cn.iocoder.yudao.framework.common.enums.DateIntervalEnum; |
| ... | ... | @@ -19,7 +20,7 @@ import static cn.hutool.core.date.DatePattern.UTC_MS_WITH_XXX_OFFSET_PATTERN; |
| 19 | 20 | import static cn.hutool.core.date.DatePattern.createFormatter; |
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | - * 时间工具类,用于 {@link java.time.LocalDateTime} | |
| 23 | + * 时间工具类,用于 {@link LocalDateTime} | |
| 23 | 24 | * |
| 24 | 25 | * @author 芋道源码 |
| 25 | 26 | */ |
| ... | ... | @@ -312,4 +313,16 @@ public class LocalDateTimeUtils { |
| 312 | 313 | } |
| 313 | 314 | } |
| 314 | 315 | |
| 316 | + /** | |
| 317 | + * 将给定的 {@link LocalDateTime} 转换为自 Unix 纪元时间(1970-01-01T00:00:00Z)以来的秒数。 | |
| 318 | + * | |
| 319 | + * @param sourceDateTime 需要转换的本地日期时间,不能为空 | |
| 320 | + * @return 自 1970-01-01T00:00:00Z 起的秒数(epoch second) | |
| 321 | + * @throws NullPointerException 如果 {@code sourceDateTime} 为 {@code null} | |
| 322 | + * @throws DateTimeException 如果转换过程中发生时间超出范围或其他时间处理异常 | |
| 323 | + */ | |
| 324 | + public static Long toEpochSecond(LocalDateTime sourceDateTime) { | |
| 325 | + return TemporalAccessorUtil.toInstant(sourceDateTime).getEpochSecond(); | |
| 326 | + } | |
| 327 | + | |
| 315 | 328 | } | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java
| ... | ... | @@ -68,6 +68,7 @@ import java.util.Objects; |
| 68 | 68 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 69 | 69 | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; |
| 70 | 70 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.UTC_MS_WITH_XXX_OFFSET_FORMATTER; |
| 71 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.toEpochSecond; | |
| 71 | 72 | import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; |
| 72 | 73 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; |
| 73 | 74 | import static java.util.Collections.singletonList; |
| ... | ... | @@ -379,7 +380,7 @@ public class SocialClientServiceImpl implements SocialClientService { |
| 379 | 380 | WxMaService service = getWxMaService(userType); |
| 380 | 381 | WxMaOrderShippingInfoNotifyConfirmRequest request = WxMaOrderShippingInfoNotifyConfirmRequest.builder() |
| 381 | 382 | .transactionId(reqDTO.getTransactionId()) |
| 382 | - .receivedTime(LocalDateTimeUtil.toEpochMilli(reqDTO.getReceivedTime())) | |
| 383 | + .receivedTime(toEpochSecond(reqDTO.getReceivedTime())) | |
| 383 | 384 | .build(); |
| 384 | 385 | try { |
| 385 | 386 | WxMaOrderShippingInfoBaseResponse response = service.getWxMaOrderShippingService().notifyConfirmReceive(request); | ... | ... |