|
|
package com.yohoufo.order.mq.consumer;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.core.rabbitmq.YhConsumer;
|
|
|
import com.yohoufo.order.constants.ClearanceFailType;
|
|
|
import com.yohoufo.order.service.impl.BuyerOrderCancelService;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
public class CustomsDeclarationMessageConsummer implements YhConsumer {
|
|
|
|
|
|
final Logger logger = LoggerUtils.getMqConsumerLogger();
|
|
|
|
|
|
@Autowired
|
|
|
BuyerOrderCancelService buyerOrderCancelService;
|
|
|
|
|
|
@Override
|
|
|
public void handleMessage(Object o) throws Exception {
|
|
|
logger.info("handler customs declaration message, msg {} ", o);
|
|
|
try {
|
|
|
JSONObject message = JSONObject.parseObject(o.toString());
|
|
|
Long orderCode = message.getLong("orderCode");
|
|
|
// 清单编号
|
|
|
String customsNo = message.getString("customsNo");
|
|
|
String customsStatus = message.getString("customsStatus");
|
|
|
// 海关回执描述
|
|
|
String customsNote = message.getString("customsNote");
|
|
|
// 回执接受时间,格式yyyyMMddHHmmss
|
|
|
String receiptDate = message.getString("receiptDate");
|
|
|
String cancelReason;
|
|
|
// 0 异常回执, 1 电子口岸已暂存 2 电子口岸申报中
|
|
|
// 100 海关退单 120 海关入库
|
|
|
// 300 人工审核 399 海关审结 500 查验
|
|
|
// 501 扣留移送通关 502 扣留移送缉私 503 扣留移送法规 599 其他扣留
|
|
|
// 700 退运
|
|
|
// 800 放行
|
|
|
if ("800".equals(customsStatus)) {
|
|
|
log.info("handler customs declaration message success, msg {}, customs declaration success",o);
|
|
|
return;
|
|
|
}
|
|
|
else if ("100".equals(customsStatus)) {
|
|
|
cancelReason = "海关退单";
|
|
|
}
|
|
|
else if ("700".equals(customsStatus)) {
|
|
|
cancelReason = "海关退运";
|
|
|
} else {
|
|
|
log.info("handler customs declaration message success, msg {}, customs declaration unknown",o);
|
|
|
return;
|
|
|
}
|
|
|
buyerOrderCancelService.clearanceFail(orderCode, cancelReason, ClearanceFailType.BUYER);
|
|
|
logger.info("handler customs declaration message success, msg {} ", o);
|
|
|
} catch (Exception e) {
|
|
|
logger.info("handler customs declaration message fail, msg {} ", o, e);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |
...
|
...
|
|