mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 02:39:19 +08:00
wip: 新增电商模块
This commit is contained in:
+5
@@ -48,6 +48,11 @@ public class PermissionAspect {
|
||||
log.debug("权限验证 - 用户角色: {}, 公司ID: {}, 岗位ID: {}, 权限码: {}",
|
||||
role, companyId, positionId, annotation.value());
|
||||
|
||||
// 检查角色是否为空
|
||||
if (role == null) {
|
||||
throw new BusinessException("用户角色信息缺失");
|
||||
}
|
||||
|
||||
// 根据角色进行权限验证
|
||||
boolean hasPermission = false;
|
||||
|
||||
|
||||
@@ -43,6 +43,11 @@ public class RoleAspect {
|
||||
|
||||
log.debug("角色权限验证 - 用户角色: {}, 注解配置: {}", role, annotation.description());
|
||||
|
||||
// 检查角色是否为空
|
||||
if (role == null) {
|
||||
throw new BusinessException("用户角色信息缺失");
|
||||
}
|
||||
|
||||
// 根据角色进行权限验证
|
||||
boolean hasPermission = false;
|
||||
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PageResultVO<T> implements Serializable {
|
||||
private List<T> list; // 当前页数据
|
||||
private List<T> records; // 当前页数据
|
||||
private Long total; // 总条数
|
||||
private Integer page; // 当前页码
|
||||
private Integer pageSize; // 每页条数
|
||||
@@ -20,8 +20,8 @@ public class PageResultVO<T> implements Serializable {
|
||||
private Boolean hasPrevPage; // 是否有上一页
|
||||
|
||||
// 构造函数
|
||||
public PageResultVO(List<T> list, Long total, Integer page, Integer pageSize) {
|
||||
this.list = list;
|
||||
public PageResultVO(List<T> records, Long total, Integer page, Integer pageSize) {
|
||||
this.records = records;
|
||||
this.total = total;
|
||||
this.page = page;
|
||||
this.pageSize = pageSize;
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.CreateOrderDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.OrderFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.UpdateOrderDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.OrderVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.service.OrderService;
|
||||
|
||||
/**
|
||||
* 订单管理控制器
|
||||
*/
|
||||
@Tag(name = "订单管理", description = "订单的增删改查接口")
|
||||
@RestController
|
||||
@RequestMapping("/ec/order")
|
||||
public class OrderController {
|
||||
|
||||
private final OrderService orderService;
|
||||
|
||||
public OrderController(OrderService orderService) {
|
||||
this.orderService = orderService;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建订单", description = "创建新的订单")
|
||||
@PostMapping("/create")
|
||||
@RequireRole(description = "创建订单", allowUser = false)
|
||||
public ApiResponse<OrderVO> createOrder(@Valid @RequestBody CreateOrderDTO createOrderDTO) {
|
||||
OrderVO orderVO = orderService.createOrder(createOrderDTO);
|
||||
return ApiResponse.success(orderVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新订单", description = "更新现有订单信息")
|
||||
@PutMapping("/update/{id}")
|
||||
@RequireRole(description = "更新订单", allowUser = false)
|
||||
public ApiResponse<OrderVO> updateOrder(@Valid @RequestBody UpdateOrderDTO updateOrderDTO,
|
||||
@Parameter(description = "订单ID") @PathVariable Long id) {
|
||||
OrderVO orderVO = orderService.updateOrder(updateOrderDTO, id);
|
||||
return ApiResponse.success(orderVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除订单", description = "删除指定订单")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequireRole(description = "删除订单", allowUser = false)
|
||||
public ApiResponse<Void> deleteOrder(
|
||||
@Parameter(description = "订单ID") @PathVariable Long id) {
|
||||
orderService.deleteOrder(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取订单列表", description = "分页获取订单列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询订单列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<OrderVO>> getOrderPage(
|
||||
@Valid @RequestBody PageQueryDTO<OrderFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<OrderVO> result = orderService.getOrderPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取订单详情", description = "根据ID获取订单详情")
|
||||
@GetMapping("/detail/{id}")
|
||||
@RequireRole(description = "查询订单详情", allowUser = true)
|
||||
public ApiResponse<OrderVO> getOrderById(
|
||||
@Parameter(description = "订单ID") @PathVariable Long id) {
|
||||
OrderVO orderVO = orderService.getOrderById(id);
|
||||
return ApiResponse.success(orderVO);
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.CreateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.ProductFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.UpdateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ProductVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.service.ProductService;
|
||||
|
||||
/**
|
||||
* 商品管理控制器
|
||||
*/
|
||||
@Tag(name = "商品管理", description = "商品的增删改查接口")
|
||||
@RestController
|
||||
@RequestMapping("/ec/product")
|
||||
public class ProductController {
|
||||
|
||||
private final ProductService productService;
|
||||
|
||||
public ProductController(ProductService productService) {
|
||||
this.productService = productService;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建商品", description = "创建新的商品")
|
||||
@PostMapping("/create")
|
||||
@RequireRole(description = "创建商品", allowUser = false)
|
||||
public ApiResponse<ProductVO> createProduct(@Valid @RequestBody CreateProductDTO createProductDTO) {
|
||||
ProductVO productVO = productService.createProduct(createProductDTO);
|
||||
return ApiResponse.success(productVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新商品", description = "更新现有商品信息")
|
||||
@PutMapping("/update/{id}")
|
||||
@RequireRole(description = "更新商品", allowUser = false)
|
||||
public ApiResponse<ProductVO> updateProduct(@Valid @RequestBody UpdateProductDTO updateProductDTO,
|
||||
@Parameter(description = "商品ID") @PathVariable Long id) {
|
||||
ProductVO productVO = productService.updateProduct(updateProductDTO, id);
|
||||
return ApiResponse.success(productVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除商品", description = "删除指定商品")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequireRole(description = "删除商品", allowUser = false)
|
||||
public ApiResponse<Void> deleteProduct(
|
||||
@Parameter(description = "商品ID") @PathVariable Long id) {
|
||||
productService.deleteProduct(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取商品列表", description = "分页获取商品列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询商品列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<ProductVO>> getProductPage(
|
||||
@Valid @RequestBody PageQueryDTO<ProductFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<ProductVO> result = productService.getProductPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.xyquan.ecomdmbbackend.common.annotation.RequireRole;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.CreateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.ShopFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.UpdateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ShopVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.service.ShopService;
|
||||
|
||||
/**
|
||||
* 店铺管理控制器
|
||||
*/
|
||||
@Tag(name = "店铺管理", description = "店铺的增删改查接口")
|
||||
@RestController
|
||||
@RequestMapping("/ec/shop")
|
||||
public class ShopController {
|
||||
|
||||
private final ShopService shopService;
|
||||
|
||||
public ShopController(ShopService shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建店铺", description = "创建新的店铺")
|
||||
@PostMapping("/create")
|
||||
@RequireRole(description = "创建店铺", allowUser = false)
|
||||
public ApiResponse<ShopVO> createShop(@Valid @RequestBody CreateShopDTO createShopDTO) {
|
||||
ShopVO shopVO = shopService.createShop(createShopDTO);
|
||||
return ApiResponse.success(shopVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新店铺", description = "更新现有店铺信息")
|
||||
@PutMapping("/update/{id}")
|
||||
@RequireRole(description = "更新店铺", allowUser = false)
|
||||
public ApiResponse<ShopVO> updateShop(@Valid @RequestBody UpdateShopDTO updateShopDTO,
|
||||
@Parameter(description = "店铺ID") @PathVariable Long id) {
|
||||
ShopVO shopVO = shopService.updateShop(updateShopDTO, id);
|
||||
return ApiResponse.success(shopVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除店铺", description = "删除指定店铺")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
@RequireRole(description = "删除店铺", allowUser = false)
|
||||
public ApiResponse<Void> deleteShop(
|
||||
@Parameter(description = "店铺ID") @PathVariable Long id) {
|
||||
shopService.deleteShop(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "分页获取店铺列表", description = "分页获取店铺列表,支持条件过滤")
|
||||
@PostMapping("/page")
|
||||
@RequireRole(description = "查询店铺列表", allowUser = true)
|
||||
public ApiResponse<PageResultVO<ShopVO>> getShopPage(
|
||||
@Valid @RequestBody PageQueryDTO<ShopFilterDTO> pageQueryDTO) {
|
||||
PageResultVO<ShopVO> result = shopService.getShopPage(pageQueryDTO);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderItemPO;
|
||||
|
||||
/**
|
||||
* 订单明细Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderItemMapper extends BaseMapper<OrderItemPO> {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderPO;
|
||||
|
||||
/**
|
||||
* 订单Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderMapper extends BaseMapper<OrderPO> {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.ProductPO;
|
||||
|
||||
/**
|
||||
* 商品Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductMapper extends BaseMapper<ProductPO> {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.ShopPO;
|
||||
|
||||
/**
|
||||
* 店铺Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface ShopMapper extends BaseMapper<ShopPO> {
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建订单DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建订单DTO")
|
||||
public class CreateOrderDTO {
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1", required = true)
|
||||
@NotNull(message = "店铺ID不能为空")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号", example = "ORDER202401010001", required = true)
|
||||
@NotBlank(message = "订单号不能为空")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 订单状态 0待发货 1已完成 2已取消
|
||||
*/
|
||||
@Schema(description = "订单状态", example = "0", allowableValues = {"0", "1", "2"})
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
@Schema(description = "订单金额", example = "9999.00", required = true)
|
||||
@NotNull(message = "订单金额不能为空")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 商家实收金额
|
||||
*/
|
||||
@Schema(description = "商家实收金额", example = "9999.00")
|
||||
private BigDecimal receivedAmount;
|
||||
|
||||
/**
|
||||
* 下单时间
|
||||
*/
|
||||
@Schema(description = "下单时间", example = "2024-01-01T10:00:00", required = true)
|
||||
@NotNull(message = "下单时间不能为空")
|
||||
private LocalDateTime orderDate;
|
||||
|
||||
/**
|
||||
* 订单明细列表
|
||||
*/
|
||||
@Schema(description = "订单明细列表", required = true)
|
||||
@NotEmpty(message = "订单明细不能为空")
|
||||
@Valid
|
||||
private List<CreateOrderItemDTO> orderItems;
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 创建订单明细DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建订单明细DTO")
|
||||
public class CreateOrderItemDTO {
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(description = "商品ID", example = "1", required = true)
|
||||
@NotNull(message = "商品ID不能为空")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 商品名称(冗余存储)
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", required = true)
|
||||
@NotBlank(message = "商品名称不能为空")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@Schema(description = "数量", example = "1", required = true)
|
||||
@NotNull(message = "数量不能为空")
|
||||
@Positive(message = "数量必须大于0")
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 销售单价
|
||||
*/
|
||||
@Schema(description = "销售单价", example = "9999.00", required = true)
|
||||
@NotNull(message = "销售单价不能为空")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
/**
|
||||
* 小计金额
|
||||
*/
|
||||
@Schema(description = "小计金额", example = "9999.00", required = true)
|
||||
@NotNull(message = "小计金额不能为空")
|
||||
private BigDecimal subtotal;
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 订单分页查询过滤DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "订单分页查询过滤DTO")
|
||||
public class OrderFilterDTO {
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 订单号(模糊查询)
|
||||
*/
|
||||
@Schema(description = "订单号(模糊查询)", example = "ORDER2024")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@Schema(description = "订单状态", example = "0", allowableValues = {"0", "1", "2"})
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 订单金额范围-最小值
|
||||
*/
|
||||
@Schema(description = "订单金额范围-最小值", example = "100.00")
|
||||
private BigDecimal minTotalAmount;
|
||||
|
||||
/**
|
||||
* 订单金额范围-最大值
|
||||
*/
|
||||
@Schema(description = "订单金额范围-最大值", example = "10000.00")
|
||||
private BigDecimal maxTotalAmount;
|
||||
|
||||
/**
|
||||
* 下单时间范围-开始时间
|
||||
*/
|
||||
@Schema(description = "下单时间范围-开始时间", example = "2024-01-01T00:00:00")
|
||||
private LocalDateTime startOrderDate;
|
||||
|
||||
/**
|
||||
* 下单时间范围-结束时间
|
||||
*/
|
||||
@Schema(description = "下单时间范围-结束时间", example = "2024-12-31T23:59:59")
|
||||
private LocalDateTime endOrderDate;
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.order;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 更新订单DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "更新订单DTO")
|
||||
public class UpdateOrderDTO {
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1", required = true)
|
||||
@NotNull(message = "店铺ID不能为空")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号", example = "ORDER202401010001", required = true)
|
||||
@NotBlank(message = "订单号不能为空")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 订单状态 0待发货 1已完成 2已取消
|
||||
*/
|
||||
@Schema(description = "订单状态", example = "0", allowableValues = {"0", "1", "2"})
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
@Schema(description = "订单金额", example = "9999.00", required = true)
|
||||
@NotNull(message = "订单金额不能为空")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 商家实收金额
|
||||
*/
|
||||
@Schema(description = "商家实收金额", example = "9999.00")
|
||||
private BigDecimal receivedAmount;
|
||||
|
||||
/**
|
||||
* 下单时间
|
||||
*/
|
||||
@Schema(description = "下单时间", example = "2024-01-01T10:00:00", required = true)
|
||||
@NotNull(message = "下单时间不能为空")
|
||||
private LocalDateTime orderDate;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 创建商品DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建商品DTO")
|
||||
public class CreateProductDTO {
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", required = true)
|
||||
@NotBlank(message = "商品名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品编码
|
||||
*/
|
||||
@Schema(description = "商品编码", example = "IPHONE15PRO001")
|
||||
private String specCode;
|
||||
|
||||
/**
|
||||
* 商品SKU
|
||||
*/
|
||||
@Schema(description = "商品SKU", example = "IPHONE15PRO-128G-BLUE")
|
||||
private String skuCode;
|
||||
|
||||
/**
|
||||
* 主图URL
|
||||
*/
|
||||
@Schema(description = "主图URL", example = "https://example.com/product.jpg")
|
||||
private String mainImage;
|
||||
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
@Schema(description = "成本价", example = "8000.00", required = true)
|
||||
@NotNull(message = "成本价不能为空")
|
||||
private BigDecimal costPrice;
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 商品分页查询过滤DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "商品分页查询过滤DTO")
|
||||
public class ProductFilterDTO {
|
||||
|
||||
/**
|
||||
* 商品名称(模糊查询)
|
||||
*/
|
||||
@Schema(description = "商品名称(模糊查询)", example = "iPhone")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品编码(模糊查询)
|
||||
*/
|
||||
@Schema(description = "商品编码(模糊查询)", example = "IPHONE")
|
||||
private String specCode;
|
||||
|
||||
/**
|
||||
* 商品SKU(模糊查询)
|
||||
*/
|
||||
@Schema(description = "商品SKU(模糊查询)", example = "IPHONE15")
|
||||
private String skuCode;
|
||||
|
||||
/**
|
||||
* 成本价范围-最小值
|
||||
*/
|
||||
@Schema(description = "成本价范围-最小值", example = "1000.00")
|
||||
private BigDecimal minCostPrice;
|
||||
|
||||
/**
|
||||
* 成本价范围-最大值
|
||||
*/
|
||||
@Schema(description = "成本价范围-最大值", example = "10000.00")
|
||||
private BigDecimal maxCostPrice;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 更新商品DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "更新商品DTO")
|
||||
public class UpdateProductDTO {
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro", required = true)
|
||||
@NotBlank(message = "商品名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品编码
|
||||
*/
|
||||
@Schema(description = "商品编码", example = "IPHONE15PRO001")
|
||||
private String specCode;
|
||||
|
||||
/**
|
||||
* 商品SKU
|
||||
*/
|
||||
@Schema(description = "商品SKU", example = "IPHONE15PRO-128G-BLUE")
|
||||
private String skuCode;
|
||||
|
||||
/**
|
||||
* 主图URL
|
||||
*/
|
||||
@Schema(description = "主图URL", example = "https://example.com/product.jpg")
|
||||
private String mainImage;
|
||||
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
@Schema(description = "成本价", example = "8000.00", required = true)
|
||||
@NotNull(message = "成本价不能为空")
|
||||
private BigDecimal costPrice;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 创建店铺DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建店铺DTO")
|
||||
public class CreateShopDTO {
|
||||
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
@Schema(description = "店铺名称", example = "旗舰店", required = true)
|
||||
@NotBlank(message = "店铺名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* logo URL
|
||||
*/
|
||||
@Schema(description = "logo URL", example = "https://example.com/logo.jpg")
|
||||
private String logo;
|
||||
|
||||
/**
|
||||
* 平台(如淘宝、京东、拼多多)
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"})
|
||||
private String platform;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 店铺分页查询过滤DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "店铺分页查询过滤DTO")
|
||||
public class ShopFilterDTO {
|
||||
|
||||
/**
|
||||
* 店铺名称(模糊查询)
|
||||
*/
|
||||
@Schema(description = "店铺名称(模糊查询)", example = "旗舰")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 平台
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"})
|
||||
private String platform;
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 更新店铺DTO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "更新店铺DTO")
|
||||
public class UpdateShopDTO {
|
||||
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
@Schema(description = "店铺名称", example = "旗舰店", required = true)
|
||||
@NotBlank(message = "店铺名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* logo URL
|
||||
*/
|
||||
@Schema(description = "logo URL", example = "https://example.com/logo.jpg")
|
||||
private String logo;
|
||||
|
||||
/**
|
||||
* 平台(如淘宝、京东、拼多多)
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝", allowableValues = {"淘宝", "京东", "拼多多", "天猫"})
|
||||
private String platform;
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 电商-订单明细实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_order_item")
|
||||
public class OrderItemPO {
|
||||
|
||||
/**
|
||||
* 订单明细ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单ID
|
||||
*/
|
||||
@TableField("order_id")
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@TableField("product_id")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 商品名称(冗余存储)
|
||||
*/
|
||||
@TableField("product_name")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@TableField("quantity")
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 销售单价
|
||||
*/
|
||||
@TableField("unit_price")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
/**
|
||||
* 小计金额
|
||||
*/
|
||||
@TableField("subtotal")
|
||||
private BigDecimal subtotal;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@TableField("delete_time")
|
||||
private LocalDateTime deleteTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@TableField("create_by")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@TableField("update_by")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除人ID
|
||||
*/
|
||||
@TableField("delete_by")
|
||||
private Long deleteBy;
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 电商-订单实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_order")
|
||||
public class OrderPO {
|
||||
|
||||
/**
|
||||
* 订单ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@TableField("company_id")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@TableField("shop_id")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@TableField("order_no")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 订单状态 0待发货 1已完成 2已取消
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
@TableField("total_amount")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 商家实收金额
|
||||
*/
|
||||
@TableField("received_amount")
|
||||
private BigDecimal receivedAmount;
|
||||
|
||||
/**
|
||||
* 下单时间
|
||||
*/
|
||||
@TableField("order_date")
|
||||
private LocalDateTime orderDate;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@TableField("delete_time")
|
||||
private LocalDateTime deleteTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@TableField("create_by")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@TableField("update_by")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除人ID
|
||||
*/
|
||||
@TableField("delete_by")
|
||||
private Long deleteBy;
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 电商-商品实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_product")
|
||||
public class ProductPO {
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@TableField("company_id")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品编码
|
||||
*/
|
||||
@TableField("spec_code")
|
||||
private String specCode;
|
||||
|
||||
/**
|
||||
* 商品SKU
|
||||
*/
|
||||
@TableField("sku_code")
|
||||
private String skuCode;
|
||||
|
||||
/**
|
||||
* 主图URL
|
||||
*/
|
||||
@TableField("main_image")
|
||||
private String mainImage;
|
||||
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
@TableField("cost_price")
|
||||
private BigDecimal costPrice;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@TableField("delete_time")
|
||||
private LocalDateTime deleteTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@TableField("create_by")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@TableField("update_by")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除人ID
|
||||
*/
|
||||
@TableField("delete_by")
|
||||
private Long deleteBy;
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 电商-店铺实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("ec_shop")
|
||||
public class ShopPO {
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 所属公司ID
|
||||
*/
|
||||
@TableField("company_id")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* logo URL
|
||||
*/
|
||||
@TableField("logo")
|
||||
private String logo;
|
||||
|
||||
/**
|
||||
* 平台(如淘宝、京东、拼多多)
|
||||
*/
|
||||
@TableField("platform")
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@TableField("delete_time")
|
||||
private LocalDateTime deleteTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@TableField("create_by")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@TableField("update_by")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除人ID
|
||||
*/
|
||||
@TableField("delete_by")
|
||||
private Long deleteBy;
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 订单明细VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "订单明细VO")
|
||||
public class OrderItemVO {
|
||||
|
||||
/**
|
||||
* 订单明细ID
|
||||
*/
|
||||
@Schema(description = "订单明细ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单ID
|
||||
*/
|
||||
@Schema(description = "订单ID", example = "1")
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(description = "商品ID", example = "1")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 商品名称(冗余存储)
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 商品主图
|
||||
*/
|
||||
@Schema(description = "商品主图", example = "https://example.com/product.jpg")
|
||||
private String productImage;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@Schema(description = "数量", example = "1")
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 销售单价
|
||||
*/
|
||||
@Schema(description = "销售单价", example = "9999.00")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
/**
|
||||
* 小计金额
|
||||
*/
|
||||
@Schema(description = "小计金额", example = "9999.00")
|
||||
private BigDecimal subtotal;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "订单VO")
|
||||
public class OrderVO {
|
||||
|
||||
/**
|
||||
* 订单ID
|
||||
*/
|
||||
@Schema(description = "订单ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Schema(description = "公司ID", example = "1")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1")
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
@Schema(description = "店铺名称", example = "旗舰店")
|
||||
private String shopName;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号", example = "ORDER202401010001")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 订单状态 0待发货 1已完成 2已取消
|
||||
*/
|
||||
@Schema(description = "订单状态", example = "0", allowableValues = {"0", "1", "2"})
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 订单状态描述
|
||||
*/
|
||||
@Schema(description = "订单状态描述", example = "待发货")
|
||||
private String statusDesc;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
@Schema(description = "订单金额", example = "9999.00")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 商家实收金额
|
||||
*/
|
||||
@Schema(description = "商家实收金额", example = "9999.00")
|
||||
private BigDecimal receivedAmount;
|
||||
|
||||
/**
|
||||
* 下单时间
|
||||
*/
|
||||
@Schema(description = "下单时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime orderDate;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@Schema(description = "创建人ID", example = "1")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@Schema(description = "更新人ID", example = "1")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 订单明细列表
|
||||
*/
|
||||
@Schema(description = "订单明细列表")
|
||||
private List<OrderItemVO> orderItems;
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 商品VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "商品VO")
|
||||
public class ProductVO {
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(description = "商品ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@Schema(description = "公司ID", example = "1")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称", example = "iPhone 15 Pro")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品编码
|
||||
*/
|
||||
@Schema(description = "商品编码", example = "IPHONE15PRO001")
|
||||
private String specCode;
|
||||
|
||||
/**
|
||||
* 商品SKU
|
||||
*/
|
||||
@Schema(description = "商品SKU", example = "IPHONE15PRO-128G-BLUE")
|
||||
private String skuCode;
|
||||
|
||||
/**
|
||||
* 主图URL
|
||||
*/
|
||||
@Schema(description = "主图URL", example = "https://example.com/product.jpg")
|
||||
private String mainImage;
|
||||
|
||||
/**
|
||||
* 成本价
|
||||
*/
|
||||
@Schema(description = "成本价", example = "8000.00")
|
||||
private BigDecimal costPrice;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@Schema(description = "创建人ID", example = "1")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@Schema(description = "更新人ID", example = "1")
|
||||
private Long updateBy;
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 店铺VO
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "店铺VO")
|
||||
public class ShopVO {
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
@Schema(description = "店铺ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 所属公司ID
|
||||
*/
|
||||
@Schema(description = "所属公司ID", example = "1")
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
@Schema(description = "店铺名称", example = "旗舰店")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* logo URL
|
||||
*/
|
||||
@Schema(description = "logo URL", example = "https://example.com/logo.jpg")
|
||||
private String logo;
|
||||
|
||||
/**
|
||||
* 平台(如淘宝、京东、拼多多)
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝")
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2024-01-01T10:00:00")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@Schema(description = "创建人ID", example = "1")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@Schema(description = "更新人ID", example = "1")
|
||||
private Long updateBy;
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.CreateOrderDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.OrderFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.UpdateOrderDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.OrderVO;
|
||||
|
||||
/**
|
||||
* 订单服务接口
|
||||
*/
|
||||
public interface OrderService extends IService<OrderPO> {
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
* @param createOrderDTO 创建订单DTO
|
||||
* @return 订单VO
|
||||
*/
|
||||
OrderVO createOrder(CreateOrderDTO createOrderDTO);
|
||||
|
||||
/**
|
||||
* 更新订单
|
||||
*
|
||||
* @param updateOrderDTO 更新订单DTO
|
||||
* @param id 订单ID
|
||||
* @return 订单VO
|
||||
*/
|
||||
OrderVO updateOrder(UpdateOrderDTO updateOrderDTO, Long id);
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
*
|
||||
* @param id 订单ID
|
||||
*/
|
||||
void deleteOrder(Long id);
|
||||
|
||||
/**
|
||||
* 分页获取订单列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<OrderVO> getOrderPage(PageQueryDTO<OrderFilterDTO> pageQueryDTO);
|
||||
|
||||
/**
|
||||
* 根据ID获取订单详情
|
||||
*
|
||||
* @param id 订单ID
|
||||
* @return 订单VO
|
||||
*/
|
||||
OrderVO getOrderById(Long id);
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.CreateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.ProductFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.UpdateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.ProductPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ProductVO;
|
||||
|
||||
/**
|
||||
* 商品服务接口
|
||||
*/
|
||||
public interface ProductService extends IService<ProductPO> {
|
||||
|
||||
/**
|
||||
* 创建商品
|
||||
*
|
||||
* @param createProductDTO 创建商品DTO
|
||||
* @return 商品VO
|
||||
*/
|
||||
ProductVO createProduct(CreateProductDTO createProductDTO);
|
||||
|
||||
/**
|
||||
* 更新商品
|
||||
*
|
||||
* @param updateProductDTO 更新商品DTO
|
||||
* @param id 商品ID
|
||||
* @return 商品VO
|
||||
*/
|
||||
ProductVO updateProduct(UpdateProductDTO updateProductDTO, Long id);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*
|
||||
* @param id 商品ID
|
||||
*/
|
||||
void deleteProduct(Long id);
|
||||
|
||||
/**
|
||||
* 分页获取商品列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<ProductVO> getProductPage(PageQueryDTO<ProductFilterDTO> pageQueryDTO);
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.CreateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.ShopFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.UpdateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.ShopPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ShopVO;
|
||||
|
||||
/**
|
||||
* 店铺服务接口
|
||||
*/
|
||||
public interface ShopService extends IService<ShopPO> {
|
||||
|
||||
/**
|
||||
* 创建店铺
|
||||
*
|
||||
* @param createShopDTO 创建店铺DTO
|
||||
* @return 店铺VO
|
||||
*/
|
||||
ShopVO createShop(CreateShopDTO createShopDTO);
|
||||
|
||||
/**
|
||||
* 更新店铺
|
||||
*
|
||||
* @param updateShopDTO 更新店铺DTO
|
||||
* @param id 店铺ID
|
||||
* @return 店铺VO
|
||||
*/
|
||||
ShopVO updateShop(UpdateShopDTO updateShopDTO, Long id);
|
||||
|
||||
/**
|
||||
* 删除店铺
|
||||
*
|
||||
* @param id 店铺ID
|
||||
*/
|
||||
void deleteShop(Long id);
|
||||
|
||||
/**
|
||||
* 分页获取店铺列表
|
||||
*
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResultVO<ShopVO> getShopPage(PageQueryDTO<ShopFilterDTO> pageQueryDTO);
|
||||
}
|
||||
+311
@@ -0,0 +1,311 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.mapper.OrderItemMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.mapper.OrderMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.CreateOrderDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.CreateOrderItemDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.OrderFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.order.UpdateOrderDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderItemPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.ShopPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.OrderItemVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.OrderVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.service.OrderService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.service.ShopService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 订单服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderPO> implements OrderService {
|
||||
|
||||
private final CurrentUserContext currentUserContext;
|
||||
private final ShopService shopService;
|
||||
private final OrderItemMapper orderItemMapper;
|
||||
|
||||
public OrderServiceImpl(CurrentUserContext currentUserContext, ShopService shopService, OrderItemMapper orderItemMapper) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
this.shopService = shopService;
|
||||
this.orderItemMapper = orderItemMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public OrderVO createOrder(CreateOrderDTO createOrderDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证店铺是否存在且属于当前公司
|
||||
ShopPO shop = shopService.getById(createOrderDTO.getShopId());
|
||||
if (shop == null || !shop.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("店铺不存在");
|
||||
}
|
||||
|
||||
// 验证订单号是否重复
|
||||
LambdaQueryWrapper<OrderPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrderPO::getOrderNo, createOrderDTO.getOrderNo())
|
||||
.eq(OrderPO::getCompanyId, companyId)
|
||||
.isNull(OrderPO::getDeleteTime);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("订单号已存在");
|
||||
}
|
||||
|
||||
// 创建订单
|
||||
OrderPO order = new OrderPO();
|
||||
BeanUtils.copyProperties(createOrderDTO, order);
|
||||
|
||||
// 设置公司ID
|
||||
order.setCompanyId(companyId);
|
||||
|
||||
// 设置默认值
|
||||
if (order.getStatus() == null) {
|
||||
order.setStatus(0); // 默认待发货
|
||||
}
|
||||
if (order.getReceivedAmount() == null) {
|
||||
order.setReceivedAmount(order.getTotalAmount());
|
||||
}
|
||||
|
||||
// 设置创建人ID
|
||||
order.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
// 保存订单
|
||||
this.save(order);
|
||||
|
||||
// 创建订单明细
|
||||
for (CreateOrderItemDTO itemDTO : createOrderDTO.getOrderItems()) {
|
||||
OrderItemPO orderItem = new OrderItemPO();
|
||||
BeanUtils.copyProperties(itemDTO, orderItem);
|
||||
orderItem.setOrderId(order.getId());
|
||||
orderItem.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
orderItemMapper.insert(orderItem);
|
||||
}
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public OrderVO updateOrder(UpdateOrderDTO updateOrderDTO, Long id) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证订单是否存在
|
||||
OrderPO existingOrder = this.getById(id);
|
||||
if (existingOrder == null || !existingOrder.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("订单不存在");
|
||||
}
|
||||
|
||||
// 验证店铺是否存在且属于当前公司
|
||||
ShopPO shop = shopService.getById(updateOrderDTO.getShopId());
|
||||
if (shop == null || !shop.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("店铺不存在");
|
||||
}
|
||||
|
||||
// 验证订单号是否重复(排除当前订单)
|
||||
LambdaQueryWrapper<OrderPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrderPO::getOrderNo, updateOrderDTO.getOrderNo())
|
||||
.eq(OrderPO::getCompanyId, companyId)
|
||||
.ne(OrderPO::getId, id)
|
||||
.isNull(OrderPO::getDeleteTime);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("订单号已存在");
|
||||
}
|
||||
|
||||
// 更新订单
|
||||
OrderPO order = new OrderPO();
|
||||
BeanUtils.copyProperties(updateOrderDTO, order);
|
||||
order.setId(id);
|
||||
order.setCompanyId(companyId);
|
||||
|
||||
// 设置更新人ID
|
||||
order.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
// 更新订单
|
||||
this.updateById(order);
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteOrder(Long id) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证订单是否存在
|
||||
OrderPO existingOrder = this.getById(id);
|
||||
if (existingOrder == null || !existingOrder.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("订单不存在");
|
||||
}
|
||||
|
||||
// 软删除订单
|
||||
OrderPO order = new OrderPO();
|
||||
order.setId(id);
|
||||
order.setDeleteTime(LocalDateTime.now());
|
||||
order.setDeleteBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
this.updateById(order);
|
||||
|
||||
// 软删除订单明细
|
||||
LambdaQueryWrapper<OrderItemPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrderItemPO::getOrderId, id)
|
||||
.isNull(OrderItemPO::getDeleteTime);
|
||||
List<OrderItemPO> orderItems = orderItemMapper.selectList(wrapper);
|
||||
for (OrderItemPO orderItem : orderItems) {
|
||||
orderItem.setDeleteTime(LocalDateTime.now());
|
||||
orderItem.setDeleteBy(currentUserContext.getCurrentUserId());
|
||||
orderItemMapper.updateById(orderItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResultVO<OrderVO> getOrderPage(PageQueryDTO<OrderFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 创建分页对象
|
||||
Page<OrderPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<OrderPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrderPO::getCompanyId, companyId)
|
||||
.isNull(OrderPO::getDeleteTime);
|
||||
|
||||
// 添加过滤条件
|
||||
OrderFilterDTO filter = pageQueryDTO.getFilters();
|
||||
if (filter != null) {
|
||||
if (filter.getShopId() != null) {
|
||||
wrapper.eq(OrderPO::getShopId, filter.getShopId());
|
||||
}
|
||||
if (filter.getOrderNo() != null && !filter.getOrderNo().trim().isEmpty()) {
|
||||
wrapper.like(OrderPO::getOrderNo, filter.getOrderNo());
|
||||
}
|
||||
if (filter.getStatus() != null) {
|
||||
wrapper.eq(OrderPO::getStatus, filter.getStatus());
|
||||
}
|
||||
if (filter.getMinTotalAmount() != null) {
|
||||
wrapper.ge(OrderPO::getTotalAmount, filter.getMinTotalAmount());
|
||||
}
|
||||
if (filter.getMaxTotalAmount() != null) {
|
||||
wrapper.le(OrderPO::getTotalAmount, filter.getMaxTotalAmount());
|
||||
}
|
||||
if (filter.getStartOrderDate() != null) {
|
||||
wrapper.ge(OrderPO::getOrderDate, filter.getStartOrderDate());
|
||||
}
|
||||
if (filter.getEndOrderDate() != null) {
|
||||
wrapper.le(OrderPO::getOrderDate, filter.getEndOrderDate());
|
||||
}
|
||||
}
|
||||
|
||||
// 排序
|
||||
wrapper.orderByDesc(OrderPO::getOrderDate)
|
||||
.orderByDesc(OrderPO::getCreateTime);
|
||||
|
||||
// 执行分页查询
|
||||
IPage<OrderPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<OrderVO> voList = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建分页结果
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderVO getOrderById(Long id) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证订单是否存在
|
||||
OrderPO order = this.getById(id);
|
||||
if (order == null || !order.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("订单不存在");
|
||||
}
|
||||
|
||||
// 转换为VO
|
||||
OrderVO orderVO = convertToVO(order);
|
||||
|
||||
// 查询订单明细
|
||||
LambdaQueryWrapper<OrderItemPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrderItemPO::getOrderId, id)
|
||||
.isNull(OrderItemPO::getDeleteTime)
|
||||
.orderByAsc(OrderItemPO::getCreateTime);
|
||||
List<OrderItemPO> orderItems = orderItemMapper.selectList(wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<OrderItemVO> orderItemVOs = orderItems.stream()
|
||||
.map(this::convertOrderItemToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
orderVO.setOrderItems(orderItemVOs);
|
||||
|
||||
return orderVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
*/
|
||||
private OrderVO convertToVO(OrderPO order) {
|
||||
OrderVO orderVO = new OrderVO();
|
||||
BeanUtils.copyProperties(order, orderVO);
|
||||
|
||||
// 设置状态描述
|
||||
orderVO.setStatusDesc(getStatusDesc(order.getStatus()));
|
||||
|
||||
// 设置店铺名称
|
||||
ShopPO shop = shopService.getById(order.getShopId());
|
||||
if (shop != null) {
|
||||
orderVO.setShopName(shop.getName());
|
||||
}
|
||||
|
||||
return orderVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换订单明细为VO
|
||||
*/
|
||||
private OrderItemVO convertOrderItemToVO(OrderItemPO orderItem) {
|
||||
OrderItemVO orderItemVO = new OrderItemVO();
|
||||
BeanUtils.copyProperties(orderItem, orderItemVO);
|
||||
return orderItemVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态描述
|
||||
*/
|
||||
private String getStatusDesc(Integer status) {
|
||||
if (status == null) {
|
||||
return "未知";
|
||||
}
|
||||
switch (status) {
|
||||
case 0:
|
||||
return "待发货";
|
||||
case 1:
|
||||
return "已完成";
|
||||
case 2:
|
||||
return "已取消";
|
||||
default:
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.mapper.ProductMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.CreateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.ProductFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.product.UpdateProductDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.ProductPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ProductVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.service.ProductService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 商品服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductPO> implements ProductService {
|
||||
|
||||
private final CurrentUserContext currentUserContext;
|
||||
|
||||
public ProductServiceImpl(CurrentUserContext currentUserContext) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ProductVO createProduct(CreateProductDTO createProductDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证商品名称是否重复
|
||||
LambdaQueryWrapper<ProductPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProductPO::getName, createProductDTO.getName())
|
||||
.eq(ProductPO::getCompanyId, companyId)
|
||||
.isNull(ProductPO::getDeleteTime);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("商品名称已存在");
|
||||
}
|
||||
|
||||
// 验证SKU是否重复
|
||||
if (createProductDTO.getSkuCode() != null && !createProductDTO.getSkuCode().trim().isEmpty()) {
|
||||
LambdaQueryWrapper<ProductPO> skuWrapper = new LambdaQueryWrapper<>();
|
||||
skuWrapper.eq(ProductPO::getSkuCode, createProductDTO.getSkuCode())
|
||||
.eq(ProductPO::getCompanyId, companyId)
|
||||
.isNull(ProductPO::getDeleteTime);
|
||||
if (this.count(skuWrapper) > 0) {
|
||||
throw new BusinessException("商品SKU已存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 创建商品
|
||||
ProductPO product = new ProductPO();
|
||||
BeanUtils.copyProperties(createProductDTO, product);
|
||||
|
||||
// 设置公司ID
|
||||
product.setCompanyId(companyId);
|
||||
|
||||
// 设置创建人ID
|
||||
product.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
// 保存商品
|
||||
this.save(product);
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(product);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ProductVO updateProduct(UpdateProductDTO updateProductDTO, Long id) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证商品是否存在
|
||||
ProductPO existingProduct = this.getById(id);
|
||||
if (existingProduct == null || !existingProduct.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("商品不存在");
|
||||
}
|
||||
|
||||
// 验证商品名称是否重复(排除当前商品)
|
||||
LambdaQueryWrapper<ProductPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProductPO::getName, updateProductDTO.getName())
|
||||
.eq(ProductPO::getCompanyId, companyId)
|
||||
.ne(ProductPO::getId, id)
|
||||
.isNull(ProductPO::getDeleteTime);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("商品名称已存在");
|
||||
}
|
||||
|
||||
// 验证SKU是否重复(排除当前商品)
|
||||
if (updateProductDTO.getSkuCode() != null && !updateProductDTO.getSkuCode().trim().isEmpty()) {
|
||||
LambdaQueryWrapper<ProductPO> skuWrapper = new LambdaQueryWrapper<>();
|
||||
skuWrapper.eq(ProductPO::getSkuCode, updateProductDTO.getSkuCode())
|
||||
.eq(ProductPO::getCompanyId, companyId)
|
||||
.ne(ProductPO::getId, id)
|
||||
.isNull(ProductPO::getDeleteTime);
|
||||
if (this.count(skuWrapper) > 0) {
|
||||
throw new BusinessException("商品SKU已存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 更新商品
|
||||
ProductPO product = new ProductPO();
|
||||
BeanUtils.copyProperties(updateProductDTO, product);
|
||||
product.setId(id);
|
||||
product.setCompanyId(companyId);
|
||||
|
||||
// 设置更新人ID
|
||||
product.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
// 更新商品
|
||||
this.updateById(product);
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(product);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteProduct(Long id) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证商品是否存在
|
||||
ProductPO existingProduct = this.getById(id);
|
||||
if (existingProduct == null || !existingProduct.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("商品不存在");
|
||||
}
|
||||
|
||||
// 软删除商品
|
||||
ProductPO product = new ProductPO();
|
||||
product.setId(id);
|
||||
product.setDeleteTime(LocalDateTime.now());
|
||||
product.setDeleteBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
this.updateById(product);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResultVO<ProductVO> getProductPage(PageQueryDTO<ProductFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 创建分页对象
|
||||
Page<ProductPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<ProductPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProductPO::getCompanyId, companyId)
|
||||
.isNull(ProductPO::getDeleteTime);
|
||||
|
||||
// 添加过滤条件
|
||||
ProductFilterDTO filter = pageQueryDTO.getFilters();
|
||||
if (filter != null) {
|
||||
if (filter.getName() != null && !filter.getName().trim().isEmpty()) {
|
||||
wrapper.like(ProductPO::getName, filter.getName());
|
||||
}
|
||||
if (filter.getSpecCode() != null && !filter.getSpecCode().trim().isEmpty()) {
|
||||
wrapper.like(ProductPO::getSpecCode, filter.getSpecCode());
|
||||
}
|
||||
if (filter.getSkuCode() != null && !filter.getSkuCode().trim().isEmpty()) {
|
||||
wrapper.like(ProductPO::getSkuCode, filter.getSkuCode());
|
||||
}
|
||||
if (filter.getMinCostPrice() != null) {
|
||||
wrapper.ge(ProductPO::getCostPrice, filter.getMinCostPrice());
|
||||
}
|
||||
if (filter.getMaxCostPrice() != null) {
|
||||
wrapper.le(ProductPO::getCostPrice, filter.getMaxCostPrice());
|
||||
}
|
||||
}
|
||||
|
||||
// 排序
|
||||
wrapper.orderByDesc(ProductPO::getCreateTime);
|
||||
|
||||
// 执行分页查询
|
||||
IPage<ProductPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<ProductVO> voList = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建分页结果
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
*/
|
||||
private ProductVO convertToVO(ProductPO product) {
|
||||
ProductVO productVO = new ProductVO();
|
||||
BeanUtils.copyProperties(product, productVO);
|
||||
return productVO;
|
||||
}
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.ec.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.mapper.ShopMapper;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.CreateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.ShopFilterDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.dto.shop.UpdateShopDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.po.ShopPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.model.vo.ShopVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ec.service.ShopService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
import top.xyquan.ecomdmbbackend.utils.SecurityUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 店铺服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements ShopService {
|
||||
|
||||
private final CurrentUserContext currentUserContext;
|
||||
|
||||
public ShopServiceImpl(CurrentUserContext currentUserContext) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ShopVO createShop(CreateShopDTO createShopDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证店铺名称是否重复
|
||||
LambdaQueryWrapper<ShopPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopPO::getName, createShopDTO.getName())
|
||||
.eq(ShopPO::getCompanyId, companyId)
|
||||
.isNull(ShopPO::getDeleteTime);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("店铺名称已存在");
|
||||
}
|
||||
|
||||
// 创建店铺
|
||||
ShopPO shop = new ShopPO();
|
||||
BeanUtils.copyProperties(createShopDTO, shop);
|
||||
|
||||
// 设置公司ID
|
||||
shop.setCompanyId(companyId);
|
||||
|
||||
// 设置创建人ID
|
||||
shop.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
// 保存店铺
|
||||
this.save(shop);
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(shop);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ShopVO updateShop(UpdateShopDTO updateShopDTO, Long id) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证店铺是否存在
|
||||
ShopPO existingShop = this.getById(id);
|
||||
if (existingShop == null || !existingShop.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("店铺不存在");
|
||||
}
|
||||
|
||||
// 验证店铺名称是否重复(排除当前店铺)
|
||||
LambdaQueryWrapper<ShopPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopPO::getName, updateShopDTO.getName())
|
||||
.eq(ShopPO::getCompanyId, companyId)
|
||||
.ne(ShopPO::getId, id)
|
||||
.isNull(ShopPO::getDeleteTime);
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("店铺名称已存在");
|
||||
}
|
||||
|
||||
// 更新店铺
|
||||
ShopPO shop = new ShopPO();
|
||||
BeanUtils.copyProperties(updateShopDTO, shop);
|
||||
shop.setId(id);
|
||||
shop.setCompanyId(companyId);
|
||||
|
||||
// 设置更新人ID
|
||||
shop.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
// 更新店铺
|
||||
this.updateById(shop);
|
||||
|
||||
// 转换为VO并返回
|
||||
return convertToVO(shop);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteShop(Long id) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 验证店铺是否存在
|
||||
ShopPO existingShop = this.getById(id);
|
||||
if (existingShop == null || !existingShop.getCompanyId().equals(companyId)) {
|
||||
throw new BusinessException("店铺不存在");
|
||||
}
|
||||
|
||||
// 软删除店铺
|
||||
ShopPO shop = new ShopPO();
|
||||
shop.setId(id);
|
||||
shop.setDeleteTime(LocalDateTime.now());
|
||||
shop.setDeleteBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
this.updateById(shop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResultVO<ShopVO> getShopPage(PageQueryDTO<ShopFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 创建分页对象
|
||||
Page<ShopPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<ShopPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopPO::getCompanyId, companyId)
|
||||
.isNull(ShopPO::getDeleteTime);
|
||||
|
||||
// 添加过滤条件
|
||||
ShopFilterDTO filter = pageQueryDTO.getFilters();
|
||||
if (filter != null) {
|
||||
if (filter.getName() != null && !filter.getName().trim().isEmpty()) {
|
||||
wrapper.like(ShopPO::getName, filter.getName());
|
||||
}
|
||||
if (filter.getPlatform() != null && !filter.getPlatform().trim().isEmpty()) {
|
||||
wrapper.eq(ShopPO::getPlatform, filter.getPlatform());
|
||||
}
|
||||
}
|
||||
|
||||
// 排序
|
||||
wrapper.orderByDesc(ShopPO::getCreateTime);
|
||||
|
||||
// 执行分页查询
|
||||
IPage<ShopPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<ShopVO> voList = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建分页结果
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
*/
|
||||
private ShopVO convertToVO(ShopPO shop) {
|
||||
ShopVO shopVO = new ShopVO();
|
||||
BeanUtils.copyProperties(shop, shopVO);
|
||||
return shopVO;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class MediaFilePO {
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class MediaImagePO {
|
||||
/**
|
||||
* 图片ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class CompanyMenuPO {
|
||||
/**
|
||||
* 关联ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class CompanyPO {
|
||||
/**
|
||||
* 公司ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class DepartmentPO {
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("rel_position_company_menu")
|
||||
@TableName("org_position_company_menu_map")
|
||||
public class PositionCompanyMenuPO {
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class PositionPO {
|
||||
/**
|
||||
* 岗位ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -115,16 +115,16 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
|
||||
// 添加过滤条件
|
||||
CompanyFilterDTO filterDTO = pageQuery.getFilters();
|
||||
if (filterDTO != null) {
|
||||
if (StringUtils.hasText(filterDTO.getName())) {
|
||||
if (filterDTO.getName() != null && StringUtils.hasText(filterDTO.getName())) {
|
||||
wrapper.like(CompanyPO::getName, filterDTO.getName());
|
||||
}
|
||||
if (StringUtils.hasText(filterDTO.getContactPerson())) {
|
||||
if (filterDTO.getContactPerson() != null && StringUtils.hasText(filterDTO.getContactPerson())) {
|
||||
wrapper.like(CompanyPO::getContactPerson, filterDTO.getContactPerson());
|
||||
}
|
||||
if (StringUtils.hasText(filterDTO.getContactPhone())) {
|
||||
if (filterDTO.getContactPhone() != null && StringUtils.hasText(filterDTO.getContactPhone())) {
|
||||
wrapper.eq(CompanyPO::getContactPhone, filterDTO.getContactPhone());
|
||||
}
|
||||
if (StringUtils.hasText(filterDTO.getEmail())) {
|
||||
if (filterDTO.getEmail() != null && StringUtils.hasText(filterDTO.getEmail())) {
|
||||
wrapper.eq(CompanyPO::getEmail, filterDTO.getEmail());
|
||||
}
|
||||
if (filterDTO.getStatus() != null) {
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
// 添加过滤条件
|
||||
DepartmentFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
if (queryDTO != null) {
|
||||
if (StringUtils.hasText(queryDTO.getName())) {
|
||||
if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) {
|
||||
wrapper.like(DepartmentPO::getName, queryDTO.getName());
|
||||
}
|
||||
if (queryDTO.getParentId() != null) {
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
||||
// 添加过滤条件
|
||||
PositionFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
if (queryDTO != null) {
|
||||
if (StringUtils.hasText(queryDTO.getName())) {
|
||||
if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) {
|
||||
wrapper.like(PositionPO::getName, queryDTO.getName());
|
||||
}
|
||||
if (queryDTO.getStatus() != null) {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class PlanPO {
|
||||
/**
|
||||
* 套餐ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public class SubscriptionPO {
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
-19
@@ -1,10 +1,7 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.po.PermissionPO;
|
||||
|
||||
/**
|
||||
@@ -12,20 +9,4 @@ import top.xyquan.ecomdmbbackend.modules.sys.model.po.PermissionPO;
|
||||
*/
|
||||
@Mapper
|
||||
public interface PermissionMapper extends BaseMapper<PermissionPO> {
|
||||
|
||||
/**
|
||||
* 分页查询权限列表
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param code 权限码
|
||||
* @param name 权限名称
|
||||
* @param type 权限类型
|
||||
* @param status 状态
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<PermissionPO> selectPermissionPage(Page<PermissionPO> page,
|
||||
@Param("code") String code,
|
||||
@Param("name") String name,
|
||||
@Param("type") String type,
|
||||
@Param("status") Integer status);
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class MenuPO {
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("rel_menu_permission")
|
||||
@TableName("sys_menu_permission_map")
|
||||
public class MenuPermissionPO {
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class UserPO {
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
||||
+27
-7
@@ -3,6 +3,7 @@ package top.xyquan.ecomdmbbackend.modules.sys.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
@@ -27,7 +28,7 @@ import java.util.stream.Collectors;
|
||||
* 权限服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class PermissionServiceImpl implements PermissionService {
|
||||
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, PermissionPO> implements PermissionService {
|
||||
|
||||
private final PermissionMapper permissionMapper;
|
||||
private final CurrentUserContext currentUserContext;
|
||||
@@ -102,12 +103,31 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
public PageResultVO<PermissionVO> getPermissionPage(PageQueryDTO<PermissionFilterDTO> filterDTO) {
|
||||
Page<PermissionPO> page = new Page<>(filterDTO.getPage(), filterDTO.getPageSize());
|
||||
|
||||
IPage<PermissionPO> permissionPage = permissionMapper.selectPermissionPage(
|
||||
page,
|
||||
filterDTO.getFilters().getCode(),
|
||||
filterDTO.getFilters().getName(),
|
||||
filterDTO.getFilters().getType(),
|
||||
filterDTO.getFilters().getStatus());
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<PermissionPO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加过滤条件
|
||||
PermissionFilterDTO filter = filterDTO.getFilters();
|
||||
if (filter != null) {
|
||||
if (filter.getCode() != null && !filter.getCode().trim().isEmpty()) {
|
||||
wrapper.like(PermissionPO::getCode, filter.getCode());
|
||||
}
|
||||
if (filter.getName() != null && !filter.getName().trim().isEmpty()) {
|
||||
wrapper.like(PermissionPO::getName, filter.getName());
|
||||
}
|
||||
if (filter.getType() != null && !filter.getType().trim().isEmpty()) {
|
||||
wrapper.eq(PermissionPO::getType, filter.getType());
|
||||
}
|
||||
if (filter.getStatus() != null) {
|
||||
wrapper.eq(PermissionPO::getStatus, filter.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
// 排序
|
||||
wrapper.orderByDesc(PermissionPO::getCreateTime);
|
||||
|
||||
// 执行分页查询
|
||||
IPage<PermissionPO> permissionPage = this.page(page, wrapper);
|
||||
|
||||
List<PermissionVO> permissionVOList = permissionPage.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
|
||||
+9
-2
@@ -18,6 +18,7 @@ import top.xyquan.ecomdmbbackend.modules.sys.model.vo.UserVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.service.UserService;
|
||||
import top.xyquan.ecomdmbbackend.utils.JwtUtils;
|
||||
import top.xyquan.ecomdmbbackend.utils.SecurityUtils;
|
||||
import top.xyquan.ecomdmbbackend.utils.TokenPayload;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -214,8 +215,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
||||
private LoginVO generateLoginResponse(UserPO user) {
|
||||
LoginVO loginVO = new LoginVO();
|
||||
|
||||
// 生成JWT令牌,包含用户ID和公司ID
|
||||
String token = jwtUtils.generateToken(user.getId().toString(), user.getCompanyId());
|
||||
// 生成JWT令牌,包含完整的用户信息
|
||||
TokenPayload payload = TokenPayload.builder()
|
||||
.userId(user.getId().toString())
|
||||
.companyId(user.getCompanyId())
|
||||
.role(user.getRole())
|
||||
.positionId(user.getPositionId())
|
||||
.build();
|
||||
String token = jwtUtils.generateToken(payload);
|
||||
loginVO.setToken(token);
|
||||
|
||||
// 转换用户信息
|
||||
|
||||
Reference in New Issue
Block a user