|
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Component; |
|
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Component; |
27
|
@Component
|
27
|
@Component
|
28
|
public class ExpressInfoUpdateConsumer implements YhConsumer {
|
28
|
public class ExpressInfoUpdateConsumer implements YhConsumer {
|
29
|
|
29
|
|
30
|
-private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
|
30
|
+ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
|
31
|
|
31
|
|
32
|
|
32
|
|
33
|
private final String topic = "ufo.order.updateExpressInfo";
|
33
|
private final String topic = "ufo.order.updateExpressInfo";
|
|
@@ -64,7 +64,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -64,7 +64,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
64
|
|
64
|
|
65
|
private void updateExpressInfo(Object message) {
|
65
|
private void updateExpressInfo(Object message) {
|
66
|
ErpExpressBo erpExpressBo = convertErpJsonToObject(message);
|
66
|
ErpExpressBo erpExpressBo = convertErpJsonToObject(message);
|
67
|
- if (erpExpressBo==null||!checkValidMessage(erpExpressBo)) {
|
67
|
+ if (erpExpressBo == null || !checkValidMessage(erpExpressBo)) {
|
68
|
return;
|
68
|
return;
|
69
|
}
|
69
|
}
|
70
|
|
70
|
|
|
@@ -85,22 +85,22 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -85,22 +85,22 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
85
|
|
85
|
|
86
|
//根据uid,orderCode,waybillCode查状态expressType
|
86
|
//根据uid,orderCode,waybillCode查状态expressType
|
87
|
//初始的expressType
|
87
|
//初始的expressType
|
88
|
- Byte initExpressType=0;
|
|
|
89
|
- ExpressRecord firstExpressRecord = expressRecordMapper.queryExpressRecord(uid,orderCode,waybillCode);
|
|
|
90
|
- if(firstExpressRecord==null){
|
|
|
91
|
- LOGGER.warn("updateExpressInfo first express info not exist, uid is {} orderCode is {} waybillCode is {}", uid,orderCode,waybillCode);
|
88
|
+ Byte initExpressType = 0;
|
|
|
89
|
+ ExpressRecord firstExpressRecord = expressRecordMapper.queryExpressRecord(uid, orderCode, waybillCode);
|
|
|
90
|
+ if (firstExpressRecord == null) {
|
|
|
91
|
+ LOGGER.warn("updateExpressInfo first express info not exist, uid is {} orderCode is {} waybillCode is {}", uid, orderCode, waybillCode);
|
92
|
//throw new ServiceException(400,"not find express type info");
|
92
|
//throw new ServiceException(400,"not find express type info");
|
93
|
- }else{
|
93
|
+ } else {
|
94
|
initExpressType = firstExpressRecord.getExpressType();
|
94
|
initExpressType = firstExpressRecord.getExpressType();
|
95
|
- if(initExpressType==null){
|
|
|
96
|
- LOGGER.warn("updateExpressInfo first express info express type is null, uid is {} orderCode is {} waybillCode is {}", uid,orderCode,waybillCode);
|
95
|
+ if (initExpressType == null) {
|
|
|
96
|
+ LOGGER.warn("updateExpressInfo first express info express type is null, uid is {} orderCode is {} waybillCode is {}", uid, orderCode, waybillCode);
|
97
|
initExpressType = 0;
|
97
|
initExpressType = 0;
|
98
|
}
|
98
|
}
|
99
|
}
|
99
|
}
|
100
|
|
100
|
|
101
|
// 正常订单,签收消息
|
101
|
// 正常订单,签收消息
|
102
|
if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) {
|
102
|
if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) {
|
103
|
- handleAcceptExpress(erpExpressBo,initExpressType);
|
103
|
+ handleAcceptExpress(erpExpressBo, initExpressType);
|
104
|
return;
|
104
|
return;
|
105
|
}
|
105
|
}
|
106
|
|
106
|
|
|
@@ -111,23 +111,22 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -111,23 +111,22 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
111
|
state = ExpressInfoConstant.EXPRESS_STATUS_UNSEND;
|
111
|
state = ExpressInfoConstant.EXPRESS_STATUS_UNSEND;
|
112
|
}
|
112
|
}
|
113
|
|
113
|
|
114
|
- processExpressInfo( state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, initExpressType);
|
114
|
+ processExpressInfo(state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, initExpressType);
|
115
|
}
|
115
|
}
|
116
|
|
116
|
|
117
|
/**
|
117
|
/**
|
118
|
- *
|
|
|
119
|
- * @param state 快递状态
|
|
|
120
|
- * @param logisticsType 快递公司id
|
|
|
121
|
- * @param orderCode 订单号
|
|
|
122
|
- * @param waybillCode 快递单号
|
|
|
123
|
- * @param acceptAddress 运单接收地
|
|
|
124
|
- * @param acceptRemark 运单信息
|
|
|
125
|
- * @param createTime 创建时间
|
118
|
+ * @param state 快递状态
|
|
|
119
|
+ * @param logisticsType 快递公司id
|
|
|
120
|
+ * @param orderCode 订单号
|
|
|
121
|
+ * @param waybillCode 快递单号
|
|
|
122
|
+ * @param acceptAddress 运单接收地
|
|
|
123
|
+ * @param acceptRemark 运单信息
|
|
|
124
|
+ * @param createTime 创建时间
|
126
|
* @param uid
|
125
|
* @param uid
|
127
|
* @param initExpressType 物流类型
|
126
|
* @param initExpressType 物流类型
|
128
|
*/
|
127
|
*/
|
129
|
- private void processExpressInfo( Integer state, Integer logisticsType, Long orderCode, String waybillCode,
|
|
|
130
|
- String acceptAddress, String acceptRemark, Integer createTime, Integer uid, Byte initExpressType) {
|
128
|
+ private void processExpressInfo(Integer state, Integer logisticsType, Long orderCode, String waybillCode,
|
|
|
129
|
+ String acceptAddress, String acceptRemark, Integer createTime, Integer uid, Byte initExpressType) {
|
131
|
|
130
|
|
132
|
ExpressInfo expressInfo = new ExpressInfo();
|
131
|
ExpressInfo expressInfo = new ExpressInfo();
|
133
|
expressInfo.setDataType(EnumExpressDataType.erp_logistics.getCode());
|
132
|
expressInfo.setDataType(EnumExpressDataType.erp_logistics.getCode());
|
|
@@ -140,6 +139,13 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -140,6 +139,13 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
140
|
expressInfo.setCreateTime(createTime);
|
139
|
expressInfo.setCreateTime(createTime);
|
141
|
expressInfo.setExpressType(initExpressType);
|
140
|
expressInfo.setExpressType(initExpressType);
|
142
|
expressInfo.setState(state);
|
141
|
expressInfo.setState(state);
|
|
|
142
|
+ // 武汉疫情鉴定中心不能收货,重置物流文案
|
|
|
143
|
+ if (isWuhanNewpneumoniaHolidayTime()
|
|
|
144
|
+ && isSellerSendExpress(expressInfo)
|
|
|
145
|
+ && StringUtils.contains(expressInfo.getAcceptRemark(), "因休息日或假期客户不便收件")
|
|
|
146
|
+ ) {
|
|
|
147
|
+ expressInfo.setAcceptRemark("受疫情影响,平台将于2月10日开始收货");
|
|
|
148
|
+ }
|
143
|
|
149
|
|
144
|
// 中通国际快递公司,存在物流则表示清关成功
|
150
|
// 中通国际快递公司,存在物流则表示清关成功
|
145
|
if (LogisticsTypes.isZtoInternational(logisticsType) && isHkClearSuccess(acceptAddress, acceptRemark)) {
|
151
|
if (LogisticsTypes.isZtoInternational(logisticsType) && isHkClearSuccess(acceptAddress, acceptRemark)) {
|
|
@@ -147,7 +153,13 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -147,7 +153,13 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
147
|
}
|
153
|
}
|
148
|
expressInfoMapper.insert(expressInfo);
|
154
|
expressInfoMapper.insert(expressInfo);
|
149
|
|
155
|
|
150
|
- updateSellerDeliverStatusAfterInsertExpress(orderCode,expressInfo);
|
156
|
+ updateSellerDeliverStatusAfterInsertExpress(orderCode, expressInfo);
|
|
|
157
|
+ }
|
|
|
158
|
+
|
|
|
159
|
+ private boolean isWuhanNewpneumoniaHolidayTime() {
|
|
|
160
|
+ int now = DateUtil.getCurrentTimeSecond();
|
|
|
161
|
+ // 武汉疫情鉴定中心不能收货(2020-01-30 23:59:59到2020-02-09 23:59:59)
|
|
|
162
|
+ return now > 1580399999 && now <= 1581263999;
|
151
|
}
|
163
|
}
|
152
|
|
164
|
|
153
|
/**
|
165
|
/**
|
|
@@ -160,11 +172,10 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -160,11 +172,10 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
160
|
}
|
172
|
}
|
161
|
|
173
|
|
162
|
|
174
|
|
163
|
-
|
|
|
164
|
/**
|
175
|
/**
|
165
|
* 确认收货处理
|
176
|
* 确认收货处理
|
166
|
*/
|
177
|
*/
|
167
|
- private void handleAcceptExpress(ErpExpressBo erpExpressBo,Byte expressType) {
|
178
|
+ private void handleAcceptExpress(ErpExpressBo erpExpressBo, Byte expressType) {
|
168
|
String waybillCode = erpExpressBo.getWaybillCode();
|
179
|
String waybillCode = erpExpressBo.getWaybillCode();
|
169
|
int logisticsType = erpExpressBo.getLogisticsType();
|
180
|
int logisticsType = erpExpressBo.getLogisticsType();
|
170
|
String acceptAddress = erpExpressBo.getAcceptAddress();
|
181
|
String acceptAddress = erpExpressBo.getAcceptAddress();
|
|
@@ -174,14 +185,14 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -174,14 +185,14 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
174
|
int uid = erpExpressBo.getUid();
|
185
|
int uid = erpExpressBo.getUid();
|
175
|
|
186
|
|
176
|
int createTime = erpExpressBo.getCreateTime();
|
187
|
int createTime = erpExpressBo.getCreateTime();
|
177
|
- if(createTime<=0){
|
188
|
+ if (createTime <= 0) {
|
178
|
createTime = DateUtil.getCurrentTimeSecond();
|
189
|
createTime = DateUtil.getCurrentTimeSecond();
|
179
|
}
|
190
|
}
|
180
|
|
191
|
|
181
|
|
192
|
|
182
|
// TODO 只有鉴定中心到买家的类型 ,才需要确认收货的,需要调用
|
193
|
// TODO 只有鉴定中心到买家的类型 ,才需要确认收货的,需要调用
|
183
|
- if(expressType!=null&&EnumExpressType.EXPRESS_TYPE_2.getCode().intValue()==expressType.intValue()){
|
|
|
184
|
- LOGGER.info("handle accept express,orderCode {},uid {},waybillCode {},state {} ", orderCode,uid,waybillCode,state);
|
194
|
+ if (expressType != null && EnumExpressType.EXPRESS_TYPE_2.getCode().intValue() == expressType.intValue()) {
|
|
|
195
|
+ LOGGER.info("handle accept express,orderCode {},uid {},waybillCode {},state {} ", orderCode, uid, waybillCode, state);
|
185
|
/* 暂时注释掉,等香港仓开发上线
|
196
|
/* 暂时注释掉,等香港仓开发上线
|
186
|
executorService.execute(() -> {
|
197
|
executorService.execute(() -> {
|
187
|
OrderRequest orderRequest = OrderRequest.builder()
|
198
|
OrderRequest orderRequest = OrderRequest.builder()
|
|
@@ -193,32 +204,37 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -193,32 +204,37 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
193
|
});
|
204
|
});
|
194
|
*/
|
205
|
*/
|
195
|
}
|
206
|
}
|
196
|
- processExpressInfo( state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType);
|
207
|
+ processExpressInfo(state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType);
|
197
|
}
|
208
|
}
|
198
|
|
209
|
|
199
|
|
210
|
|
200
|
- private void updateSellerDeliverStatusAfterInsertExpress(long orderCode,ExpressInfo expressInfo ){
|
211
|
+ private void updateSellerDeliverStatusAfterInsertExpress(long orderCode, ExpressInfo expressInfo) {
|
201
|
//卖家物流的情形
|
212
|
//卖家物流的情形
|
202
|
- LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus enter orderCode {}",orderCode);
|
|
|
203
|
- if(expressInfo.getExpressType()!=null&&expressInfo.getExpressType().intValue()== EnumExpressType.EXPRESS_TYPE_1.getCode().intValue()){
|
213
|
+ LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus enter orderCode {}", orderCode);
|
|
|
214
|
+ if (isSellerSendExpress(expressInfo)) {
|
204
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
215
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
205
|
- if(buyerOrder==null){
|
216
|
+ if (buyerOrder == null) {
|
206
|
LOGGER.warn("ExpressInfoUpdateConsumer updateSellerDeliverStatus buyerOrder is null,order code {} ", orderCode);
|
217
|
LOGGER.warn("ExpressInfoUpdateConsumer updateSellerDeliverStatus buyerOrder is null,order code {} ", orderCode);
|
207
|
- return ;
|
218
|
+ return;
|
208
|
}
|
219
|
}
|
209
|
- if(buyerOrder.getSellerDeliveryStatus()==null||buyerOrder.getSellerDeliveryStatus().intValue()==0){
|
220
|
+ if (buyerOrder.getSellerDeliveryStatus() == null || buyerOrder.getSellerDeliveryStatus().intValue() == 0) {
|
210
|
//卖家发货的物流存在,但是状态仍然是未更新,更新一下就可以了
|
221
|
//卖家发货的物流存在,但是状态仍然是未更新,更新一下就可以了
|
211
|
buyerOrderMapper.updateSellerDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
222
|
buyerOrderMapper.updateSellerDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
212
|
1);
|
223
|
1);
|
213
|
- LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus with express info ,buyerOrder {},expressInfo {} ", buyerOrder,expressInfo);
|
224
|
+ LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus with express info ,buyerOrder {},expressInfo {} ", buyerOrder, expressInfo);
|
214
|
}
|
225
|
}
|
215
|
}
|
226
|
}
|
216
|
}
|
227
|
}
|
217
|
-
|
228
|
+
|
|
|
229
|
+ private boolean isSellerSendExpress(ExpressInfo expressInfo) {
|
|
|
230
|
+ return expressInfo.getExpressType() != null
|
|
|
231
|
+ && expressInfo.getExpressType().intValue() == EnumExpressType.EXPRESS_TYPE_1.getCode().intValue();
|
|
|
232
|
+ }
|
|
|
233
|
+
|
218
|
private ErpExpressBo convertErpJsonToObject(Object message) {
|
234
|
private ErpExpressBo convertErpJsonToObject(Object message) {
|
219
|
- try{
|
235
|
+ try {
|
220
|
JSONObject jsonMsg = JSONObject.parseObject(message.toString());
|
236
|
JSONObject jsonMsg = JSONObject.parseObject(message.toString());
|
221
|
- ErpExpressBo bo=new ErpExpressBo();
|
237
|
+ ErpExpressBo bo = new ErpExpressBo();
|
222
|
bo.setBusinessType(jsonMsg.getIntValue("businessType"));
|
238
|
bo.setBusinessType(jsonMsg.getIntValue("businessType"));
|
223
|
bo.setWaybillCode(jsonMsg.getString("waybillCode"));
|
239
|
bo.setWaybillCode(jsonMsg.getString("waybillCode"));
|
224
|
bo.setLogisticsType(jsonMsg.getIntValue("logisticsType"));
|
240
|
bo.setLogisticsType(jsonMsg.getIntValue("logisticsType"));
|
|
@@ -230,7 +246,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
@@ -230,7 +246,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
230
|
bo.setUid(jsonMsg.getIntValue("uid"));
|
246
|
bo.setUid(jsonMsg.getIntValue("uid"));
|
231
|
bo.setOrderCode(jsonMsg.getLongValue("orderCode"));
|
247
|
bo.setOrderCode(jsonMsg.getLongValue("orderCode"));
|
232
|
return bo;
|
248
|
return bo;
|
233
|
- }catch (Exception e){
|
249
|
+ } catch (Exception e) {
|
234
|
LOGGER.warn("convertErpJsonToObject express info message error,message is {}.", message);
|
250
|
LOGGER.warn("convertErpJsonToObject express info message error,message is {}.", message);
|
235
|
return null;
|
251
|
return null;
|
236
|
}
|
252
|
}
|