小程序(及后端)订单详情页完成;后端获取用户订单列表接口完成
This commit is contained in:
@@ -1,19 +1,34 @@
|
||||
package com.cxyxiaomo.epp.common.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
public enum OrderStatus {
|
||||
PENDING("Pending"),
|
||||
PROCESSING("Processing"),
|
||||
SHIPPED("Shipped"),
|
||||
DELIVERED("Delivered"),
|
||||
CANCELLED("Cancelled");
|
||||
PENDING("Pending", "等待确认"),
|
||||
PROCESSING("Processing", "已支付,正在处理"),
|
||||
SHIPPED("Shipped", "已发货,等待确认收货"),
|
||||
DELIVERED("Delivered", "已送达"),
|
||||
CANCELLED("Cancelled", "已取消");
|
||||
|
||||
private final String value;
|
||||
private final String description;
|
||||
|
||||
private OrderStatus(String value) {
|
||||
private OrderStatus(String value, String description) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public static OrderStatus get(String code) {
|
||||
Optional<OrderStatus> first = Arrays.stream(OrderStatus.values()).filter(e -> e.getValue().equals(code)).findFirst();
|
||||
OrderStatus orderStatus = first.orElse(null);
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.cxyxiaomo.epp.common.pojo;
|
||||
|
||||
import com.cxyxiaomo.epp.common.enums.OrderStatus;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -14,5 +13,5 @@ public class Order {
|
||||
private Long id;
|
||||
private Integer userId;
|
||||
private LocalDateTime orderDate;
|
||||
private OrderStatus orderStatus;
|
||||
private String orderStatus;
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ import java.util.stream.Collectors;
|
||||
@Accessors(chain = true) // 链式写法
|
||||
// 微服务必须要实现Serializable
|
||||
public class GoodVO implements Serializable {
|
||||
Long id;
|
||||
String id;
|
||||
String goodsName;
|
||||
Integer categoryId;
|
||||
String brand;
|
||||
@@ -38,6 +38,7 @@ public class GoodVO implements Serializable {
|
||||
}
|
||||
GoodVO goodVO = new GoodVO();
|
||||
BeanUtils.copyProperties(good, goodVO);
|
||||
goodVO.setId(String.valueOf(good.getId()));
|
||||
return goodVO;
|
||||
}
|
||||
|
||||
|
@@ -4,6 +4,7 @@ import com.cxyxiaomo.epp.common.pojo.OrderDetail;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -17,8 +18,8 @@ import java.util.stream.Collectors;
|
||||
// 微服务必须要实现Serializable
|
||||
public class OrderDetailVO implements Serializable {
|
||||
private Long id;
|
||||
private Long orderId;
|
||||
private Long goodId;
|
||||
private String orderId;
|
||||
private String goodId;
|
||||
private Integer goodCount;
|
||||
private Double unitPrice;
|
||||
|
||||
@@ -27,7 +28,9 @@ public class OrderDetailVO implements Serializable {
|
||||
return null;
|
||||
}
|
||||
OrderDetailVO orderDetailVO = new OrderDetailVO();
|
||||
// BeanUtils.copyProperties(orderDetail, orderDetailVO);
|
||||
BeanUtils.copyProperties(orderDetail, orderDetailVO);
|
||||
orderDetailVO.setOrderId(String.valueOf(orderDetail.getOrderId()));
|
||||
orderDetailVO.setGoodId(String.valueOf(orderDetail.getGoodId()));
|
||||
return orderDetailVO;
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,6 @@ import lombok.experimental.Accessors;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -20,10 +19,10 @@ import java.util.stream.Collectors;
|
||||
@Accessors(chain = true) // 链式写法
|
||||
// 微服务必须要实现Serializable
|
||||
public class OrderVO implements Serializable {
|
||||
private Long id;
|
||||
private String id;
|
||||
private Integer userId;
|
||||
private LocalDateTime orderDate;
|
||||
private OrderStatus orderStatus;
|
||||
private String orderStatus;
|
||||
|
||||
public static OrderVO convertFrom(Order order) {
|
||||
if (order == null) {
|
||||
@@ -31,6 +30,10 @@ public class OrderVO implements Serializable {
|
||||
}
|
||||
OrderVO orderVO = new OrderVO();
|
||||
BeanUtils.copyProperties(order, orderVO);
|
||||
|
||||
orderVO.setId(String.valueOf(order.getId())); // 转成字符串 避免前端丢失精度
|
||||
OrderStatus orderStatus = OrderStatus.get(order.getOrderStatus());
|
||||
orderVO.setOrderStatus(orderStatus.toString());
|
||||
return orderVO;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user