var app = getApp()
var socketOpen = false;//WebSocket 打开状态
Page({
  data: {
    messageTip: '',
    messageTextArr:[],
    messageContent:'',
    userinfo:{}
  },
  //sendMessage
  formSubmit: function(e) {
    var that = this;
    var msg =  e.detail.value.messageContent;//获得输入文字
    console.log('send message:' +msg );
     if (socketOpen) {
      wx.sendSocketMessage({
        data:msg
      });
      that.setData({
        messageContent:''
      })
    } else {
      that.setData({
        messageTip:'WebSocket 链接失败,请重新连接!'
      })
    }
  },
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //连接 Websocket
    wx.connectSocket({
      url: 'wss://sdk.weixin.senparc.com/SenparcWebSocket',
      header:{ 
        'content-type': 'application/json'
      },
      method:"GET"
    });
    //WebSocket 连接成功
    wx.onSocketOpen(function(res) {
      console.log('WebSocket 连接成功!')
      socketOpen = true;
      that.setData({
        messageTip:'WebSocket 连接成功!'
      })
    })
    //收到 WebSocket 推送消息
    wx.onSocketMessage(function(res) {
      console.log('收到服务器内容:' + res.data)
      var jsonResult = JSON.parse(res.data);
      var currentIndex= that.data.messageTextArr.length+1;
      var newArr = that.data.messageTextArr;
      newArr.push(
        {
          index:currentIndex,
          content:jsonResult.content,
          time:jsonResult.time
        });
        console.log(that);
      that.setData({
        messageTextArr:newArr
      });
    })
    //WebSocket 已关闭
    wx.onSocketClose(function(res) {
      console.log('WebSocket 已关闭!')
      socketOpen = false;
    })
    //WebSocket 打开失败
    wx.onSocketError(function(res){
      console.log('WebSocket连接打开失败,请检查!')
    })
  }
})

USE [WeixinMarketing]
GO
/****** Object:  Table [dbo].[Account]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Account](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[ParentAccountId] [int] NULL,
	[ParentIsKF] [bit] NOT NULL,
	[UserName] [varchar](50) NOT NULL,
	[Password] [varchar](50) NOT NULL,
	[PasswordSalt] [varchar](50) NOT NULL,
	[NickName] [nvarchar](50) NULL,
	[RealName] [nvarchar](50) NULL,
	[Tel] [varchar](50) NULL,
	[Email] [varchar](150) NULL,
	[EmailChecked] [bit] NOT NULL,
	[Phone] [varchar](20) NOT NULL,
	[PhoneChecked] [bit] NOT NULL,
	[WeixinOpenId] [varchar](100) NULL,
	[PicUrl] [varchar](200) NULL,
	[HeadImgUrl] [varchar](200) NULL,
	[Package] [decimal](18, 2) NOT NULL,
	[Balance] [decimal](18, 2) NOT NULL,
	[LockMoney] [decimal](18, 2) NOT NULL,
	[Sex] [tinyint] NOT NULL,
	[QQ] [varchar](50) NULL,
	[Country] [nvarchar](20) NULL,
	[Province] [nvarchar](20) NULL,
	[City] [nvarchar](20) NULL,
	[District] [nvarchar](20) NULL,
	[Address] [nvarchar](250) NULL,
	[Note] [ntext] NULL,
	[Type] [int] NOT NULL,
	[ThisLoginTime] [datetime] NOT NULL,
	[ThisLoginIP] [varchar](50) NULL,
	[LastLoginTime] [datetime] NOT NULL,
	[LastLoginIP] [varchar](50) NULL,
	[AddTime] [datetime] NOT NULL,
	[Points] [decimal](18, 2) NOT NULL,
	[LastWeixinSignInTime] [datetime] NULL,
	[WeixinSignTimes] [int] NOT NULL,
	[Wallet] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_Account] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Address]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Address](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[AccountId] [int] NOT NULL,
	[Name] [nvarchar](20) NOT NULL,
	[Phone] [varchar](20) NOT NULL,
	[PostalCode] [varchar](20) NOT NULL,
	[UsedCount] [int] NOT NULL,
	[Country] [varchar](20) NOT NULL,
	[Province] [varchar](20) NOT NULL,
	[City] [varchar](20) NOT NULL,
	[District] [varchar](20) NOT NULL,
	[FullAddress] [nvarchar](250) NOT NULL,
	[IsDefault] [bit] NOT NULL,
	[AddTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Address] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[AdminUserInfo]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AdminUserInfo](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [varchar](50) NOT NULL,
	[Password] [varchar](50) NOT NULL,
	[PasswordSalt] [varchar](50) NOT NULL,
	[RealName] [nvarchar](50) NULL,
	[Sex] [int] NOT NULL,
	[Phone] [varchar](50) NOT NULL,
	[ThisLoginTime] [datetime] NOT NULL,
	[ThisLoginIP] [varchar](50) NULL,
	[LastLoginTime] [datetime] NOT NULL,
	[LastLoginIP] [varchar](50) NULL,
	[Note] [ntext] NULL,
	[AddTime] [datetime] NOT NULL,
	[AddIP] [varchar](50) NULL,
	[UpdateTime] [datetime] NOT NULL,
	[UpdateIP] [varchar](50) NULL,
 CONSTRAINT [PK_AdminUserInfo] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[APP_RedPackage_Activity]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[APP_RedPackage_Activity](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](250) NOT NULL,
	[Type] [int] NOT NULL,
	[State] [int] NOT NULL,
	[Description] [ntext] NULL,
	[PicUrl] [varchar](250) NULL,
	[EndTime] [datetime] NOT NULL,
	[BeginTime] [datetime] NOT NULL,
	[AddTime] [datetime] NOT NULL,
	[TotalMoney] [money] NOT NULL,
	[Rule] [ntext] NULL,
	[RemainingMoney] [money] NOT NULL,
 CONSTRAINT [PK_Activity] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[APP_RedPackage_Activity_Award]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[APP_RedPackage_Activity_Award](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[ActivityId] [int] NOT NULL,
	[AwardName] [nvarchar](200) NOT NULL,
	[Money] [decimal](18, 2) NOT NULL,
	[State] [int] NOT NULL,
	[Number] [int] NOT NULL,
	[EndTime] [datetime] NOT NULL,
	[BeginTime] [datetime] NOT NULL,
	[PicUrl] [varchar](250) NULL,
	[AddTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Award] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[APP_RedPackage_Activity_Award_Log]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[APP_RedPackage_Activity_Award_Log](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[AccountId] [int] NOT NULL,
	[AwardId] [int] NULL,
	[ActivityId] [int] NOT NULL,
	[AwardName] [nvarchar](20) NOT NULL,
	[Money] [decimal](18, 2) NOT NULL,
	[State] [int] NOT NULL,
	[AddTime] [datetime] NOT NULL,
	[RegisterInfo] [ntext] NULL,
 CONSTRAINT [PK_AwardLog] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Banner]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Banner](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[PicUrl] [varchar](250) NOT NULL,
	[ProductId] [int] NOT NULL,
	[Url] [varchar](100) NOT NULL,
	[AddTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Banner] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[MessageBox]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MessageBox](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[AccountId] [int] NOT NULL,
	[Title] [nvarchar](50) NOT NULL,
	[Content] [ntext] NOT NULL,
	[PicUrl] [varchar](250) NULL,
	[Url] [varchar](150) NULL,
	[HasRead] [bit] NOT NULL,
	[AddTime] [datetime] NOT NULL,
 CONSTRAINT [PK_MessageBox] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Notice]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Notice](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) NOT NULL,
	[Content] [ntext] NOT NULL,
	[PicUrl] [varchar](250) NULL,
	[Url] [varchar](150) NULL,
	[Type] [int] NOT NULL,
	[HasSend] [bit] NOT NULL,
	[AddTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Notice] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Order]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Order](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[AccountId] [int] NULL,
	[ActivityId] [int] NOT NULL,
	[OrderNumber] [varchar](100) NOT NULL,
	[TotalPrice] [money] NOT NULL,
	[Price] [money] NOT NULL,
	[PayMoney] [money] NOT NULL,
	[UsedPoints] [decimal](18, 2) NULL,
	[CompleteTime] [datetime] NOT NULL,
	[GetPayOrderTime] [datetime] NULL,
	[AddIp] [varchar](50) NULL,
	[Status] [tinyint] NOT NULL,
	[Description] [varchar](250) NULL,
	[Type] [tinyint] NULL,
	[TradeNumber] [varchar](150) NULL,
	[PrepayId] [varchar](100) NULL,
	[PrepayCodeUrl] [varchar](100) NULL,
	[PayType] [int] NOT NULL,
	[OrderType] [int] NOT NULL,
	[PayParam] [ntext] NULL,
	[AddTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Order] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[SystemConfig]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SystemConfig](
	[Id] [int] NOT NULL,
	[SystemName] [varchar](150) NULL,
	[SmsPlatform] [int] NOT NULL,
	[SmsServiceAddress] [varchar](50) NULL,
	[SmsAccountName] [varchar](50) NULL,
	[SmsAccountPassword] [varchar](50) NULL,
	[SmsAccountCORPID] [varchar](50) NULL,
	[SmsAccountSubNumber] [varchar](20) NULL,
	[SmsSign] [varchar](20) NULL,
	[MchId] [varchar](20) NULL,
	[MchKey] [varchar](150) NULL,
	[TenPayAppId] [varchar](50) NULL,
	[Rate] [decimal](18, 2) NOT NULL,
	[TotalCoupon] [decimal](18, 2) NOT NULL,
	[CouponNum] [int] NOT NULL,
	[CouponAmount] [int] NOT NULL,
 CONSTRAINT [PK_SystemConfig] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[WithdrawLog]    Script Date: 2017/4/3 17:04:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WithdrawLog](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[AccountId] [int] NOT NULL,
	[ActivityId] [int] NOT NULL,
	[ActivityLogId] [int] NOT NULL,
	[Money] [decimal](18, 5) NOT NULL,
	[State] [int] NOT NULL,
	[AddTime] [datetime] NOT NULL,
	[OrderNumber] [varchar](100) NULL,
	[Description] [nvarchar](100) NULL,
	[LastUpdateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_WithdrawLog] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Account] ADD  CONSTRAINT [DF_Account_ParentIsKF]  DEFAULT ((0)) FOR [ParentIsKF]
GO
ALTER TABLE [dbo].[Account] ADD  CONSTRAINT [DF_Account_Package]  DEFAULT ((0)) FOR [Package]
GO
ALTER TABLE [dbo].[Account] ADD  CONSTRAINT [DF_Account_Balance]  DEFAULT ((0)) FOR [Balance]
GO
ALTER TABLE [dbo].[Account] ADD  CONSTRAINT [DF_Account_LockMoney]  DEFAULT ((0)) FOR [LockMoney]
GO
ALTER TABLE [dbo].[Account] ADD  CONSTRAINT [DF_Account_Type]  DEFAULT ((0)) FOR [Type]
GO
ALTER TABLE [dbo].[Account] ADD  CONSTRAINT [DF_Account_Wallet]  DEFAULT ((0)) FOR [Wallet]
GO
ALTER TABLE [dbo].[Address] ADD  CONSTRAINT [DF_Address_UsedCount]  DEFAULT ((0)) FOR [UsedCount]
GO
ALTER TABLE [dbo].[AdminUserInfo] ADD  CONSTRAINT [DF_AdminUserInfo_Sex]  DEFAULT ((0)) FOR [Sex]
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity] ADD  CONSTRAINT [DF_APP_RedPackage_Activity_TotalMoney1]  DEFAULT ((0)) FOR [TotalMoney]
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity] ADD  CONSTRAINT [DF_APP_RedPackage_Activity_RemainingMoney]  DEFAULT ((0)) FOR [RemainingMoney]
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award] ADD  CONSTRAINT [DF_Award_Number]  DEFAULT ((0)) FOR [Number]
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award_Log] ADD  CONSTRAINT [DF_ActivityAwardLog_RewardName]  DEFAULT ('') FOR [AwardName]
GO
ALTER TABLE [dbo].[Order] ADD  CONSTRAINT [DF_Order_TotalPrice]  DEFAULT ((0)) FOR [TotalPrice]
GO
ALTER TABLE [dbo].[Order] ADD  CONSTRAINT [DF_Order_Price]  DEFAULT ((0)) FOR [Price]
GO
ALTER TABLE [dbo].[Order] ADD  CONSTRAINT [DF_Order_UsedPoints]  DEFAULT ((0)) FOR [UsedPoints]
GO
ALTER TABLE [dbo].[Order] ADD  CONSTRAINT [DF_Order_PayType]  DEFAULT ((0)) FOR [PayType]
GO
ALTER TABLE [dbo].[Order] ADD  CONSTRAINT [DF_Order_OrderType]  DEFAULT ((0)) FOR [OrderType]
GO
ALTER TABLE [dbo].[SystemConfig] ADD  CONSTRAINT [DF_SystemConfig_SmsPlatform]  DEFAULT ((0)) FOR [SmsPlatform]
GO
ALTER TABLE [dbo].[SystemConfig] ADD  CONSTRAINT [DF_SystemConfig_Rate]  DEFAULT ((0)) FOR [Rate]
GO
ALTER TABLE [dbo].[SystemConfig] ADD  CONSTRAINT [DF_SystemConfig_Coupon]  DEFAULT ((0)) FOR [TotalCoupon]
GO
ALTER TABLE [dbo].[SystemConfig] ADD  CONSTRAINT [DF_SystemConfig_CouponNum]  DEFAULT ((0)) FOR [CouponNum]
GO
ALTER TABLE [dbo].[SystemConfig] ADD  CONSTRAINT [DF_SystemConfig_CouponAmount]  DEFAULT ((0)) FOR [CouponAmount]
GO
ALTER TABLE [dbo].[Account]  WITH CHECK ADD  CONSTRAINT [FK_Account_Account1] FOREIGN KEY([ParentAccountId])
REFERENCES [dbo].[Account] ([Id])
GO
ALTER TABLE [dbo].[Account] CHECK CONSTRAINT [FK_Account_Account1]
GO
ALTER TABLE [dbo].[Address]  WITH CHECK ADD  CONSTRAINT [FK_Address_Account] FOREIGN KEY([AccountId])
REFERENCES [dbo].[Account] ([Id])
GO
ALTER TABLE [dbo].[Address] CHECK CONSTRAINT [FK_Address_Account]
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award]  WITH CHECK ADD  CONSTRAINT [FK_APP_RedPackage_Activity_APP_RedPackage_Activity_Award] FOREIGN KEY([ActivityId])
REFERENCES [dbo].[APP_RedPackage_Activity] ([Id])
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award] CHECK CONSTRAINT [FK_APP_RedPackage_Activity_APP_RedPackage_Activity_Award]
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award_Log]  WITH CHECK ADD  CONSTRAINT [FK_Account_APP_RedPackage_Activity_Award_Log] FOREIGN KEY([AccountId])
REFERENCES [dbo].[Account] ([Id])
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award_Log] CHECK CONSTRAINT [FK_Account_APP_RedPackage_Activity_Award_Log]
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award_Log]  WITH CHECK ADD  CONSTRAINT [FK_APP_RedPackage_Activity_APP_RedPackage_Activity_Award_Log] FOREIGN KEY([ActivityId])
REFERENCES [dbo].[APP_RedPackage_Activity] ([Id])
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award_Log] CHECK CONSTRAINT [FK_APP_RedPackage_Activity_APP_RedPackage_Activity_Award_Log]
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award_Log]  WITH CHECK ADD  CONSTRAINT [FK_APP_RedPackage_Activity_Award_Log_APP_RedPackage_Activity_Award] FOREIGN KEY([AwardId])
REFERENCES [dbo].[APP_RedPackage_Activity_Award] ([Id])
GO
ALTER TABLE [dbo].[APP_RedPackage_Activity_Award_Log] CHECK CONSTRAINT [FK_APP_RedPackage_Activity_Award_Log_APP_RedPackage_Activity_Award]
GO
ALTER TABLE [dbo].[MessageBox]  WITH CHECK ADD  CONSTRAINT [FK_MessageBox_Account] FOREIGN KEY([AccountId])
REFERENCES [dbo].[Account] ([Id])
GO
ALTER TABLE [dbo].[MessageBox] CHECK CONSTRAINT [FK_MessageBox_Account]
GO
ALTER TABLE [dbo].[Order]  WITH CHECK ADD  CONSTRAINT [FK_Account_Order] FOREIGN KEY([AccountId])
REFERENCES [dbo].[Account] ([Id])
GO
ALTER TABLE [dbo].[Order] CHECK CONSTRAINT [FK_Account_Order]
GO
ALTER TABLE [dbo].[Order]  WITH CHECK ADD  CONSTRAINT [FK_APP_RedPackage_Activity_Order] FOREIGN KEY([ActivityId])
REFERENCES [dbo].[APP_RedPackage_Activity] ([Id])
GO
ALTER TABLE [dbo].[Order] CHECK CONSTRAINT [FK_APP_RedPackage_Activity_Order]
GO
ALTER TABLE [dbo].[WithdrawLog]  WITH CHECK ADD  CONSTRAINT [FK_Account_WithdrawLog] FOREIGN KEY([AccountId])
REFERENCES [dbo].[Account] ([Id])
GO
ALTER TABLE [dbo].[WithdrawLog] CHECK CONSTRAINT [FK_Account_WithdrawLog]
GO
ALTER TABLE [dbo].[WithdrawLog]  WITH CHECK ADD  CONSTRAINT [FK_APP_RedPackage_Activity_Award_Log_WithdrawLog] FOREIGN KEY([ActivityLogId])
REFERENCES [dbo].[APP_RedPackage_Activity_Award_Log] ([Id])
GO
ALTER TABLE [dbo].[WithdrawLog] CHECK CONSTRAINT [FK_APP_RedPackage_Activity_Award_Log_WithdrawLog]
GO
ALTER TABLE [dbo].[WithdrawLog]  WITH CHECK ADD  CONSTRAINT [FK_APP_RedPackage_Activity_WithdrawLog] FOREIGN KEY([ActivityId])
REFERENCES [dbo].[APP_RedPackage_Activity] ([Id])
GO
ALTER TABLE [dbo].[WithdrawLog] CHECK CONSTRAINT [FK_APP_RedPackage_Activity_WithdrawLog]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'微信订单编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Order', @level2type=N'COLUMN',@level2name=N'PrepayId'
GO