标签:
目前系统中,关于购物添加了该业务还会影响业务地方:
/****** Object: Table [dbo].[cx_GoodsMarketingCampaignCategory] Script Date: 05/23/2015 11:17:53 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[cx_GoodsMarketingCampaignCategory]( [ID] [int] IDENTITY(1,1) NOT NULL, [Title] [nvarchar](64) NOT NULL, [Discount] [decimal](9, 1) NOT NULL, [IsWipingPoints11] [bit] NOT NULL, [IsWipingPoints01] [bit] NOT NULL, [BeginDate] [datetime] NOT NULL, [EndDate] [datetime] NOT NULL, [Enabled] [bit] NOT NULL, [SortID] [int] NOT NULL, [ModifyDate] [datetime] NOT NULL, [CreateDate] [datetime] NOT NULL, CONSTRAINT [PK_cx_GoodsMarketingCampaignCategory] 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].[cx_GoodsMarketingCampaignCategory] ADD CONSTRAINT [DF_cx_GoodsMarketingCampaignCategory_CreateDate] DEFAULT (getdate()) FOR [CreateDate] GO
1 SET ANSI_NULLS ON 2 GO 3 4 SET QUOTED_IDENTIFIER ON 5 GO 6 7 CREATE TABLE [dbo].[cx_GoodsMarketingCampaign]( 8 [ID] [int] IDENTITY(1,1) NOT NULL, 9 [GoodsID] [int] NOT NULL, 10 [GoodsMarketingCampaignCategoryOID] [int] NOT NULL, 11 [Discount] [decimal](9, 1) NOT NULL, 12 [CreateDate] [datetime] NOT NULL, 13 [ModifyDate] [datetime] NOT NULL, 14 CONSTRAINT [PK_cx_GoodsMarketingCampaign] PRIMARY KEY CLUSTERED 15 ( 16 [ID] ASC 17 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 18 ) ON [PRIMARY] 19 20 GO
1 Declare @GoodsID Int; 2 Declare @NowDateTime Datetime; 3 4 Set @GoodsID=1; 5 Set @NowDateTime=GETDATE(); 6 7 -- 获取参与过活动的产品的原始价格,活动折扣,折扣后价格 8 Select 9 T11.SellPrice, 10 T12.Discount, 11 (Case When T13.IsWipingPoints01=1 Then Round(T11.SellPrice*T12.Discount,1) 12 When T13.IsWipingPoints11=1 Then ROUND(T11.SellPrice*T12.Discount,0) 13 Else Round(T11.SellPrice*T12.Discount,2) End) as RealPrice 14 From cx_Article as T10 15 inner join cx_ArticleAttributeValue as T11 on T10.ID=T11.ArticleID 16 inner join cx_ArticleGoodsMarketingCampaign as T12 on T10.ID=T12.ArticleID 17 inner join cx_GoodsMarketingCampaignCategory as T13 on T12.GoodsMarketingCampaignCategoryOID=T13.ID 18 Where T13.[Enabled]=1 19 and T13.BeginDate<=@NowDateTime and T13.EndDate>@NowDateTime
1 Declare @GoodsID Int; 2 Declare @NowDateTime Datetime; 3 4 Set @GoodsID=1; 5 Set @NowDateTime=GETDATE(); 6 7 -- 判断是否该产品是否参与过有效活动 8 Select COUNT(T10.ID) 9 From cx_Article as T10 10 inner join cx_ArticleGoodsMarketingCampaign as T11 on T10.ID=T11.ArticleID 11 inner join cx_GoodsMarketingCampaignCategory as T12 on T11.GoodsMarketingCampaignCategoryOID=T12.ID 12 Where T12.[Enabled]=1 13 and T12.BeginDate<=@NowDateTime and T12.EndDate>@NowDateTime
到此,该逻辑已经完整的清晰了。突然感觉到文字的力量很神奇,苦想了,也没有理清的业务,文字写出来后竟然清晰了很多。
标签:
原文地址:http://www.cnblogs.com/yy3b2007com/p/4523872.html