Authored by tanling

Merge branch 'test6.9.14' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.14

... ... @@ -152,6 +152,6 @@
<update id="updateValue" parameterType="com.yohoufo.dal.order.model.SellerOrderMeta">
update seller_order_meta
set meta_value = #{metaValue,jdbcType=VARCHAR}
where skup = #{sourceSkup,jdbcType=INTEGER} and meta_key = #{metaKey,jdbcType=VARCHAR}
where skup = #{skup,jdbcType=INTEGER} and meta_key = #{metaKey,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -62,16 +62,18 @@ public class AddressInfoConvertor {
return addressInfo;
}
public static void mergeChangedAddress4NoHidden(AddressInfo noHiddenAddress,OrderAddressReq req){
noHiddenAddress.setArea(req.getArea());
noHiddenAddress.setMobile(req.getMobile());
noHiddenAddress.setConsignee(req.getConsignee());
noHiddenAddress.setAddress(req.getAddress());
public static void mergeChangedAddress4NoHidden(AddressInfo noHiddenAddress,AddressInfo changedAddress, OrderAddressReq req){
noHiddenAddress.setArea(changedAddress.getArea());
noHiddenAddress.setMobile(changedAddress.getMobile());
noHiddenAddress.setConsignee(changedAddress.getConsignee());
noHiddenAddress.setAddress(changedAddress.getAddress());
noHiddenAddress.setSelfModifyTimes(calSelfModifyTimes(req.isFromPlatform()));
}
public static void mergeChangedAddress4Hidden(AddressInfo hiddenAddress,OrderAddressReq req,AddressInfo hiddenAddressTemp){
public static void mergeChangedAddress4Hidden(AddressInfo hiddenAddress,
OrderAddressReq req,
AddressInfo hiddenAddressTemp){
hiddenAddress.setArea(req.getArea());
hiddenAddress.setMobile(hiddenAddressTemp.getMobile());
hiddenAddress.setConsignee(hiddenAddressTemp.getConsignee());
... ...
... ... @@ -28,4 +28,14 @@ public class DeliverNoticeEvent extends Event{
private long orderCode;
private int orderAttributes;
/**
* 剩余发货时间
*/
private Integer minutesOfLeft;
private Integer times;
}
... ...
... ... @@ -2,7 +2,9 @@ package com.yohoufo.order.mq.consumer;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yohobuy.ufo.model.order.bo.IntervalBo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
... ... @@ -10,6 +12,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.event.DeliverNoticeEvent;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.service.proxy.DeliveryMinutesService;
import com.yohoufo.order.service.proxy.SellerNoticeFacade;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
... ... @@ -35,11 +38,21 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer {
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
/**
* 当前通知的次数
*/
private static final int defaultTimes = 2;
/**
* 单位 : 小时
*/
private static final int defaultLeftTime = 12;
private static final int MAX_TIMES = 3;
@Override
public void handleMessage(Object o) throws Exception {
LOGGER.info("in topic {}, msg {}", TopicConstants.ORDER_NOT_DELIVER_NOTICE, o);
final String topic = TopicConstants.ORDER_NOT_DELIVER_NOTICE;
LOGGER.info("in topic {}, msg {}", topic, o);
if (Objects.isNull(o)){
return;
}
... ... @@ -48,11 +61,40 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer {
int buyerUid;
long orderCode;
if ((buyerUid = msg.getBuyerUid()) < 0 || (orderCode=msg.getOrderCode())< 0L){
LOGGER.warn("fail in {}, msg {}", TopicConstants.ORDER_NOT_DELIVER_NOTICE, msg);
LOGGER.warn("fail in {}, msg {}", topic, msg);
return;
}
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, buyerUid);
if(OrderStatus.HAS_PAYED.getCode() == buyerOrder.getStatus().intValue()){
//之前没有这个属性,兼容老数据
final Integer currentTimes = msg.getTimes() == null ? defaultTimes : msg.getTimes();
final int maxTimes = MAX_TIMES;
IntervalBo intervalBo = null;
if (maxTimes>currentTimes){
intervalBo = DeliveryMinutesService.calculateNextInterval(currentTimes, DeliveryMinutesService.getTotalMinutes(), DeliveryMinutesService.getDelayTime());
LOGGER.info("in topic {}, msg {} intervalBo {}", topic, msg, intervalBo);
}
int leftHours = msg.getMinutesOfLeft() == null ? defaultLeftTime : minutes2Hour(msg.getMinutesOfLeft());
//
if (intervalBo != null){
//
//离发货截止12小时提醒
DeliverNoticeEvent deliverNoticeEvent = DeliverNoticeEvent.builder()
.skup(msg.getSkup())
.sellerOrderGoods(msg.getSellerOrderGoods())
.orderAttributes(msg.getOrderAttributes())
.sellerUid(msg.getSellerUid())
.buyerUid(msg.getBuyerUid())
.prdName(msg.getPrdName())
.orderCode(orderCode)
.minutesOfLeft(intervalBo.getMinutesOfLeft())
.times(intervalBo.getTimes())
.build();
EventBusPublisher.publishEvent(deliverNoticeEvent);
}
SellerOrderGoods sog = msg.getSellerOrderGoods();
if (sog == null){
sog = sellerOrderGoodsMapper.selectByPrimaryKey(msg.getSkup());
... ... @@ -63,9 +105,15 @@ public class NotDeliverNoticeDelayMsgConsumer implements YhConsumer {
sog.setProductName(msg.getPrdName());
}
LOGGER.info("ready notice sellerDeliverWithTimes, msg {}", msg);
sellerNoticeFacade.sellerDeliverWithTimes(sog, buyerOrder, 2, 12, DateUtil.UNIT_HOURS);
sellerNoticeFacade.sellerDeliverWithTimes(sog, buyerOrder, currentTimes, leftHours, DateUtil.UNIT_HOURS);
}
}
private int minutes2Hour(int minutes){
return minutes/60;
}
}
... ...
... ... @@ -57,8 +57,11 @@ public class BuyerOrderMetaServiceImpl implements IBuyerOrderMetaService {
.fromPlatform(req.isFromPlatform())
.build();
commomAddressService.checkAddressContent(orderAddressReq);
AddressInfo hiddenAddress = commomAddressService.buildHiddenAddress(orderAddressReq);
AddressInfo changedAddress = new AddressInfo();
changedAddress.setAddress(str_address);
changedAddress.setConsignee(str_consignee);
changedAddress.setMobile(str_mobile);
AddressInfo hiddenAddress = commomAddressService.buildHiddenAddress(changedAddress);
String rtn="";
int updateRowNum=0;
... ...
... ... @@ -46,11 +46,39 @@ public class CommomAddressService {
orderAddressReq.setMobile(mobile);
}
public void checkAddressContentOfMaybeWithHidden(OrderAddressReq orderAddressReq){
String address = orderAddressReq.getAddress();
if(StringUtils.isBlank(address)){
logger.warn("checkAddressContent address empty, req {}", orderAddressReq);
throw new ServiceException(400,"参数错误,地址不能为空");
}
String consignee = orderAddressReq.getConsignee();
if(StringUtils.isBlank(consignee)){
logger.warn("checkAddressContent consignee empty,req {} ", orderAddressReq);
throw new ServiceException(400,"参数错误,收货人不能为空");
}
String mobile = orderAddressReq.getMobile();
if(StringUtils.isBlank(mobile)){
logger.warn("checkAddressContent mobile empty,req {} ", orderAddressReq);
throw new ServiceException(400,"参数错误,手机号不能为空");
}
mobile = mobile.trim();
if(!mobile.contains("*") && !UserInfoHiddenHelper.isPhone(mobile)){
logger.warn("checkAddressContent mobile not correct, req {}", orderAddressReq);
throw new ServiceException(400,"参数错误,手机号不合法");
}
orderAddressReq.setMobile(mobile);
}
public AddressInfo buildHiddenAddress(OrderAddressReq orderAddressReq){
String str_address = orderAddressReq.getAddress();
String str_consignee= orderAddressReq.getConsignee();
String str_mobile = orderAddressReq.getMobile();
public AddressInfo buildHiddenAddress(AddressInfo changedAddress){
String str_address = changedAddress.getAddress();
String str_consignee= changedAddress.getConsignee();
String str_mobile = changedAddress.getMobile();
AddressInfo addressInfo = new AddressInfo();
addressInfo.setAddress(UserInfoHiddenHelper.getHiddenAddress(str_address));
addressInfo.setConsignee(UserInfoHiddenHelper.getHiddenUserNickName(str_consignee));
... ...
... ... @@ -586,7 +586,8 @@ public class ShoppingServiceImpl implements IShoppingService {
if(AddressHelper.isNeedUpdate(addressInfo)){
logger.warn("submit addressId need update, uid is {}, skup is {}, addressId is {}", shoppingRequest.getUid(),
shoppingRequest.getSkup(), shoppingRequest.getAddressId());
throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);
//throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);
throw new UfoServiceException(400,"您的收货地址缺少所在地的街道信息,请更新收货地址");
}
// 检查地址是否是鉴定中心的地址
... ...
package com.yohoufo.order.service.proxy;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.Lists;
import com.yoho.core.cache.LocalCache;
import com.yoho.core.config.ConfigReader;
import com.yohobuy.ufo.model.order.resp.ExpressCompanyRespBo;
import com.yohoufo.common.utils.OrikaUtils;
import com.yohoufo.dal.order.model.ExpressCompany;
import com.yohoufo.order.model.bo.TradeBillsSummaryBo;
import com.yohoufo.order.model.response.AppraiseAddressResp;
import com.yohoufo.order.service.impl.AppraiseAddressService;
import com.yohobuy.ufo.model.order.bo.IntervalBo;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -18,7 +11,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
... ... @@ -109,4 +101,47 @@ public class DeliveryMinutesService {
// (21天-12小时)
return getDeliverOverSeasDay()*24*60 - 12*60;
}
/**
* 点与点之间的间隔分钟
* 第一次通知 起始36小时,等待0小时,发送通知 (剩余36小时)
* 第二次通知 等待24小时,发送通知(剩余12小时);
* 第三次通知 再等待10小时,发送通知(剩余2小时)
*/
@Getter
private static final int[] delayTime = new int[]{0, 24*60, 10*60};
@Getter
private static final int totalMinutes = 36*60;
public static IntervalBo calculateNextInterval(int times,int start, int[] delayTime){
if (times>=delayTime.length){
return null;
}
int index = times;
//延时等待时间
int interval = delayTime[index];
int delay = interval;
//剩余时间
int left = start;
for(int i=0; i<=index; i++){
int range = delayTime[i];
left -= range;
}
IntervalBo intervalBo = new IntervalBo();
intervalBo.setDelayTime(delayTime);
intervalBo.setTimes(++times);
intervalBo.setTotalMinutes(start);
intervalBo.setMinutesOfLeft(left);
intervalBo.setMinutesofDelay(delay);
return intervalBo;
}
public static void main(String[] args) {
for(int times=0;times<=3;times++) {
int start = totalMinutes;
int[] intervals1 = delayTime;
IntervalBo intervalBo = calculateNextInterval(times, start, intervals1);
System.out.println(intervalBo);
}
}
}
... ...
... ... @@ -5,8 +5,8 @@ import com.yoho.core.dal.datasource.annotation.Database;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.req.OrderAddressReq;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.SellerOrderMetaMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
... ... @@ -14,7 +14,6 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrderMeta;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.constants.MetaKey;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.order.convert.AddressInfoConvertor;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.service.impl.BuyerOrderAssistant;
... ... @@ -22,8 +21,6 @@ import com.yohoufo.order.service.impl.CommomAddressService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.OrderAssist;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -156,7 +153,7 @@ public class SellerAddressService {
req, fromPlatform, pbo.getStatus());
throw new UfoServiceException(400, "目前订单状态下不支持修改地址");
}
commomAddressService.checkAddressContent(req);
commomAddressService.checkAddressContentOfMaybeWithHidden(req);
int sellerUid = psog.getUid();
... ... @@ -168,13 +165,13 @@ public class SellerAddressService {
AddressInfo changedAddress = AddressInfoConvertor.convertChangedAddress(req);
commomAddressService.convertAddressInfoFrontRequest(sellerUid, orderCode, fromPlatform, noHiddenAddress, hiddenAddress, changedAddress);
AddressInfo hiddenAddressTemp = commomAddressService.buildHiddenAddress(req);
AddressInfo hiddenAddressTemp = commomAddressService.buildHiddenAddress(changedAddress);
//hidden
AddressInfoConvertor.mergeChangedAddress4Hidden(hiddenAddress, req, hiddenAddressTemp);
rows += updateHiddenAddress(skup, hiddenAddress);
//no hidden
AddressInfoConvertor.mergeChangedAddress4NoHidden(noHiddenAddress, req);
AddressInfoConvertor.mergeChangedAddress4NoHidden(noHiddenAddress, changedAddress, req);
rows += updateNoHiddenAddress(skup, noHiddenAddress);
logger.info("updateSellerDeliveryAddressByBuyerOrderCode finish req {} rows {}", req, rows);
break;
... ...
... ... @@ -111,7 +111,7 @@ public class SellerOrderPrepareProcessor
if(AddressHelper.isNeedUpdate(noHiddenBackAddress)){
log.warn("seller submit addressId need update, uid is {}, storageId is {}, addressId is {}",
uid, storageId, addressId);
throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);
throw new UfoServiceException(400,"您的收货地址缺少所在地的街道信息,请更新收货地址");
}
Integer businessClientCode = OrderAssist.findBusinessClientCode(req.getBusinessClient());
... ...
package com.yohoufo.product.helper;
import com.yohoufo.common.constant.BusinessClientEnum;
import com.yohoufo.common.utils.AppVersion;
import com.yohoufo.product.request.ProductSearchReq;
import org.apache.commons.lang3.StringUtils;
... ... @@ -45,7 +46,9 @@ public class SearchHelpService {
* @return
*/
public void setContainYoho(String appVersion, ProductSearchReq req) {
if(StringUtils.isNotBlank(appVersion) && AppVersion.of(appVersion).greaterThanOrEquals(AppVersion.of("6.8.5"))){
// 闲鱼请求不能含YOHO
if(StringUtils.isNotBlank(appVersion) && AppVersion.of(appVersion).greaterThanOrEquals(AppVersion.of("6.8.5"))
&& !BusinessClientEnum.isXianYu(req.getBusinessClient())){
req.setContainYoho("Y");
}
}
... ...