-- ----------------------------
-- Table structure for t_Applet_Order
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_Applet_Order]') AND type IN ('U'))
	DROP TABLE [dbo].[t_Applet_Order]
GO

CREATE TABLE [dbo].[t_Applet_Order] (
  [FRowID] [dbo].[RowID] NOT NULL,
  [FCode] varchar(50) NULL,
  [FPlacer] bigint NULL,
  [FPlaceTime] datetime DEFAULT GETDATE() NULL,
  [FStatus] int DEFAULT 0 NULL,
  
  -- 常规审计字段
  [CreateDept] bigint NULL,
  [CreateBy] bigint NULL,
  [CreateTime] datetime DEFAULT GETDATE() NULL,
  [UpdateBy] bigint NULL,
  [UpdateTime] datetime NULL
)
GO

ALTER TABLE [dbo].[t_Applet_Order] ADD CONSTRAINT [PK_t_Applet_Order] PRIMARY KEY CLUSTERED ([FRowID])
GO

-- 字段注释
EXEC sp_addextendedproperty 'MS_Description', N'订单主键', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order', 'COLUMN', N'FRowID'
GO
EXEC sp_addextendedproperty 'MS_Description', N'订单单号', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order', 'COLUMN', N'FCode'
GO
EXEC sp_addextendedproperty 'MS_Description', N'下单人', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order', 'COLUMN', N'FPlacer'
GO
EXEC sp_addextendedproperty 'MS_Description', N'下单时间', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order', 'COLUMN', N'FPlaceTime'
GO
EXEC sp_addextendedproperty 'MS_Description', N'订单状态 (0-待审核)', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order', 'COLUMN', N'FStatus'
GO
EXEC sp_addextendedproperty 'MS_Description', N'创建部门', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order', 'COLUMN', N'CreateDept'
GO

-- ----------------------------
-- Table structure for t_Applet_Order_Details
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_Applet_Order_Details]') AND type IN ('U'))
	DROP TABLE [dbo].[t_Applet_Order_Details]
GO

CREATE TABLE [dbo].[t_Applet_Order_Details] (
  [FRowID] [dbo].[RowID] NOT NULL,
  [FOrderID] [dbo].[RowID] NULL,
  
  -- 型材信息
  [ModelID] [dbo].[RowID] NULL,
  [ModelNum] [dbo].[FNum] NULL,
  [ModelName] [dbo].[FNum] NULL,
  [Material] [dbo].[FNum] NULL,
  
  -- 表面处理
  [SurfaceID] [dbo].[RowID] NULL,
  [SurfaceName] [dbo].[FNum] NULL,
  
  -- 包装方式
  [PackID] [dbo].[RowID] NULL,
  [PackName] [dbo].[FNum] NULL,
  
  -- 规格与数量
  [Length] [dbo].[CustomFloat] NULL,
  [WallThickness] [dbo].[CustomFloat] NULL,
  [Count] int NULL,
  
  -- 审计字段
  [CreateDept] bigint NULL,
  [CreateBy] bigint NULL,
  [CreateTime] datetime DEFAULT GETDATE() NULL,
  [UpdateBy] bigint NULL,
  [UpdateTime] datetime NULL
)
GO

ALTER TABLE [dbo].[t_Applet_Order_Details] ADD CONSTRAINT [PK_t_Applet_Order_Details] PRIMARY KEY CLUSTERED ([FRowID])
GO

-- 字段注释
EXEC sp_addextendedproperty 'MS_Description', N'记录主键', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'FRowID'
GO
EXEC sp_addextendedproperty 'MS_Description', N'主订单ID', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'FOrderID'
GO
EXEC sp_addextendedproperty 'MS_Description', N'型材ID', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'ModelID'
GO
EXEC sp_addextendedproperty 'MS_Description', N'型材编号', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'ModelNum'
GO
EXEC sp_addextendedproperty 'MS_Description', N'型材名称', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'ModelName'
GO
EXEC sp_addextendedproperty 'MS_Description', N'型材材质', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'Material'
GO
EXEC sp_addextendedproperty 'MS_Description', N'表面处理ID', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'SurfaceID'
GO
EXEC sp_addextendedproperty 'MS_Description', N'表面处理名称', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'SurfaceName'
GO
EXEC sp_addextendedproperty 'MS_Description', N'包装方式ID', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'PackID'
GO
EXEC sp_addextendedproperty 'MS_Description', N'包装方式名称', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'PackName'
GO
EXEC sp_addextendedproperty 'MS_Description', N'长度(mm)', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'Length'
GO
EXEC sp_addextendedproperty 'MS_Description', N'壁厚(mm)', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'WallThickness'
GO
EXEC sp_addextendedproperty 'MS_Description', N'支数', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'Count'
GO
EXEC sp_addextendedproperty 'MS_Description', N'创建部门', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Details', 'COLUMN', N'CreateDept'
GO

-- ----------------------------
-- Table structure for t_Applet_Order_Audit
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[t_Applet_Order_Audit]') AND type IN ('U'))
	DROP TABLE [dbo].[t_Applet_Order_Audit]
GO

CREATE TABLE [dbo].[t_Applet_Order_Audit] (
  [FRowID] [dbo].[RowID] NOT NULL,
  [FOrderID] [dbo].[RowID] NOT NULL,
  [FAuditor] bigint NULL,
  [FAuditTime] datetime DEFAULT GETDATE() NULL,
  [FAuditResult] int NULL, -- 1-通过, 2-驳回
  [FRejectReason] nvarchar(500) NULL,
  
  -- 审计字段
  [CreateDept] bigint NULL,
  [CreateBy] bigint NULL,
  [CreateTime] datetime DEFAULT GETDATE() NULL,
  [UpdateBy] bigint NULL,
  [UpdateTime] datetime NULL
)
GO

ALTER TABLE [dbo].[t_Applet_Order_Audit] ADD CONSTRAINT [PK_t_Applet_Order_Audit] PRIMARY KEY CLUSTERED ([FRowID])
GO

-- 字段注释
EXEC sp_addextendedproperty 'MS_Description', N'审核记录主键', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Audit', 'COLUMN', N'FRowID'
GO
EXEC sp_addextendedproperty 'MS_Description', N'订单ID', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Audit', 'COLUMN', N'FOrderID'
GO
EXEC sp_addextendedproperty 'MS_Description', N'审核人', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Audit', 'COLUMN', N'FAuditor'
GO
EXEC sp_addextendedproperty 'MS_Description', N'审核时间', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Audit', 'COLUMN', N'FAuditTime'
GO
EXEC sp_addextendedproperty 'MS_Description', N'审核结果(1-通过, 2-驳回)', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Audit', 'COLUMN', N'FAuditResult'
GO
EXEC sp_addextendedproperty 'MS_Description', N'驳回原因', 'SCHEMA', N'dbo', 'TABLE', N't_Applet_Order_Audit', 'COLUMN', N'FRejectReason'
GO
