Просмотр исходного кода

feat(models): add product brand/alias and plan brand qty models

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu 3 месяцев назад
Родитель
Сommit
ea43150b8a
3 измененных файлов с 78 добавлено и 0 удалено
  1. 2 0
      backend/app/models/__init__.py
  2. 45 0
      backend/app/models/crm_models.py
  3. 31 0
      backend/app/models/pl_models.py

+ 2 - 0
backend/app/models/__init__.py

@@ -37,6 +37,7 @@ from app.models.pl_models import (
     PlVehiclePersonnel,
     PlPlan,
     PlPlanProduct,
+    PlPlanProductBrandQty,
     PlPlanChange,
     PlTransport,
     PlTransportDbLink,
@@ -96,6 +97,7 @@ __all__ = [
     "PlVehiclePersonnel",
     "PlPlan",
     "PlPlanProduct",
+    "PlPlanProductBrandQty",
     "PlPlanChange",
     "PlTransport",
     "PlTransportDbLink",

+ 45 - 0
backend/app/models/crm_models.py

@@ -75,6 +75,45 @@ class CrmProduct(Base):
     del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
 
 
+class CrmProductBrand(Base):
+    """CRM-产品品牌(按产品独立维护)"""
+
+    __tablename__ = "crm_product_brand"
+
+    id = Column(String(64), primary_key=True, comment="主键ID")
+    product_id = Column(String(64), nullable=False, comment="产品ID")
+    brand_name = Column(String(100), nullable=False, comment="品牌名称")
+    status = Column(String(3), nullable=False, default="on", comment="状态 on/off")
+    tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
+    order_num = Column(Integer, nullable=True, comment="排序号")
+    remark = Column(String(512), nullable=True, comment="备注")
+    create_by = Column(String(64), nullable=True, comment="创建人id")
+    create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
+    create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
+    update_by = Column(String(64), nullable=True, comment="更新人id")
+    update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
+    del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
+
+
+class CrmProductAlias(Base):
+    """CRM-产品别名"""
+
+    __tablename__ = "crm_product_alias"
+
+    id = Column(String(64), primary_key=True, comment="主键ID")
+    product_id = Column(String(64), nullable=False, comment="产品ID")
+    alias_name = Column(String(200), nullable=False, comment="别名")
+    tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
+    order_num = Column(Integer, nullable=True, comment="排序号")
+    remark = Column(String(512), nullable=True, comment="备注")
+    create_by = Column(String(64), nullable=True, comment="创建人id")
+    create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
+    create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
+    update_by = Column(String(64), nullable=True, comment="更新人id")
+    update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
+    del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
+
+
 class SysOss(Base):
     """统一附件表(全系统共用 sys_oss)"""
 
@@ -656,6 +695,9 @@ class CrmContractProduct(Base):
     contract_id = Column(String(64), nullable=False, comment="合同ID")
     product_id = Column(String(64), nullable=False, comment="产品ID")
     product_name = Column(String(200), nullable=False, comment="产品名称")
+    brand_mode = Column(String(20), nullable=True, comment="required/any")
+    brand_id = Column(String(64), nullable=True, comment="指定品牌ID")
+    brand_name = Column(String(100), nullable=True, comment="品牌名快照")
     product_no = Column(String(50), nullable=True, comment="产品编号")
     category_id = Column(String(64), nullable=True, comment="产品分类ID")
     category_name = Column(String(100), nullable=True, comment="产品分类名称")
@@ -777,6 +819,9 @@ class CrmQuoteProduct(Base):
     quote_id = Column(String(64), nullable=False, comment="报价单ID")
     product_id = Column(String(64), nullable=False, comment="产品ID")
     product_name = Column(String(200), nullable=False, comment="产品名称")
+    brand_mode = Column(String(20), nullable=True, comment="required/any")
+    brand_id = Column(String(64), nullable=True, comment="指定品牌ID")
+    brand_name = Column(String(100), nullable=True, comment="品牌名快照")
     product_no = Column(String(50), nullable=True, comment="产品编号")
     category_id = Column(String(64), nullable=True, comment="产品分类ID")
     category_name = Column(String(100), nullable=True, comment="产品分类名称")

+ 31 - 0
backend/app/models/pl_models.py

@@ -348,6 +348,9 @@ class PlPlanProduct(Base):
     product_id = Column(String(64), nullable=False, comment="产品ID")
     product_no = Column(String(50), nullable=False, comment="产品编号")
     product_name = Column(String(200), nullable=False, comment="产品名称")
+    brand_mode = Column(String(20), nullable=True, comment="required/any")
+    brand_id = Column(String(64), nullable=True, comment="指定品牌ID")
+    brand_name = Column(String(100), nullable=True, comment="品牌名快照")
     model = Column(String(100), nullable=True, comment="规格型号")
     unit = Column(String(20), nullable=False, default="吨", comment="单位")
     category_name = Column(String(200), nullable=True, comment="产品分类")
@@ -392,6 +395,28 @@ class PlPlanProduct(Base):
     del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
 
 
+class PlPlanProductBrandQty(Base):
+    """计划产品归档品牌数量 pl_plan_product_brand_qty"""
+
+    __tablename__ = "pl_plan_product_brand_qty"
+
+    id = Column(String(64), primary_key=True, comment="主键ID")
+    plan_id = Column(String(64), nullable=False, comment="计划ID")
+    plan_product_id = Column(String(64), nullable=False, comment="计划产品明细ID")
+    brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,空串=无品牌键")
+    brand_name = Column(String(100), nullable=True, comment="品牌名称")
+    qty = Column(DECIMAL(15, 3), nullable=False, default=0, comment="本品牌归档实际数量")
+    tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
+    order_num = Column(Integer, nullable=True, comment="排序号")
+    remark = Column(String(512), nullable=True, comment="备注")
+    create_by = Column(String(64), nullable=True, comment="创建人id")
+    create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
+    create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
+    update_by = Column(String(64), nullable=True, comment="更新人id")
+    update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
+    del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记:0-正常 1-已删除")
+
+
 class PlPlanChange(Base):
     """计划变更记录表 pl_plan_change"""
 
@@ -810,6 +835,8 @@ class PlInventory(Base):
 
     id = Column(String(64), primary_key=True, comment="主键ID")
     product_id = Column(String(64), nullable=False, comment="产品ID")
+    brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,无品牌为空串")
+    brand_name = Column(String(100), nullable=True, comment="品牌名称")
     product_no = Column(String(50), nullable=False, comment="产品编号")
     product_name = Column(String(200), nullable=False, comment="产品名称")
     model = Column(String(100), nullable=True, comment="规格型号")
@@ -842,6 +869,8 @@ class PlInventoryTransaction(Base):
 
     id = Column(String(64), primary_key=True, comment="主键ID")
     product_id = Column(String(64), nullable=False, comment="产品ID")
+    brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,无品牌为空串")
+    brand_name = Column(String(100), nullable=True, comment="品牌名称")
     product_name = Column(String(200), nullable=False, comment="产品名称")
     transaction_type = Column(String(20), nullable=False, comment="事务类型 inbound-入库 outbound-出库")
     plan_id = Column(String(64), nullable=True, comment="计划ID")
@@ -871,6 +900,8 @@ class PlInventoryWarning(Base):
 
     id = Column(String(64), primary_key=True, comment="主键ID")
     product_id = Column(String(64), nullable=False, comment="产品ID")
+    brand_id = Column(String(64), nullable=False, default="", comment="品牌ID,无品牌为空串")
+    brand_name = Column(String(100), nullable=True, comment="品牌名称")
     product_name = Column(String(200), nullable=False, comment="产品名称")
     warning_type = Column(String(20), nullable=False, comment="预警类型 low-低于最低 high-高于最高")
     current_qty = Column(DECIMAL(15, 3), nullable=False, comment="当前库存")