Authored by unknown

fix dynamic proporties of in cache

... ... @@ -68,6 +68,7 @@ public class OrderDetailInfo {
private String bankTransferFee;
private Integer secendLevelCreateTime;
private String createTime;
... ...
... ... @@ -49,6 +49,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{
abstract AddressInfo getHiddenAddressInfo(int uid, long orderCode, int skup);
/**
* 获取订单详情
* @param orderRequest
... ... @@ -160,7 +161,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{
}
}
orderDetailInfo.setCreateTime(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
orderDetailInfo.setSecendLevelCreateTime(buyerOrder.getCreateTime());
// 需要查询 时间点 and 物流定位
orderDetailInfo.setLastExpressInfo(buildNode.lastEID);
... ... @@ -204,4 +205,10 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{
protected int calLeftTime(int creatTime){
return OrderInfo.PAY_TIME_SECOND -(DateUtil.getCurrentTimeSecond() - creatTime);
}
/**
* 用于从cache中获取数据后,重置动态数据
* @param orderDetailInfo
*/
protected abstract void resetDynamicProporties(OrderDetailInfo orderDetailInfo);
}
... ...
... ... @@ -3,16 +3,16 @@ package com.yohoufo.order.service.impl;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohoufo.order.service.IOrderListService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -161,8 +161,10 @@ public abstract class AbsOrderListService implements IOrderListService{
goodsInfo.setProductId(sellerOrderGoods.getProductId());
goodsInfo.setSkup(buyerOrderGoods.getSkup());
orderListInfo.setGoodsInfo(goodsInfo);
orderListInfo.setSecendLevelCreateTime(buyerOrder.getCreateTime());
orderListInfo.setCreateTime(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
return orderListInfo;
}
protected abstract void resetDynamicProporties(List<OrderListInfo> list);
}
... ...
... ... @@ -145,11 +145,12 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
return statusDetail;
}
@Override
protected void resetDynamicProporties(OrderDetailInfo orderDetailInfo) {
if (orderDetailInfo.getStatusDetail().getStatus() == OrderStatus.WAITING_PAY.getCode()){
int leftTime = calLeftTime(orderDetailInfo.getSecendLevelCreateTime());
orderDetailInfo.getStatusDetail().setLeftTime(leftTime);
}
}
}
... ...
... ... @@ -2,6 +2,8 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
... ... @@ -13,6 +15,7 @@ import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.IOrderListService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -87,4 +90,16 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
});
return sellerOrderGoodsList;
}
@Override
protected void resetDynamicProporties(List<OrderListInfo> list) {
if(CollectionUtils.isNotEmpty(list)){
list.forEach(oli -> {
if (oli.getStatus() == OrderStatus.WAITING_PAY.getCode()){
oli.setLeftTime(calLeftTime(oli.getSecendLevelCreateTime()));
}
});
}
}
}
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.vo.OrderListVo;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -35,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@Service
... ... @@ -215,6 +217,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
OrderDetailInfo orderDetailInfo = orderCacheService.getOrderDetailInfo(uid = orderRequest.getUid(),
orderCode=orderRequest.getOrderCode(), actor);
if(Objects.nonNull(orderDetailInfo)){
buyerOrderDetailService.resetDynamicProporties(orderDetailInfo);
return orderDetailInfo;
}
orderDetailInfo = buyerOrderDetailService.getOrderDetail(orderRequest);
... ... @@ -235,8 +238,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
.page(request.getPage())
.pageSize(orderListVo.getPageSize())
.total(orderListVo.getTotal())
.pagetotal(orderListVo.getPagetotal());;
return respBuilder.data(orderListVo.getOrderList()).build();
.pagetotal(orderListVo.getPagetotal());
List<OrderListInfo> oliList = orderListVo.getOrderList();
buyerOrderListService.resetDynamicProporties(oliList);
return respBuilder.data(oliList).build();
}
PageResp orderListInfoRsp = buyerOrderListService.getOrderList(request);
... ...
... ... @@ -115,6 +115,8 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
if (Objects.nonNull(orderDetailInfo)){
orderCacheService.cacheOrderDetailInfo(uid, orderCode, TabType.SELL, orderDetailInfo);
}
}else{//fetch from cache
resetDynamicProporties(orderDetailInfo);
}
return orderDetailInfo;
... ... @@ -305,6 +307,7 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
}
//
orderDetailInfo.setIsPaid(getIsPaid(skupStatus));
orderDetailInfo.setSecendLevelCreateTime(order.getCreateTime());
orderDetailInfo.setCreateTime(DateUtil.formatDate(order.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
return orderDetailInfo;
}
... ... @@ -326,15 +329,17 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
.detailDesc(orderStatus.getDetailDesc(tabType))
.build();
if(sellerViewExpressStatus.contains(orderStatus.getCode())){
statusDetail.setExpressShow(true);
}
return statusDetail;
}
@Override
protected void resetDynamicProporties(OrderDetailInfo orderDetailInfo) {
if (orderDetailInfo.getStatusDetail().getStatus() == SkupStatus.CAN_NOT_SELL.getCode()){
int leftTime = calLeftTime(orderDetailInfo.getSecendLevelCreateTime());
orderDetailInfo.getStatusDetail().setLeftTime(leftTime);
}
}
}
... ...
... ... @@ -23,6 +23,7 @@ import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.IOrderListService;
import com.yohoufo.order.service.cache.OrderCacheService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -63,8 +64,10 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
.page(request.getPage())
.pageSize(orderListVo.getPageSize())
.total(orderListVo.getTotal())
.pagetotal(orderListVo.getPagetotal());;
return respBuilder.data(orderListVo.getOrderList()).build();
.pagetotal(orderListVo.getPagetotal());
List<OrderListInfo> oliList = orderListVo.getOrderList();
resetDynamicProporties(oliList);
return respBuilder.data(oliList).build();
}
PageResp orderListInfoRsp;
int type;
... ... @@ -117,6 +120,17 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
return orderListInfoRsp;
}
@Override
protected void resetDynamicProporties(List<OrderListInfo> list) {
if(CollectionUtils.isNotEmpty(list)){
list.forEach(oli -> {
if (oli.getStatus() == SkupStatus.CAN_NOT_SELL.getCode()){
oli.setLeftTime(calLeftTime(oli.getSecendLevelCreateTime()));
}
});
}
}
OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods,
SellerOrder sellerOrder) {
... ... @@ -124,18 +138,17 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
orderListInfo.setUid(sellerOrder.getUid());
orderListInfo.setOrderCode(sellerOrder.getOrderCode());
orderListInfo.setRealPrice(sellerOrderGoods.getGoodsPrice().toPlainString());
// 订单中状态显示
orderListInfo.setStatus(sellerOrder.getStatus() == null ? -1 : sellerOrder.getStatus());
SellerOrderStatus sellerOrderStatus = SellerOrderStatus.getSellerOrderStatus(orderListInfo.getStatus());
SkupStatus skupStatus = sellerOrderStatus.getSkupStatus();
SellerOrderStatus sellerOrderStatus = SellerOrderStatus.getSellerOrderStatus(sellerOrder.getStatus());
SkupStatus skupStatus = sellerOrderStatus.getSkupStatus();
if (skupStatus == null){
log.warn("get seller Order List skupStatus not exist, uid is {}, orderCode is {}, status is {}",
sellerOrder.getUid(), orderListInfo.getOrderCode(), sellerOrder.getStatus());
return null;
}
// 订单中状态显示
orderListInfo.setStatus(skupStatus.getCode());
orderListInfo.setStatuStr(skupStatus.getDesc());
// 按钮显示
... ... @@ -157,7 +170,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
goodsInfo.setGoodPrice(sellerOrderGoods.getGoodsPrice().toPlainString());
goodsInfo.setStorageId(sellerOrderGoods.getStorageId());
orderListInfo.setGoodsInfo(goodsInfo);
orderListInfo.setSecendLevelCreateTime(sellerOrder.getCreateTime());
orderListInfo.setCreateTime(DateUtil.formatDate(sellerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
return orderListInfo;
}
... ...