|
@@ -6,12 +6,11 @@ import com.google.common.collect.Lists; |
|
@@ -6,12 +6,11 @@ import com.google.common.collect.Lists; |
6
|
import com.yoho.core.rabbitmq.YhConsumer;
|
6
|
import com.yoho.core.rabbitmq.YhConsumer;
|
7
|
import com.yohoufo.common.constant.ExpressInfoConstant;
|
7
|
import com.yohoufo.common.constant.ExpressInfoConstant;
|
8
|
import com.yohoufo.common.utils.DateUtil;
|
8
|
import com.yohoufo.common.utils.DateUtil;
|
9
|
-import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
10
|
import com.yohoufo.dal.order.ExpressInfoMapper;
|
9
|
import com.yohoufo.dal.order.ExpressInfoMapper;
|
11
|
import com.yohoufo.dal.order.ExpressRecordMapper;
|
10
|
import com.yohoufo.dal.order.ExpressRecordMapper;
|
12
|
-import com.yohoufo.dal.order.model.BuyerOrder;
|
|
|
13
|
import com.yohoufo.dal.order.model.ExpressInfo;
|
11
|
import com.yohoufo.dal.order.model.ExpressInfo;
|
14
|
import com.yohoufo.dal.order.model.ExpressRecord;
|
12
|
import com.yohoufo.dal.order.model.ExpressRecord;
|
|
|
13
|
+import com.yohoufo.order.model.bo.ErpExpressBo;
|
15
|
import com.yohoufo.order.mq.publisher.ConsumerExceptionPublisher;
|
14
|
import com.yohoufo.order.mq.publisher.ConsumerExceptionPublisher;
|
16
|
import com.yohoufo.order.utils.LoggerUtils;
|
15
|
import com.yohoufo.order.utils.LoggerUtils;
|
17
|
import org.apache.commons.collections.CollectionUtils;
|
16
|
import org.apache.commons.collections.CollectionUtils;
|
|
@@ -38,10 +37,6 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -38,10 +37,6 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
38
|
private ExpressRecordMapper expressRecordMapper;
|
37
|
private ExpressRecordMapper expressRecordMapper;
|
39
|
|
38
|
|
40
|
@Autowired
|
39
|
@Autowired
|
41
|
- private BuyerOrderMapper buyerOrderMapper;
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
- @Autowired
|
|
|
45
|
private ConsumerExceptionPublisher consumerExceptionPublisher;
|
40
|
private ConsumerExceptionPublisher consumerExceptionPublisher;
|
46
|
|
41
|
|
47
|
public String getMessageTopic() {
|
42
|
public String getMessageTopic() {
|
|
@@ -63,37 +58,27 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -63,37 +58,27 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
63
|
}
|
58
|
}
|
64
|
|
59
|
|
65
|
private void updateExpressInfo(Object message) {
|
60
|
private void updateExpressInfo(Object message) {
|
66
|
- JSONObject jsonMsg = JSONObject.parseObject(message.toString());
|
|
|
67
|
- if (!checkValidMessage(jsonMsg)) {
|
61
|
+ ErpExpressBo erpExpressBo = convertErpJsonToObject(message);
|
|
|
62
|
+ if (erpExpressBo==null||!checkValidMessage(erpExpressBo)) {
|
68
|
return;
|
63
|
return;
|
69
|
}
|
64
|
}
|
70
|
|
65
|
|
71
|
- int uid = jsonMsg.getIntValue("uid");
|
66
|
+ String waybillCode = erpExpressBo.getWaybillCode();
|
|
|
67
|
+ int logisticsType = erpExpressBo.getLogisticsType();
|
|
|
68
|
+ String acceptAddress = erpExpressBo.getAcceptAddress();
|
|
|
69
|
+ String acceptRemark = erpExpressBo.getAcceptRemark();
|
|
|
70
|
+ int createTime = erpExpressBo.getCreateTime();
|
|
|
71
|
+ int state = erpExpressBo.getState();
|
|
|
72
|
+
|
|
|
73
|
+ long orderCode = erpExpressBo.getOrderCode();
|
|
|
74
|
+ int uid = erpExpressBo.getUid();
|
|
|
75
|
+
|
72
|
if (uid == 0) {
|
76
|
if (uid == 0) {
|
73
|
LOGGER.info("handle express info update message, not give me a uid, message is {}.", message);
|
77
|
LOGGER.info("handle express info update message, not give me a uid, message is {}.", message);
|
74
|
return;
|
78
|
return;
|
75
|
}
|
79
|
}
|
76
|
|
80
|
|
77
|
- long orderCode = jsonMsg.getLongValue("orderCode");
|
|
|
78
|
- String waybillCode = jsonMsg.getString("waybillCode");
|
|
|
79
|
- int logisticsType = jsonMsg.getIntValue("logisticsType");
|
|
|
80
|
- int createTime = jsonMsg.getIntValue("createTime");
|
|
|
81
|
- int state = jsonMsg.getIntValue("state");
|
|
|
82
|
- String acceptAddress = jsonMsg.getString("acceptAddress");
|
|
|
83
|
- String acceptRemark = jsonMsg.getString("acceptRemark");
|
|
|
84
|
-
|
|
|
85
|
- /*
|
|
|
86
|
- BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
87
|
-
|
|
|
88
|
- if (buyerOrder == null){
|
|
|
89
|
- LOGGER.warn("handle express info update message,getOrderInfo order not exist, orderCode is {}", orderCode);
|
|
|
90
|
- //遇到这种情况,也记录物流信息
|
|
|
91
|
- //throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
92
|
- }
|
|
|
93
|
- */
|
|
|
94
|
-
|
|
|
95
|
//根据uid,orderCode,waybillCode查状态expressType
|
81
|
//根据uid,orderCode,waybillCode查状态expressType
|
96
|
-
|
|
|
97
|
//初始的expressType
|
82
|
//初始的expressType
|
98
|
Byte initExpressType=0;
|
83
|
Byte initExpressType=0;
|
99
|
ExpressRecord firstExpressRecord = expressRecordMapper.queryExpressRecord(uid,orderCode,waybillCode);
|
84
|
ExpressRecord firstExpressRecord = expressRecordMapper.queryExpressRecord(uid,orderCode,waybillCode);
|
|
@@ -110,7 +95,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -110,7 +95,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
110
|
|
95
|
|
111
|
// 正常订单,签收消息
|
96
|
// 正常订单,签收消息
|
112
|
if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) {
|
97
|
if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) {
|
113
|
- handleAcceptExpress(jsonMsg,initExpressType.intValue());
|
98
|
+ handleAcceptExpress(erpExpressBo,initExpressType.intValue());
|
114
|
return;
|
99
|
return;
|
115
|
}
|
100
|
}
|
116
|
|
101
|
|
|
@@ -135,19 +120,40 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -135,19 +120,40 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
135
|
expressInfoMapper.insert(expressInfo);
|
120
|
expressInfoMapper.insert(expressInfo);
|
136
|
}
|
121
|
}
|
137
|
|
122
|
|
138
|
- private boolean checkValidMessage(JSONObject jsonMsg) {
|
123
|
+ private ErpExpressBo convertErpJsonToObject(Object message) {
|
|
|
124
|
+ try{
|
|
|
125
|
+ JSONObject jsonMsg = JSONObject.parseObject(message.toString());
|
|
|
126
|
+ ErpExpressBo bo=new ErpExpressBo();
|
|
|
127
|
+ bo.setBusinessType(jsonMsg.getIntValue("businessType"));
|
|
|
128
|
+ bo.setWaybillCode(jsonMsg.getString("waybillCode"));
|
|
|
129
|
+ bo.setLogisticsType(jsonMsg.getIntValue("logisticsType"));
|
|
|
130
|
+ bo.setAcceptAddress(jsonMsg.getString("acceptAddress"));
|
|
|
131
|
+ bo.setAcceptRemark(jsonMsg.getString("acceptRemark"));
|
|
|
132
|
+ bo.setCreateTime(jsonMsg.getIntValue("createTime"));
|
|
|
133
|
+ bo.setState(jsonMsg.getIntValue("state"));
|
|
|
134
|
+
|
|
|
135
|
+ bo.setUid(jsonMsg.getIntValue("uid"));
|
|
|
136
|
+ bo.setOrderCode(jsonMsg.getLongValue("orderCode"));
|
|
|
137
|
+ return bo;
|
|
|
138
|
+ }catch (Exception e){
|
|
|
139
|
+ LOGGER.warn("convertErpJsonToObject express info message error,message is {}.", message);
|
|
|
140
|
+ return null;
|
|
|
141
|
+ }
|
|
|
142
|
+ }
|
|
|
143
|
+
|
|
|
144
|
+ private boolean checkValidMessage(ErpExpressBo erpExpressBo) {
|
139
|
boolean flag = true;
|
145
|
boolean flag = true;
|
140
|
- int smsType = jsonMsg.getIntValue("businessType");
|
|
|
141
|
- int logisticsType = jsonMsg.getIntValue("logisticsType");
|
|
|
142
|
- int state = jsonMsg.getIntValue("state");
|
|
|
143
|
- long orderCode = jsonMsg.getLongValue("orderCode");
|
|
|
144
|
- String waybillCode = jsonMsg.getString("waybillCode");
|
|
|
145
|
- if (smsType < 1 || state < 0 || logisticsType < 0 || orderCode < 0) {
|
|
|
146
|
- LOGGER.warn("invalid express info message,message is {}.", jsonMsg);
|
146
|
+ int businessType = erpExpressBo.getBusinessType();
|
|
|
147
|
+ int logisticsType = erpExpressBo.getLogisticsType();
|
|
|
148
|
+ int state = erpExpressBo.getState();
|
|
|
149
|
+ long orderCode = erpExpressBo.getOrderCode();
|
|
|
150
|
+ String waybillCode = erpExpressBo.getWaybillCode();
|
|
|
151
|
+ if (businessType < 1 || state < 0 || logisticsType < 0 || orderCode < 0) {
|
|
|
152
|
+ LOGGER.warn("invalid express info message,message is {}.", erpExpressBo);
|
147
|
flag = false;
|
153
|
flag = false;
|
148
|
}
|
154
|
}
|
149
|
if (logisticsType > 0 && StringUtils.isBlank(waybillCode)) {
|
155
|
if (logisticsType > 0 && StringUtils.isBlank(waybillCode)) {
|
150
|
- LOGGER.warn("invalid express info message,message is {}.", jsonMsg);
|
156
|
+ LOGGER.warn("invalid express info message,message is {}.", erpExpressBo);
|
151
|
flag = false;
|
157
|
flag = false;
|
152
|
}
|
158
|
}
|
153
|
return flag;
|
159
|
return flag;
|
|
@@ -156,14 +162,15 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -156,14 +162,15 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
156
|
/**
|
162
|
/**
|
157
|
* 确认收货处理
|
163
|
* 确认收货处理
|
158
|
*/
|
164
|
*/
|
159
|
- private void handleAcceptExpress(JSONObject jsonMsg,Integer expressType) {
|
|
|
160
|
- int state = jsonMsg.getIntValue("state");
|
|
|
161
|
- long orderCode = jsonMsg.getLongValue("orderCode");
|
|
|
162
|
- int logisticsType = jsonMsg.getIntValue("logisticsType");
|
|
|
163
|
- String waybillCode = jsonMsg.getString("waybillCode");
|
|
|
164
|
- String acceptAddress = jsonMsg.getString("acceptAddress");
|
|
|
165
|
- String acceptRemark = jsonMsg.getString("acceptRemark");
|
|
|
166
|
- int uid = jsonMsg.getIntValue("uid");
|
165
|
+ private void handleAcceptExpress(ErpExpressBo erpExpressBo,Integer expressType) {
|
|
|
166
|
+ String waybillCode = erpExpressBo.getWaybillCode();
|
|
|
167
|
+ int logisticsType = erpExpressBo.getLogisticsType();
|
|
|
168
|
+ String acceptAddress = erpExpressBo.getAcceptAddress();
|
|
|
169
|
+ String acceptRemark = erpExpressBo.getAcceptRemark();
|
|
|
170
|
+ int state = erpExpressBo.getState();
|
|
|
171
|
+ long orderCode = erpExpressBo.getOrderCode();
|
|
|
172
|
+ int uid = erpExpressBo.getUid();
|
|
|
173
|
+
|
167
|
int createTime = DateUtil.getCurrentTimeSecond();
|
174
|
int createTime = DateUtil.getCurrentTimeSecond();
|
168
|
|
175
|
|
169
|
List<ExpressInfo> expressInfos = expressInfoMapper.selectByOrderCodeAndStatesAndUidAndExpressType(uid, orderCode, Lists.newArrayList(ExpressInfoConstant.EXPRESS_STATUS_SIGN), expressType);
|
176
|
List<ExpressInfo> expressInfos = expressInfoMapper.selectByOrderCodeAndStatesAndUidAndExpressType(uid, orderCode, Lists.newArrayList(ExpressInfoConstant.EXPRESS_STATUS_SIGN), expressType);
|