From 73404d9938c3cf2c782fcb79a96c6e82c2151258 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 6 Nov 2025 20:29:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E5=8C=BA=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other/app/convertor/PropCouponConvertor.java | 14 +++++++------- .../other/infra/utils/ZonedDateTimeUtils.java | 7 +++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/PropCouponConvertor.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/PropCouponConvertor.java index e8eb47f5..6bbe2adc 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/PropCouponConvertor.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/PropCouponConvertor.java @@ -44,11 +44,11 @@ public class PropCouponConvertor { co.setSource(propCoupon.getSource().getCode()); co.setSourceName(propCoupon.getSource().getDesc()); - Timestamp timestamp = ZonedDateTimeUtils.toTimestamp(propCoupon.getExpireTime()); + Timestamp timestamp = ZonedDateTimeUtils.toTimestampDefault(propCoupon.getExpireTime()); co.setExpireTime(timestamp); co.setExpireSeconds(Math.abs(Duration.between(propCoupon.getExpireTime(), LocalDateTime.now()).getSeconds())); - co.setUseTime(ZonedDateTimeUtils.toTimestamp(propCoupon.getUseTime())); - co.setCreateTime(ZonedDateTimeUtils.toTimestamp(propCoupon.getCreateTime())); + co.setUseTime(ZonedDateTimeUtils.toTimestampDefault(propCoupon.getUseTime())); + co.setCreateTime(ZonedDateTimeUtils.toTimestampDefault(propCoupon.getCreateTime())); return co; } @@ -89,9 +89,9 @@ public class PropCouponConvertor { co.setSourceName(source.getDesc()); } - co.setExpireTime(ZonedDateTimeUtils.toTimestamp(propCouponDO.getExpireTime())); - co.setUseTime(ZonedDateTimeUtils.toTimestamp(propCouponDO.getUseTime())); - co.setCreateTime(ZonedDateTimeUtils.toTimestamp(propCouponDO.getCreateTime())); + co.setExpireTime(ZonedDateTimeUtils.toTimestampDefault(propCouponDO.getExpireTime())); + co.setUseTime(ZonedDateTimeUtils.toTimestampDefault(propCouponDO.getUseTime())); + co.setCreateTime(ZonedDateTimeUtils.toTimestampDefault(propCouponDO.getCreateTime())); return co; } @@ -127,7 +127,7 @@ public class PropCouponConvertor { co.setReceiverId(recordDO.getReceiverId()); co.setRemark(recordDO.getRemark()); - co.setCreateTime(ZonedDateTimeUtils.toTimestamp(recordDO.getCreateTime())); + co.setCreateTime(ZonedDateTimeUtils.toTimestampDefault(recordDO.getCreateTime())); return co; } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/ZonedDateTimeUtils.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/ZonedDateTimeUtils.java index 5ec4a65b..f3f56cb3 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/ZonedDateTimeUtils.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/ZonedDateTimeUtils.java @@ -465,6 +465,13 @@ public final class ZonedDateTimeUtils { return Timestamp.from(localDateTime.atZone(ZonedId.ASIA_RIYADH.getZonedId()).toInstant()); } + public static Timestamp toTimestampDefault(LocalDateTime localDateTime) { + if (localDateTime == null) { + return null; + } + return Timestamp.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + /** * 转换zoneId *