Authored by LUOXC

Merge branch 'master' into test6.9.21

package com.yohoufo.common.config;
import com.yoho.core.config.ConfigReader;
import com.yohobuy.ufo.model.order.constants.DepotType;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Slf4j
@Service
public class SpecialTimeConfigReader {
@Autowired
private ConfigReader configReader;
/**
* 特殊时期
*
* @return
*/
public Pair<Integer, Integer> specialTimeRange() {
// 2020.1.31武汉病毒(2020-01-30 23:59:59到2020-02-29 23:59:59)
Pair<Integer, Integer> specialTimeRange = Pair.of(1580399999, 1582991999);
return specialTimeRange;
}
public Optional<DepotType> specialTimeDepotType(Integer time) {
Pair<Integer, Integer> specialTimeRange = specialTimeRange();
boolean isAtSpecialTime = time > specialTimeRange.getLeft() && time <= specialTimeRange.getRight();
if (isAtSpecialTime) {
return Optional.of(DepotType.NJ);
} else {
return Optional.empty();
}
}
}
... ...
... ... @@ -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;
}
... ...
... ... @@ -21,6 +21,7 @@ import com.yohobuy.ufo.model.order.resp.MiniFaultForSecondDetail;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.resp.product.SecondDetailResp;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.config.SpecialTimeConfigReader;
import com.yohoufo.common.constant.ExpressInfoConstant;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.lock.RedisLock;
... ... @@ -52,6 +53,7 @@ import com.yohoufo.order.utils.OrderAssist;
import lombok.NonNull;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -60,6 +62,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
... ... @@ -152,6 +155,8 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
@Autowired
private SellerService sellerService;
@Autowired
private SpecialTimeConfigReader specialTimeConfigReader;
private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data";
... ... @@ -1503,7 +1508,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
String deliverDesc=SellerConfig.DeliverDesc.SELLER_DEPOSIT_ORDER;
switch (oa){
case APPRAISE:
depotType = DepotType.BJ;
depotType = DepotType.NJ;
deliverDesc = SellerConfig.DeliverDesc.APPRAISE_ORDER;
break;
case DEPOSITE:
... ... @@ -1525,6 +1530,14 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
return resp;
}
Optional<DepotType> specialTimeDepotType = specialTimeConfigReader.specialTimeDepotType(DateUtil.getCurrentTimeSecond());
if(specialTimeDepotType.isPresent()){
resp = appraiseAddressService.findByDepotType(specialTimeDepotType.get().getCode());
resp.setDeliverDesc(commonDeliverDescSupplier.get());
resp.setWarnTips(warnTipsSupplier.get());
return resp;
}
//寄存订单
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
... ...
... ... @@ -13,6 +13,7 @@ import com.yohobuy.ufo.model.order.constants.OrderDetailDesc;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.config.SpecialTimeConfigReader;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
... ... @@ -39,12 +40,14 @@ import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.order.service.wrapper.SellerOrderTimeoutWrapper;
import com.yohoufo.order.utils.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Predicate;
import java.util.function.Supplier;
/**
... ... @@ -96,6 +99,8 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
@Autowired
private SellerGoodsStatusFlowMapper sellerGoodsStatusFlowMapper;
@Autowired
private SpecialTimeConfigReader specialTimeConfigReader;
private static List<SkupStatus> noNeedShowOrderCode = Arrays.asList(SkupStatus.CAN_NOT_SELL,SkupStatus.CAN_SELL,
... ... @@ -180,18 +185,23 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
Integer pboa = pbo.getAttributes();
boolean isQuickDeliver = SellerGoodsHelper.isQuickDeliver(skupType);
boolean isInstockDepositOrder = BuyerOrderUtils.isInstockDeposit(skupType, pboa);
boolean isSpecialDepot = isInstockDepositOrder;
boolean isAssignNjDepot = isInstockDepositOrder;
AppraiseAddressInfo aai = null;
//big prepare condition : not isQuickDeliver
if(!isQuickDeliver){
if (isSpecialDepot) {
if (!isQuickDeliver) {
if (isAssignNjDepot) {
AppraiseAddressResp aaResp = appraiseAddressService.findByDepotType(DepotType.NJ.getCode());
aai = AppraiseAddressService.convert2AppraiseAddressInfo(aaResp);
}else {
// 收货地址 and 用户信息
} else {
// 卖家寄回收货地址
if (Objects.nonNull(buildNode.userAddress)) {
//卖家订单详情里才会有,买家没有
aai = appraiseAddressService.findAppraiseAddress(buildNode.userAddress.getAreaCode());
Optional<DepotType> specialTimeDepotType = specialTimeConfigReader.specialTimeDepotType(pbo.getCreateTime());
if (specialTimeDepotType.isPresent()) {
AppraiseAddressResp aaResp = appraiseAddressService.findByDepotType(specialTimeDepotType.get().getCode());
aai = AppraiseAddressService.convert2AppraiseAddressInfo(aaResp);
} else {
aai = appraiseAddressService.findAppraiseAddress(buildNode.userAddress.getAreaCode());
}
}
}
orderDetailInfo.setAppraiseAddress(aai);
... ...