|
|
@@ -1,5 +1,6 @@
|
|
|
package com.kxs.product.biz.mq;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.kxs.product.api.amqp.rabbit.RabbitShopTimeoutQueueMQ;
|
|
|
import com.kxs.product.api.model.KxsShopOrder;
|
|
|
import com.kxs.product.biz.constant.enums.KxsShopEnum;
|
|
|
@@ -10,7 +11,6 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.amqp.core.Message;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
@@ -35,26 +35,25 @@ public class RabbitShopQueueListener {
|
|
|
@RabbitListener(queues = RabbitShopTimeoutQueueMQ.QUEUE_NAME, ackMode = "MANUAL")
|
|
|
@RabbitHandler
|
|
|
public void onMessage(String msg, Message message, Channel channel){
|
|
|
- log.info("shop消费端Payload: " + RabbitShopTimeoutQueueMQ.parse(msg));
|
|
|
+ log.info("商品下单过期队列: " + RabbitShopTimeoutQueueMQ.parse(msg));
|
|
|
try {
|
|
|
RabbitShopTimeoutQueueMQ.MsgEntity parse = RabbitShopTimeoutQueueMQ.parse(msg);
|
|
|
Integer id = parse.getId();
|
|
|
//根据订单号查询该订单是否付款成功,如果仍未付款成功,关闭订单
|
|
|
- KxsShopOrder byId = kxsShopOrderService.getById(id);
|
|
|
- if (byId != null && byId.getStatus().equals(KxsShopEnum.ORDER_NO_PAY.getType())){
|
|
|
- KxsShopOrder kxsShopOrder = new KxsShopOrder();
|
|
|
- BeanUtils.copyProperties(parse,kxsShopOrder);
|
|
|
- //取消订单
|
|
|
+ KxsShopOrder order = kxsShopOrderService.getById(id);
|
|
|
+ if (order != null && order.getStatus().equals(KxsShopEnum.ORDER_NO_PAY.getType())){
|
|
|
+
|
|
|
//todo 这里只取消了我们平台的订单,如已发起支付渠道调用,仍需取消支付渠道
|
|
|
- kxsShopOrderService.cancelOrder(kxsShopOrder);
|
|
|
+ order.setStatus(KxsShopEnum.ORDER_CANCEL.getType());
|
|
|
+ kxsShopOrderService.updateById(order);
|
|
|
}
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
|
|
} catch (Exception e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
+ log.error("商品下单过期队列消费失败:{}", JSON.toJSONString(msg), e);
|
|
|
try {
|
|
|
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
} catch (IOException ex) {
|
|
|
- log.error("进入死信队列失败" + ex.getMessage(), ex);
|
|
|
+ log.error("商品下单过期进入死信队列失败" + ex.getMessage(), ex);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -67,7 +66,7 @@ public class RabbitShopQueueListener {
|
|
|
@RabbitListener(queues = RabbitShopTimeoutQueueMQ.DEAD_QUEUE_NAME)
|
|
|
@RabbitHandler
|
|
|
public void onDeadMessage(String msg, Message message, Channel channel){
|
|
|
- log.info("死信队列Payload: " + RabbitShopTimeoutQueueMQ.parse(msg));
|
|
|
+ log.info("商品下单过期死信队列: " + RabbitShopTimeoutQueueMQ.parse(msg));
|
|
|
try {
|
|
|
RabbitShopTimeoutQueueMQ.MsgEntity parse = RabbitShopTimeoutQueueMQ.parse(msg);
|
|
|
} catch (Exception e) {
|