From 89fd6145692c152c668d42ab81ef586373396066 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 5 Nov 2025 18:59:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=94=B9=E4=B8=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/convertor/PropCouponConvertor.java | 18 +++++++------ .../app/dto/clientobject/PropCouponCO.java | 10 +++----- .../dto/clientobject/PropCouponRecordCO.java | 4 +-- .../other/infra/utils/ZonedDateTimeUtils.java | 25 +++++++++++++++++++ 4 files changed, 41 insertions(+), 16 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 2ca28ba6..1c6e1d9d 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 @@ -8,6 +8,7 @@ import com.red.circle.other.domain.propcoupon.PropCouponStatus; import com.red.circle.other.domain.propcoupon.PropCouponType; import com.red.circle.other.infra.database.rds.entity.props.PropCouponDO; import com.red.circle.other.infra.database.rds.entity.props.PropCouponUseRecordDO; +import com.red.circle.other.infra.utils.ZonedDateTimeUtils; /** * 道具券对象转换器 @@ -37,9 +38,10 @@ public class PropCouponConvertor { co.setStatusName(propCoupon.getStatus().getDesc()); co.setSource(propCoupon.getSource().getCode()); co.setSourceName(propCoupon.getSource().getDesc()); - co.setExpireTime(propCoupon.getExpireTime()); - co.setUseTime(propCoupon.getUseTime()); - co.setCreateTime(propCoupon.getCreateTime()); + + co.setExpireTime(ZonedDateTimeUtils.toTimestamp(propCoupon.getExpireTime())); + co.setUseTime(ZonedDateTimeUtils.toTimestamp(propCoupon.getUseTime())); + co.setCreateTime(ZonedDateTimeUtils.toTimestamp(propCoupon.getCreateTime())); return co; } @@ -79,10 +81,10 @@ public class PropCouponConvertor { if (source != null) { co.setSourceName(source.getDesc()); } - - co.setExpireTime(propCouponDO.getExpireTime()); - co.setUseTime(propCouponDO.getUseTime()); - co.setCreateTime(propCouponDO.getCreateTime()); + + co.setExpireTime(ZonedDateTimeUtils.toTimestamp(propCouponDO.getExpireTime())); + co.setUseTime(ZonedDateTimeUtils.toTimestamp(propCouponDO.getUseTime())); + co.setCreateTime(ZonedDateTimeUtils.toTimestamp(propCouponDO.getCreateTime())); return co; } @@ -117,7 +119,7 @@ public class PropCouponConvertor { co.setReceiverId(recordDO.getReceiverId()); co.setRemark(recordDO.getRemark()); - co.setCreateTime(recordDO.getCreateTime()); + co.setCreateTime(ZonedDateTimeUtils.toTimestamp(recordDO.getCreateTime())); return co; } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/PropCouponCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/PropCouponCO.java index e6702d17..16ae3fe5 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/PropCouponCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/PropCouponCO.java @@ -3,6 +3,7 @@ package com.red.circle.other.app.dto.clientobject; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import java.sql.Timestamp; import java.time.LocalDateTime; /** @@ -77,18 +78,15 @@ public class PropCouponCO { /** * 过期时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime expireTime; + private Timestamp expireTime; /** * 使用时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime useTime; + private Timestamp useTime; /** * 创建时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Timestamp createTime; } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/PropCouponRecordCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/PropCouponRecordCO.java index 818c8498..3354fc32 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/PropCouponRecordCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/PropCouponRecordCO.java @@ -3,6 +3,7 @@ package com.red.circle.other.app.dto.clientobject; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import java.sql.Timestamp; import java.time.LocalDateTime; /** @@ -77,6 +78,5 @@ public class PropCouponRecordCO { /** * 创建时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; + private Timestamp createTime; } 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 593997e7..5ec4a65b 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 @@ -3,6 +3,7 @@ package com.red.circle.other.infra.utils; import com.alibaba.cloud.commons.lang.StringUtils; import com.red.circle.tool.core.date.ZonedId; +import java.sql.Timestamp; import java.time.DayOfWeek; import java.time.Duration; import java.time.LocalDate; @@ -440,6 +441,30 @@ public final class ZonedDateTimeUtils { return time.format(DateTimeFormatter.ofPattern(format.getPattern())); } + /** + * localDateTime 转毫秒 + * @param localDateTime + * @return + */ + public static long toTimestampMillis(LocalDateTime localDateTime) { + if (localDateTime == null) { + throw new IllegalArgumentException("LocalDateTime cannot be null"); + } + return localDateTime.atZone(ZonedId.ASIA_RIYADH.getZonedId()).toInstant().toEpochMilli(); + } + + /** + * localDateTime 转时间戳 + * @param localDateTime + * @return + */ + public static Timestamp toTimestamp(LocalDateTime localDateTime) { + if (localDateTime == null) { + return null; + } + return Timestamp.from(localDateTime.atZone(ZonedId.ASIA_RIYADH.getZonedId()).toInstant()); + } + /** * 转换zoneId *