Authored by wujiexiang

Merge branch 'dev_bid' into test6.9.13

Showing 18 changed files with 377 additions and 72 deletions
... ... @@ -357,6 +357,9 @@
<if test="originalStatus != null">
and status = #{originalStatus,jdbcType=INTEGER}
</if>
<if test="bidType != null">
and bid_type = #{bidType,jdbcType=INTEGER}
</if>
</update>
... ...
package com.yohoufo.order.controller;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/erp")
public class ErpGWSkupController {
private final Logger logger = LoggerUtils.getOrderCloseLogger();
@Autowired
private IBuyerOrderService buyerOrderService;
/**
* 客服根据skup取消求购中的订单
*
* @return
*/
@RequestMapping(value = "/bid/cancelBiding")
@IgnoreSession
@IgnoreSignature
public ApiResponse cancelBidingByCS(@RequestParam(name = "skup") int skup) {
logger.info("method cs cancel biding order by skup in, skup is {}", skup);
// 检查
if (skup <= 0) {
return new ApiResponse.ApiResponseBuilder().code(400).message("参数校验不通过").build();
}
buyerOrderService.cancelBidingBySkup(skup);
return new ApiResponse.ApiResponseBuilder().code(200).build();
}
}
... ...
package com.yohoufo.order.model.bo;
public interface DetailItem {
/**
* 详情内容
*/
String getDetailDesc();
/**
* 剩余时间
*/
int getLeftTime();
}
... ...
package com.yohoufo.order.model.request;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.order.common.Operator;
import com.yohoufo.order.event.OrderCancelEvent;
import lombok.AllArgsConstructor;
import lombok.Data;
... ... @@ -27,8 +26,4 @@ public class OrderRequest {
OrderCancelEvent orderCancelEvent;
String appVersion;
//操作者
Operator operator;
}
... ...
... ... @@ -8,11 +8,13 @@ public interface DelayTime {
int MINUTES_7_DAYS = 24 * 60 * 7;
int BUYER_ORDER_WAITING_PAY = 10;
int BUYER_ORDER_WAITING_PAY_DEPOSIT = 15;
//求购订单待支付
int BUYER_BID_ORDER_WAITING_PAY = 24 * 60;
int MINUTES_36_HOURS = 36*60;
... ...
package com.yohoufo.order.mq.consumer;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.order.common.Operator;
import com.yohoufo.order.event.OrderCancelEvent;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.BuyerOrderStateChangers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
public class BuyerOrderAutoCancelDelayNDayMsgConsumer extends AbsOrderAutoCancelDelayMsgConsumer {
@Autowired
private IBuyerOrderService buyerOrderService;
private BuyerOrderStateChangers buyerOrderStateChangers;
@Override
public String getTopic() {
... ... @@ -23,8 +23,7 @@ public class BuyerOrderAutoCancelDelayNDayMsgConsumer extends AbsOrderAutoCancel
public void cancel(OrderCancelEvent event) {
int uid = event.getUid();
long orderCode = event.getOrderCode();
OrderRequest req = OrderRequest.builder().uid(uid).orderCode(orderCode).operator(Operator.SYSTEM).build();
buyerOrderService.cancelBiding(req);
buyerOrderStateChangers.selectOneToChange(uid, orderCode, OrderStatus.BIDING, OrderStatus.SYSTEM_CLOSE_BID, Operator.SYSTEM);
}
@Override
... ...
... ... @@ -34,10 +34,10 @@ public interface IBuyerOrderService {
void cancelByAuto(OrderRequest orderRequest);
/**
* 取消求购中的订单
* @param orderRequest
* 通过skup取消求购中的订单
* @param skup
*/
void cancelBiding(OrderRequest orderRequest);
void cancelBidingBySkup(int skup);
/**
* 提交订单
... ...
... ... @@ -32,6 +32,7 @@ import com.yohoufo.order.service.IExpressInfoService;
import com.yohoufo.order.service.IOrderDetailService;
import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport;
import com.yohoufo.order.service.support.BuyerOrderMetaMapperSupport;
import com.yohoufo.order.service.support.OrderStatusDetailItemFactory;
import com.yohoufo.order.utils.*;
import lombok.Builder;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -58,6 +59,9 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
@Autowired
protected BuyerOrderStatusFlowMapper buyerOrderStatusFlowMapper;
@Autowired
protected OrderStatusDetailItemFactory orderStatusDetailItemFactory;
abstract BuyerOrder getBuyerOrder(int uid, long orderCode);
... ...
... ... @@ -7,15 +7,10 @@ import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.bo.SubmitSellerOrder;
import com.yohoufo.order.service.seller.SkupService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
... ...
... ... @@ -18,6 +18,7 @@ import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.bo.BidOrderMetaBo;
import com.yohoufo.order.model.bo.DetailItem;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohobuy.ufo.model.order.resp.OrderDetailInfo;
import com.yohoufo.order.service.IOrderDetailService;
... ... @@ -161,14 +162,7 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
String detailDesc = temp;
Integer orderStatus = buyerOrder.getStatus();
try {
if (buyerOrder.isBidOrder() && orderStatus == OrderStatus.BIDING.getCode()) {
//求购中状态
BidOrderMetaBo bidOrderMetaBo = buyerOrderMetaMapperSupport.selectByMetaKey(buyerOrder.getUid(), buyerOrder.getOrderCode(), MetaKey.BID_KEY, BidOrderMetaBo.class);
detailDesc = String.format(temp, bidOrderMetaBo.getDay());
} else if (buyerOrder.isBidOrder() && orderStatus == OrderStatus.WAITING_PAY.getCode()) {
//求购 待付尾款
detailDesc = OrderDetailDesc.BID_NO_PAY;
} else if (orderStatus == OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode()
if (orderStatus == OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode()
|| orderStatus == OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode()
|| OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE_USE_DEPOSIT_GOODS.getCode() == orderStatus) {
Object[] formatParms = new Object[1];
... ... @@ -203,6 +197,22 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
.status(orderStatus.getCode())
.statuStr(orderStatus.getStatusStr(tabType))
.build();
DetailItem detailItem = orderStatusDetailItemFactory.get(buyerOrder, orderStatus, tabType);
if (detailItem != null) {
statusDetail.setDetailDesc(detailItem.getDetailDesc());
statusDetail.setLeftTime(detailItem.getLeftTime());
} else {
internalSetStatusDetail(statusDetail, skupType, buyerOrder, orderStatus, tabType);
}
if(ActionStatusHold.getBuyerShowExpressStatusList().contains(orderStatus.getCode())){
statusDetail.setExpressShow(true);
}
return statusDetail;
}
private void internalSetStatusDetail(OrderDetailInfo.StatusDetail statusDetail, SkupType skupType, BuyerOrder buyerOrder, OrderStatus orderStatus, TabType tabType) {
OrderAttributes oa = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes());
String detailDesc = formatDetailDesc(buyerOrder, orderStatus.getDetailDesc(tabType, oa), skupType);
statusDetail.setDetailDesc(detailDesc);
... ... @@ -211,15 +221,9 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
TimeoutBo timeoutBo = calTimeout(tabType, buyerOrder.getUid(),
buyerOrder.getOrderCode(), orderStatus.getCode(),
buyerOrder.getCreateTime(), oa);
if (Objects.nonNull(timeoutBo)){
if (Objects.nonNull(timeoutBo)) {
statusDetail.setLeftTime(timeoutBo.getLeftTime());
}
if(ActionStatusHold.getBuyerShowExpressStatusList().contains(orderStatus.getCode())){
statusDetail.setExpressShow(true);
}
return statusDetail;
}
private void procsessButtons(OrderDetailInfo orderDetailInfo){
... ...
... ... @@ -42,6 +42,7 @@ import com.yohoufo.order.service.proxy.*;
import com.yohoufo.order.service.seller.SkupService;
import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
import com.yohoufo.order.service.seller.orderMeta.SellerOrderMetaService;
import com.yohoufo.order.service.support.BuyerOrderGoodsMapperSupport;
import com.yohoufo.order.utils.BuyerOrderUtils;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerGoodsHelper;
... ... @@ -145,6 +146,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
private BuyerOrderStateChangers buyerOrderStateChangers;
@Autowired
private BuyerOrderGoodsMapperSupport buyerOrderGoodsMapperSupport;
/**
* 提交订单
* @param orderRequest
... ... @@ -422,14 +426,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
orderStatusFlowService.addAsy(orderRequest.getOrderCode(), targetStatus.getCode());
}
/**
* 取消求购订单
*
* @param orderRequest
*/
@Override
public void cancelBiding(OrderRequest orderRequest) {
buyerOrderStateChangers.selectOneToChange(orderRequest.getUid(), orderRequest.getOrderCode(), OrderStatus.BIDING, OrderStatus.BUYER_BID_CLOSE, orderRequest.getOperator());
public void cancelBidingBySkup(int skup) {
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapperSupport.selectBuyerOrderGoodsBySkup(skup);
buyerOrderStateChangers.selectOneToChange(buyerOrderGoods.getUid(), buyerOrderGoods.getOrderCode(), OrderStatus.BIDING, OrderStatus.PLATFORM_CLOSE_BID, Operator.CS);
}
private void doCancelBidByAuto(BuyerOrder buyerOrder, OrderCancelEvent orderCancelEvent, OrderStatus sourceStatus, OrderStatus targetStatus) {
... ... @@ -478,11 +478,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
boolean useDepositGoods = node.useDepositGoods;
switch (expectStatus){
case WAITING_PAY_DEPOSIT:
targetStatus = OrderStatus.BUYER_BID_CLOSE;
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOSIT_PAY;
buyerOrderStateChangers.selectOneToChange(buyerOrder, OrderStatus.WAITING_PAY_DEPOSIT, targetStatus);
break;
case BIDING:
targetStatus = OrderStatus.BUYER_BID_CLOSE;
targetStatus = OrderStatus.BUYER_CLOSE_BID;
//求购中取消
buyerOrderStateChangers.selectOneToChange(buyerOrder, OrderStatus.BIDING, targetStatus);
break;
... ...
... ... @@ -6,6 +6,7 @@ import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohobuy.ufo.model.order.common.SellerOrderStatus;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -15,8 +16,8 @@ import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.bo.SubmitSellerOrder;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.service.support.BuyerOrderGoodsMapperSupport;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -80,7 +81,7 @@ public class SellerBidOrderBindService {
private SellerOrderMetaMapper somMapper;
@Autowired
private BuyerOrderGoodsMapper buyerOrderGoodsMapper;
private BuyerOrderGoodsMapperSupport buyerOrderGoodsMapperSupport;
@Autowired
private BuyerOrderMapper buyerOrderMapper;
... ... @@ -198,32 +199,18 @@ public class SellerBidOrderBindService {
}
protected void bindSellerUidWithBuyerOrder(int skup, int sellerUid) {
BuyerOrderGoods buyerOrderGoods = getBuyerOrderGoods(skup);
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapperSupport.selectBuyerOrderGoodsBySkup(skup);
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setUid(buyerOrderGoods.getUid());
buyerOrder.setOrderCode(buyerOrderGoods.getOrderCode());
buyerOrder.setSellerUid(sellerUid);
buyerOrder.setBidType(OrderConstant.BUYER_BID_TYPE);
boolean success = buyerOrderMapper.updateByOrderCode(buyerOrder) > 0;
if (!success) {
logger.warn("[{}] buyer order is bind with sellerUid:{} fail ", buyerOrderGoods.getOrderCode());
throw new UfoServiceException(500, "操作失败");
}
logger.warn("[{}] buyer order is bind with sellerUid:{} success ", buyerOrderGoods.getOrderCode());
}
private BuyerOrderGoods getBuyerOrderGoods(int skup) {
List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectOrderBySkups(skup);
if (CollectionUtils.isEmpty(buyerOrderGoodsList)) {
logger.warn("not find buyer order goods by skup:{}", skup);
return null;
}
if (buyerOrderGoodsList.size() != 1) {
logger.warn("is impossible,buyer order goods size != 1 by skup:{}", skup);
return null;
}
return buyerOrderGoodsList.get(0);
logger.info("[{}] buyer order is bind with sellerUid:{} success ", buyerOrderGoods.getOrderCode());
}
}
}
\ No newline at end of file
... ...
... ... @@ -21,6 +21,7 @@ import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.bo.DetailItem;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohobuy.ufo.model.order.resp.AppraiseAddressInfo;
... ... @@ -460,7 +461,21 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
.statuStr(orderStatus.getStatusStr(tabType))
.build();
DetailItem detailItem = orderStatusDetailItemFactory.get(buyerOrder, orderStatus, tabType);
if (detailItem != null) {
statusDetail.setDetailDesc(detailItem.getDetailDesc());
statusDetail.setLeftTime(detailItem.getLeftTime());
} else {
internalSetStatusDetail(statusDetail, skupType, buyerOrder, orderStatus, tabType);
}
if(ActionStatusHold.getSellerShowExpressStatusList().contains(orderStatus.getCode())){
statusDetail.setExpressShow(true);
}
return statusDetail;
}
private void internalSetStatusDetail(OrderDetailInfo.StatusDetail statusDetail, SkupType skupType, BuyerOrder buyerOrder, OrderStatus orderStatus, TabType tabType) {
OrderAttributes oa = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes());
Integer buyerUid = buyerOrder.getUid();
... ... @@ -468,16 +483,12 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
int orderStatusCode = orderStatus.getCode();
Integer createTime = buyerOrder.getCreateTime();
TimeoutBo timeoutBo = calTimeout(tabType, buyerUid, orderCode, orderStatusCode, createTime, oa);
if (Objects.nonNull(timeoutBo)){
if (Objects.nonNull(timeoutBo)) {
statusDetail.setLeftTime(timeoutBo.getLeftTime());
}
if(ActionStatusHold.getSellerShowExpressStatusList().contains(orderStatus.getCode())){
statusDetail.setExpressShow(true);
}
boolean usingDepositGoods = StringUtils.isNotBlank(buyerOrderMetaService.getDepositCode(buyerUid, orderCode));
String detailDesc = formatDetailDesc(skupType, buyerOrder, orderStatus, tabType, usingDepositGoods);
statusDetail.setDetailDesc(detailDesc);
return statusDetail;
}
... ... @@ -521,8 +532,6 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
}else{
detailDesc = String.format(detailDesc, skupType == SkupType.FAST_DELIVERY ? 24 :72);
}
} else if (buyerOrder.isBidOrder() && orderStatus.getCode() == OrderStatus.WAITING_PAY.getCode()) {
detailDesc = OrderDetailDesc.Seller.BID_BUYER_NO_PAY;
}
//闪购发货商品,且已完成(区分寄存 发货)
... ...
... ... @@ -76,6 +76,6 @@ public class BuyerOrderBidingCancelChanger extends AbstractBuyerOrderStateChange
public boolean isSupport(RequestedStatusChangeBuyerOrder statusChangeBuyerOrder) {
OrderStatus sourceStatus = statusChangeBuyerOrder.getSourceStatus();
OrderStatus targetStatus = statusChangeBuyerOrder.getTargetStatus();
return sourceStatus == BIDING && targetStatus == BUYER_BID_CLOSE;
return sourceStatus == BIDING && (targetStatus == BUYER_CLOSE_BID || targetStatus == SYSTEM_CLOSE_BID || targetStatus == PLATFORM_CLOSE_BID);
}
}
... ...
... ... @@ -6,6 +6,7 @@ import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.order.event.BuyerOrderDelayCancelEvent;
import com.yohoufo.order.model.RequestedStatusChangeBuyerOrder;
import com.yohoufo.order.mq.DelayTime;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.service.AbstractBuyerOrderStateChanger;
import org.springframework.stereotype.Service;
... ... @@ -39,7 +40,7 @@ public class BuyerOrderBidingToWaitingPayChanger extends AbstractBuyerOrderState
BuyerOrderDelayCancelEvent buyerCancelEvent = BuyerOrderDelayCancelEvent.builder().uid(uid)
.orderCode(orderCode)
.topic(TopicConstants.BUYER_ORDER_AUTO_CANCEL)
.delayTime(1 * 24 * 60).build();
.delayTime(DelayTime.BUYER_BID_ORDER_WAITING_PAY).build();
EventBusPublisher.publishEvent(buyerCancelEvent);
}
}
... ...
... ... @@ -37,7 +37,7 @@ public class BuyerOrderWaitingPayDepositCancelChanger extends AbstractBuyerOrder
public boolean isSupport(RequestedStatusChangeBuyerOrder statusChangeBuyerOrder) {
OrderStatus sourceStatus = statusChangeBuyerOrder.getSourceStatus();
OrderStatus targetStatus = statusChangeBuyerOrder.getTargetStatus();
return sourceStatus == WAITING_PAY_DEPOSIT && targetStatus == BUYER_BID_CLOSE ;
return sourceStatus == WAITING_PAY_DEPOSIT && targetStatus == BUYER_CANCEL_BEFORE_DEPOSIT_PAY ;
}
private void processIfExistChangePriceRecord(long orderCode, Operator operator) {
... ...
package com.yohoufo.order.service.support;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class BuyerOrderGoodsMapperSupport {
private final static Logger logger = LoggerUtils.getBuyerOrderLogger();
@Autowired
private BuyerOrderGoodsMapper buyerOrderGoodsMapper;
public BuyerOrderGoods selectBuyerOrderGoodsBySkup(int skup) {
List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectOrderBySkups(skup);
if (CollectionUtils.isEmpty(buyerOrderGoodsList)) {
logger.warn("not find buyer order goods by skup:{}", skup);
return null;
}
if (buyerOrderGoodsList.size() != 1) {
logger.warn("is impossible,buyer order goods size != 1 by skup:{}", skup);
return null;
}
return buyerOrderGoodsList.get(0);
}
}
... ...
package com.yohoufo.order.service.support;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.bo.BidOrderMetaBo;
import com.yohoufo.order.model.bo.DetailItem;
import com.yohoufo.order.mq.DelayTime;
import com.yohoufo.order.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class OrderStatusDetailItemFactory {
@Autowired
private BuyerOrderMetaMapperSupport buyerOrderMetaMapperSupport;
/**
* @param buyerOrder
* @param orderStatus
* @param tabType
* @return
*/
public DetailItem get(BuyerOrder buyerOrder, OrderStatus orderStatus, TabType tabType) {
DetailItem detailItem = null;
if (buyerOrder.isBidOrder()) {
detailItem = getBidOrderDetailItem(buyerOrder, orderStatus, tabType);
}
return detailItem;
}
private DetailItem getBidOrderDetailItem(BuyerOrder buyerOrder, OrderStatus orderStatus, TabType tabType) {
DetailItem detailItem = null;
int createTime = buyerOrder.getCreateTime();
switch (orderStatus) {
case WAITING_PAY_DEPOSIT:
detailItem = new WaitingPayDepositItem(createTime, tabType);
break;
case BIDING:
BidOrderMetaBo bidOrderMetaBo = buyerOrderMetaMapperSupport.selectByMetaKey(buyerOrder.getUid(), buyerOrder.getOrderCode(), MetaKey.BID_KEY, BidOrderMetaBo.class);
detailItem = new BidingOrderItem(bidOrderMetaBo.getDay());
break;
case WAITING_PAY:
detailItem = new WaitingPayItem(createTime, tabType);
break;
case BUYER_CANCEL_BEFORE_PAY:
detailItem = new CancelBeforePayItem(tabType);
break;
case BUYER_CANCEL_TIMEOUT:
detailItem = new CancelTimeOutBeforePayItem(tabType);
break;
default:
break;
}
return detailItem;
}
private abstract class AbstractOrderDetailItem implements DetailItem {
public final static String EMPTY_DESC = "";
/**
* 求购定金支付
*/
public final static String WAITING_PAY_DEPOSIT_DESC = "请在%s分钟内支付,超时将自动取消";
/**
* 买家求购中
*/
public final static String BIDING_DESC = "如果%s天内未完成匹配,定金将退回你的支付账户";
/**
* 卖家变现后买家未支付
*/
public final static String WAITING_PAY_BUYER_DESC = "支付完成后,定金将原路返回,如果超时未能完成支付,定金将补偿给卖家";
public final static String WAITING_PAY_SELLER_DESC = "如果买家未能在%s小时完成支付,你将获得定金赔偿";
public final static String CANCEL_BEFORE_PAY_BUYER_DESC = "您已取消商品购买,您的定金已赔偿给卖家";
public final static String CANCEL_BEFORE_PAY_SELLER_DESC = "买家取消订单,您的商品已下架,您已获得买家定金赔偿";
public final static String CANCEL_TIMEOUT_BEFORE_PAY_BUYER_DESC = "您支付超时,您的定金已赔偿给卖家";
public final static String CANCEL_TIMEOUT_BEFORE_PAY_SELLER_DESC = "买家付款超时,系统取消订单,您已获得买家定金赔偿";
protected int createTime;
protected TabType tabType;
public AbstractOrderDetailItem() {
this(0, TabType.BUY);
}
public AbstractOrderDetailItem(TabType tabType) {
this(0, tabType);
}
public AbstractOrderDetailItem(int createTime, TabType tabType) {
this.createTime = createTime;
this.tabType = tabType;
}
public int getLeftTime() {
return 0;
}
protected int calLeftTime(int timeout) {
return TimeUtils.calLeftTime(timeout, this.createTime);
}
}
/**
* 待付定金
*/
private class WaitingPayDepositItem extends AbstractOrderDetailItem {
public WaitingPayDepositItem(int createTime, TabType tabType) {
super(createTime, tabType);
}
@Override
public String getDetailDesc() {
return String.format(WAITING_PAY_DEPOSIT_DESC, DelayTime.BUYER_ORDER_WAITING_PAY_DEPOSIT);
}
@Override
public int getLeftTime() {
return calLeftTime(DelayTime.BUYER_ORDER_WAITING_PAY_DEPOSIT);
}
}
/**
* 求购中
*/
private class BidingOrderItem extends AbstractOrderDetailItem {
int day = 1;
public BidingOrderItem(int day) {
this.day = day;
}
@Override
public String getDetailDesc() {
return String.format(BIDING_DESC, day);
}
}
/**
* 待支付
*/
private class WaitingPayItem extends AbstractOrderDetailItem {
public WaitingPayItem(int createTime, TabType tabType) {
super(createTime, tabType);
}
@Override
public String getDetailDesc() {
switch (tabType) {
case BUY:
return WAITING_PAY_BUYER_DESC;
case SELL:
return String.format(WAITING_PAY_SELLER_DESC, DelayTime.BUYER_BID_ORDER_WAITING_PAY);
default:
return EMPTY_DESC;
}
}
@Override
public int getLeftTime() {
return calLeftTime(DelayTime.BUYER_BID_ORDER_WAITING_PAY);
}
}
private class CancelBeforePayItem extends AbstractOrderDetailItem {
public CancelBeforePayItem(TabType tabType) {
super(tabType);
}
@Override
public String getDetailDesc() {
switch (tabType) {
case BUY:
return CANCEL_BEFORE_PAY_BUYER_DESC;
case SELL:
return CANCEL_BEFORE_PAY_SELLER_DESC;
default:
return EMPTY_DESC;
}
}
}
private class CancelTimeOutBeforePayItem extends AbstractOrderDetailItem {
public CancelTimeOutBeforePayItem(TabType tabType) {
super(tabType);
}
@Override
public String getDetailDesc() {
switch (tabType) {
case BUY:
return CANCEL_TIMEOUT_BEFORE_PAY_BUYER_DESC;
case SELL:
return CANCEL_TIMEOUT_BEFORE_PAY_SELLER_DESC;
default:
return EMPTY_DESC;
}
}
}
}
... ...