...
|
...
|
@@ -27,7 +27,7 @@ import org.springframework.stereotype.Component; |
|
|
@Component
|
|
|
public class ExpressInfoUpdateConsumer implements YhConsumer {
|
|
|
|
|
|
private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
|
|
|
private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
|
|
|
|
|
|
|
|
|
private final String topic = "ufo.order.updateExpressInfo";
|
...
|
...
|
@@ -64,7 +64,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
|
|
|
|
private void updateExpressInfo(Object message) {
|
|
|
ErpExpressBo erpExpressBo = convertErpJsonToObject(message);
|
|
|
if (erpExpressBo==null||!checkValidMessage(erpExpressBo)) {
|
|
|
if (erpExpressBo == null || !checkValidMessage(erpExpressBo)) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -85,22 +85,22 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
|
|
|
|
//根据uid,orderCode,waybillCode查状态expressType
|
|
|
//初始的expressType
|
|
|
Byte initExpressType=0;
|
|
|
ExpressRecord firstExpressRecord = expressRecordMapper.queryExpressRecord(uid,orderCode,waybillCode);
|
|
|
if(firstExpressRecord==null){
|
|
|
LOGGER.warn("updateExpressInfo first express info not exist, uid is {} orderCode is {} waybillCode is {}", uid,orderCode,waybillCode);
|
|
|
Byte initExpressType = 0;
|
|
|
ExpressRecord firstExpressRecord = expressRecordMapper.queryExpressRecord(uid, orderCode, waybillCode);
|
|
|
if (firstExpressRecord == null) {
|
|
|
LOGGER.warn("updateExpressInfo first express info not exist, uid is {} orderCode is {} waybillCode is {}", uid, orderCode, waybillCode);
|
|
|
//throw new ServiceException(400,"not find express type info");
|
|
|
}else{
|
|
|
} else {
|
|
|
initExpressType = firstExpressRecord.getExpressType();
|
|
|
if(initExpressType==null){
|
|
|
LOGGER.warn("updateExpressInfo first express info express type is null, uid is {} orderCode is {} waybillCode is {}", uid,orderCode,waybillCode);
|
|
|
if (initExpressType == null) {
|
|
|
LOGGER.warn("updateExpressInfo first express info express type is null, uid is {} orderCode is {} waybillCode is {}", uid, orderCode, waybillCode);
|
|
|
initExpressType = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 正常订单,签收消息
|
|
|
if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) {
|
|
|
handleAcceptExpress(erpExpressBo,initExpressType);
|
|
|
handleAcceptExpress(erpExpressBo, initExpressType);
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -111,23 +111,22 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
|
state = ExpressInfoConstant.EXPRESS_STATUS_UNSEND;
|
|
|
}
|
|
|
|
|
|
processExpressInfo( state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, initExpressType);
|
|
|
processExpressInfo(state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, initExpressType);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param state 快递状态
|
|
|
* @param logisticsType 快递公司id
|
|
|
* @param orderCode 订单号
|
|
|
* @param waybillCode 快递单号
|
|
|
* @param acceptAddress 运单接收地
|
|
|
* @param acceptRemark 运单信息
|
|
|
* @param createTime 创建时间
|
|
|
* @param state 快递状态
|
|
|
* @param logisticsType 快递公司id
|
|
|
* @param orderCode 订单号
|
|
|
* @param waybillCode 快递单号
|
|
|
* @param acceptAddress 运单接收地
|
|
|
* @param acceptRemark 运单信息
|
|
|
* @param createTime 创建时间
|
|
|
* @param uid
|
|
|
* @param initExpressType 物流类型
|
|
|
*/
|
|
|
private void processExpressInfo( Integer state, Integer logisticsType, Long orderCode, String waybillCode,
|
|
|
String acceptAddress, String acceptRemark, Integer createTime, Integer uid, Byte initExpressType) {
|
|
|
private void processExpressInfo(Integer state, Integer logisticsType, Long orderCode, String waybillCode,
|
|
|
String acceptAddress, String acceptRemark, Integer createTime, Integer uid, Byte initExpressType) {
|
|
|
|
|
|
ExpressInfo expressInfo = new ExpressInfo();
|
|
|
expressInfo.setDataType(EnumExpressDataType.erp_logistics.getCode());
|
...
|
...
|
@@ -140,6 +139,13 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
|
expressInfo.setCreateTime(createTime);
|
|
|
expressInfo.setExpressType(initExpressType);
|
|
|
expressInfo.setState(state);
|
|
|
// 武汉疫情鉴定中心不能收货,重置物流文案
|
|
|
if (isWuhanNewpneumoniaHolidayTime()
|
|
|
&& isSellerSendExpress(expressInfo)
|
|
|
&& StringUtils.contains(expressInfo.getAcceptRemark(), "因休息日或假期客户不便收件")
|
|
|
) {
|
|
|
expressInfo.setAcceptRemark("受疫情影响,平台将于2月10日开始收货");
|
|
|
}
|
|
|
|
|
|
// 中通国际快递公司,存在物流则表示清关成功
|
|
|
if (LogisticsTypes.isZtoInternational(logisticsType) && isHkClearSuccess(acceptAddress, acceptRemark)) {
|
...
|
...
|
@@ -147,7 +153,13 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
|
}
|
|
|
expressInfoMapper.insert(expressInfo);
|
|
|
|
|
|
updateSellerDeliverStatusAfterInsertExpress(orderCode,expressInfo);
|
|
|
updateSellerDeliverStatusAfterInsertExpress(orderCode, expressInfo);
|
|
|
}
|
|
|
|
|
|
private boolean isWuhanNewpneumoniaHolidayTime() {
|
|
|
int now = DateUtil.getCurrentTimeSecond();
|
|
|
// 武汉疫情鉴定中心不能收货(2020-01-30 23:59:59到2020-02-09 23:59:59)
|
|
|
return now > 1580399999 && now <= 1581263999;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -160,11 +172,10 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 确认收货处理
|
|
|
*/
|
|
|
private void handleAcceptExpress(ErpExpressBo erpExpressBo,Byte expressType) {
|
|
|
private void handleAcceptExpress(ErpExpressBo erpExpressBo, Byte expressType) {
|
|
|
String waybillCode = erpExpressBo.getWaybillCode();
|
|
|
int logisticsType = erpExpressBo.getLogisticsType();
|
|
|
String acceptAddress = erpExpressBo.getAcceptAddress();
|
...
|
...
|
@@ -174,14 +185,14 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
|
int uid = erpExpressBo.getUid();
|
|
|
|
|
|
int createTime = erpExpressBo.getCreateTime();
|
|
|
if(createTime<=0){
|
|
|
if (createTime <= 0) {
|
|
|
createTime = DateUtil.getCurrentTimeSecond();
|
|
|
}
|
|
|
|
|
|
|
|
|
// TODO 只有鉴定中心到买家的类型 ,才需要确认收货的,需要调用
|
|
|
if(expressType!=null&&EnumExpressType.EXPRESS_TYPE_2.getCode().intValue()==expressType.intValue()){
|
|
|
LOGGER.info("handle accept express,orderCode {},uid {},waybillCode {},state {} ", orderCode,uid,waybillCode,state);
|
|
|
if (expressType != null && EnumExpressType.EXPRESS_TYPE_2.getCode().intValue() == expressType.intValue()) {
|
|
|
LOGGER.info("handle accept express,orderCode {},uid {},waybillCode {},state {} ", orderCode, uid, waybillCode, state);
|
|
|
/* 暂时注释掉,等香港仓开发上线
|
|
|
executorService.execute(() -> {
|
|
|
OrderRequest orderRequest = OrderRequest.builder()
|
...
|
...
|
@@ -193,32 +204,37 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
|
});
|
|
|
*/
|
|
|
}
|
|
|
processExpressInfo( state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType);
|
|
|
processExpressInfo(state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType);
|
|
|
}
|
|
|
|
|
|
|
|
|
private void updateSellerDeliverStatusAfterInsertExpress(long orderCode,ExpressInfo expressInfo ){
|
|
|
private void updateSellerDeliverStatusAfterInsertExpress(long orderCode, ExpressInfo expressInfo) {
|
|
|
//卖家物流的情形
|
|
|
LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus enter orderCode {}",orderCode);
|
|
|
if(expressInfo.getExpressType()!=null&&expressInfo.getExpressType().intValue()== EnumExpressType.EXPRESS_TYPE_1.getCode().intValue()){
|
|
|
LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus enter orderCode {}", orderCode);
|
|
|
if (isSellerSendExpress(expressInfo)) {
|
|
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
if(buyerOrder==null){
|
|
|
if (buyerOrder == null) {
|
|
|
LOGGER.warn("ExpressInfoUpdateConsumer updateSellerDeliverStatus buyerOrder is null,order code {} ", orderCode);
|
|
|
return ;
|
|
|
return;
|
|
|
}
|
|
|
if(buyerOrder.getSellerDeliveryStatus()==null||buyerOrder.getSellerDeliveryStatus().intValue()==0){
|
|
|
if (buyerOrder.getSellerDeliveryStatus() == null || buyerOrder.getSellerDeliveryStatus().intValue() == 0) {
|
|
|
//卖家发货的物流存在,但是状态仍然是未更新,更新一下就可以了
|
|
|
buyerOrderMapper.updateSellerDeliveryStatusByOrderCode(orderCode, buyerOrder.getUid(),
|
|
|
1);
|
|
|
LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus with express info ,buyerOrder {},expressInfo {} ", buyerOrder,expressInfo);
|
|
|
LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus with express info ,buyerOrder {},expressInfo {} ", buyerOrder, expressInfo);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
private boolean isSellerSendExpress(ExpressInfo expressInfo) {
|
|
|
return expressInfo.getExpressType() != null
|
|
|
&& expressInfo.getExpressType().intValue() == EnumExpressType.EXPRESS_TYPE_1.getCode().intValue();
|
|
|
}
|
|
|
|
|
|
private ErpExpressBo convertErpJsonToObject(Object message) {
|
|
|
try{
|
|
|
try {
|
|
|
JSONObject jsonMsg = JSONObject.parseObject(message.toString());
|
|
|
ErpExpressBo bo=new ErpExpressBo();
|
|
|
ErpExpressBo bo = new ErpExpressBo();
|
|
|
bo.setBusinessType(jsonMsg.getIntValue("businessType"));
|
|
|
bo.setWaybillCode(jsonMsg.getString("waybillCode"));
|
|
|
bo.setLogisticsType(jsonMsg.getIntValue("logisticsType"));
|
...
|
...
|
@@ -230,7 +246,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger(); |
|
|
bo.setUid(jsonMsg.getIntValue("uid"));
|
|
|
bo.setOrderCode(jsonMsg.getLongValue("orderCode"));
|
|
|
return bo;
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.warn("convertErpJsonToObject express info message error,message is {}.", message);
|
|
|
return null;
|
|
|
}
|
...
|
...
|
|