diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/filter/JwtAuthenticationFilter.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/filter/JwtAuthenticationFilter.java index aebc5777..4110f649 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/filter/JwtAuthenticationFilter.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/common/filter/JwtAuthenticationFilter.java @@ -51,6 +51,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { SecurityContextHolder.getContext().setAuthentication(authentication); logger.debug("JWT认证成功,用户ID: " + userId); logger.debug("JWT认证成功,公司ID: " + companyId); + logger.debug("JWT认证成功,Token: " + token); } } else { logger.debug("JWT Token无效或为空"); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderItemMapper.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderItemMapper.java deleted file mode 100644 index 0421fd00..00000000 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/mapper/OrderItemMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -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 { -} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderDTO.java index 1f0bf55c..ff3fc38e 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderDTO.java @@ -65,10 +65,22 @@ public class CreateOrderDTO { /** * 商品规格ID */ - @Schema(description = "商品规格ID", example = "1", required = true) - @NotNull(message = "商品规格ID不能为空") + @Schema(description = "商品规格ID", example = "1") private Long productSpecId; + /** + * 商品名称(冗余存储) + */ + @Schema(description = "商品名称", example = "iPhone 15 Pro", required = true) + @NotNull(message = "商品名称不能为空") + private String productName; + + /** + * 规格名称(冗余存储) + */ + @Schema(description = "规格名称", example = "256GB 深空黑色") + private String specName; + /** * 数量 */ @@ -76,4 +88,25 @@ public class CreateOrderDTO { @NotNull(message = "数量不能为空") @Positive(message = "数量必须大于0") private Integer quantity; + + /** + * 销售单价 + */ + @Schema(description = "销售单价", example = "9999.00", required = true) + @NotNull(message = "销售单价不能为空") + private BigDecimal unitPrice; + + /** + * 成本价(下单时快照) + */ + @Schema(description = "成本价", example = "8000.00", required = true) + @NotNull(message = "成本价不能为空") + private BigDecimal costPrice; + + /** + * 成本小计 + */ + @Schema(description = "成本小计", example = "8000.00", required = true) + @NotNull(message = "成本小计不能为空") + private BigDecimal costTotal; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderItemDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderItemDTO.java deleted file mode 100644 index d9347a6d..00000000 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/CreateOrderItemDTO.java +++ /dev/null @@ -1,79 +0,0 @@ -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; - - /** - * 商品规格ID - */ - @Schema(description = "商品规格ID", example = "1") - private Long productSpecId; - - /** - * 商品名称(冗余存储) - */ - @Schema(description = "商品名称", example = "iPhone 15 Pro", required = true) - @NotBlank(message = "商品名称不能为空") - private String productName; - - /** - * 规格名称(冗余存储) - */ - @Schema(description = "规格名称", example = "128GB 深空黑色") - private String specName; - - /** - * 数量 - */ - @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 = "8000.00", required = true) - @NotNull(message = "成本价不能为空") - private BigDecimal costPrice; - - /** - * 小计金额 - */ - @Schema(description = "小计金额", example = "9999.00", required = true) - @NotNull(message = "小计金额不能为空") - private BigDecimal subtotal; - - /** - * 成本小计 - */ - @Schema(description = "成本小计", example = "8000.00", required = true) - @NotNull(message = "成本小计不能为空") - private BigDecimal costTotal; -} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/UpdateOrderDTO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/UpdateOrderDTO.java index 90ce0014..99f0c5c4 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/UpdateOrderDTO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/dto/order/UpdateOrderDTO.java @@ -52,4 +52,52 @@ public class UpdateOrderDTO { @Schema(description = "下单时间", example = "2024-01-01T10:00:00", required = true) @NotNull(message = "下单时间不能为空") private LocalDateTime orderDate; + + /** + * 商品ID + */ + @Schema(description = "商品ID", example = "1") + private Long productId; + + /** + * 商品规格ID + */ + @Schema(description = "商品规格ID", example = "1") + private Long productSpecId; + + /** + * 商品名称(冗余存储) + */ + @Schema(description = "商品名称", example = "iPhone 15 Pro") + private String productName; + + /** + * 规格名称(冗余存储) + */ + @Schema(description = "规格名称", example = "256GB 深空黑色") + private String specName; + + /** + * 数量 + */ + @Schema(description = "数量", example = "1") + private Integer quantity; + + /** + * 销售单价 + */ + @Schema(description = "销售单价", example = "9999.00") + private BigDecimal unitPrice; + + /** + * 成本价(下单时快照) + */ + @Schema(description = "成本价", example = "8000.00") + private BigDecimal costPrice; + + /** + * 成本小计 + */ + @Schema(description = "成本小计", example = "8000.00") + private BigDecimal costTotal; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderItemPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderItemPO.java deleted file mode 100644 index d42ad43f..00000000 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderItemPO.java +++ /dev/null @@ -1,119 +0,0 @@ -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; - - /** - * 商品规格ID - */ - @TableField("product_spec_id") - private Long productSpecId; - - /** - * 商品名称(冗余存储) - */ - @TableField("product_name") - private String productName; - - /** - * 规格名称(冗余存储) - */ - @TableField("spec_name") - private String specName; - - /** - * 数量 - */ - @TableField("quantity") - private Integer quantity; - - /** - * 销售单价 - */ - @TableField("unit_price") - private BigDecimal unitPrice; - - /** - * 成本价(下单时快照) - */ - @TableField("cost_price") - private BigDecimal costPrice; - - /** - * 小计金额 - */ - @TableField("subtotal") - private BigDecimal subtotal; - - /** - * 成本小计 - */ - @TableField("cost_total") - private BigDecimal costTotal; - - /** - * 创建时间 - */ - @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; -} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderPO.java index 399a30b1..3f60d244 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderPO.java @@ -8,7 +8,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; /** - * 电商-订单实体 + * 电商-订单实体(含商品明细) */ @Data @EqualsAndHashCode(callSuper = false) @@ -45,6 +45,54 @@ public class OrderPO { @TableField("status_id") private Long statusId; + /** + * 商品ID + */ + @TableField("product_id") + private Long productId; + + /** + * 商品规格ID + */ + @TableField("product_spec_id") + private Long productSpecId; + + /** + * 商品名称(冗余存储) + */ + @TableField("product_name") + private String productName; + + /** + * 规格名称(冗余存储) + */ + @TableField("spec_name") + private String specName; + + /** + * 数量 + */ + @TableField("quantity") + private Integer quantity; + + /** + * 销售单价 + */ + @TableField("unit_price") + private BigDecimal unitPrice; + + /** + * 成本价(下单时快照) + */ + @TableField("cost_price") + private BigDecimal costPrice; + + /** + * 成本小计 + */ + @TableField("cost_total") + private BigDecimal costTotal; + /** * 商家实收金额 */ @@ -75,12 +123,6 @@ public class OrderPO { @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; - /** - * 删除时间 - */ - @TableField("delete_time") - private LocalDateTime deleteTime; - /** * 创建人ID */ @@ -92,10 +134,4 @@ public class OrderPO { */ @TableField("update_by") private Long updateBy; - - /** - * 删除人ID - */ - @TableField("delete_by") - private Long deleteBy; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderStatusPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderStatusPO.java index 74e1f5cb..fe30f054 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderStatusPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/OrderStatusPO.java @@ -26,12 +26,6 @@ public class OrderStatusPO { @TableField("company_id") private Long companyId; - /** - * 状态码 - */ - @TableField("status_code") - private Integer statusCode; - /** * 状态名称 */ @@ -68,12 +62,6 @@ public class OrderStatusPO { @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; - /** - * 删除时间 - */ - @TableField("delete_time") - private LocalDateTime deleteTime; - /** * 创建人ID */ @@ -85,10 +73,4 @@ public class OrderStatusPO { */ @TableField("update_by") private Long updateBy; - - /** - * 删除人ID - */ - @TableField("delete_by") - private Long deleteBy; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductPO.java index 4a4ca7f8..c22134c6 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductPO.java @@ -56,12 +56,6 @@ public class ProductPO { @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; - /** - * 删除时间 - */ - @TableField("delete_time") - private LocalDateTime deleteTime; - /** * 创建人ID */ @@ -73,10 +67,4 @@ public class ProductPO { */ @TableField("update_by") private Long updateBy; - - /** - * 删除人ID - */ - @TableField("delete_by") - private Long deleteBy; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductSpecPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductSpecPO.java index 5aa48fd0..42945b9a 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductSpecPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ProductSpecPO.java @@ -63,12 +63,6 @@ public class ProductSpecPO { @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; - /** - * 删除时间 - */ - @TableField("delete_time") - private LocalDateTime deleteTime; - /** * 创建人ID */ @@ -80,10 +74,4 @@ public class ProductSpecPO { */ @TableField("update_by") private Long updateBy; - - /** - * 删除人ID - */ - @TableField("delete_by") - private Long deleteBy; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/PromotionFeePO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/PromotionFeePO.java index 255bf9d2..78d45621 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/PromotionFeePO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/PromotionFeePO.java @@ -118,12 +118,6 @@ public class PromotionFeePO { @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; - /** - * 删除时间 - */ - @TableField("delete_time") - private LocalDateTime deleteTime; - /** * 创建人ID */ @@ -135,10 +129,4 @@ public class PromotionFeePO { */ @TableField("update_by") private Long updateBy; - - /** - * 删除人ID - */ - @TableField("delete_by") - private Long deleteBy; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/PromotionFeeTypePO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/PromotionFeeTypePO.java index 11b790d9..85f1e1e9 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/PromotionFeeTypePO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/PromotionFeeTypePO.java @@ -26,12 +26,6 @@ public class PromotionFeeTypePO { @TableField("company_id") private Long companyId; - /** - * 类型编码 - */ - @TableField("type_code") - private String typeCode; - /** * 类型名称 */ @@ -74,12 +68,6 @@ public class PromotionFeeTypePO { @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; - /** - * 删除时间 - */ - @TableField("delete_time") - private LocalDateTime deleteTime; - /** * 创建人ID */ @@ -91,10 +79,4 @@ public class PromotionFeeTypePO { */ @TableField("update_by") private Long updateBy; - - /** - * 删除人ID - */ - @TableField("delete_by") - private Long deleteBy; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ShopPO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ShopPO.java index ffe47615..e2e12fc8 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ShopPO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/po/ShopPO.java @@ -62,12 +62,6 @@ public class ShopPO { @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; - /** - * 删除时间 - */ - @TableField("delete_time") - private LocalDateTime deleteTime; - /** * 创建人ID */ @@ -79,10 +73,4 @@ public class ShopPO { */ @TableField("update_by") private Long updateBy; - - /** - * 删除人ID - */ - @TableField("delete_by") - private Long deleteBy; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderItemVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderItemVO.java deleted file mode 100644 index 69569f71..00000000 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderItemVO.java +++ /dev/null @@ -1,99 +0,0 @@ -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; - - /** - * 商品规格ID - */ - @Schema(description = "商品规格ID", example = "1") - private Long productSpecId; - - /** - * 商品名称(冗余存储) - */ - @Schema(description = "商品名称", example = "iPhone 15 Pro") - private String productName; - - /** - * 规格名称(冗余存储) - */ - @Schema(description = "规格名称", example = "128GB 深空黑色") - private String specName; - - /** - * 商品主图 - */ - @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 = "8000.00") - private BigDecimal costPrice; - - /** - * 小计金额 - */ - @Schema(description = "小计金额", example = "9999.00") - private BigDecimal subtotal; - - /** - * 成本小计 - */ - @Schema(description = "成本小计", example = "8000.00") - private BigDecimal costTotal; - - /** - * 创建时间 - */ - @Schema(description = "创建时间", example = "2024-01-01T10:00:00") - private LocalDateTime createTime; - - /** - * 更新时间 - */ - @Schema(description = "更新时间", example = "2024-01-01T10:00:00") - private LocalDateTime updateTime; -} diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderVO.java index 3d05a407..5dbf894d 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/model/vo/OrderVO.java @@ -98,8 +98,50 @@ public class OrderVO { private Long updateBy; /** - * 订单明细 + * 商品ID */ - @Schema(description = "订单明细") - private OrderItemVO orderItem; + @Schema(description = "商品ID", example = "1") + private Long productId; + + /** + * 商品规格ID + */ + @Schema(description = "商品规格ID", example = "1") + private Long productSpecId; + + /** + * 商品名称(冗余存储) + */ + @Schema(description = "商品名称", example = "iPhone 15 Pro") + private String productName; + + /** + * 规格名称(冗余存储) + */ + @Schema(description = "规格名称", example = "256GB 深空黑色") + private String specName; + + /** + * 数量 + */ + @Schema(description = "数量", example = "1") + private Integer quantity; + + /** + * 销售单价 + */ + @Schema(description = "销售单价", example = "9999.00") + private BigDecimal unitPrice; + + /** + * 成本价(下单时快照) + */ + @Schema(description = "成本价", example = "8000.00") + private BigDecimal costPrice; + + /** + * 成本小计 + */ + @Schema(description = "成本小计", example = "8000.00") + private BigDecimal costTotal; } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderServiceImpl.java index 08f01dc6..210ef087 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderServiceImpl.java @@ -10,19 +10,16 @@ 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.BatchImportOrderDTO; 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.OrderItemPO; import top.xyquan.ecomdmbbackend.modules.ec.model.po.OrderPO; import top.xyquan.ecomdmbbackend.modules.ec.model.po.ProductPO; import top.xyquan.ecomdmbbackend.modules.ec.model.po.ProductSpecPO; import top.xyquan.ecomdmbbackend.modules.ec.model.po.ShopPO; import top.xyquan.ecomdmbbackend.modules.ec.model.vo.BatchImportResultVO; -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.ProductService; @@ -45,16 +42,13 @@ public class OrderServiceImpl extends ServiceImpl implemen private final ShopService shopService; private final ProductService productService; private final ProductSpecService productSpecService; - private final OrderItemMapper orderItemMapper; public OrderServiceImpl(CurrentUserContext currentUserContext, ShopService shopService, - ProductService productService, ProductSpecService productSpecService, - OrderItemMapper orderItemMapper) { + ProductService productService, ProductSpecService productSpecService) { this.currentUserContext = currentUserContext; this.shopService = shopService; this.productService = productService; this.productSpecService = productSpecService; - this.orderItemMapper = orderItemMapper; } @Override @@ -75,30 +69,40 @@ public class OrderServiceImpl extends ServiceImpl implemen throw new BusinessException("商品不存在"); } - // 验证商品规格是否存在且属于当前公司 - ProductSpecPO productSpec = productSpecService.getById(createOrderDTO.getProductSpecId()); - if (productSpec == null || !productSpec.getCompanyId().equals(companyId) || - !productSpec.getProductId().equals(createOrderDTO.getProductId())) { - throw new BusinessException("商品规格不存在或不属于该商品"); + // 验证商品规格是否存在且属于当前公司(如果提供了规格ID) + ProductSpecPO productSpec = null; + if (createOrderDTO.getProductSpecId() != null) { + productSpec = productSpecService.getById(createOrderDTO.getProductSpecId()); + if (productSpec == null || !productSpec.getCompanyId().equals(companyId) || + !productSpec.getProductId().equals(createOrderDTO.getProductId())) { + throw new BusinessException("商品规格不存在或不属于该商品"); + } } // 验证平台订单号是否重复(如果提供了的话) if (createOrderDTO.getPlatformOrderNo() != null && !createOrderDTO.getPlatformOrderNo().trim().isEmpty()) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(OrderPO::getPlatformOrderNo, createOrderDTO.getPlatformOrderNo()) - .eq(OrderPO::getCompanyId, companyId) - .isNull(OrderPO::getDeleteTime); + .eq(OrderPO::getCompanyId, companyId); if (this.count(wrapper) > 0) { throw new BusinessException("平台订单号已存在"); } } - // 创建订单 + // 创建订单(包含商品明细) OrderPO order = new OrderPO(); order.setCompanyId(companyId); order.setShopId(createOrderDTO.getShopId()); order.setPlatformOrderNo(createOrderDTO.getPlatformOrderNo()); order.setStatusId(createOrderDTO.getStatusId()); + order.setProductId(createOrderDTO.getProductId()); + order.setProductSpecId(createOrderDTO.getProductSpecId()); + order.setProductName(createOrderDTO.getProductName()); + order.setSpecName(createOrderDTO.getSpecName()); + order.setQuantity(createOrderDTO.getQuantity()); + order.setUnitPrice(createOrderDTO.getUnitPrice()); + order.setCostPrice(createOrderDTO.getCostPrice()); + order.setCostTotal(createOrderDTO.getCostTotal()); order.setReceivedAmount(createOrderDTO.getReceivedAmount()); order.setShippingFee(createOrderDTO.getShippingFee() != null ? createOrderDTO.getShippingFee() : java.math.BigDecimal.ZERO); order.setOrderDate(createOrderDTO.getOrderDate()); @@ -107,29 +111,6 @@ public class OrderServiceImpl extends ServiceImpl implemen // 保存订单 this.save(order); - // 计算订单明细相关字段 - java.math.BigDecimal unitPrice = createOrderDTO.getReceivedAmount().divide( - java.math.BigDecimal.valueOf(createOrderDTO.getQuantity()), 2, java.math.RoundingMode.HALF_UP); - java.math.BigDecimal costPrice = productSpec.getCostPrice(); - java.math.BigDecimal subtotal = unitPrice.multiply(java.math.BigDecimal.valueOf(createOrderDTO.getQuantity())); - java.math.BigDecimal costTotal = costPrice.multiply(java.math.BigDecimal.valueOf(createOrderDTO.getQuantity())); - - // 创建订单明细 - OrderItemPO orderItem = new OrderItemPO(); - orderItem.setOrderId(order.getId()); - orderItem.setProductId(createOrderDTO.getProductId()); - orderItem.setProductSpecId(createOrderDTO.getProductSpecId()); - orderItem.setProductName(product.getName()); // 冗余存储商品名称 - orderItem.setSpecName(productSpec.getName()); // 冗余存储规格名称 - orderItem.setQuantity(createOrderDTO.getQuantity()); - orderItem.setUnitPrice(unitPrice); // 销售单价 = 实收金额 / 数量 - orderItem.setCostPrice(costPrice); // 成本价(下单时快照) - orderItem.setSubtotal(subtotal); // 小计金额 = 销售单价 × 数量 - orderItem.setCostTotal(costTotal); // 成本小计 = 成本价 × 数量 - orderItem.setCreateBy(currentUserContext.getCurrentUserId()); - - orderItemMapper.insert(orderItem); - // 转换为VO并返回 return convertToVO(order); } @@ -157,8 +138,7 @@ public class OrderServiceImpl extends ServiceImpl implemen LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(OrderPO::getPlatformOrderNo, updateOrderDTO.getPlatformOrderNo()) .eq(OrderPO::getCompanyId, companyId) - .ne(OrderPO::getId, id) - .isNull(OrderPO::getDeleteTime); + .ne(OrderPO::getId, id); if (this.count(wrapper) > 0) { throw new BusinessException("平台订单号已存在"); } @@ -192,24 +172,8 @@ public class OrderServiceImpl extends ServiceImpl implemen throw new BusinessException("订单不存在"); } - // 软删除订单 - OrderPO order = new OrderPO(); - order.setId(id); - order.setDeleteTime(LocalDateTime.now()); - order.setDeleteBy(currentUserContext.getCurrentUserId()); - - this.updateById(order); - - // 软删除订单明细 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(OrderItemPO::getOrderId, id) - .isNull(OrderItemPO::getDeleteTime); - List orderItems = orderItemMapper.selectList(wrapper); - for (OrderItemPO orderItem : orderItems) { - orderItem.setDeleteTime(LocalDateTime.now()); - orderItem.setDeleteBy(currentUserContext.getCurrentUserId()); - orderItemMapper.updateById(orderItem); - } + // 硬删除订单(外键约束会自动处理相关数据) + this.removeById(id); } @Override @@ -222,8 +186,7 @@ public class OrderServiceImpl extends ServiceImpl implemen // 构建查询条件 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(OrderPO::getCompanyId, companyId) - .isNull(OrderPO::getDeleteTime); + wrapper.eq(OrderPO::getCompanyId, companyId); // 添加过滤条件 OrderFilterDTO filter = pageQueryDTO.getFilters(); @@ -258,25 +221,9 @@ public class OrderServiceImpl extends ServiceImpl implemen // 执行分页查询 IPage pageResult = this.page(page, wrapper); - // 转换为VO并加载订单明细 + // 转换为VO List voList = pageResult.getRecords().stream() - .map(order -> { - OrderVO orderVO = convertToVO(order); - // 查询订单明细(只取第一条) - LambdaQueryWrapper itemWrapper = new LambdaQueryWrapper<>(); - itemWrapper.eq(OrderItemPO::getOrderId, order.getId()) - .isNull(OrderItemPO::getDeleteTime) - .orderByAsc(OrderItemPO::getCreateTime) - .last("LIMIT 1"); - OrderItemPO orderItem = orderItemMapper.selectOne(itemWrapper); - - // 转换为VO - if (orderItem != null) { - OrderItemVO orderItemVO = convertOrderItemToVO(orderItem); - orderVO.setOrderItem(orderItemVO); - } - return orderVO; - }) + .map(this::convertToVO) .collect(Collectors.toList()); // 构建分页结果 @@ -294,24 +241,8 @@ public class OrderServiceImpl extends ServiceImpl implemen throw new BusinessException("订单不存在"); } - // 转换为VO - OrderVO orderVO = convertToVO(order); - - // 查询订单明细(只取第一条) - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(OrderItemPO::getOrderId, id) - .isNull(OrderItemPO::getDeleteTime) - .orderByAsc(OrderItemPO::getCreateTime) - .last("LIMIT 1"); - OrderItemPO orderItem = orderItemMapper.selectOne(wrapper); - - // 转换为VO - if (orderItem != null) { - OrderItemVO orderItemVO = convertOrderItemToVO(orderItem); - orderVO.setOrderItem(orderItemVO); - } - - return orderVO; + // 转换为VO并返回 + return convertToVO(order); } @Override @@ -376,13 +307,4 @@ public class OrderServiceImpl extends ServiceImpl implemen return orderVO; } - /** - * 转换订单明细为VO - */ - private OrderItemVO convertOrderItemToVO(OrderItemPO orderItem) { - OrderItemVO orderItemVO = new OrderItemVO(); - BeanUtils.copyProperties(orderItem, orderItemVO); - return orderItemVO; - } - } diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderStatusServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderStatusServiceImpl.java index 7a7e0939..2e85e4c5 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderStatusServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/OrderStatusServiceImpl.java @@ -29,13 +29,12 @@ public class OrderStatusServiceImpl implements OrderStatusService { @Override @Transactional(rollbackFor = Exception.class) public Long createOrderStatus(CreateOrderStatusDTO dto) { - // 检查状态码是否重复 + // 检查状态名称是否重复 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(OrderStatusPO::getCompanyId, currentUserContext.getCurrentCompanyId()) - .eq(OrderStatusPO::getStatusCode, dto.getStatusCode()) - .isNull(OrderStatusPO::getDeleteTime); + .eq(OrderStatusPO::getStatusName, dto.getStatusName()); if (orderStatusMapper.selectCount(wrapper) > 0) { - throw new RuntimeException("该状态码已存在"); + throw new RuntimeException("该状态名称已存在"); } OrderStatusPO po = new OrderStatusPO(); @@ -61,12 +60,8 @@ public class OrderStatusServiceImpl implements OrderStatusService { @Override @Transactional(rollbackFor = Exception.class) public void deleteOrderStatus(Long id) { - OrderStatusPO po = new OrderStatusPO(); - po.setId(id); - po.setDeleteBy(currentUserContext.getCurrentUserId()); - po.setDeleteTime(java.time.LocalDateTime.now()); - - orderStatusMapper.updateById(po); + // 硬删除订单状态(外键约束会自动处理相关数据) + orderStatusMapper.deleteById(id); } @Override @@ -86,7 +81,6 @@ public class OrderStatusServiceImpl implements OrderStatusService { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(OrderStatusPO::getCompanyId, currentUserContext.getCurrentCompanyId()) .eq(OrderStatusPO::getIsActive, 1) // 1表示启用状态 - .isNull(OrderStatusPO::getDeleteTime) .orderByAsc(OrderStatusPO::getSortOrder); List poList = orderStatusMapper.selectList(wrapper); @@ -103,7 +97,6 @@ public class OrderStatusServiceImpl implements OrderStatusService { public List getAllOrderStatusList() { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(OrderStatusPO::getCompanyId, currentUserContext.getCurrentCompanyId()) - .isNull(OrderStatusPO::getDeleteTime) .orderByAsc(OrderStatusPO::getSortOrder); List poList = orderStatusMapper.selectList(wrapper); @@ -124,20 +117,19 @@ public class OrderStatusServiceImpl implements OrderStatusService { public void initOrderStatusForCompany(Long companyId) { // 检查是否已经初始化过 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(OrderStatusPO::getCompanyId, companyId) - .isNull(OrderStatusPO::getDeleteTime); + wrapper.eq(OrderStatusPO::getCompanyId, companyId); if (orderStatusMapper.selectCount(wrapper) > 0) { return; // 已经初始化过,直接返回 } // 初始化订单状态数据 List initialStatuses = List.of( - createOrderStatusPO(companyId, 0, "待发货", "订单已创建,等待发货", 1), - createOrderStatusPO(companyId, 1, "已发货", "商品已发出,运输中", 2), - createOrderStatusPO(companyId, 2, "已完成", "订单已完成,交易成功", 3), - createOrderStatusPO(companyId, 3, "已取消", "订单已取消", 4), - createOrderStatusPO(companyId, 4, "退款中", "正在处理退款", 5), - createOrderStatusPO(companyId, 5, "已退款", "退款已完成", 6) + createOrderStatusPO(companyId, "待发货", "订单已创建,等待发货", 1), + createOrderStatusPO(companyId, "已发货", "商品已发出,运输中", 2), + createOrderStatusPO(companyId, "已完成", "订单已完成,交易成功", 3), + createOrderStatusPO(companyId, "已取消", "订单已取消", 4), + createOrderStatusPO(companyId, "退款中", "正在处理退款", 5), + createOrderStatusPO(companyId, "已退款", "退款已完成", 6) ); // 批量插入 @@ -162,10 +154,9 @@ public class OrderStatusServiceImpl implements OrderStatusService { /** * 创建订单状态PO对象 */ - private OrderStatusPO createOrderStatusPO(Long companyId, Integer statusCode, String statusName, String description, Integer sortOrder) { + private OrderStatusPO createOrderStatusPO(Long companyId, String statusName, String description, Integer sortOrder) { OrderStatusPO po = new OrderStatusPO(); po.setCompanyId(companyId); - po.setStatusCode(statusCode); po.setStatusName(statusName); po.setDescription(description); po.setSortOrder(sortOrder); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductServiceImpl.java index afe0e005..03990336 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductServiceImpl.java @@ -26,7 +26,6 @@ import top.xyquan.ecomdmbbackend.modules.media.service.MediaImageService; import top.xyquan.ecomdmbbackend.modules.media.model.vo.MediaImageVO; import top.xyquan.ecomdmbbackend.utils.CurrentUserContext; -import java.time.LocalDateTime; import java.util.List; import java.util.stream.Collectors; @@ -55,8 +54,7 @@ public class ProductServiceImpl extends ServiceImpl im // 验证商品名称是否重复 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ProductPO::getName, createProductDTO.getName()) - .eq(ProductPO::getCompanyId, companyId) - .isNull(ProductPO::getDeleteTime); + .eq(ProductPO::getCompanyId, companyId); if (this.count(wrapper) > 0) { throw new BusinessException("商品名称已存在"); } @@ -104,8 +102,7 @@ public class ProductServiceImpl extends ServiceImpl im LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ProductPO::getName, updateProductDTO.getName()) .eq(ProductPO::getCompanyId, companyId) - .ne(ProductPO::getId, id) - .isNull(ProductPO::getDeleteTime); + .ne(ProductPO::getId, id); if (this.count(wrapper) > 0) { throw new BusinessException("商品名称已存在"); } @@ -148,13 +145,8 @@ public class ProductServiceImpl extends ServiceImpl im throw new BusinessException("商品不存在"); } - // 软删除商品 - ProductPO product = new ProductPO(); - product.setId(id); - product.setDeleteTime(LocalDateTime.now()); - product.setDeleteBy(currentUserContext.getCurrentUserId()); - - this.updateById(product); + // 硬删除商品(外键约束会自动处理相关数据) + this.removeById(id); } @Override @@ -167,8 +159,7 @@ public class ProductServiceImpl extends ServiceImpl im // 构建查询条件 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(ProductPO::getCompanyId, companyId) - .isNull(ProductPO::getDeleteTime); + wrapper.eq(ProductPO::getCompanyId, companyId); // 添加过滤条件 ProductFilterDTO filter = pageQueryDTO.getFilters(); @@ -202,8 +193,7 @@ public class ProductServiceImpl extends ServiceImpl im // 验证商品名称是否重复 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ProductPO::getName, createProductWithSpecsDTO.getName()) - .eq(ProductPO::getCompanyId, companyId) - .isNull(ProductPO::getDeleteTime); + .eq(ProductPO::getCompanyId, companyId); if (this.count(wrapper) > 0) { throw new BusinessException("商品名称已存在"); } @@ -257,7 +247,6 @@ public class ProductServiceImpl extends ServiceImpl im LambdaQueryWrapper specWrapper = new LambdaQueryWrapper<>(); specWrapper.eq(ProductSpecPO::getProductId, product.getId()) .eq(ProductSpecPO::getCompanyId, product.getCompanyId()) - .isNull(ProductSpecPO::getDeleteTime) .orderByAsc(ProductSpecPO::getCreateTime); List specPOs = productSpecService.list(specWrapper); @@ -277,8 +266,7 @@ public class ProductServiceImpl extends ServiceImpl im // 根据名称精准查询商品 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ProductPO::getName, name) - .eq(ProductPO::getCompanyId, companyId) - .isNull(ProductPO::getDeleteTime); + .eq(ProductPO::getCompanyId, companyId); ProductPO product = this.getOne(wrapper); if (product == null) { @@ -301,7 +289,6 @@ public class ProductServiceImpl extends ServiceImpl im LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(ProductPO::getName, names) .eq(ProductPO::getCompanyId, companyId) - .isNull(ProductPO::getDeleteTime) .orderByAsc(ProductPO::getName); List products = this.list(wrapper); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductSpecServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductSpecServiceImpl.java index 37a26293..fadb18a7 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductSpecServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ProductSpecServiceImpl.java @@ -22,7 +22,6 @@ import top.xyquan.ecomdmbbackend.modules.ec.service.ProductService; import top.xyquan.ecomdmbbackend.modules.ec.service.ProductSpecService; import top.xyquan.ecomdmbbackend.utils.CurrentUserContext; -import java.time.LocalDateTime; import java.util.List; import java.util.stream.Collectors; @@ -47,20 +46,16 @@ public class ProductSpecServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(ProductSpecPO::getProductId, createProductSpecDTO.getProductId()) - .eq(ProductSpecPO::getCompanyId, companyId) - .isNull(ProductSpecPO::getDeleteTime); - if (this.count(wrapper) == 0) { + ProductPO product = productService.getById(createProductSpecDTO.getProductId()); + if (product == null || !product.getCompanyId().equals(companyId)) { throw new BusinessException("商品不存在"); } // 验证规格名称是否重复 - wrapper.clear(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ProductSpecPO::getProductId, createProductSpecDTO.getProductId()) .eq(ProductSpecPO::getName, createProductSpecDTO.getName()) - .eq(ProductSpecPO::getCompanyId, companyId) - .isNull(ProductSpecPO::getDeleteTime); + .eq(ProductSpecPO::getCompanyId, companyId); if (this.count(wrapper) > 0) { throw new BusinessException("规格名称已存在"); } @@ -97,8 +92,7 @@ public class ProductSpecServiceImpl extends ServiceImpl 0) { throw new BusinessException("规格名称已存在"); } @@ -132,13 +126,8 @@ public class ProductSpecServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(ProductSpecPO::getCompanyId, companyId) - .isNull(ProductSpecPO::getDeleteTime); + wrapper.eq(ProductSpecPO::getCompanyId, companyId); // 添加过滤条件 ProductSpecFilterDTO filter = pageQueryDTO.getFilters(); @@ -188,8 +176,7 @@ public class ProductSpecServiceImpl extends ServiceImpl productWrapper = new LambdaQueryWrapper<>(); productWrapper.eq(ProductPO::getName, productName) - .eq(ProductPO::getCompanyId, companyId) - .isNull(ProductPO::getDeleteTime); + .eq(ProductPO::getCompanyId, companyId); ProductPO product = productService.getOne(productWrapper); if (product == null) { @@ -200,8 +187,7 @@ public class ProductSpecServiceImpl extends ServiceImpl specWrapper = new LambdaQueryWrapper<>(); specWrapper.eq(ProductSpecPO::getProductId, product.getId()) .eq(ProductSpecPO::getSpecCode, specCode) - .eq(ProductSpecPO::getCompanyId, companyId) - .isNull(ProductSpecPO::getDeleteTime); + .eq(ProductSpecPO::getCompanyId, companyId); ProductSpecPO productSpec = this.getOne(specWrapper); if (productSpec == null) { @@ -212,7 +198,7 @@ public class ProductSpecServiceImpl extends ServiceImpl getProductSpecsByProductAndSpecs(List queries) { + public List getProductSpecsByProductAndSpecs(List queries) { if (queries == null || queries.isEmpty()) { return List.of(); } @@ -222,15 +208,14 @@ public class ProductSpecServiceImpl extends ServiceImpl productNames = queries.stream() - .map(ProductSpecQueryDTO::getProductName) + .map(ProductSpecService.ProductSpecQueryDTO::getProductName) .distinct() .collect(Collectors.toList()); // 批量查询商品 LambdaQueryWrapper productWrapper = new LambdaQueryWrapper<>(); productWrapper.in(ProductPO::getName, productNames) - .eq(ProductPO::getCompanyId, companyId) - .isNull(ProductPO::getDeleteTime); + .eq(ProductPO::getCompanyId, companyId); List products = productService.list(productWrapper); if (products.isEmpty()) { @@ -243,7 +228,7 @@ public class ProductSpecServiceImpl extends ServiceImpl specCodes = queries.stream() - .map(ProductSpecQueryDTO::getSpecCode) + .map(ProductSpecService.ProductSpecQueryDTO::getSpecCode) .distinct() .collect(Collectors.toList()); @@ -251,8 +236,7 @@ public class ProductSpecServiceImpl extends ServiceImpl specWrapper = new LambdaQueryWrapper<>(); specWrapper.in(ProductSpecPO::getSpecCode, specCodes) .in(ProductSpecPO::getProductId, productNameToIdMap.values()) - .eq(ProductSpecPO::getCompanyId, companyId) - .isNull(ProductSpecPO::getDeleteTime); + .eq(ProductSpecPO::getCompanyId, companyId); List productSpecs = this.list(specWrapper); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/PromotionFeeServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/PromotionFeeServiceImpl.java index 597287a3..e393f0c3 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/PromotionFeeServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/PromotionFeeServiceImpl.java @@ -54,12 +54,8 @@ public class PromotionFeeServiceImpl implements PromotionFeeService { @Override @Transactional(rollbackFor = Exception.class) public void deletePromotionFee(Long id) { - PromotionFeePO po = new PromotionFeePO(); - po.setId(id); - po.setDeleteBy(currentUserContext.getCurrentUserId()); - po.setDeleteTime(java.time.LocalDateTime.now()); - - promotionFeeMapper.updateById(po); + // 硬删除推广费记录(外键约束会自动处理相关数据) + promotionFeeMapper.deleteById(id); } @Override diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/PromotionFeeTypeServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/PromotionFeeTypeServiceImpl.java index 1ea5fe62..d436b45f 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/PromotionFeeTypeServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/PromotionFeeTypeServiceImpl.java @@ -29,13 +29,12 @@ public class PromotionFeeTypeServiceImpl implements PromotionFeeTypeService { @Override @Transactional(rollbackFor = Exception.class) public Long createPromotionFeeType(CreatePromotionFeeTypeDTO dto) { - // 检查类型编码是否重复 + // 检查类型名称是否重复 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(PromotionFeeTypePO::getCompanyId, currentUserContext.getCurrentCompanyId()) - .eq(PromotionFeeTypePO::getTypeCode, dto.getTypeCode()) - .isNull(PromotionFeeTypePO::getDeleteTime); + .eq(PromotionFeeTypePO::getTypeName, dto.getTypeName()); if (promotionFeeTypeMapper.selectCount(wrapper) > 0) { - throw new RuntimeException("该类型编码已存在"); + throw new RuntimeException("该类型名称已存在"); } PromotionFeeTypePO po = new PromotionFeeTypePO(); @@ -61,12 +60,8 @@ public class PromotionFeeTypeServiceImpl implements PromotionFeeTypeService { @Override @Transactional(rollbackFor = Exception.class) public void deletePromotionFeeType(Long id) { - PromotionFeeTypePO po = new PromotionFeeTypePO(); - po.setId(id); - po.setDeleteBy(currentUserContext.getCurrentUserId()); - po.setDeleteTime(java.time.LocalDateTime.now()); - - promotionFeeTypeMapper.updateById(po); + // 硬删除推广费类型(外键约束会自动处理相关数据) + promotionFeeTypeMapper.deleteById(id); } @Override @@ -108,7 +103,6 @@ public class PromotionFeeTypeServiceImpl implements PromotionFeeTypeService { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(PromotionFeeTypePO::getCompanyId, currentUserContext.getCurrentCompanyId()) .eq(PromotionFeeTypePO::getIsActive, 1) - .isNull(PromotionFeeTypePO::getDeleteTime) .orderByAsc(PromotionFeeTypePO::getSortOrder); List poList = promotionFeeTypeMapper.selectList(wrapper); @@ -147,7 +141,6 @@ public class PromotionFeeTypeServiceImpl implements PromotionFeeTypeService { public List getAllPromotionFeeTypeList() { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(PromotionFeeTypePO::getCompanyId, currentUserContext.getCurrentCompanyId()) - .isNull(PromotionFeeTypePO::getDeleteTime) .orderByAsc(PromotionFeeTypePO::getSortOrder); List poList = promotionFeeTypeMapper.selectList(wrapper); @@ -190,22 +183,21 @@ public class PromotionFeeTypeServiceImpl implements PromotionFeeTypeService { public void initPromotionFeeTypeForCompany(Long companyId) { // 检查是否已经初始化过 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PromotionFeeTypePO::getCompanyId, companyId) - .isNull(PromotionFeeTypePO::getDeleteTime); + wrapper.eq(PromotionFeeTypePO::getCompanyId, companyId); if (promotionFeeTypeMapper.selectCount(wrapper) > 0) { return; // 已经初始化过,直接返回 } // 初始化推广费类型数据 List initialTypes = List.of( - createPromotionFeeTypePO(companyId, "DIRECT_TRAFFIC", "直通车", "淘宝直通车推广费用", 3, 1), - createPromotionFeeTypePO(companyId, "DIAMOND_DISPLAY", "钻展", "钻石展位推广费用", 4, 2), - createPromotionFeeTypePO(companyId, "SUPER_RECOMMEND", "超级推荐", "超级推荐推广费用", 3, 3), - createPromotionFeeTypePO(companyId, "PLATFORM_COMMISSION", "平台佣金", "平台交易佣金", 2, 4), - createPromotionFeeTypePO(companyId, "DISTRIBUTION_COMMISSION", "分销佣金", "分销商佣金", 2, 5), - createPromotionFeeTypePO(companyId, "ACTIVITY_FEE", "活动费用", "平台活动参与费用", 1, 6), - createPromotionFeeTypePO(companyId, "EXTERNAL_AD", "站外广告", "站外广告投放费用", 1, 7), - createPromotionFeeTypePO(companyId, "LIVE_STREAMING", "直播推广", "直播推广费用", 1, 8) + createPromotionFeeTypePO(companyId, "直通车", "淘宝直通车推广费用", 3, 1), + createPromotionFeeTypePO(companyId, "钻展", "钻石展位推广费用", 4, 2), + createPromotionFeeTypePO(companyId, "超级推荐", "超级推荐推广费用", 3, 3), + createPromotionFeeTypePO(companyId, "平台佣金", "平台交易佣金", 2, 4), + createPromotionFeeTypePO(companyId, "分销佣金", "分销商佣金", 2, 5), + createPromotionFeeTypePO(companyId, "活动费用", "平台活动参与费用", 1, 6), + createPromotionFeeTypePO(companyId, "站外广告", "站外广告投放费用", 1, 7), + createPromotionFeeTypePO(companyId, "直播推广", "直播推广费用", 1, 8) ); // 批量插入 @@ -230,10 +222,9 @@ public class PromotionFeeTypeServiceImpl implements PromotionFeeTypeService { /** * 创建推广费类型PO对象 */ - private PromotionFeeTypePO createPromotionFeeTypePO(Long companyId, String typeCode, String typeName, String description, Integer calculationMethod, Integer sortOrder) { + private PromotionFeeTypePO createPromotionFeeTypePO(Long companyId, String typeName, String description, Integer calculationMethod, Integer sortOrder) { PromotionFeeTypePO po = new PromotionFeeTypePO(); po.setCompanyId(companyId); - po.setTypeCode(typeCode); po.setTypeName(typeName); po.setDescription(description); po.setCalculationMethod(calculationMethod); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ShopServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ShopServiceImpl.java index 57448112..e1c45070 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ShopServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ec/service/impl/ShopServiceImpl.java @@ -22,7 +22,6 @@ import top.xyquan.ecomdmbbackend.modules.media.model.vo.MediaImageVO; import top.xyquan.ecomdmbbackend.utils.CurrentUserContext; import org.springframework.web.multipart.MultipartFile; -import java.time.LocalDateTime; import java.util.List; import java.util.stream.Collectors; @@ -49,8 +48,7 @@ public class ShopServiceImpl extends ServiceImpl implements // 验证店铺名称是否重复 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ShopPO::getName, createShopDTO.getName()) - .eq(ShopPO::getCompanyId, companyId) - .isNull(ShopPO::getDeleteTime); + .eq(ShopPO::getCompanyId, companyId); if (this.count(wrapper) > 0) { throw new BusinessException("店铺名称已存在"); } @@ -97,8 +95,7 @@ public class ShopServiceImpl extends ServiceImpl implements LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ShopPO::getName, updateShopDTO.getName()) .eq(ShopPO::getCompanyId, companyId) - .ne(ShopPO::getId, id) - .isNull(ShopPO::getDeleteTime); + .ne(ShopPO::getId, id); if (this.count(wrapper) > 0) { throw new BusinessException("店铺名称已存在"); } @@ -140,13 +137,8 @@ public class ShopServiceImpl extends ServiceImpl implements throw new BusinessException("店铺不存在"); } - // 软删除店铺 - ShopPO shop = new ShopPO(); - shop.setId(id); - shop.setDeleteTime(LocalDateTime.now()); - shop.setDeleteBy(currentUserContext.getCurrentUserId()); - - this.updateById(shop); + // 硬删除店铺(外键约束会自动处理相关数据) + this.removeById(id); } @Override @@ -159,8 +151,7 @@ public class ShopServiceImpl extends ServiceImpl implements // 构建查询条件 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(ShopPO::getCompanyId, companyId) - .isNull(ShopPO::getDeleteTime); + wrapper.eq(ShopPO::getCompanyId, companyId); // 添加过滤条件 ShopFilterDTO filter = pageQueryDTO.getFilters(); @@ -202,8 +193,7 @@ public class ShopServiceImpl extends ServiceImpl implements // 根据名称精准查询店铺 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ShopPO::getName, name) - .eq(ShopPO::getCompanyId, companyId) - .isNull(ShopPO::getDeleteTime); + .eq(ShopPO::getCompanyId, companyId); ShopPO shop = this.getOne(wrapper); if (shop == null) { @@ -226,7 +216,6 @@ public class ShopServiceImpl extends ServiceImpl implements LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(ShopPO::getName, names) .eq(ShopPO::getCompanyId, companyId) - .isNull(ShopPO::getDeleteTime) .orderByAsc(ShopPO::getName); List shops = this.list(wrapper); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/sql/ec_design.sql b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/sql/ec_design.sql index 97fe878f..23b2daf0 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/sql/ec_design.sql +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/sql/ec_design.sql @@ -8,21 +8,17 @@ CREATE TABLE `ec_shop` ( `platform` VARCHAR(50) DEFAULT NULL COMMENT '平台(如淘宝、京东、拼多多)', `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间', `create_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '创建人ID', `update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID', - `delete_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '删除人ID', PRIMARY KEY (`id`), KEY `idx_company_id` (`company_id`), KEY `fk_ec_shop_logo_image` (`logo_image_id`), KEY `fk_ec_shop_creator` (`create_by`), KEY `fk_ec_shop_updater` (`update_by`), - KEY `fk_ec_shop_deleter` (`delete_by`), CONSTRAINT `fk_ec_shop_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_ec_shop_logo_image` FOREIGN KEY (`logo_image_id`) REFERENCES `media_image` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_ec_shop_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_shop_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_shop_deleter` FOREIGN KEY (`delete_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `fk_ec_shop_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-店铺表'; -- 商品表 @@ -34,21 +30,17 @@ CREATE TABLE `ec_product` ( `main_image_id` BIGINT UNSIGNED DEFAULT NULL COMMENT '主图图片ID', `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间', `create_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '创建人ID', `update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID', - `delete_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '删除人ID', PRIMARY KEY (`id`), KEY `idx_company_id` (`company_id`), KEY `fk_ec_product_main_image` (`main_image_id`), KEY `fk_ec_product_creator` (`create_by`), KEY `fk_ec_product_updater` (`update_by`), - KEY `fk_ec_product_deleter` (`delete_by`), CONSTRAINT `fk_ec_product_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_ec_product_main_image` FOREIGN KEY (`main_image_id`) REFERENCES `media_image` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_ec_product_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_product_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_product_deleter` FOREIGN KEY (`delete_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `fk_ec_product_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-商品表(含成本价)'; -- 商品规格表 @@ -61,51 +53,42 @@ CREATE TABLE `ec_product_spec` ( `cost_price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '成本价', `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间', `create_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '创建人ID', `update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID', - `delete_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '删除人ID', PRIMARY KEY (`id`), KEY `idx_company_id` (`company_id`), KEY `idx_product_id` (`product_id`), KEY `idx_spec_code` (`spec_code`), KEY `fk_ec_spec_creator` (`create_by`), KEY `fk_ec_spec_updater` (`update_by`), - KEY `fk_ec_spec_deleter` (`delete_by`), CONSTRAINT `fk_ec_spec_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_ec_spec_product` FOREIGN KEY (`product_id`) REFERENCES `ec_product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_ec_spec_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_spec_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_spec_deleter` FOREIGN KEY (`delete_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `fk_ec_spec_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-规格表'; -- 订单状态表 CREATE TABLE `ec_order_status` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '状态ID', `company_id` BIGINT UNSIGNED NOT NULL COMMENT '公司ID', - `status_code` TINYINT NOT NULL COMMENT '状态码', `status_name` VARCHAR(50) NOT NULL COMMENT '状态名称', `description` VARCHAR(200) DEFAULT NULL COMMENT '状态描述', `sort_order` INT NOT NULL DEFAULT 0 COMMENT '排序', `is_active` TINYINT NOT NULL DEFAULT 1 COMMENT '是否启用 0禁用 1启用', `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间', `create_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '创建人ID', `update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID', - `delete_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '删除人ID', PRIMARY KEY (`id`), KEY `idx_company_id` (`company_id`), - UNIQUE KEY `uk_company_status_code` (`company_id`, `status_code`), + UNIQUE KEY `uk_company_status_name` (`company_id`, `status_name`), KEY `idx_sort_order` (`sort_order`), KEY `idx_is_active` (`is_active`), KEY `fk_ec_order_status_creator` (`create_by`), KEY `fk_ec_order_status_updater` (`update_by`), - KEY `fk_ec_order_status_deleter` (`delete_by`), CONSTRAINT `fk_ec_order_status_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_ec_order_status_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_status_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_status_deleter` FOREIGN KEY (`delete_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `fk_ec_order_status_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-订单状态表'; -- 订单表 @@ -115,34 +98,6 @@ CREATE TABLE `ec_order` ( `shop_id` BIGINT UNSIGNED NOT NULL COMMENT '店铺ID', `platform_order_no` VARCHAR(100) DEFAULT NULL COMMENT '平台订单号', `status_id` BIGINT UNSIGNED NOT NULL COMMENT '订单状态ID', - `received_amount` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '商家实收金额', - `shipping_fee` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '运费', - `order_date` TIMESTAMP NOT NULL COMMENT '下单时间', - `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间', - `create_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '创建人ID', - `update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID', - `delete_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '删除人ID', - PRIMARY KEY (`id`), - KEY `idx_company_shop_date` (`company_id`, `shop_id`, `order_date`), - KEY `idx_status_id` (`status_id`), - KEY `idx_platform_order_no` (`platform_order_no`), - KEY `fk_ec_order_creator` (`create_by`), - KEY `fk_ec_order_updater` (`update_by`), - KEY `fk_ec_order_deleter` (`delete_by`), - CONSTRAINT `fk_ec_order_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_status` FOREIGN KEY (`status_id`) REFERENCES `ec_order_status` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_deleter` FOREIGN KEY (`delete_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-订单表'; - --- 订单明细表 -CREATE TABLE `ec_order_item` ( - `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '订单明细ID', - `order_id` BIGINT UNSIGNED NOT NULL COMMENT '订单ID', `product_id` BIGINT UNSIGNED NOT NULL COMMENT '商品ID', `product_spec_id` BIGINT UNSIGNED DEFAULT NULL COMMENT '商品规格ID', `product_name` VARCHAR(255) NOT NULL COMMENT '商品名称(冗余存储)', @@ -150,34 +105,36 @@ CREATE TABLE `ec_order_item` ( `quantity` INT NOT NULL DEFAULT 1 COMMENT '数量', `unit_price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '销售单价', `cost_price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '成本价(下单时快照)', - `subtotal` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '小计金额', `cost_total` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '成本小计', + `received_amount` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '商家实收金额', + `shipping_fee` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '运费', + `order_date` TIMESTAMP NOT NULL COMMENT '下单时间', `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间', `create_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '创建人ID', `update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID', - `delete_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '删除人ID', PRIMARY KEY (`id`), - KEY `idx_order_id` (`order_id`), + KEY `idx_company_shop_date` (`company_id`, `shop_id`, `order_date`), + KEY `idx_status_id` (`status_id`), + KEY `idx_platform_order_no` (`platform_order_no`), KEY `idx_product_id` (`product_id`), KEY `idx_product_spec_id` (`product_spec_id`), - KEY `fk_ec_order_item_creator` (`create_by`), - KEY `fk_ec_order_item_updater` (`update_by`), - KEY `fk_ec_order_item_deleter` (`delete_by`), - CONSTRAINT `fk_ec_order_item_order` FOREIGN KEY (`order_id`) REFERENCES `ec_order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_item_product` FOREIGN KEY (`product_id`) REFERENCES `ec_product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_item_product_spec` FOREIGN KEY (`product_spec_id`) REFERENCES `ec_product_spec` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_item_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_item_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_order_item_deleter` FOREIGN KEY (`delete_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-订单明细表'; + KEY `fk_ec_order_creator` (`create_by`), + KEY `fk_ec_order_updater` (`update_by`), + CONSTRAINT `fk_ec_order_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_ec_order_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_ec_order_status` FOREIGN KEY (`status_id`) REFERENCES `ec_order_status` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT `fk_ec_order_product` FOREIGN KEY (`product_id`) REFERENCES `ec_product` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_ec_order_product_spec` FOREIGN KEY (`product_spec_id`) REFERENCES `ec_product_spec` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_ec_order_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_ec_order_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-订单表(含商品明细)'; + -- 推广费类型表 CREATE TABLE `ec_promotion_fee_type` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '推广费类型ID', `company_id` BIGINT UNSIGNED NOT NULL COMMENT '公司ID', - `type_code` VARCHAR(50) NOT NULL COMMENT '类型编码', `type_name` VARCHAR(100) NOT NULL COMMENT '类型名称', `description` VARCHAR(200) DEFAULT NULL COMMENT '类型描述', `calculation_method` TINYINT NOT NULL DEFAULT 1 COMMENT '计算方式 1固定金额 2按比例 3按点击 4按展示', @@ -185,22 +142,18 @@ CREATE TABLE `ec_promotion_fee_type` ( `is_active` TINYINT NOT NULL DEFAULT 1 COMMENT '是否启用 0禁用 1启用', `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间', `create_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '创建人ID', `update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID', - `delete_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '删除人ID', PRIMARY KEY (`id`), KEY `idx_company_id` (`company_id`), - UNIQUE KEY `uk_company_type_code` (`company_id`, `type_code`), + UNIQUE KEY `uk_company_type_name` (`company_id`, `type_name`), KEY `idx_sort_order` (`sort_order`), KEY `idx_is_active` (`is_active`), KEY `fk_ec_promotion_fee_type_creator` (`create_by`), KEY `fk_ec_promotion_fee_type_updater` (`update_by`), - KEY `fk_ec_promotion_fee_type_deleter` (`delete_by`), CONSTRAINT `fk_ec_promotion_fee_type_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_ec_promotion_fee_type_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_promotion_fee_type_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_promotion_fee_type_deleter` FOREIGN KEY (`delete_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `fk_ec_promotion_fee_type_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-推广费类型表'; -- 推广费记录表 @@ -222,10 +175,8 @@ CREATE TABLE `ec_promotion_fee` ( `remark` VARCHAR(500) DEFAULT NULL COMMENT '备注', `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `delete_time` TIMESTAMP NULL DEFAULT NULL COMMENT '删除时间', `create_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '创建人ID', `update_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '更新人ID', - `delete_by` BIGINT UNSIGNED DEFAULT NULL COMMENT '删除人ID', PRIMARY KEY (`id`), KEY `idx_company_id` (`company_id`), KEY `idx_shop_id` (`shop_id`), @@ -234,13 +185,11 @@ CREATE TABLE `ec_promotion_fee` ( KEY `idx_platform` (`platform`), KEY `fk_ec_promotion_fee_creator` (`create_by`), KEY `fk_ec_promotion_fee_updater` (`update_by`), - KEY `fk_ec_promotion_fee_deleter` (`delete_by`), CONSTRAINT `fk_ec_promotion_fee_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_ec_promotion_fee_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_ec_promotion_fee_type` FOREIGN KEY (`fee_type_id`) REFERENCES `ec_promotion_fee_type` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT `fk_ec_promotion_fee_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_promotion_fee_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `fk_ec_promotion_fee_deleter` FOREIGN KEY (`delete_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `fk_ec_promotion_fee_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电商-推广费记录表'; -- 注意:推广费类型初始数据现在通过服务层方法按公司插入,不再在此处插入 diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/CurrentUserContext.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/CurrentUserContext.java index d8fad739..2fa28b97 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/CurrentUserContext.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/utils/CurrentUserContext.java @@ -26,8 +26,12 @@ public class CurrentUserContext { */ public TokenPayload getCurrentUserPayload() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if (authentication == null || authentication.getCredentials() == null) { - throw new BusinessException("用户未登录"); + if (authentication == null) { + throw new BusinessException("用户未登录 - 认证信息为空"); + } + + if (authentication.getCredentials() == null) { + throw new BusinessException("用户未登录 - Token信息为空"); } String token = authentication.getCredentials().toString(); diff --git a/ecom-dmb-backend/src/main/resources/application.yml b/ecom-dmb-backend/src/main/resources/application.yml index e44c6cde..32d3e19c 100644 --- a/ecom-dmb-backend/src/main/resources/application.yml +++ b/ecom-dmb-backend/src/main/resources/application.yml @@ -3,7 +3,7 @@ server: spring: datasource: - url: "jdbc:mysql://192.168.10.3:3306/ecom_dmb_dev?characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true" + url: "jdbc:mysql://jumper:3306/ecom_dmb_dev?characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true" username: ecom_dmb_dev password: ecom_dmb_dev hikari: