Commit a18c0453 by 李学兴

opt@feature/20210802_异步发券优化_lxx:# 异步发券提前到 callBack中

parent b0136e47
......@@ -23,6 +23,9 @@ public class OrderCallBackConfig {
public static final String QUEUE_NAME = "order-call-back-queue";
public static final String QUEUE_ROUTING_KEY = "order-call-back-queue-routing-key";
public static final String CALL_BACK_QUEUE_NAME = "order-call-back-send-coupon-queue";
public static final String CALL_BACK_QUEUE_ROUTING_KEY = "order-call-back-send-coupon-queue-routing-key";
///开放平台
public static final String TOPIC_EXCHANGE_NAME = "topic-Exchange";
public static final String OPEN_PLATFORM_ORDER_STATUS_CHANGE_PUSH_QUEUE_NAME = "open-platform-order-status-change-push-queue";
......
......@@ -93,6 +93,24 @@ public class OrderCallBackMQService {
//支付宝订单状态变更上报
sendzfbOrderMQ(body);
//支付回调订单后发券
this.sendCoupon(body);
}
/**
* 支付回调订单后发券
* @param body
*/
public void sendCoupon(OrderCallBackRequestVo body) {
try {
Header header = new Header(MQAction.UPDATE.getAction(), "call-back-service-api",
OrderCallBackConfig.CALL_BACK_QUEUE_ROUTING_KEY, OrderCallBackConfig.CALL_BACK_QUEUE_NAME);
MQMessage<OrderCallBackRequestVo> message = new MQMessage<>(header, body);
mqService.convertAndSend(OrderCallBackConfig.EXCHANGE_NAME, OrderCallBackConfig.CALL_BACK_QUEUE_ROUTING_KEY, message);
ApiLog.infoMessage("sendCoupon end orderCode:{}", body.getOrderCode());
} catch (Exception e) {
ApiLog.infoMessage("sendCoupon Error orderCode:{} e:{}", e, body.getOrderCode(), ExceptionUtils.getFullStackTrace(e));
}
}
/**
......
package cn.freemud.amq;
import cn.freemud.ApiApplication;
import cn.freemud.amp.service.OrderCallBackMQService;
import cn.freemud.entities.vo.OrderCallBackRequestVo;
import com.alibaba.fastjson.JSON;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplication.class)
public class OrderCallBackMQServiceTest {
@Autowired
OrderCallBackMQService orderCallBackMQService;
@Test
public void testSendOrderMQ() {
OrderCallBackRequestVo body = JSON.parseObject("{\"orderCode\":\"demoData\",\"afterSalesCode\":\"demoData\",\"delayMsgEventType\":1,\"operateType\":1,\"orderClient\":1,\"partnerId\":\"demoData\",\"storeId\":\"demoData\",\"msgType\":\"demoData\",\"content\":\"demoData\",\"requestId\":\"demoData\"}",
OrderCallBackRequestVo.class);
orderCallBackMQService.sendCoupon(body);
}
}
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