Commit 3b651c63 by 吕明尚

增加线程池延时Redis操作

parent a31a2a95
......@@ -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.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map);
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());
}
if (response.getStatus().equals(YesNoEnum.yes.getFlag())) {
......@@ -1003,7 +1005,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map);
if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
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());
}
// 订单预定成功, 发送短信通知运维客服
......@@ -1884,27 +1894,33 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
creatExtracted(consumerWallet, sOrder, consumerMember);
baseMapper.updateSOrder(sOrder);
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.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} else if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
new Thread(() -> {
try {
Thread.sleep(1000L);
// 这里设置你的延迟时间,例如5秒
Thread.sleep(1000);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} catch (InterruptedException e) {
throw new RuntimeException(e);
e.printStackTrace();
}
}).start();
} else if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map);
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();
SStore sStore = storeService.getById(sOrder.getStoreId());
......@@ -2246,13 +2262,21 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sOrder.setEndDate(sOrder.getPreEndDate());
}
}
sOrder.setArrivalTime(new Date());
baseMapper.updateById(sOrder);
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map);
new Thread(() -> {
try {
// 这里设置你的延迟时间,例如5秒
Thread.sleep(1000);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
sOrder.setArrivalTime(new Date());
baseMapper.updateById(sOrder);
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
//更改房间状态
SRoom sRoom = new SRoom();
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