From 884428c4134bc72d1cf773cc03ca73ed6a3aa10f Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期四, 16 一月 2025 16:16:41 +0800 Subject: [PATCH] 12.18 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java | 2 +- ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml | 2 +- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java index 92acd9e..d85091e 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java @@ -26,6 +26,7 @@ import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; import java.util.List; /** @@ -90,13 +91,44 @@ GoodsSeckill goodsSeckill = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, one.getId()).eq(GoodsSeckill::getVip, info.getVip())); if(null != goodsSeckill){ LocalDateTime endTime = one.getEndTime(); -// // 转时间戳 + // 转时间戳 long timeStamp = endTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); goodsSeckill.setEndTime(timeStamp); } return R.ok(goodsSeckill); } + public static void main(String[] args) { + // 创建 LocalDateTime 对象 + LocalDateTime localDateTime = LocalDateTime.of(2025, 1, 16, 9, 34, 55); + + // 转换为 UTC 时间戳(毫秒) + long l = localDateTime.toEpochSecond(ZoneOffset.UTC) * 1000; + System.out.println("UTC 时间戳: " + l); + + // 转换为 UTC+8 时间戳(毫秒) + long l2 = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); + System.out.println("UTC+8 时间戳: " + l2); + + // 将时间戳转换为 yyyy-MM-dd HH:mm:ss 格式的字符串 + String utcTime = formatTimestamp(l, ZoneOffset.UTC); + String utcPlus8Time = formatTimestamp(l2, ZoneOffset.of("+8")); + + System.out.println("UTC 时间: " + utcTime); + System.out.println("UTC+8 时间: " + utcPlus8Time); + } + + /** + * 将时间戳转换为指定时区的 yyyy-MM-dd HH:mm:ss 格式字符串 + * + * @param timestamp 时间戳(毫秒) + * @param zoneOffset 时区偏移量 + * @return 格式化后的时间字符串 + */ + private static String formatTimestamp(long timestamp, ZoneOffset zoneOffset) { + return LocalDateTime.ofEpochSecond(timestamp / 1000, 0, zoneOffset) + .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java index 8fa55b7..931bfdd 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/TechnicianSubscribeVO.java @@ -52,7 +52,7 @@ /** * 预约状态:0=待服务,1=已服务,2=已取消 */ - @ApiModelProperty(value = "预约状态:0=待服务,1=已服务,2=已取消 4 已到期") + @ApiModelProperty(value = "预约状态:0=待服务,1=已服务,2=已取消 3 已到期") private Integer status; @ApiModelProperty(value = "经度") diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml index 5b8fb49..b331c08 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/TechnicianSubscribeMapper.xml @@ -74,7 +74,7 @@ tts.subscribe_time, tts.service_mode, CASE - WHEN tts.subscribe_time <![CDATA[<]]> NOW() THEN 4 + WHEN tts.subscribe_time <![CDATA[<]]> NOW() THEN 3 ELSE tts.status END AS status FROM -- Gitblit v1.7.1