Commit 3b651c63 by 吕明尚

增加线程池延时Redis操作

parent a31a2a95
...@@ -976,16 +976,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -976,16 +976,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}); });
} }
} }
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo()); map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getEndDate().toString()); map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString()); new Thread(() -> {
try {
Thread.sleep(1000);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
unLockOrder(request.getRoomId()); unLockOrder(request.getRoomId());
} }
if (response.getStatus().equals(YesNoEnum.yes.getFlag())) { if (response.getStatus().equals(YesNoEnum.yes.getFlag())) {
...@@ -1003,7 +1005,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1003,7 +1005,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
map.put("expirationTime", sOrder.getPreStartDate().toString()); map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) { if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
redisUtil.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString()); new Thread(() -> {
try {
// 这里设置你的延迟时间,例如5秒
Thread.sleep(1000);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
unLockOrder(request.getRoomId()); unLockOrder(request.getRoomId());
} }
// 订单预定成功, 发送短信通知运维客服 // 订单预定成功, 发送短信通知运维客服
...@@ -1884,27 +1894,33 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1884,27 +1894,33 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
creatExtracted(consumerWallet, sOrder, consumerMember); creatExtracted(consumerWallet, sOrder, consumerMember);
baseMapper.updateSOrder(sOrder); baseMapper.updateSOrder(sOrder);
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) { if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo()); map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getEndDate().toString()); map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString()); new Thread(() -> {
try {
// 这里设置你的延迟时间,例如5秒
Thread.sleep(1000);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
} else if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) { } else if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo()); map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString()); map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString()); new Thread(() -> {
try {
// 这里设置你的延迟时间,例如5秒
Thread.sleep(1000);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
} }
Long couponId = sOrder.getCouponId(); Long couponId = sOrder.getCouponId();
SStore sStore = storeService.getById(sOrder.getStoreId()); SStore sStore = storeService.getById(sOrder.getStoreId());
...@@ -2246,13 +2262,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -2246,13 +2262,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sOrder.setEndDate(sOrder.getPreEndDate()); sOrder.setEndDate(sOrder.getPreEndDate());
} }
} }
sOrder.setArrivalTime(new Date());
baseMapper.updateById(sOrder);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo()); map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getEndDate().toString()); map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString()); new Thread(() -> {
sOrder.setArrivalTime(new Date()); try {
baseMapper.updateById(sOrder); // 这里设置你的延迟时间,例如5秒
Thread.sleep(1000);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
//更改房间状态 //更改房间状态
SRoom sRoom = new SRoom(); SRoom sRoom = new SRoom();
sRoom.setId(sOrder.getRoomId()); sRoom.setId(sOrder.getRoomId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment