Showing
2 changed files
with
66 additions
and
0 deletions
order/src/main/java/com/yohoufo/order/mq/consumer/CustomsDeclarationMessageConsummer.java
0 → 100644
1 | +package com.yohoufo.order.mq.consumer; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | +import com.yoho.core.rabbitmq.YhConsumer; | ||
5 | +import com.yohoufo.order.constants.ClearanceFailType; | ||
6 | +import com.yohoufo.order.service.impl.BuyerOrderCancelService; | ||
7 | +import com.yohoufo.order.utils.LoggerUtils; | ||
8 | +import lombok.extern.slf4j.Slf4j; | ||
9 | +import org.slf4j.Logger; | ||
10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
11 | +import org.springframework.stereotype.Component; | ||
12 | + | ||
13 | + | ||
14 | +@Slf4j | ||
15 | +@Component | ||
16 | +public class CustomsDeclarationMessageConsummer implements YhConsumer { | ||
17 | + | ||
18 | + final Logger logger = LoggerUtils.getMqConsumerLogger(); | ||
19 | + | ||
20 | + @Autowired | ||
21 | + BuyerOrderCancelService buyerOrderCancelService; | ||
22 | + | ||
23 | + @Override | ||
24 | + public void handleMessage(Object o) throws Exception { | ||
25 | + logger.info("handler customs declaration message, msg {} ", o); | ||
26 | + try { | ||
27 | + JSONObject message = JSONObject.parseObject(o.toString()); | ||
28 | + Long orderCode = message.getLong("orderCode"); | ||
29 | + // 清单编号 | ||
30 | + String customsNo = message.getString("customsNo"); | ||
31 | + String customsStatus = message.getString("customsStatus"); | ||
32 | + // 海关回执描述 | ||
33 | + String customsNote = message.getString("customsNote"); | ||
34 | + // 回执接受时间,格式yyyyMMddHHmmss | ||
35 | + String receiptDate = message.getString("receiptDate"); | ||
36 | + String cancelReason; | ||
37 | + // 0 异常回执, 1 电子口岸已暂存 2 电子口岸申报中 | ||
38 | + // 100 海关退单 120 海关入库 | ||
39 | + // 300 人工审核 399 海关审结 500 查验 | ||
40 | + // 501 扣留移送通关 502 扣留移送缉私 503 扣留移送法规 599 其他扣留 | ||
41 | + // 700 退运 | ||
42 | + // 800 放行 | ||
43 | + if ("800".equals(customsStatus)) { | ||
44 | + log.info("handler customs declaration message success, msg {}, customs declaration success",o); | ||
45 | + return; | ||
46 | + } | ||
47 | + else if ("100".equals(customsStatus)) { | ||
48 | + cancelReason = "海关退单"; | ||
49 | + } | ||
50 | + else if ("700".equals(customsStatus)) { | ||
51 | + cancelReason = "海关退运"; | ||
52 | + } else { | ||
53 | + log.info("handler customs declaration message success, msg {}, customs declaration unknown",o); | ||
54 | + return; | ||
55 | + } | ||
56 | + buyerOrderCancelService.clearanceFail(orderCode, cancelReason, ClearanceFailType.BUYER); | ||
57 | + logger.info("handler customs declaration message success, msg {} ", o); | ||
58 | + } catch (Exception e) { | ||
59 | + logger.info("handler customs declaration message fail, msg {} ", o, e); | ||
60 | + } | ||
61 | + | ||
62 | + } | ||
63 | +} |
@@ -131,6 +131,9 @@ consumer: | @@ -131,6 +131,9 @@ consumer: | ||
131 | topic: buyerOrder.couponSendResultForAppraiseUnsure | 131 | topic: buyerOrder.couponSendResultForAppraiseUnsure |
132 | ratelimit: 20 | 132 | ratelimit: 20 |
133 | 133 | ||
134 | + - class: com.yohoufo.order.mq.consumer.CustomsDeclarationMessageConsummer | ||
135 | + topic: ufo.order.customsDeclaration | ||
136 | + | ||
134 | # promotion | 137 | # promotion |
135 | # 发券 | 138 | # 发券 |
136 | - class: com.yohoufo.promotion.mq.CouponSendWithTradeMqNotifyConsumer | 139 | - class: com.yohoufo.promotion.mq.CouponSendWithTradeMqNotifyConsumer |
-
Please register or login to post a comment