买家端订单fegin接口
This commit is contained in:
@@ -5,6 +5,7 @@ import com.aida.seller.common.result.PageResponse;
|
|||||||
import com.aida.seller.common.result.Response;
|
import com.aida.seller.common.result.Response;
|
||||||
import com.aida.seller.module.order.dto.OrderListDTO;
|
import com.aida.seller.module.order.dto.OrderListDTO;
|
||||||
import com.aida.seller.module.order.service.OrderService;
|
import com.aida.seller.module.order.service.OrderService;
|
||||||
|
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
||||||
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
||||||
import com.aida.seller.module.order.vo.OrderVO;
|
import com.aida.seller.module.order.vo.OrderVO;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@@ -12,10 +13,13 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* My Orders - 订单管理控制器
|
* My Orders - 订单管理控制器
|
||||||
*/
|
*/
|
||||||
@@ -61,4 +65,10 @@ public class OrderController {
|
|||||||
IPage<OrderVO> orderPage = orderService.getOrderPage(dto, sellerId);
|
IPage<OrderVO> orderPage = orderService.getOrderPage(dto, sellerId);
|
||||||
return Response.success(PageResponse.success(orderPage));
|
return Response.success(PageResponse.success(orderPage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/buyer/orders")
|
||||||
|
@Operation(summary = "根据买家ID查询订单列表(供远程调用)")
|
||||||
|
public Response<List<BuyerOrderVO>> getOrdersByBuyerId(@RequestParam Long buyerId) {
|
||||||
|
return Response.success(orderService.getOrdersByBuyerId(buyerId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ public class OrderInfoEntity implements Serializable {
|
|||||||
/** 订单状态:0-未支付,1-已支付,2-已取消 */
|
/** 订单状态:0-未支付,1-已支付,2-已取消 */
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
/** 店铺名称 */
|
||||||
|
private String shopName;
|
||||||
|
|
||||||
/** 订单总金额(HK$) */
|
/** 订单总金额(HK$) */
|
||||||
private BigDecimal totalPrice;
|
private BigDecimal totalPrice;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.aida.seller.module.order.entity;
|
package com.aida.seller.module.order.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -8,6 +9,7 @@ import lombok.Data;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单商品明细表
|
* 订单商品明细表
|
||||||
@@ -53,4 +55,8 @@ public class OrderItemEntity implements Serializable {
|
|||||||
/** 是否删除:0-否,1-是 */
|
/** 是否删除:0-否,1-是 */
|
||||||
@TableLogic
|
@TableLogic
|
||||||
private Integer deleted;
|
private Integer deleted;
|
||||||
|
|
||||||
|
/** 商品分类列表 */
|
||||||
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
|
private List<String> productCategory;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.aida.seller.module.order.service;
|
package com.aida.seller.module.order.service;
|
||||||
|
|
||||||
import com.aida.seller.module.order.dto.OrderListDTO;
|
import com.aida.seller.module.order.dto.OrderListDTO;
|
||||||
|
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
||||||
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
||||||
import com.aida.seller.module.order.vo.OrderVO;
|
import com.aida.seller.module.order.vo.OrderVO;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单服务接口
|
* 订单服务接口
|
||||||
*/
|
*/
|
||||||
@@ -26,4 +29,12 @@ public interface OrderService {
|
|||||||
* @return 分页后的订单列表,按下单时间降序排列
|
* @return 分页后的订单列表,按下单时间降序排列
|
||||||
*/
|
*/
|
||||||
IPage<OrderVO> getOrderPage(OrderListDTO dto, Long sellerId);
|
IPage<OrderVO> getOrderPage(OrderListDTO dto, Long sellerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据买家ID查询订单列表(供远程调用)
|
||||||
|
*
|
||||||
|
* @param buyerId 买家ID
|
||||||
|
* @return 买家订单列表
|
||||||
|
*/
|
||||||
|
List<BuyerOrderVO> getOrdersByBuyerId(Long buyerId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.aida.seller.module.order.entity.OrderInfoEntity;
|
|||||||
import com.aida.seller.module.order.entity.OrderItemEntity;
|
import com.aida.seller.module.order.entity.OrderItemEntity;
|
||||||
import com.aida.seller.module.order.mapper.OrderInfoMapper;
|
import com.aida.seller.module.order.mapper.OrderInfoMapper;
|
||||||
import com.aida.seller.module.order.mapper.OrderItemMapper;
|
import com.aida.seller.module.order.mapper.OrderItemMapper;
|
||||||
|
import com.aida.seller.module.order.vo.BuyerOrderItemVO;
|
||||||
|
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
||||||
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
||||||
import com.aida.seller.module.order.vo.OrderVO;
|
import com.aida.seller.module.order.vo.OrderVO;
|
||||||
import com.aida.seller.util.MinioUtil;
|
import com.aida.seller.util.MinioUtil;
|
||||||
@@ -123,4 +125,49 @@ public class OrderServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||||||
resultPage.setRecords(voList);
|
resultPage.setRecords(voList);
|
||||||
return resultPage;
|
return resultPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BuyerOrderVO> getOrdersByBuyerId(Long buyerId) {
|
||||||
|
LambdaQueryWrapper<OrderInfoEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(OrderInfoEntity::getBuyerId, buyerId);
|
||||||
|
wrapper.orderByDesc(OrderInfoEntity::getUpdateTime);
|
||||||
|
|
||||||
|
List<OrderInfoEntity> orders = this.list(wrapper);
|
||||||
|
if (orders.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Long> orderIds = orders.stream()
|
||||||
|
.map(OrderInfoEntity::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
Map<Long, List<OrderItemEntity>> itemsMap = orderItemMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<OrderItemEntity>()
|
||||||
|
.in(OrderItemEntity::getOrderId, orderIds)
|
||||||
|
).stream()
|
||||||
|
.collect(Collectors.groupingBy(OrderItemEntity::getOrderId));
|
||||||
|
|
||||||
|
return orders.stream().map(order -> {
|
||||||
|
BuyerOrderVO vo = new BuyerOrderVO();
|
||||||
|
vo.setOrderId(order.getId());
|
||||||
|
vo.setUpdateTime(order.getUpdateTime());
|
||||||
|
vo.setTotalPrice(order.getTotalPrice());
|
||||||
|
vo.setStatus(order.getStatus());
|
||||||
|
vo.setShopName(order.getShopName());
|
||||||
|
|
||||||
|
List<OrderItemEntity> items = itemsMap.getOrDefault(order.getId(), Collections.emptyList());
|
||||||
|
List<BuyerOrderItemVO> itemVOs = items.stream().map(item -> {
|
||||||
|
BuyerOrderItemVO itemVO = new BuyerOrderItemVO();
|
||||||
|
itemVO.setId(item.getId());
|
||||||
|
itemVO.setThumbnailUrl(minioUtil.processMinioResource(item.getThumbnailUrl(), CommonConstants.MINIO_PATH_TIMEOUT));
|
||||||
|
itemVO.setListingName(item.getListingName());
|
||||||
|
itemVO.setProductCategory(item.getProductCategory());
|
||||||
|
itemVO.setPrice(item.getPrice());
|
||||||
|
return itemVO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
vo.setItems(itemVOs);
|
||||||
|
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.aida.seller.module.order.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "买家订单商品明细")
|
||||||
|
public class BuyerOrderItemVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "订单商品ID")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "商品缩略图URL")
|
||||||
|
private String thumbnailUrl;
|
||||||
|
|
||||||
|
@Schema(description = "商品名称")
|
||||||
|
private String listingName;
|
||||||
|
|
||||||
|
@Schema(description = "商品分类列表")
|
||||||
|
private List<String> productCategory;
|
||||||
|
|
||||||
|
@Schema(description = "成交单价(HK$)")
|
||||||
|
private BigDecimal price;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.aida.seller.module.order.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "买家订单信息")
|
||||||
|
public class BuyerOrderVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "订货号")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
@Schema(description = "订单更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@Schema(description = "订单总金额(HK$)")
|
||||||
|
private BigDecimal totalPrice;
|
||||||
|
|
||||||
|
@Schema(description = "订单状态:0-未支付,1-已支付,2-已取消")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "店铺名称")
|
||||||
|
private String shopName;
|
||||||
|
|
||||||
|
@Schema(description = "商品明细列表")
|
||||||
|
private List<BuyerOrderItemVO> items;
|
||||||
|
}
|
||||||
@@ -88,6 +88,7 @@ CREATE TABLE seller_order_item (
|
|||||||
price DECIMAL(10,2) COMMENT '成交单价(HK$)',
|
price DECIMAL(10,2) COMMENT '成交单价(HK$)',
|
||||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
deleted INT(1) DEFAULT 0 COMMENT '是否删除:0-否,1-是',
|
deleted INT(1) DEFAULT 0 COMMENT '是否删除:0-否,1-是',
|
||||||
|
product_category JSON COMMENT '商品分类列表',
|
||||||
INDEX idx_order_id (order_id),
|
INDEX idx_order_id (order_id),
|
||||||
INDEX idx_listing_id (listing_id),
|
INDEX idx_listing_id (listing_id),
|
||||||
INDEX idx_deleted (deleted)
|
INDEX idx_deleted (deleted)
|
||||||
|
|||||||
Reference in New Issue
Block a user