|
@@ -40,6 +40,7 @@ public class MessageConsumerService {
|
|
|
map.put("mid",mid);
|
|
|
snatchMaskService.doDecrAndCreateOrder(uid, mid);
|
|
|
MsgPara msgPara = new MsgPara(uid+"",mid+"");
|
|
|
+ //订单生成后发送延时消息,处理订单状态
|
|
|
iMessageProducerService.delayMessage(new ActiveMQQueue("delay.mask.queue"),msgPara, (long) 60000);
|
|
|
} catch (JMSException e) {
|
|
|
e.printStackTrace();
|
|
@@ -47,21 +48,29 @@ public class MessageConsumerService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 延时队列消费端
|
|
|
+ * @param msgPara 消息
|
|
|
+ */
|
|
|
@JmsListener(destination = "delay.mask.queue")
|
|
|
public void delayMask(MsgPara msgPara) { // 进行消息接收处理
|
|
|
if (null !=msgPara) {
|
|
|
+ // 获取口罩id
|
|
|
Integer mid =Integer.parseInt(msgPara.getMid());
|
|
|
+ // 获取用户id
|
|
|
Integer uid = Integer.parseInt(msgPara.getUid());
|
|
|
QueryWrapper<TOrder> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("uid", uid);
|
|
|
queryWrapper.eq("mid", mid);
|
|
|
+ //查询订单
|
|
|
TOrder order = tOrderService.getOne(queryWrapper);
|
|
|
if (order != null) {
|
|
|
- if ("2".equals(order.getState())) {
|
|
|
+ if ("2".equals(order.getState())) { //判断订单是否已经处理
|
|
|
System.out.println("订单已处理");
|
|
|
return;
|
|
|
- } else if("1".equals(order.getState())) {
|
|
|
+ } else if("1".equals(order.getState())) { //判断订单是否没有处理
|
|
|
order.setState("3");
|
|
|
+ //修改订单状态
|
|
|
tOrderService.updateById(order);
|
|
|
System.out.println("订单已过期");
|
|
|
}
|