订单相关
This commit is contained in:
@@ -4,11 +4,13 @@ import com.aida.seller.common.annotation.InternalOnly;
|
|||||||
import com.aida.seller.common.context.UserContext;
|
import com.aida.seller.common.context.UserContext;
|
||||||
import com.aida.seller.common.result.PageResponse;
|
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.AssetsDTO;
|
||||||
import com.aida.seller.module.order.dto.CreateOrderDTO;
|
import com.aida.seller.module.order.dto.CreateOrderDTO;
|
||||||
import com.aida.seller.module.order.dto.OrderListDTO;
|
import com.aida.seller.module.order.dto.OrderListDTO;
|
||||||
import com.aida.seller.module.order.dto.BuyerOrdersDTO;
|
import com.aida.seller.module.order.dto.BuyerOrdersDTO;
|
||||||
import com.aida.seller.module.order.dto.UpdateOrderStatusDTO;
|
import com.aida.seller.module.order.dto.UpdateOrderStatusDTO;
|
||||||
import com.aida.seller.module.order.service.OrderService;
|
import com.aida.seller.module.order.service.OrderService;
|
||||||
|
import com.aida.seller.module.order.vo.AssetsItemVO;
|
||||||
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
||||||
import com.aida.seller.module.order.vo.CreateOrderResultVO;
|
import com.aida.seller.module.order.vo.CreateOrderResultVO;
|
||||||
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
||||||
@@ -18,8 +20,6 @@ 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 java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,12 +68,14 @@ public class OrderController {
|
|||||||
return Response.success(PageResponse.success(orderPage));
|
return Response.success(PageResponse.success(orderPage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@InternalOnly
|
||||||
@PostMapping("/buyer/orders")
|
@PostMapping("/buyer/orders")
|
||||||
@Operation(summary = "根据买家ID查询订单列表(供远程调用)")
|
@Operation(summary = "根据买家ID查询订单列表(供远程调用)")
|
||||||
public Response<PageResponse<BuyerOrderVO>> getOrdersByBuyerId(@RequestBody BuyerOrdersDTO dto) {
|
public Response<PageResponse<BuyerOrderVO>> getOrdersByBuyerId(@RequestBody BuyerOrdersDTO dto) {
|
||||||
return Response.success(PageResponse.success(orderService.getOrdersByBuyerId(dto)));
|
return Response.success(PageResponse.success(orderService.getOrdersByBuyerId(dto)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@InternalOnly
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建订单(按卖家分组合并)")
|
@Operation(summary = "创建订单(按卖家分组合并)")
|
||||||
public Response<CreateOrderResultVO> createOrder(@RequestBody CreateOrderDTO dto) {
|
public Response<CreateOrderResultVO> createOrder(@RequestBody CreateOrderDTO dto) {
|
||||||
@@ -87,4 +89,11 @@ public class OrderController {
|
|||||||
orderService.updateOrderStatus(dto);
|
orderService.updateOrderStatus(dto);
|
||||||
return Response.success();
|
return Response.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@InternalOnly
|
||||||
|
@PostMapping("/assets/page")
|
||||||
|
@Operation(summary = "我的资产分页查询")
|
||||||
|
public Response<PageResponse<AssetsItemVO>> getAssetsPage(@RequestBody AssetsDTO dto) {
|
||||||
|
return Response.success(PageResponse.success(orderService.getAssetsPage(dto)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.aida.seller.module.order.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "我的资产分页查询请求参数")
|
||||||
|
public class AssetsDTO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "买家ID")
|
||||||
|
private Long buyerId;
|
||||||
|
|
||||||
|
@Schema(description = "商品分类列表,支持多选,如 outwear&categories=dress")
|
||||||
|
private List<String> categories;
|
||||||
|
|
||||||
|
@Schema(description = "适用性别 female/male/all,不传表示全部")
|
||||||
|
private String designFor;
|
||||||
|
|
||||||
|
@Schema(description = "页码,默认1")
|
||||||
|
private long page = 1;
|
||||||
|
|
||||||
|
@Schema(description = "每页数量,默认10")
|
||||||
|
private long size = 10;
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
* 订单商品明细表
|
* 订单商品明细表
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("seller_order_item")
|
@TableName(value = "seller_order_item", autoResultMap = true)
|
||||||
public class OrderItemEntity implements Serializable {
|
public class OrderItemEntity implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -55,7 +55,7 @@ public class OrderItemEntity implements Serializable {
|
|||||||
/** 是否删除:0-否,1-是 */
|
/** 是否删除:0-否,1-是 */
|
||||||
@TableLogic
|
@TableLogic
|
||||||
private Integer deleted;
|
private Integer deleted;
|
||||||
|
|
||||||
/** 商品分类列表 */
|
/** 商品分类列表 */
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
private List<String> productCategory;
|
private List<String> productCategory;
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
package com.aida.seller.module.order.mapper;
|
package com.aida.seller.module.order.mapper;
|
||||||
|
|
||||||
|
import com.aida.seller.module.order.dto.AssetsDTO;
|
||||||
import com.aida.seller.module.order.entity.OrderItemEntity;
|
import com.aida.seller.module.order.entity.OrderItemEntity;
|
||||||
|
import com.aida.seller.module.order.vo.AssetsItemVO;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface OrderItemMapper extends BaseMapper<OrderItemEntity> {
|
public interface OrderItemMapper extends BaseMapper<OrderItemEntity> {
|
||||||
|
|
||||||
|
List<AssetsItemVO> selectAssetsPage(@Param("offset") long offset, @Param("size") long size, @Param("dto") AssetsDTO dto);
|
||||||
|
|
||||||
|
Long selectAssetsCount(@Param("dto") AssetsDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.aida.seller.module.order.service;
|
package com.aida.seller.module.order.service;
|
||||||
|
|
||||||
|
import com.aida.seller.module.order.dto.AssetsDTO;
|
||||||
import com.aida.seller.module.order.dto.CreateOrderDTO;
|
import com.aida.seller.module.order.dto.CreateOrderDTO;
|
||||||
import com.aida.seller.module.order.dto.OrderListDTO;
|
import com.aida.seller.module.order.dto.OrderListDTO;
|
||||||
import com.aida.seller.module.order.dto.UpdateOrderStatusDTO;
|
import com.aida.seller.module.order.dto.UpdateOrderStatusDTO;
|
||||||
import com.aida.seller.module.order.dto.BuyerOrdersDTO;
|
import com.aida.seller.module.order.dto.BuyerOrdersDTO;
|
||||||
|
import com.aida.seller.module.order.vo.AssetsItemVO;
|
||||||
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
||||||
import com.aida.seller.module.order.vo.CreateOrderResultVO;
|
import com.aida.seller.module.order.vo.CreateOrderResultVO;
|
||||||
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
import com.aida.seller.module.order.vo.OrderSummaryVO;
|
||||||
@@ -56,4 +58,12 @@ public interface OrderService {
|
|||||||
* @return 买家订单分页列表,按更新时间降序排列
|
* @return 买家订单分页列表,按更新时间降序排列
|
||||||
*/
|
*/
|
||||||
IPage<BuyerOrderVO> getOrdersByBuyerId(BuyerOrdersDTO dto);
|
IPage<BuyerOrderVO> getOrdersByBuyerId(BuyerOrdersDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 我的资产分页查询
|
||||||
|
*
|
||||||
|
* @param dto 查询参数(买家ID、分类列表、适用性别)
|
||||||
|
* @return 已购商品分页列表,按购买时间降序排列
|
||||||
|
*/
|
||||||
|
IPage<AssetsItemVO> getAssetsPage(AssetsDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.aida.seller.module.designer.entity.DesignerEntity;
|
|||||||
import com.aida.seller.module.designer.mapper.DesignerMapper;
|
import com.aida.seller.module.designer.mapper.DesignerMapper;
|
||||||
import com.aida.seller.module.listing.entity.ListingEntity;
|
import com.aida.seller.module.listing.entity.ListingEntity;
|
||||||
import com.aida.seller.module.listing.mapper.ListingMapper;
|
import com.aida.seller.module.listing.mapper.ListingMapper;
|
||||||
|
import com.aida.seller.module.order.dto.AssetsDTO;
|
||||||
import com.aida.seller.module.order.dto.CreateOrderDTO;
|
import com.aida.seller.module.order.dto.CreateOrderDTO;
|
||||||
import com.aida.seller.module.order.dto.OrderListDTO;
|
import com.aida.seller.module.order.dto.OrderListDTO;
|
||||||
import com.aida.seller.module.order.dto.UpdateOrderStatusDTO;
|
import com.aida.seller.module.order.dto.UpdateOrderStatusDTO;
|
||||||
@@ -14,6 +15,7 @@ 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.AssetsItemVO;
|
||||||
import com.aida.seller.module.order.vo.BuyerOrderItemVO;
|
import com.aida.seller.module.order.vo.BuyerOrderItemVO;
|
||||||
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
import com.aida.seller.module.order.vo.BuyerOrderVO;
|
||||||
import com.aida.seller.module.order.vo.CreateOrderResultVO;
|
import com.aida.seller.module.order.vo.CreateOrderResultVO;
|
||||||
@@ -153,7 +155,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||||||
|
|
||||||
Page<OrderInfoEntity> orderPage = this.page(pageParam, wrapper);
|
Page<OrderInfoEntity> orderPage = this.page(pageParam, wrapper);
|
||||||
if (orderPage.getRecords().isEmpty()) {
|
if (orderPage.getRecords().isEmpty()) {
|
||||||
return new Page<>(page, size, 0);
|
return new Page<>(dto.getPage(), dto.getSize(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Long> orderIds = orderPage.getRecords().stream()
|
List<Long> orderIds = orderPage.getRecords().stream()
|
||||||
@@ -298,4 +300,25 @@ public class OrderServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfoEnti
|
|||||||
throw new BusinessException("订单不存在或无权修改");
|
throw new BusinessException("订单不存在或无权修改");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<AssetsItemVO> getAssetsPage(AssetsDTO dto) {
|
||||||
|
if (dto.getBuyerId() == null) {
|
||||||
|
throw new BusinessException("买家ID不能为空");
|
||||||
|
}
|
||||||
|
long page = dto.getPage();
|
||||||
|
long size = dto.getSize();
|
||||||
|
long offset = (page - 1) * size;
|
||||||
|
|
||||||
|
List<AssetsItemVO> records = orderItemMapper.selectAssetsPage(offset, size, dto);
|
||||||
|
Long total = orderItemMapper.selectAssetsCount(dto);
|
||||||
|
|
||||||
|
records.forEach(item -> {
|
||||||
|
item.setThumbnailUrl(minioUtil.processMinioResource(item.getThumbnailUrl(), CommonConstants.MINIO_PATH_TIMEOUT));
|
||||||
|
});
|
||||||
|
|
||||||
|
Page<AssetsItemVO> resultPage = new Page<>(page, size, total);
|
||||||
|
resultPage.setRecords(records);
|
||||||
|
return resultPage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "我的资产商品明细")
|
||||||
|
public class AssetsItemVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "商品ID")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long listingId;
|
||||||
|
|
||||||
|
@Schema(description = "商品名称")
|
||||||
|
private String listingName;
|
||||||
|
|
||||||
|
@Schema(description = "商品缩略图URL")
|
||||||
|
private String thumbnailUrl;
|
||||||
|
|
||||||
|
@Schema(description = "成交单价(HK$)")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@Schema(description = "购买时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
@@ -64,6 +64,7 @@ CREATE TABLE seller_orders (
|
|||||||
seller_id BIGINT NOT NULL COMMENT '卖家ID',
|
seller_id BIGINT NOT NULL COMMENT '卖家ID',
|
||||||
buyer_id BIGINT NOT NULL COMMENT '买家ID',
|
buyer_id BIGINT NOT NULL COMMENT '买家ID',
|
||||||
status INT DEFAULT 0 COMMENT '订单状态: 0-未支付, 1-已支付, 2-已取消',
|
status INT DEFAULT 0 COMMENT '订单状态: 0-未支付, 1-已支付, 2-已取消',
|
||||||
|
shop_name VARCHAR(100) COMMENT '店铺名称',
|
||||||
total_price DECIMAL(10,2) COMMENT '订单总金额(HK$)',
|
total_price DECIMAL(10,2) COMMENT '订单总金额(HK$)',
|
||||||
buyer_username VARCHAR(100) COMMENT '买家账号',
|
buyer_username VARCHAR(100) COMMENT '买家账号',
|
||||||
total_items INT COMMENT '商品总数量',
|
total_items INT COMMENT '商品总数量',
|
||||||
|
|||||||
50
src/main/resources/mapper/OrderItemMapper.xml
Normal file
50
src/main/resources/mapper/OrderItemMapper.xml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.aida.seller.module.order.mapper.OrderItemMapper">
|
||||||
|
|
||||||
|
<select id="selectAssetsPage" resultType="com.aida.seller.module.order.vo.AssetsItemVO">
|
||||||
|
SELECT
|
||||||
|
soi.listing_id,
|
||||||
|
soi.listing_name,
|
||||||
|
soi.thumbnail_url,
|
||||||
|
soi.price,
|
||||||
|
soi.create_time
|
||||||
|
FROM seller_order_item soi
|
||||||
|
INNER JOIN seller_orders so ON soi.order_id = so.id
|
||||||
|
INNER JOIN seller_listing l ON soi.listing_id = l.id
|
||||||
|
WHERE soi.deleted = 0
|
||||||
|
AND so.deleted = 0
|
||||||
|
AND so.buyer_id = #{dto.buyerId}
|
||||||
|
AND so.status = 1
|
||||||
|
<if test="dto.categories != null and dto.categories.size() > 0">
|
||||||
|
<foreach collection="dto.categories" item="cat">
|
||||||
|
AND JSON_CONTAINS(soi.product_category, #{cat})
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="dto.designFor != null and dto.designFor != '' and dto.designFor != 'all'">
|
||||||
|
AND l.design_for = #{dto.designFor}
|
||||||
|
</if>
|
||||||
|
ORDER BY soi.create_time DESC
|
||||||
|
LIMIT #{offset}, #{size}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAssetsCount" resultType="java.lang.Long">
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM seller_order_item soi
|
||||||
|
INNER JOIN seller_orders so ON soi.order_id = so.id
|
||||||
|
INNER JOIN seller_listing l ON soi.listing_id = l.id
|
||||||
|
WHERE soi.deleted = 0
|
||||||
|
AND so.deleted = 0
|
||||||
|
AND so.buyer_id = #{dto.buyerId}
|
||||||
|
AND so.status = 1
|
||||||
|
<if test="dto.categories != null and dto.categories.size() > 0">
|
||||||
|
<foreach collection="dto.categories" item="cat">
|
||||||
|
AND JSON_CONTAINS(soi.product_category, #{cat})
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="dto.designFor != null and dto.designFor != '' and dto.designFor != 'all'">
|
||||||
|
AND l.design_for = #{dto.designFor}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user