Authored by chenchao

cal deliver left time

... ... @@ -83,6 +83,11 @@ public class OrderDetailInfo {
*/
private Integer isPaid;
/**
* 发货剩余时间
*/
private Long deliverLeftTime;
@Builder
@Data
@AllArgsConstructor
... ...
... ... @@ -6,10 +6,8 @@ import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail;
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.BuyerOrderMeta;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.OrdersPayMapper;
import com.yohoufo.dal.order.model.*;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.order.common.Payment;
import com.yohobuy.ufo.model.order.common.TabType;
... ... @@ -19,6 +17,7 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.GoodsInfo;
import com.yohoufo.order.model.response.OrderDetailInfo;
import com.yohoufo.order.mq.DelayTime;
import com.yohoufo.order.service.IExpressInfoService;
import com.yohoufo.order.service.IOrderDetailService;
import lombok.experimental.Builder;
... ... @@ -34,6 +33,9 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private OrdersPayService ordersPayService;
@Autowired
protected IExpressInfoService expressInfoService;
abstract BuyerOrder getBuyerOrder(int uid, long orderCode);
... ... @@ -51,6 +53,13 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{
abstract AddressInfo getHiddenAddressInfo(int uid, long orderCode, int skup);
Long getDeliverLeftTime(int buyerUid, long orderCode, Integer orderStatus){
if (OrderStatus.HAS_PAYED.getCode() == orderStatus){
return ordersPayService.getDeliverLeftTime(buyerUid, orderCode);
}else{
return null;
}
}
/**
* 获取订单详情
* @param orderRequest
... ... @@ -133,10 +142,12 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{
BuyerOrderGoods buyerOrderGoods = buildNode.buyerOrderGoods;
SellerOrderGoods sellerOrderGoods = buildNode.sellerOrderGoods;
AddressInfo userAddress = buildNode.userAddress;
Integer buyerUid;
Long orderCode;
//ready 2 set
OrderDetailInfo orderDetailInfo = new OrderDetailInfo();
orderDetailInfo.setUid(buyerOrder.getUid());
orderDetailInfo.setOrderCode(buyerOrder.getOrderCode());
orderDetailInfo.setUid(buyerUid = buyerOrder.getUid());
orderDetailInfo.setOrderCode(orderCode = buyerOrder.getOrderCode());
orderDetailInfo.setSubmitOrderTimeStr(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
orderDetailInfo.setButtons(orderStatus.getDetailButtons(tabType));
OrderDetailInfo.StatusDetail statusDetail = getStatusDetail(buyerOrder, orderStatus, tabType);
... ... @@ -170,6 +181,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{
//只有卖家在查看买家的订单时才有
assembleSoldPrdCompute(orderDetailInfo, buyerOrder.getSellerUid(), buyerOrderGoods.getSkup());
orderDetailInfo.setDeliverLeftTime(getDeliverLeftTime(buyerUid, orderCode, buyerOrder.getStatus()));
return orderDetailInfo;
}
... ...
... ... @@ -16,6 +16,7 @@ import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.service.IOrderListService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Map;
... ... @@ -29,6 +30,8 @@ public abstract class AbsOrderListService implements IOrderListService{
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private OrdersPayService ordersPayService;
abstract List<Integer> initOrderListRequest(OrderListRequest request);
... ... @@ -40,6 +43,13 @@ public abstract class AbsOrderListService implements IOrderListService{
abstract List<SellerOrderGoods> getBaseOrderGoodsList(List<Integer> skups);
Long getDeliverLeftTime(int buyerUid, long orderCode, Integer orderStatus){
if (OrderStatus.HAS_PAYED.getCode() == orderStatus){
return ordersPayService.getDeliverLeftTime(buyerUid, orderCode);
}else{
return null;
}
}
/**
* 订单列表
* @param request
... ... @@ -163,6 +173,9 @@ public abstract class AbsOrderListService implements IOrderListService{
orderListInfo.setGoodsInfo(goodsInfo);
orderListInfo.setSecendLevelCreateTime(buyerOrder.getCreateTime());
orderListInfo.setCreateTime(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
//
orderListInfo.setDeliverLeftTime(getDeliverLeftTime(buyerOrder.getUid(), buyerOrder.getOrderCode(),
buyerOrder.getStatus()));
return orderListInfo;
}
... ...
... ... @@ -150,6 +150,8 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
if (orderDetailInfo.getStatusDetail().getStatus() == OrderStatus.WAITING_PAY.getCode()){
int leftTime = calLeftTime(orderDetailInfo.getSecendLevelCreateTime());
orderDetailInfo.getStatusDetail().setLeftTime(leftTime);
orderDetailInfo.setDeliverLeftTime(getDeliverLeftTime(orderDetailInfo.getUid(),
orderDetailInfo.getOrderCode(), orderDetailInfo.getStatusDetail().getStatus()));
}
}
... ...
... ... @@ -96,6 +96,7 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
if (oli.getStatus() == OrderStatus.WAITING_PAY.getCode()){
oli.setLeftTime(calLeftTime(oli.getSecendLevelCreateTime()));
}
oli.setDeliverLeftTime(getDeliverLeftTime(oli.getUid(), oli.getOrderCode(), oli.getStatus()));
});
}
}
... ...
package com.yohoufo.order.service.impl;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.OrdersPayMapper;
import com.yohoufo.dal.order.model.OrdersPay;
import com.yohoufo.order.mq.DelayTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by chao.chen on 2018/11/23.
*/
@Service
public class OrdersPayService {
@Autowired
private OrdersPayMapper ordersPayMapper;
public Long getDeliverLeftTime(int buyerUid, long orderCode){
OrdersPay ordersPay = ordersPayMapper.selectOrdersPay(orderCode, buyerUid);
if (ordersPay == null){
return null;
}
return (long)DelayTime.MINUTES_36_HOURS * 60 - (DateUtil.getCurrentTimeSecond()-ordersPay.getCreateTime());
}
}
... ...
... ... @@ -30,6 +30,7 @@ import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -387,5 +388,12 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
int leftTime = calLeftTime(orderDetailInfo.getSecendLevelCreateTime());
orderDetailInfo.getStatusDetail().setLeftTime(leftTime);
}
List<BuyerOrderGoods> bogList = buyerOrderGoodsMapper.selectBySkups(Arrays.asList(orderDetailInfo.getGoodsInfo().getSkup()));
if (CollectionUtils.isNotEmpty(bogList)){
//存在时说明已经有买家下单 当前状态来自于买家订单
BuyerOrderGoods bog = bogList.get(0);
int status = orderDetailInfo.getStatusDetail().getStatus();
orderDetailInfo.setDeliverLeftTime(getDeliverLeftTime(bog.getUid(), bog.getOrderCode(), status));
}
}
}
... ...
... ... @@ -31,10 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
... ... @@ -140,6 +137,14 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
if (oli.getStatus() == SkupStatus.CAN_NOT_SELL.getCode()){
oli.setLeftTime(calLeftTime(oli.getSecendLevelCreateTime()));
}
List<BuyerOrderGoods> bogList = buyerOrderGoodsMapper.selectBySkups(Arrays.asList(oli.getGoodsInfo().getSkup()));
if (CollectionUtils.isNotEmpty(bogList)){
//存在时说明已经有买家下单 当前状态来自于买家订单
BuyerOrderGoods bog = bogList.get(0);
int status = oli.getStatus();
oli.setDeliverLeftTime(getDeliverLeftTime(bog.getUid(), bog.getOrderCode(), status));
}
});
}
}
... ...