Initial commit: backend code

This commit is contained in:
Agent
2026-03-20 04:59:00 +00:00
commit e7c7f3b174
42 changed files with 2855 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
package com.example.building.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 商品分类实体类
* 默认分类:五金建材、板材、木门、地板
*/
@Data
@TableName("categories")
public class Category {
@TableId(type = IdType.ASSIGN_UUID)
private String categoryId;
/**
* 分类名称
*/
private String name;
/**
* 父分类ID
*/
private String parentId;
/**
* 排序
*/
private Integer sortOrder;
/**
* 图标
*/
private String icon;
/**
* 状态: 1启用 0禁用
*/
private Integer status;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@@ -0,0 +1,59 @@
package com.example.building.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 客户实体类
*/
@Data
@TableName("customers")
public class Customer {
@TableId(type = IdType.ASSIGN_UUID)
private String customerId;
/**
* 客户名称
*/
private String name;
/**
* 联系电话
*/
private String phone;
/**
* 客户微信OpenID(用于推送)
*/
private String wechatOpenid;
/**
* 地址
*/
private String address;
/**
* 备注
*/
private String remark;
/**
* 累计消费金额
*/
private BigDecimal totalAmount;
/**
* 创建人ID
*/
private String createdBy;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@@ -0,0 +1,101 @@
package com.example.building.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 订单实体类
* 核心业务逻辑:
* - total_amount: 订单原价(商品标价×数量之和)
* - discount_amount: 优惠金额
* - actual_amount: 实付金额 = 原价 - 优惠金额
*/
@Data
@TableName("orders")
public class Order {
@TableId(type = IdType.ASSIGN_UUID)
private String orderId;
/**
* 订单编号(唯一)
*/
private String orderNo;
/**
* 客户ID
*/
private String customerId;
/**
* 客户名称(冗余)
*/
private String customerName;
/**
* 客户电话(冗余)
*/
private String customerPhone;
/**
* 客户微信OpenID
*/
private String customerWechat;
/**
* 订单原价(标价总和)
* 计算公式: Σ(item.price × item.quantity)
*/
private BigDecimal totalAmount;
/**
* 优惠金额
* 计算公式: totalAmount × (100 - discountRate) / 100
*/
private BigDecimal discountAmount;
/**
* 实收金额
* 计算公式: totalAmount - discountAmount
*/
private BigDecimal actualAmount;
/**
* 折扣率(百分比)
*/
private BigDecimal discountRate;
/**
* 状态: 1已完成 2已取消 3退款中 4已退款
*/
private Integer status;
/**
* 支付方式
*/
private String paymentMethod;
/**
* 备注
*/
private String remark;
/**
* 操作人ID
*/
private String operatorId;
/**
* 操作人姓名(冗余)
*/
private String operatorName;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@@ -0,0 +1,61 @@
package com.example.building.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 订单明细实体类
*/
@Data
@TableName("order_items")
public class OrderItem {
@TableId(type = IdType.ASSIGN_UUID)
private String itemId;
/**
* 订单ID
*/
private String orderId;
/**
* 商品ID
*/
private String productId;
/**
* 商品名称(冗余)
*/
private String productName;
/**
* 商品规格(冗余)
*/
private String productSpec;
/**
* 单位(冗余)
*/
private String unit;
/**
* 销售单价(当时标价)
*/
private BigDecimal price;
/**
* 数量
*/
private Integer quantity;
/**
* 小计(单价×数量)
*/
private BigDecimal subtotal;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
}

View File

@@ -0,0 +1,79 @@
package com.example.building.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 商品实体类
*/
@Data
@TableName("products")
public class Product {
@TableId(type = IdType.ASSIGN_UUID)
private String productId;
/**
* 分类ID
*/
private String categoryId;
/**
* 商品名称
*/
private String name;
/**
* 规格型号
*/
private String spec;
/**
* 单位
*/
private String unit;
/**
* 销售单价(原价)
*/
private BigDecimal price;
/**
* 成本价
*/
private BigDecimal costPrice;
/**
* 商品图片URL
*/
private String imageUrl;
/**
* 商品条码
*/
private String barcode;
/**
* 库存预警阈值
*/
private Integer stockAlert;
/**
* 商品描述
*/
private String description;
/**
* 状态: 1正常 0删除
*/
private Integer status;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@@ -0,0 +1,40 @@
package com.example.building.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 库存实体类
*/
@Data
@TableName("stock")
public class Stock {
@TableId(type = IdType.ASSIGN_UUID)
private String stockId;
/**
* 商品ID
*/
private String productId;
/**
* 仓库ID
*/
private String warehouseId;
/**
* 当前库存数量
*/
private Integer quantity;
/**
* 锁定数量(待发货)
*/
private Integer lockedQuantity;
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}

View File

@@ -0,0 +1,66 @@
package com.example.building.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 库存流水实体类
* 记录库存变动历史
*/
@Data
@TableName("stock_flow")
public class StockFlow {
@TableId(type = IdType.ASSIGN_UUID)
private String flowId;
/**
* 商品ID
*/
private String productId;
/**
* 类型: 1入库 2出库 3调整 4盘点
*/
private Integer type;
/**
* 变动数量(正数增加/负数减少)
*/
private Integer quantity;
/**
* 变动前数量
*/
private Integer beforeQuantity;
/**
* 变动后数量
*/
private Integer afterQuantity;
/**
* 关联单据ID
*/
private String relatedId;
/**
* 关联单据类型
*/
private String relatedType;
/**
* 操作人ID
*/
private String operatorId;
/**
* 备注
*/
private String remark;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
}

View File

@@ -0,0 +1,55 @@
package com.example.building.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 用户实体类
*/
@Data
@TableName("users")
public class User {
@TableId(type = IdType.ASSIGN_UUID)
private String userId;
private String username;
private String phone;
private String password;
/**
* 微信OpenID
*/
private String wechatOpenid;
/**
* 微信UnionID
*/
private String wechatUnionid;
/**
* 支付宝OpenID
*/
private String alipayOpenid;
/**
* 角色: admin-管理员, sales-销售员, warehouse-库管
*/
private String role;
/**
* 状态: 1正常 0禁用
*/
private Integer status;
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
}