修改--支付回调订单详情添加剩余时间字符串

This commit is contained in:
haotian 2025-04-01 11:33:31 +08:00
parent 8b5769219f
commit fdf1301244
3 changed files with 58 additions and 2 deletions

View File

@ -36,6 +36,7 @@ import com.ruoyi.web.controller.app.baidu.OcrIdCardBAI;
//import com.ruoyi.web.controller.app.pay.PayService;
import com.ruoyi.web.controller.backstage.BackstageController;
import javafx.scene.chart.StackedAreaChart;
import java.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -2186,14 +2187,51 @@ public class AppSystemController extends BaseController {
@GetMapping("/getSystemOrder/{orderId}")
public AjaxResult getSystemOrder(@PathVariable("orderId") Long orderId)
{
Long userId = getUserId();
SysOrderPayBackDto sysOrderPayBackDto = sysOrderService.getSysOrderPayBackDto(orderId);
if(sysOrderPayBackDto != null){
if(!sysOrderPayBackDto.getUserId().equals(userId)){
return error("请不要查看不是自己的订单");
}
sysOrderPayBackDto.setPayTime(sysOrderPayBackDto.getCreateTime());
String c_x = String.format("%02d", sysOrderPayBackDto.getC_x());
String c_y = String.format("%02d", sysOrderPayBackDto.getC_y());
sysOrderPayBackDto.setArLocation(sysOrderPayBackDto.getPart()+c_x+c_y);
LocalDateTime now = LocalDateTime.now();
sysOrderPayBackDto.setRemainTime(Math.max(ChronoUnit.SECONDS.between(now, sysOrderPayBackDto.getEndTime()), 0));
Duration duration = Duration.between(now, sysOrderPayBackDto.getEndTime());
boolean isNegative = duration.isNegative();
// 分解单位同上
long days = duration.toDays();
long hours = duration.toHours() % 24;
long minutes = duration.toMinutes() % 60;
long seconds = duration.getSeconds() % 60;
String s = "剩余";
if (days > 0){
s = s + days + "";
}
if (hours > 0){
s = s + hours + "小时";
}
if (minutes > 0){
s = s + minutes + "";
}
if (seconds > 0){
s = s + seconds + "";
}
if (s.equals("剩余")){
s = "订单已结束展示";
}
sysOrderPayBackDto.setRemainTimeString(s);
return success(sysOrderPayBackDto);
}
return error("获取订单详情失败");

View File

@ -5,6 +5,7 @@ import java.time.LocalDateTime;
public class SysOrderPayBackDto {
private Long orderId;
private Long userId;
private String orderInfoId;
private LocalDateTime createTime;
private LocalDateTime payTime;
@ -15,6 +16,7 @@ public class SysOrderPayBackDto {
private int c_x;
private int c_y;
private Long remainTime;
private String remainTimeString;
public Long getOrderId() {
return orderId;
@ -24,6 +26,14 @@ public class SysOrderPayBackDto {
this.orderId = orderId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getOrderInfoId() {
return orderInfoId;
}
@ -103,6 +113,13 @@ public class SysOrderPayBackDto {
public void setRemainTime(Long remainTime) {
this.remainTime = remainTime;
}
public String getRemainTimeString() {
return remainTimeString;
}
public void setRemainTimeString(String remainTimeString) {
this.remainTimeString = remainTimeString;
}
}

View File

@ -69,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap id="SysOrderPayBackDtoResult" type="SysOrderPayBackDto">
<result property="orderId" column="order_id"/>
<result property="userId" column="user_id"/>
<result property="createTime" column="create_time"/>
<result property="endTime" column="end_time"/>
<result property="orderInfoId" column="order_info_id"/>
@ -139,7 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where status = '1' and create_time = #{date} and delete_flag = '0'
</select>
<select id="getSysOrderPayBackDto" resultMap="SysOrderPayBackDtoResult">
select sys_order.order_id, create_time, sys_order.end_time, order_info_id, money, part, c_x, c_y
select sys_order.order_id, sys_order.user_id ,create_time, sys_order.end_time, order_info_id, money, part, c_x, c_y
from sys_order
left join sys_source
on sys_order.source_id = sys_source.source_id