|
@@ -0,0 +1,59 @@
|
|
|
+package com.fdkankan.ucenter.mq.consumer;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fdkankan.ucenter.httpClient.vo.PayOrderVo;
|
|
|
+import com.fdkankan.ucenter.pay.strategy.impl.DownloadOrderImpl;
|
|
|
+import com.fdkankan.ucenter.pay.strategy.impl.EntityOrderImpl;
|
|
|
+import com.fdkankan.ucenter.pay.strategy.impl.IncrementOrderImpl;
|
|
|
+import com.rabbitmq.client.Channel;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringEscapeUtils;
|
|
|
+import org.springframework.amqp.core.Message;
|
|
|
+import org.springframework.amqp.rabbit.annotation.Queue;
|
|
|
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class AutoOrderConsumer {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IncrementOrderImpl incrementOrder;
|
|
|
+ @Autowired
|
|
|
+ DownloadOrderImpl downloadOrder;
|
|
|
+ @Autowired
|
|
|
+ EntityOrderImpl entityOrder;
|
|
|
+
|
|
|
+
|
|
|
+ @RabbitListener(
|
|
|
+ queuesToDeclare = @Queue("${queue.orderPay.autoorder-payResult:autoorder-payResult}")
|
|
|
+ )
|
|
|
+ public void consumerQueue(Channel channel, Message message) {
|
|
|
+ try {
|
|
|
+ String messageId = message.getMessageProperties().getMessageId();
|
|
|
+ String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
+ log.info("接受下单结果mq--messageId:{},msg:{}",messageId,msg);
|
|
|
+
|
|
|
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
+
|
|
|
+ PayOrderVo order = JSONObject.parseObject(msg, PayOrderVo.class);
|
|
|
+ if(order == null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("order-payResult----消费失败",e);
|
|
|
+ }finally {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|