--水控卡类信息表
IF OBJECT_ID('dbo.SK_CardType') IS NULL
CREATE TABLE dbo.SK_CardType(
	Type_No       varchar(3) NOT NULL,	
	Discount_Info varchar(100) NULL,
  Max_Fund	    money NOT NULL DEFAULT 99999,
	Max_DayFund   money NOT NULL DEFAULT 99999,
	LimitTimes    int NOT NULL DEFAULT 0,
	Discount      int NOT NULL DEFAULT 100,
	Remark        varchar(40) NULL,
  PRIMARY KEY (Type_No ASC)
)
GO

--水控优惠信息表
IF OBJECT_ID('dbo.SK_DiscountInfo') IS NULL
CREATE TABLE dbo.SK_DiscountInfo(
	Discount_No   varchar(20) NOT NULL,
	Discount_Name varchar(40) NOT NULL,
	Week_Info     tinyint NOT NULL,
	Time_Bgn1     varchar(5) NULL,
	Time_End1     varchar(5) NULL,
	Time_Bgn2     varchar(5) NULL,
	Time_End2     varchar(5) NULL,
	Time_Bgn3     varchar(5) NULL,
	Time_End3     varchar(5) NULL,
	Remark        varchar(40) NULL,
	Week_Value    varchar(20) NULL,
  PRIMARY KEY (Discount_No ASC)
)
GO

--水控系统参数表
IF OBJECT_ID('dbo.SK_SysParam') IS NULL
CREATE TABLE dbo.SK_SysParam(
       Param_ID    int IDENTITY,
       Param_Code  varchar(20) NOT NULL,
       Param_Name  varchar(40) NOT NULL,
       Param_Value varchar(100) NOT NULL,
       PRIMARY KEY (Param_ID ASC)
)
go

--系统参数表
IF OBJECT_ID('dbo.ST_SysParam') IS NULL
CREATE TABLE dbo.ST_SysParam (
       Param_ID             int IDENTITY,
       Param_Code           varchar(20) NOT NULL,
       Param_Name           varchar(40) NOT NULL,
       Param_Value          varchar(100) NOT NULL,
       PRIMARY KEY (Param_ID ASC)
)
go

--灵活消费表（小金额）
IF OBJECT_ID('dbo.SK_GetConsume') IS NULL
CREATE TABLE dbo.SK_GetConsume (
       ID_Key               int IDENTITY,
       Card_No              varchar(12) NULL,
       Moc_No               int NOT NULL,
       Get_Time             datetime NOT NULL,
       Consume_AllTime      float NULL,
       Consume_AllCopy      int NULL,
       Consume_AllFund      money NOT NULL,
       Consume_AllCapacity  float NULL,
       Get_Index            int NULL,
       User_Name            varchar(20) NULL,
       Remark               varchar(20) NULL,
       PRIMARY KEY (ID_Key ASC)
)
go

--设置参数卡中的参数列表
IF OBJECT_ID('dbo.SK_SetParamCard') IS NULL
CREATE TABLE dbo.SK_SetParamCard (
	Mny_Index tinyint NOT NULL ,
	Week_No   tinyint NOT NULL ,
	Bgn_Time  varchar(5) NOT NULL ,
	End_Time  varchar(5) NOT NULL ,
	Unit_Fund money NOT NULL ,
	PRIMARY KEY (Mny_Index)
)
GO

--脱机小金额应用的消费场合
IF OBJECT_ID('dbo.SK_ConsumeArea') IS NULL
CREATE TABLE dbo.SK_ConsumeArea (
  Area_No              varchar(12) NOT NULL,
	Area_Name            varchar(30) NOT NULL,
	Area_Use             int         NOT NULL,
	Range_Bgn            int         NOT NULL,
	Range_End            int         NOT NULL,	
	Remark               varchar(20) NULL,
	PRIMARY KEY (Area_No ASC)	
)
GO

--水控补贴表
IF OBJECT_ID('dbo.SK_SubsidyRecord') IS NULL
CREATE TABLE dbo.SK_SubsidyRecord(
	Person_No     varchar(20) NOT NULL,
    SubsidyFund   money NOT NULL,
	SubsidyDate   DateTime NOT NULL,
    Moc_No        varchar(50) NOT NULL,
    Card_No       varchar(50) NOT NULL,
    PRIMARY KEY (Person_No ASC,SubsidyDate ASC)
)
GO

IF OBJECT_ID('dbo.XF_Section') IS NULL
CREATE TABLE dbo.XF_Section (
       Sect_No              varchar(4) NOT NULL,
       Sect_Name            varchar(20) NOT NULL,
       Remark               varchar(20) NULL,
       PRIMARY KEY (Sect_No ASC)
)
GO

IF OBJECT_ID('dbo.XF_Area') IS NULL
CREATE TABLE dbo.XF_Area (
       Area_No              varchar(12) NOT NULL,
       Sect_No              varchar(4)  NOT NULL,
       Area_Name            varchar(30) NOT NULL,
       Remark               varchar(20) NULL,
       PRIMARY KEY (Area_No ASC), 
       FOREIGN KEY (Sect_No)
                             REFERENCES dbo.XF_Section  (Sect_No)
                             ON DELETE NO ACTION
                             ON UPDATE NO ACTION
)
GO
