From bccd25039a08f8833b72ff906d156da63018db98 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期二, 19 三月 2024 15:10:13 +0800
Subject: [PATCH] 新增心跳缓存
---
src/main/java/com/boying/controller/phone/YCPayController.java | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/boying/controller/phone/YCPayController.java b/src/main/java/com/boying/controller/phone/YCPayController.java
index 349ba82..f2872ab 100644
--- a/src/main/java/com/boying/controller/phone/YCPayController.java
+++ b/src/main/java/com/boying/controller/phone/YCPayController.java
@@ -2,7 +2,6 @@
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
-import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -13,15 +12,14 @@
import com.boying.entity.*;
import com.boying.service.*;
import com.boying.util.DateUtilOther;
-import com.boying.util.HTTPEntityUtil;
import com.google.gson.Gson;
import lombok.RequiredArgsConstructor;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -36,6 +34,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
/**
* @author kdq
@@ -59,6 +58,9 @@
private final WhiteListService whiteListService;
private final EnterParkService enterParkService;
private final WXService wxService;
+ private final OutParkLogService outParkLogService;
+ private StringRedisTemplate redisTemplate;
+
/**
* 鏌ヨ璁㈠崟鎺ュ彛
@@ -187,6 +189,9 @@
if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 0){
String logs = sdf.format(new Date())+" 杞︾墝鍙蜂负锛�"+outPark.getCarNo()+",鐢宠缂磋垂2------銆媆n";
writeTxt(logs);
+ OutParkLog byOutPark = outParkLogService.getByOutPark(outPark.getCarNo(), outPark.getId());
+ byOutPark.setPayStartTime(LocalDateTime.now());
+ outParkLogService.saveOrUpdate(byOutPark);
return R.ok(null,"璺宠浆閭㈠彴閾惰鏀粯");
}else if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 1){
return R.failed("宸茬即璐�");
@@ -204,6 +209,9 @@
}else {
outPark.setPrice(outPark.getPrice()-enterPark.getPrice());
outParkService.updateById(outPark);
+ OutParkLog byOutPark = outParkLogService.getByOutPark(outPark.getCarNo(), outPark.getId());
+ byOutPark.setPayStartTime(LocalDateTime.now());
+ outParkLogService.saveOrUpdate(byOutPark);
}
}
}
@@ -452,6 +460,9 @@
if(byPayCode.getStatus() == 1){
return R.ok(null,"璁㈠崟宸叉敮浠�");
}else {
+ OutParkLog byOutPark = outParkLogService.getByOutPark(byPayCode.getCarNo(), byPayCode.getId());
+ byOutPark.setPayEndTime(LocalDateTime.now());
+ outParkLogService.saveOrUpdate(byOutPark);
updateOrderRecord((long)byPayCode.getId(),"03");
List<EnterPark> byCarNo = enterParkService.findByCarNo(byPayCode.getCarNo(),byPayCode.getParkId());
if(byCarNo.size()>0){
@@ -666,10 +677,13 @@
//鏇存柊鍑哄満
public void updateOutPark(Integer outParkId, String status){
OutPark outPark = outParkService.getById(outParkId);
- if(outPark!=null){
+ if(outPark!=null && outPark.getEnterTime() !=null){
if(status.equals("03")){
outPark.setStatus(1);
outParkService.saveOrUpdate(outPark);
+ //缂撳瓨鍦╮edis閲�
+ String jsonValue = JSON.toJSONString(outPark);
+ redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue);
}
}
}
--
Gitblit v1.9.1