Authored by qinchao

优化物流

... ... @@ -101,7 +101,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
// 正常订单,签收消息
if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) {
handleAcceptExpress(erpExpressBo,initExpressType.intValue());
handleAcceptExpress(erpExpressBo,initExpressType);
return;
}
... ... @@ -110,14 +110,31 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
&& logisticsType < 1
&& (StringUtils.isEmpty(waybillCode) || StringUtils.equals(waybillCode, "0"))) {
state = ExpressInfoConstant.EXPRESS_STATUS_UNSEND;
}
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 uid
* @param 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());
expressInfo.setUid(uid);
expressInfo.setOrderCode(orderCode);
expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode));
expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode).trim());
expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress));
expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark));
expressInfo.setLogisticsType(logisticsType);
... ... @@ -125,9 +142,31 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
expressInfo.setExpressType(initExpressType);
expressInfo.setState(state);
expressInfoMapper.insert(expressInfo);
updateSellerDeliverStatusAfterInsertExpress(orderCode,expressInfo);
}
/**
* 确认收货处理
*/
private void handleAcceptExpress(ErpExpressBo erpExpressBo,Byte expressType) {
String waybillCode = erpExpressBo.getWaybillCode();
int logisticsType = erpExpressBo.getLogisticsType();
String acceptAddress = erpExpressBo.getAcceptAddress();
String acceptRemark = erpExpressBo.getAcceptRemark();
int state = erpExpressBo.getState();
long orderCode = erpExpressBo.getOrderCode();
int uid = erpExpressBo.getUid();
int createTime = erpExpressBo.getCreateTime();
if(createTime<=0){
createTime = DateUtil.getCurrentTimeSecond();
}
processExpressInfo( state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType);
}
private void updateSellerDeliverStatusAfterInsertExpress(long orderCode,ExpressInfo expressInfo ){
//卖家物流的情形
LOGGER.info("ExpressInfoUpdateConsumer update SellerDeliveryStatus enter orderCode {}",orderCode);
... ... @@ -145,7 +184,7 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
}
}
}
private ErpExpressBo convertErpJsonToObject(Object message) {
try{
JSONObject jsonMsg = JSONObject.parseObject(message.toString());
... ... @@ -185,74 +224,4 @@ private static final Logger LOGGER = LoggerUtils.getMqConsumerLogger();
return flag;
}
/**
* 确认收货处理
*/
private void handleAcceptExpress(ErpExpressBo erpExpressBo,Integer expressType) {
String waybillCode = erpExpressBo.getWaybillCode();
int logisticsType = erpExpressBo.getLogisticsType();
String acceptAddress = erpExpressBo.getAcceptAddress();
String acceptRemark = erpExpressBo.getAcceptRemark();
int state = erpExpressBo.getState();
long orderCode = erpExpressBo.getOrderCode();
int uid = erpExpressBo.getUid();
int createTime = erpExpressBo.getCreateTime();
if(createTime<=0){
createTime = DateUtil.getCurrentTimeSecond();
}
//快递100推送过来的数据,如果当前订单已经被签收,则所有推送过来的记录都是已签收,原来的for循环逻辑只能存一条签收记录,
//因此修改为以下方式,不管如何都直接存下来。
List<ExpressInfo> expressInfos = null;
processExpressInfo(expressInfos, state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType);
}
/**
*
* @param expressInfos 快递信息
* @param state 快递状态
* @param logisticsType 快递公司id
* @param orderCode 订单号
* @param waybillCode 快递单号
* @param acceptAddress 运单接收地
* @param acceptRemark 运单信息
* @param createTime 创建时间
* @param uid
* @param expressType 物流类型
*/
private void processExpressInfo(List<ExpressInfo> expressInfos, Integer state, Integer logisticsType, Long orderCode, String waybillCode,
String acceptAddress, String acceptRemark, Integer createTime, Integer uid, Integer expressType) {
if (CollectionUtils.isEmpty(expressInfos)) {
ExpressInfo expressInfo = new ExpressInfo();
expressInfo.setDataType(EnumExpressDataType.erp_logistics.getCode());
expressInfo.setState(state);
expressInfo.setLogisticsType(logisticsType);
expressInfo.setOrderCode(orderCode);
expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode));
expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress));
expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark));
expressInfo.setCreateTime(createTime);
expressInfo.setUid(uid);
expressInfo.setExpressType(expressType.byteValue());
expressInfoMapper.insert(expressInfo);
updateSellerDeliverStatusAfterInsertExpress(orderCode,expressInfo);
} /*else {
for (ExpressInfo expressInfo : expressInfos) {
expressInfo.setDataType(EnumExpressDataType.erp_logistics.getCode());
expressInfo.setState(state);
expressInfo.setLogisticsType(logisticsType);
expressInfo.setOrderCode(orderCode);
expressInfo.setWaybillCode(StringUtils.defaultString(waybillCode));
expressInfo.setAcceptAddress(StringUtils.defaultString(acceptAddress));
expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark));
expressInfo.setCreateTime(createTime);
expressInfo.setUid(uid);
expressInfo.setExpressType(expressType.byteValue());
expressInfoMapper.updateByPrimaryKeySelective(expressInfo);
}
}*/
}
}
\ No newline at end of file
... ...