package com.ruoyi.order.dto; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.order.api.model.TChargingOrder; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.Duration; import java.math.BigDecimal; import java.time.LocalDateTime; @Data public class PayOrderChargingInfo { @ApiModelProperty(value = "站点名称", required = true) private String siteName; @ApiModelProperty(value = "充电设备名称", required = true) private String chargingName; @ApiModelProperty(value = "接口名称", required = true) private String gunName; @ApiModelProperty(value = "充电开始时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("start_time") private LocalDateTime startTime; @ApiModelProperty(value = "充电结束时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("end_time") private LocalDateTime endTime; @ApiModelProperty(value = "订单金额(总金额)") @TableField("order_amount") private BigDecimal orderAmount; @ApiModelProperty(value = "车牌") private String carNum; private TChargingOrder tChargingOrder; private Long periodCount; private String timeCount; public String calculateDuration() { if (startTime == null || endTime == null) { return "00:00:00"; } Duration duration = Duration.between(startTime, endTime); long totalSeconds = duration.getSeconds(); long hours = totalSeconds / 3600; long minutes = (totalSeconds % 3600) / 60; long seconds = totalSeconds % 60; return String.format("%02d:%02d:%02d", hours, minutes, seconds); } }