Authored by Lixiaodi

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

... ... @@ -2,6 +2,8 @@ package com.yohoufo.order.common;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* 主要用于追踪保证金状态
... ... @@ -51,6 +53,18 @@ public enum SellerOrderStatus {
return node == null ? null : node.skupStatus;
}
private static Map<Integer, SellerOrderStatus> cache;
static {
cache = new HashMap<>(16);
for (SellerOrderStatus status : values()){
cache.put(status.code, status);
}
}
public static SellerOrderStatus getSellerOrderStatus(int code){
return cache.get(code);
}
static {
for (SellerOrderStatus sellerOrderStatus : values()){
switch (sellerOrderStatus){
... ...
... ... @@ -82,7 +82,7 @@ public class SellerOrderController {
@RequestMapping(params = "method=ufo.sellerOrder.cancel")
@ResponseBody
public ApiResponse cancel(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "order_code", required = true)long orderCode
@RequestParam(name = "orderCode", required = true)long orderCode
) throws GatewayException {
SellerOrderCancelReq req = SellerOrderCancelReq.builder()
.uid(uid)
... ... @@ -100,7 +100,7 @@ public class SellerOrderController {
@RequestMapping(params = "method=ufo.sellerOrder.delete")
@ResponseBody
public ApiResponse delete(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "order_code", required = true)long orderCode
@RequestParam(name = "orderCode", required = true)long orderCode
) throws GatewayException {
SellerOrderCancelReq req = SellerOrderCancelReq.builder()
.uid(uid)
... ...
... ... @@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
... ... @@ -70,6 +71,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
List<SellerOrder> sellerOrders = sellerOrderMapper.selectBySkups(skupList);
List<OrderListInfo> data = sellerOrders.parallelStream()
.map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()), sellerOrder))
.filter(oli -> Objects.nonNull(oli))
.collect(Collectors.toList());
PageResp orderListInfoRsp = respBuilder.data(data).build();
... ... @@ -80,30 +82,32 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
}
OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods,
SellerOrder buyerOrder) {
SellerOrder sellerOrder) {
OrderListInfo orderListInfo = new OrderListInfo();
orderListInfo.setUid(buyerOrder.getUid());
orderListInfo.setOrderCode(buyerOrder.getOrderCode());
orderListInfo.setUid(sellerOrder.getUid());
orderListInfo.setOrderCode(sellerOrder.getOrderCode());
orderListInfo.setRealPrice(sellerOrderGoods.getGoodsPrice().toPlainString());
// 订单中状态显示
orderListInfo.setStatus(buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus());
SkupStatus orderStatus = SkupStatus.getSkupStatus(orderListInfo.getStatus());
orderListInfo.setStatus(sellerOrder.getStatus() == null ? -1 : sellerOrder.getStatus());
if (orderStatus == null){
log.warn("getOrderList orderStatus not exist, uid is {}, orderCode is {}, status is {}",
buyerOrder.getUid(), orderListInfo.getOrderCode(), buyerOrder.getStatus());
SellerOrderStatus sellerOrderStatus = SellerOrderStatus.getSellerOrderStatus(orderListInfo.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.setStatuStr(orderStatus.getDesc());
orderListInfo.setStatuStr(skupStatus.getDesc());
// 按钮显示
orderListInfo.setButtons(orderStatus.getListButtons());
orderListInfo.setButtons(skupStatus.getListButtons());
// 当订单状态是待付款, 显示leftTime
if (orderListInfo.getStatus() == SellerOrderStatus.WAITING_PAY.getCode()){
orderListInfo.setLeftTime(DateUtil.getCurrentTimeSecond() - buyerOrder.getCreateTime());
orderListInfo.setLeftTime(DateUtil.getCurrentTimeSecond() - sellerOrder.getCreateTime());
}
... ...