Authored by chenchao

new calculate method 4 list timeout

@@ -91,7 +91,10 @@ public class SellerController { @@ -91,7 +91,10 @@ public class SellerController {
91 } 91 }
92 92
93 93
94 - 94 + /**
  95 + * 入驻超级卖家阈值配置
  96 + * @return
  97 + */
95 @RequestMapping(params = "method=ufo.seller.entryThresholds") 98 @RequestMapping(params = "method=ufo.seller.entryThresholds")
96 @ResponseBody 99 @ResponseBody
97 public ApiResponse getEntryThresholds() { 100 public ApiResponse getEntryThresholds() {
@@ -101,7 +104,11 @@ public class SellerController { @@ -101,7 +104,11 @@ public class SellerController {
101 } 104 }
102 105
103 106
104 - 107 + /**
  108 + * 入驻的普通卖家当钱包金额满足5000,可以直接申请为超级卖家
  109 + * @param uid
  110 + * @return
  111 + */
105 @RequestMapping(params = "method=ufo.seller.applySuperEnter") 112 @RequestMapping(params = "method=ufo.seller.applySuperEnter")
106 @ResponseBody 113 @ResponseBody
107 public ApiResponse applySuperEnter(@RequestParam("uid") Integer uid) { 114 public ApiResponse applySuperEnter(@RequestParam("uid") Integer uid) {
@@ -3,7 +3,7 @@ package com.yohoufo.order.service.impl; @@ -3,7 +3,7 @@ package com.yohoufo.order.service.impl;
3 import com.google.common.collect.Lists; 3 import com.google.common.collect.Lists;
4 import com.yohobuy.ufo.model.order.bo.ButtonShowBo; 4 import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
5 import com.yohobuy.ufo.model.order.bo.GoodsInfo; 5 import com.yohobuy.ufo.model.order.bo.GoodsInfo;
6 -import com.yohobuy.ufo.model.order.bo.OrderInfo; 6 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
7 import com.yohobuy.ufo.model.order.common.ButtonShow; 7 import com.yohobuy.ufo.model.order.common.ButtonShow;
8 import com.yohobuy.ufo.model.order.common.OrderStatus; 8 import com.yohobuy.ufo.model.order.common.OrderStatus;
9 import com.yohobuy.ufo.model.order.common.TabType; 9 import com.yohobuy.ufo.model.order.common.TabType;
@@ -13,7 +13,6 @@ import com.yohoufo.common.helper.ImageUrlAssist; @@ -13,7 +13,6 @@ import com.yohoufo.common.helper.ImageUrlAssist;
13 import com.yohoufo.common.utils.DateUtil; 13 import com.yohoufo.common.utils.DateUtil;
14 import com.yohoufo.dal.order.model.BuyerOrder; 14 import com.yohoufo.dal.order.model.BuyerOrder;
15 import com.yohoufo.dal.order.model.BuyerOrderGoods; 15 import com.yohoufo.dal.order.model.BuyerOrderGoods;
16 -import com.yohoufo.dal.order.model.QiniuLiveRecord;  
17 import com.yohoufo.dal.order.model.SellerOrderGoods; 16 import com.yohoufo.dal.order.model.SellerOrderGoods;
18 import com.yohoufo.order.constants.ViewType; 17 import com.yohoufo.order.constants.ViewType;
19 import com.yohoufo.order.model.request.OrderListRequest; 18 import com.yohoufo.order.model.request.OrderListRequest;
@@ -155,9 +154,11 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements @@ -155,9 +154,11 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
155 orderListInfo.setStatuStr(orderStatus.getStatusStr(tabType)); 154 orderListInfo.setStatuStr(orderStatus.getStatusStr(tabType));
156 155
157 // 当订单状态是待付款, 显示leftTime 156 // 当订单状态是待付款, 显示leftTime
158 - Integer leftTime = getLeftTime(tabType, buyerUid, orderCode, buyerOrder.getStatus(), buyerOrder.getCreateTime()); 157 + //Integer leftTime = getLeftTime(tabType, buyerUid, orderCode, buyerOrder.getStatus(), buyerOrder.getCreateTime());
  158 + TimeoutBo timeoutBo = calTimeout(tabType, buyerUid, orderCode, buyerOrder.getStatus(), buyerOrder.getCreateTime());
  159 + Integer leftTime = timeoutBo.getLeftTime();
159 orderListInfo.setLeftTime(leftTime); 160 orderListInfo.setLeftTime(leftTime);
160 - 161 + orderListInfo.setTimeLimit(timeoutBo.getTimelimit());
161 // 按钮显示 162 // 按钮显示
162 List<ButtonShowBo> buttonShowBos = orderStatus.getListButtons(tabType); 163 List<ButtonShowBo> buttonShowBos = orderStatus.getListButtons(tabType);
163 164
@@ -199,8 +200,6 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements @@ -199,8 +200,6 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
199 orderListInfo.setCreateTime(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS)); 200 orderListInfo.setCreateTime(DateUtil.formatDate(buyerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
200 setAddressInfo(orderListInfo); 201 setAddressInfo(orderListInfo);
201 orderListInfo.setAppraiseVideoUrl(appraiseVideo.get(buyerOrder.getOrderCode())); 202 orderListInfo.setAppraiseVideoUrl(appraiseVideo.get(buyerOrder.getOrderCode()));
202 - //  
203 - orderListInfo.setPayTimeLimit(OrderInfo.PAY_TIME_SECOND);  
204 return orderListInfo; 203 return orderListInfo;
205 } 204 }
206 205
@@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl; @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
2 2
3 import com.yohobuy.ufo.model.order.bo.ButtonShowBo; 3 import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
4 import com.yohobuy.ufo.model.order.bo.OrderInfo; 4 import com.yohobuy.ufo.model.order.bo.OrderInfo;
  5 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
5 import com.yohobuy.ufo.model.order.common.*; 6 import com.yohobuy.ufo.model.order.common.*;
6 import com.yohoufo.common.utils.DateUtil; 7 import com.yohoufo.common.utils.DateUtil;
7 import com.yohoufo.dal.order.model.BuyerOrder; 8 import com.yohoufo.dal.order.model.BuyerOrder;
@@ -10,6 +11,10 @@ import com.yohoufo.order.constants.ViewType; @@ -10,6 +11,10 @@ import com.yohoufo.order.constants.ViewType;
10 import com.yohoufo.order.model.dto.BuyerPenaltyCalResult; 11 import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
11 import com.yohoufo.order.model.response.OrderDetailInfo; 12 import com.yohoufo.order.model.response.OrderDetailInfo;
12 import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler; 13 import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
  14 +import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
  15 +import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
  16 +import com.yohoufo.order.service.wrapper.BuyerOrderTimeoutWrapper;
  17 +import com.yohoufo.order.service.wrapper.SellerOrderTimeoutWrapper;
13 import com.yohoufo.order.utils.BuyerOrderUtils; 18 import com.yohoufo.order.utils.BuyerOrderUtils;
14 import org.apache.commons.collections.CollectionUtils; 19 import org.apache.commons.collections.CollectionUtils;
15 import org.slf4j.Logger; 20 import org.slf4j.Logger;
@@ -31,6 +36,8 @@ public abstract class AbsOrderViewService { @@ -31,6 +36,8 @@ public abstract class AbsOrderViewService {
31 @Autowired 36 @Autowired
32 private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler; 37 private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler;
33 38
  39 + @Autowired
  40 + OrderCodeGenerator orderCodeGenerator;
34 41
35 abstract Logger getLogger(); 42 abstract Logger getLogger();
36 43
@@ -124,6 +131,81 @@ public abstract class AbsOrderViewService { @@ -124,6 +131,81 @@ public abstract class AbsOrderViewService {
124 return detailDesc; 131 return detailDesc;
125 } 132 }
126 133
  134 + private BuyerOrder buildBuyerOrder4Timeout(Integer uid, Long orderCode, Integer orderStatus, Integer createTime){
  135 + BuyerOrder qbo = new BuyerOrder();
  136 + qbo.setUid(uid);
  137 + qbo.setOrderCode(orderCode);
  138 + qbo.setStatus(orderStatus);
  139 + qbo.setCreateTime(createTime);
  140 + return qbo;
  141 + }
  142 +
  143 + TimeoutBo calTimeout(TabType actor, Integer uid, Long orderCode, Integer orderStatus, Integer createTime){
  144 +
  145 + boolean isBuyer = actor.equals(TabType.BUY);
  146 + boolean isSeller = actor.equals(TabType.SELL);
  147 + TimeoutBo timeoutBo = new TimeoutBo();
  148 + if (isBuyer){
  149 + boolean isPaid = OrderStatus.HAS_PAYED.getCode() == orderStatus;
  150 + boolean isWaitingPay = OrderStatus.WAITING_PAY.getCode() == orderStatus;
  151 + if (isPaid){
  152 + BuyerOrder qbo = buildBuyerOrder4Timeout(uid,orderCode,orderStatus,createTime);
  153 + timeoutBo = new BuyerOrderTimeoutWrapper(qbo, ordersPayService::getDeliverLeftTime)
  154 + .calDeliverLeftTime();
  155 + }
  156 +
  157 + if (isWaitingPay){
  158 + BuyerOrder qbo = buildBuyerOrder4Timeout(uid,orderCode,orderStatus,createTime);
  159 + timeoutBo = new BuyerOrderTimeoutWrapper(qbo).calPayLeftTime(actor);
  160 + }
  161 + }
  162 +
  163 + if (isSeller){
  164 + CodeMeta codeMeta = orderCodeGenerator.expId(orderCode);
  165 + if (codeMeta!=null) {
  166 + OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType());
  167 + boolean isWaitingPay;
  168 + boolean isPaid;
  169 + //查看买家
  170 + if (orderCodeType == OrderCodeType.BUYER_TYPE) {
  171 + isWaitingPay = orderStatus == OrderStatus.WAITING_PAY.getCode();
  172 + if (isWaitingPay) {
  173 + timeoutBo = new SellerOrderTimeoutWrapper()
  174 + .orderCodeType(orderCodeType)
  175 + .orderStatus(orderStatus)
  176 + .createTime(createTime)
  177 + .calculatePayLeftTime();
  178 + }
  179 + isPaid = orderStatus == OrderStatus.HAS_PAYED.getCode();
  180 + if (isPaid){
  181 + BuyerOrder qbo = buildBuyerOrder4Timeout(uid,orderCode,orderStatus,createTime);
  182 + timeoutBo = new BuyerOrderTimeoutWrapper(qbo, ordersPayService::getDeliverLeftTime)
  183 + .calDeliverLeftTime();
  184 + }
  185 + }
  186 + //查看卖家
  187 + if (orderCodeType == OrderCodeType.SELLER_TYPE) {
  188 + isWaitingPay = orderStatus == SkupStatus.CAN_NOT_SELL.getCode();
  189 + if (isWaitingPay) {
  190 + timeoutBo = new SellerOrderTimeoutWrapper()
  191 + .orderCodeType(orderCodeType)
  192 + .orderStatus(orderStatus)
  193 + .createTime(createTime)
  194 + .calculatePayLeftTime();
  195 + }
  196 + }
  197 +
  198 + }
  199 + }
  200 +
  201 + Integer leftTime = timeoutBo.getLeftTime();
  202 + if (leftTime != null && leftTime<0){
  203 + timeoutBo.setLeftTime(0);
  204 + }
  205 + return timeoutBo;
  206 + }
  207 +
  208 + @Deprecated
127 Integer getLeftTime(TabType actor, Integer uid, Long orderCode, Integer orderStatus, Integer createTime){ 209 Integer getLeftTime(TabType actor, Integer uid, Long orderCode, Integer orderStatus, Integer createTime){
128 Integer leftTime =null; 210 Integer leftTime =null;
129 Integer payLeftTime = getPayLeftTime(actor, orderStatus, 211 Integer payLeftTime = getPayLeftTime(actor, orderStatus,
@@ -149,6 +231,15 @@ public abstract class AbsOrderViewService { @@ -149,6 +231,15 @@ public abstract class AbsOrderViewService {
149 return leftTime; 231 return leftTime;
150 } 232 }
151 233
  234 + /**
  235 + * 请移步至
  236 + * @see {@link SellerOrderTimeoutWrapper#calculatePayLeftTime()}
  237 + * @param orderCodeType
  238 + * @param orderStatus
  239 + * @param createTime
  240 + * @return
  241 + */
  242 + @Deprecated
152 Integer getPayLeftTime4Seller(OrderCodeType orderCodeType, Integer orderStatus, int createTime){ 243 Integer getPayLeftTime4Seller(OrderCodeType orderCodeType, Integer orderStatus, int createTime){
153 if (orderCodeType == null){ 244 if (orderCodeType == null){
154 return null; 245 return null;
@@ -186,7 +277,8 @@ public abstract class AbsOrderViewService { @@ -186,7 +277,8 @@ public abstract class AbsOrderViewService {
186 Integer getDeliverLeftTime(int buyerUid, long orderCode, Integer orderStatus){ 277 Integer getDeliverLeftTime(int buyerUid, long orderCode, Integer orderStatus){
187 Integer leftTime = null; 278 Integer leftTime = null;
188 if (OrderStatus.HAS_PAYED.getCode() == orderStatus){ 279 if (OrderStatus.HAS_PAYED.getCode() == orderStatus){
189 - leftTime = ordersPayService.getDeliverLeftTime(buyerUid, orderCode); 280 + TimeoutBo timeoutBo = ordersPayService.getDeliverLeftTime(buyerUid, orderCode);
  281 + leftTime = timeoutBo.getLeftTime();
190 } 282 }
191 return leftTime; 283 return leftTime;
192 } 284 }
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl; @@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl;
3 import com.google.common.collect.Maps; 3 import com.google.common.collect.Maps;
4 import com.yoho.error.ServiceError; 4 import com.yoho.error.ServiceError;
5 import com.yoho.error.exception.ServiceException; 5 import com.yoho.error.exception.ServiceException;
  6 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
6 import com.yohobuy.ufo.model.order.common.ButtonShow; 7 import com.yohobuy.ufo.model.order.common.ButtonShow;
7 import com.yohobuy.ufo.model.order.common.OrderListType; 8 import com.yohobuy.ufo.model.order.common.OrderListType;
8 import com.yohobuy.ufo.model.order.common.TabType; 9 import com.yohobuy.ufo.model.order.common.TabType;
@@ -128,9 +129,14 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO @@ -128,9 +129,14 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
128 if(CollectionUtils.isNotEmpty(list)){ 129 if(CollectionUtils.isNotEmpty(list)){
129 processButtons(list); 130 processButtons(list);
130 list.forEach(oli -> { 131 list.forEach(oli -> {
131 - Integer leftTime = getLeftTime(TabType.BUY, oli.getUid(), oli.getOrderCode(), oli.getStatus(), 132 + //Integer leftTime = getLeftTime(TabType.BUY, oli.getUid(), oli.getOrderCode(), oli.getStatus(),
  133 + // oli.getSecendLevelCreateTime());
  134 +
  135 + TimeoutBo timeoutBo = calTimeout(TabType.BUY, oli.getUid(), oli.getOrderCode(), oli.getStatus(),
132 oli.getSecendLevelCreateTime()); 136 oli.getSecendLevelCreateTime());
  137 + Integer leftTime = timeoutBo.getLeftTime();
133 oli.setLeftTime(leftTime); 138 oli.setLeftTime(leftTime);
  139 + oli.setTimeLimit(timeoutBo.getTimelimit());
134 140
135 if (oli.getLeftTime()!=null && oli.getLeftTime()<=0){ 141 if (oli.getLeftTime()!=null && oli.getLeftTime()<=0){
136 oli.getButtons().removeIf(x-> x!=null && ButtonShow.NOW_BUY.getCode().equals(x.getCode())); 142 oli.getButtons().removeIf(x-> x!=null && ButtonShow.NOW_BUY.getCode().equals(x.getCode()));
1 package com.yohoufo.order.service.impl; 1 package com.yohoufo.order.service.impl;
2 2
  3 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
  4 +import com.yohobuy.ufo.model.order.constants.TimeoutCase;
3 import com.yohoufo.common.utils.DateUtil; 5 import com.yohoufo.common.utils.DateUtil;
4 import com.yohoufo.dal.order.OrdersPayMapper; 6 import com.yohoufo.dal.order.OrdersPayMapper;
5 import com.yohoufo.dal.order.model.OrdersPay; 7 import com.yohoufo.dal.order.model.OrdersPay;
@@ -16,11 +18,20 @@ public class OrdersPayService { @@ -16,11 +18,20 @@ public class OrdersPayService {
16 @Autowired 18 @Autowired
17 private OrdersPayMapper ordersPayMapper; 19 private OrdersPayMapper ordersPayMapper;
18 20
19 - public Integer getDeliverLeftTime(int buyerUid, long orderCode){ 21 + public TimeoutBo getDeliverLeftTime(int buyerUid, long orderCode){
20 OrdersPay ordersPay = ordersPayMapper.selectOrdersPay(orderCode, buyerUid); 22 OrdersPay ordersPay = ordersPayMapper.selectOrdersPay(orderCode, buyerUid);
21 if (ordersPay == null){ 23 if (ordersPay == null){
22 return null; 24 return null;
23 } 25 }
24 - return DelayTime.MINUTES_36_HOURS * 60 - (DateUtil.getCurrentTimeSecond()-ordersPay.getCreateTime()); 26 + int timelimit = DelayTime.MINUTES_36_HOURS * 60;
  27 + Integer createTime = ordersPay.getCreateTime();
  28 +
  29 + int left = timelimit - (DateUtil.getCurrentTimeSecond()-createTime);
  30 + TimeoutBo timeoutBo = new TimeoutBo();
  31 + timeoutBo.setLeftTime(left);
  32 + timeoutBo.setStartTime(createTime);
  33 + timeoutBo.setTimelimit(timelimit);
  34 + timeoutBo.setTimeoutCase(TimeoutCase.DELIVER);
  35 + return timeoutBo;
25 } 36 }
26 } 37 }
@@ -6,6 +6,7 @@ import com.yoho.error.exception.ServiceException; @@ -6,6 +6,7 @@ import com.yoho.error.exception.ServiceException;
6 import com.yohobuy.ufo.model.order.bo.ButtonShowBo; 6 import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
7 import com.yohobuy.ufo.model.order.bo.OrderInfo; 7 import com.yohobuy.ufo.model.order.bo.OrderInfo;
8 import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo; 8 import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
  9 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
9 import com.yohobuy.ufo.model.order.common.*; 10 import com.yohobuy.ufo.model.order.common.*;
10 import com.yohobuy.ufo.model.order.constants.OrderConstant; 11 import com.yohobuy.ufo.model.order.constants.OrderConstant;
11 import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; 12 import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail;
@@ -31,6 +32,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; @@ -31,6 +32,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService;
31 import com.yohoufo.order.service.proxy.UserProxyService; 32 import com.yohoufo.order.service.proxy.UserProxyService;
32 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 33 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
33 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; 34 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
  35 +import com.yohoufo.order.service.wrapper.SellerOrderTimeoutWrapper;
34 import com.yohoufo.order.utils.LoggerUtils; 36 import com.yohoufo.order.utils.LoggerUtils;
35 import org.apache.commons.lang3.StringUtils; 37 import org.apache.commons.lang3.StringUtils;
36 import org.slf4j.Logger; 38 import org.slf4j.Logger;
@@ -272,8 +274,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I @@ -272,8 +274,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
272 .build(); 274 .build();
273 275
274 // 待付款时 或待发货,剩余时间 276 // 待付款时 或待发货,剩余时间
275 - Integer leftTime = getPayLeftTime4Seller(OrderCodeType.SELLER_TYPE,  
276 - skupStatus.getCode(), order.getCreateTime()); 277 + //Integer leftTime = getPayLeftTime4Seller(OrderCodeType.SELLER_TYPE, skupStatus.getCode(), order.getCreateTime());
  278 + TimeoutBo timeoutBo = new SellerOrderTimeoutWrapper()
  279 + .createTime(order.getCreateTime())
  280 + .orderCodeType(OrderCodeType.SELLER_TYPE)
  281 + .orderStatus(skupStatus.getCode())
  282 + .calculatePayLeftTime();
  283 + Integer leftTime = timeoutBo.getLeftTime();
277 statusDetail.setLeftTime(leftTime); 284 statusDetail.setLeftTime(leftTime);
278 285
279 return statusDetail; 286 return statusDetail;
@@ -366,7 +373,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I @@ -366,7 +373,13 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
366 return ActionStatusHold.getSellerOrderIsPaidStatusList().contains(skupStatus.getCode()) ? 1 : 0; 373 return ActionStatusHold.getSellerOrderIsPaidStatusList().contains(skupStatus.getCode()) ? 1 : 0;
367 } 374 }
368 375
369 - 376 + /**
  377 + * 当卖家查看买家订单时才会调用
  378 + * @param buyerOrder
  379 + * @param orderStatus
  380 + * @param tabType
  381 + * @return
  382 + */
370 @Override 383 @Override
371 protected OrderDetailInfo.StatusDetail getStatusDetail(BuyerOrder buyerOrder,OrderStatus orderStatus, TabType tabType) { 384 protected OrderDetailInfo.StatusDetail getStatusDetail(BuyerOrder buyerOrder,OrderStatus orderStatus, TabType tabType) {
372 OrderDetailInfo.StatusDetail statusDetail = OrderDetailInfo.StatusDetail.builder() 385 OrderDetailInfo.StatusDetail statusDetail = OrderDetailInfo.StatusDetail.builder()
@@ -401,7 +414,12 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I @@ -401,7 +414,12 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
401 Integer orderStatus = orderDetailInfo.getStatusDetail().getStatus(); 414 Integer orderStatus = orderDetailInfo.getStatusDetail().getStatus();
402 if (codeMeta!=null) { 415 if (codeMeta!=null) {
403 OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType()); 416 OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType());
404 - Integer leftTime = getPayLeftTime4Seller(orderCodeType, orderStatus, orderDetailInfo.getSecendLevelCreateTime()); 417 + //Integer leftTime = getPayLeftTime4Seller(orderCodeType, orderStatus, orderDetailInfo.getSecendLevelCreateTime());
  418 + TimeoutBo timeoutBo = new SellerOrderTimeoutWrapper().createTime(orderDetailInfo.getSecendLevelCreateTime())
  419 + .orderCodeType(orderCodeType)
  420 + .orderStatus(orderStatus)
  421 + .calculatePayLeftTime();
  422 + Integer leftTime = timeoutBo.getLeftTime();
405 orderDetailInfo.getStatusDetail().setLeftTime(leftTime); 423 orderDetailInfo.getStatusDetail().setLeftTime(leftTime);
406 424
407 if (leftTime!=null && leftTime<=0){ 425 if (leftTime!=null && leftTime<=0){
@@ -6,6 +6,7 @@ import com.yoho.error.exception.ServiceException; @@ -6,6 +6,7 @@ import com.yoho.error.exception.ServiceException;
6 import com.yohobuy.ufo.model.order.bo.ButtonShowBo; 6 import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
7 import com.yohobuy.ufo.model.order.bo.GoodsInfo; 7 import com.yohobuy.ufo.model.order.bo.GoodsInfo;
8 import com.yohobuy.ufo.model.order.bo.OrderInfo; 8 import com.yohobuy.ufo.model.order.bo.OrderInfo;
  9 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
9 import com.yohobuy.ufo.model.order.common.*; 10 import com.yohobuy.ufo.model.order.common.*;
10 import com.yohobuy.ufo.model.order.resp.OrderListInfo; 11 import com.yohobuy.ufo.model.order.resp.OrderListInfo;
11 import com.yohobuy.ufo.model.order.resp.PageResp; 12 import com.yohobuy.ufo.model.order.resp.PageResp;
@@ -30,6 +31,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService; @@ -30,6 +31,7 @@ import com.yohoufo.order.service.proxy.ProductProxyService;
30 import com.yohoufo.order.service.proxy.UserProxyService; 31 import com.yohoufo.order.service.proxy.UserProxyService;
31 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 32 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
32 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; 33 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
  34 +import com.yohoufo.order.service.wrapper.SellerOrderTimeoutWrapper;
33 import com.yohoufo.order.utils.LoggerUtils; 35 import com.yohoufo.order.utils.LoggerUtils;
34 import com.yohoufo.order.utils.OrderAssist; 36 import com.yohoufo.order.utils.OrderAssist;
35 import org.apache.commons.collections.CollectionUtils; 37 import org.apache.commons.collections.CollectionUtils;
@@ -70,8 +72,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde @@ -70,8 +72,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
70 @Autowired 72 @Autowired
71 private ProductProxyService productProxyService; 73 private ProductProxyService productProxyService;
72 74
73 - @Autowired  
74 - private OrderCodeGenerator orderCodeGenerator; 75 +
75 76
76 @Autowired 77 @Autowired
77 private SkupListService skupListService; 78 private SkupListService skupListService;
@@ -182,7 +183,13 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde @@ -182,7 +183,13 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
182 Integer orderStatus = oli.getStatus(); 183 Integer orderStatus = oli.getStatus();
183 if (codeMeta!=null){ 184 if (codeMeta!=null){
184 OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType()); 185 OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType());
185 - oli.setLeftTime(getPayLeftTime4Seller(orderCodeType, orderStatus, oli.getSecendLevelCreateTime())); 186 + TimeoutBo timeoutBo = new SellerOrderTimeoutWrapper().createTime(oli.getSecendLevelCreateTime())
  187 + .orderCodeType(orderCodeType)
  188 + .orderStatus(orderStatus)
  189 + .calculatePayLeftTime();
  190 + oli.setLeftTime(timeoutBo.getLeftTime());
  191 + oli.setTimeLimit(timeoutBo.getTimelimit());
  192 + //oli.setLeftTime(getPayLeftTime4Seller(orderCodeType, orderStatus, oli.getSecendLevelCreateTime()));
186 } 193 }
187 194
188 195
@@ -278,7 +285,6 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde @@ -278,7 +285,6 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
278 if (SHOW_OVER_FLOW_PRICE_STATUS.contains(skupStatus.getCode())){ 285 if (SHOW_OVER_FLOW_PRICE_STATUS.contains(skupStatus.getCode())){
279 orderListInfo.setTips(overPriceTipsMap.get(OrderAssist.overFlowPriceKey(sellerOrderGoods.getStorageId(), sellerOrderGoods.getGoodsPrice()))); 286 orderListInfo.setTips(overPriceTipsMap.get(OrderAssist.overFlowPriceKey(sellerOrderGoods.getStorageId(), sellerOrderGoods.getGoodsPrice())));
280 } 287 }
281 - orderListInfo.setPayTimeLimit(OrderInfo.SELLER_PAY_TIMEOUT);  
282 return orderListInfo; 288 return orderListInfo;
283 } 289 }
284 290
@@ -421,7 +421,6 @@ public class SkupListService { @@ -421,7 +421,6 @@ public class SkupListService {
421 productInfo.setStorageNumDesc(psogOfMerge.getStorageNum() + "个商品库存"); 421 productInfo.setStorageNumDesc(psogOfMerge.getStorageNum() + "个商品库存");
422 } 422 }
423 orderListInfo.setGoodsInfo(productInfo); 423 orderListInfo.setGoodsInfo(productInfo);
424 - orderListInfo.setPayTimeLimit(OrderInfo.SELLER_PAY_TIMEOUT);  
425 return orderListInfo; 424 return orderListInfo;
426 } 425 }
427 426
  1 +package com.yohoufo.order.service.wrapper;
  2 +
  3 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
  4 +import com.yohoufo.common.utils.DateUtil;
  5 +import org.slf4j.Logger;
  6 +
  7 +import java.util.function.BiFunction;
  8 +
  9 +/**
  10 + * Created by chao.chen on 2019/1/23.
  11 + */
  12 +public abstract class AbsTimeoutWrapper {
  13 + Logger logger;
  14 + BiFunction<Integer,Long,TimeoutBo> deliverLeftTimeDS ;
  15 +
  16 + protected int calLeftTime(int timeout, int creatTime){
  17 + int payExpire = timeout - (DateUtil.getCurrentTimeSecond() - creatTime);
  18 + if (payExpire < 0){
  19 + payExpire = 0;
  20 + }
  21 + return payExpire;
  22 + }
  23 +
  24 +}
  1 +package com.yohoufo.order.service.wrapper;
  2 +
  3 +import com.yohobuy.ufo.model.order.bo.OrderInfo;
  4 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
  5 +import com.yohobuy.ufo.model.order.common.OrderStatus;
  6 +import com.yohobuy.ufo.model.order.common.SkupStatus;
  7 +import com.yohobuy.ufo.model.order.common.TabType;
  8 +import com.yohobuy.ufo.model.order.constants.TimeoutCase;
  9 +import com.yohoufo.dal.order.model.BuyerOrder;
  10 +import org.slf4j.Logger;
  11 +
  12 +import java.util.function.BiFunction;
  13 +
  14 +/**
  15 + * Created by chao.chen on 2019/1/23.
  16 + */
  17 +public class BuyerOrderTimeoutWrapper extends AbsTimeoutWrapper{
  18 +
  19 + private BuyerOrder buyerOrder;
  20 + private BuyerOrderTimeoutWrapper(){
  21 + throw new RuntimeException("what r u doing?");
  22 + }
  23 +
  24 + public BuyerOrderTimeoutWrapper(BuyerOrder buyerOrder, BiFunction<Integer,Long,TimeoutBo> deliverLeftTimeDS){
  25 + this.buyerOrder = buyerOrder;
  26 + this.deliverLeftTimeDS = deliverLeftTimeDS;
  27 + }
  28 +
  29 + public BuyerOrderTimeoutWrapper(BuyerOrder buyerOrder){
  30 + this.buyerOrder = buyerOrder;
  31 + }
  32 +
  33 + public BuyerOrderTimeoutWrapper logger(Logger logger){
  34 + this.logger = logger;
  35 + return this;
  36 + }
  37 +
  38 + public TimeoutBo calDeliverLeftTime(){
  39 + int buyerUid = buyerOrder.getUid();
  40 + long orderCode = buyerOrder.getOrderCode();
  41 + Integer orderStatus = buyerOrder.getStatus();
  42 + TimeoutBo timeoutBo = new TimeoutBo();
  43 + if (OrderStatus.HAS_PAYED.getCode() == orderStatus){
  44 + timeoutBo = deliverLeftTimeDS.apply(buyerUid, orderCode);
  45 + }
  46 + return timeoutBo;
  47 + }
  48 +
  49 + public TimeoutBo calPayLeftTime(TabType actor){
  50 + Integer orderStatus = buyerOrder.getStatus();
  51 + int createTime = buyerOrder.getCreateTime();
  52 + boolean isBuyer = actor.equals(TabType.BUY);
  53 + boolean isSeller = actor.equals(TabType.SELL);
  54 + Integer leftTime = null;
  55 + int timeout = OrderInfo.PAY_TIME_SECOND;
  56 + boolean isFiredCal = (isBuyer && orderStatus == OrderStatus.WAITING_PAY.getCode())
  57 + || (isSeller && orderStatus == SkupStatus.CAN_NOT_SELL.getCode());
  58 + if(isFiredCal){
  59 + leftTime = calLeftTime(timeout, createTime);
  60 + }
  61 + TimeoutBo timeoutBo = new TimeoutBo();
  62 + timeoutBo.setLeftTime(leftTime);
  63 + timeoutBo.setTimelimit(timeout);
  64 + timeoutBo.setStartTime(createTime);
  65 + timeoutBo.setTimeoutCase(TimeoutCase.PAY);
  66 + return timeoutBo;
  67 + }
  68 +}
  1 +package com.yohoufo.order.service.wrapper;
  2 +
  3 +import com.yohobuy.ufo.model.order.bo.OrderInfo;
  4 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
  5 +import com.yohobuy.ufo.model.order.common.OrderCodeType;
  6 +import com.yohobuy.ufo.model.order.common.OrderStatus;
  7 +import com.yohobuy.ufo.model.order.common.SkupStatus;
  8 +import com.yohobuy.ufo.model.order.constants.TimeoutCase;
  9 +
  10 +/**
  11 + * Created by chao.chen on 2019/1/23.
  12 + *
  13 + * @author chao.chen
  14 + * @since yohobuy version 6.8.5
  15 + */
  16 +public class SellerOrderTimeoutWrapper extends AbsTimeoutWrapper{
  17 +
  18 +
  19 + private OrderCodeType orderCodeType;
  20 + private Integer orderStatus;
  21 + private int createTime;
  22 +
  23 + public SellerOrderTimeoutWrapper orderCodeType(OrderCodeType orderCodeType){
  24 + this.orderCodeType = orderCodeType;
  25 + return this;
  26 + }
  27 +
  28 + public SellerOrderTimeoutWrapper orderStatus(Integer orderStatus){
  29 + this.orderStatus = orderStatus;
  30 + return this;
  31 + }
  32 +
  33 + public SellerOrderTimeoutWrapper createTime(int createTime){
  34 + this.createTime = createTime;
  35 + return this;
  36 + }
  37 +
  38 + /**
  39 + *
  40 + * @return
  41 + */
  42 + public TimeoutBo calculatePayLeftTime(){
  43 + if (orderCodeType == null){
  44 + return null;
  45 + }
  46 + Integer leftTime = null;
  47 + Integer timeout = OrderInfo.PAY_TIME_SECOND;
  48 + boolean isWaitingPay = false;
  49 + //查看买家
  50 + if (orderCodeType == OrderCodeType.BUYER_TYPE){
  51 + isWaitingPay = orderStatus == OrderStatus.WAITING_PAY.getCode();
  52 + if (isWaitingPay){
  53 + timeout = OrderInfo.PAY_TIME_SECOND;
  54 + }
  55 + }
  56 + //查看卖家
  57 + if (orderCodeType == OrderCodeType.SELLER_TYPE){
  58 + isWaitingPay = orderStatus == SkupStatus.CAN_NOT_SELL.getCode();
  59 + if (isWaitingPay)timeout = OrderInfo.SELLER_PAY_TIMEOUT;
  60 + }
  61 +
  62 + if(isWaitingPay){
  63 + leftTime = calLeftTime(timeout, createTime);
  64 + }
  65 +
  66 + TimeoutBo timeoutBo = new TimeoutBo();
  67 + timeoutBo.setLeftTime(leftTime);
  68 + timeoutBo.setTimelimit(timeout);
  69 + timeoutBo.setStartTime(createTime);
  70 + timeoutBo.setTimeoutCase(TimeoutCase.PAY);
  71 + return timeoutBo;
  72 + }
  73 +
  74 +}