if(@goldSum>=8) --如果金币足够8,那么就可以发帖了
begininsert into bbsTopic values(@code ,@title ,@Tcontent ,@uid ,@ucode ,@ccode ,@replyCount ,@clickCount ,@Tstate ,@Ttime ,@isRecommand ,@isessential ,@customSort ,@belongTo ,@ttcode ,@jieriCode ,@xuanshangjinbi ,@zhidingTime ,@isPingBi ,@editTime) select @insertTopicIdentity=@@identityINSERT INTO [wts_Community].[dbo].[bbsGold]
([uid] ,[bbsGold] ,[datetime] ,[itemtype]) VALUES (@uid ,-8 ,getdate() ,'每日发帖') select @insertGoldIdentity=@@identityINSERT INTO [wts_Community].[dbo].[bbsIntegral] ([uid] ,[bbsIntegral] ,[datetime] ,[itemtype]) VALUES (@uid ,12 ,getdate() ,'每日发帖') select @insertIntegralIdentity=@@identityif(@insertTopicIdentity!=0 and @insertGoldIdentity!=0 and @insertGoldIdentity!=0)
beginprint '您成功发布了一篇普通帖,奖励12积分,扣除8金币'endelsebeginprint '发布普通帖失败!'end endelsebeginprint '金币不够'
--raisError('金币不够', 16, 1);--rollback tran;end
endelse if(@topictype='主题帖') --发布普通帖一篇支付 - 10金币 +10积分beginif(@goldSum>=10) --如果金币足够10,那么就可以发帖了begininsert into bbsTopic values(@code ,@title ,@Tcontent ,@uid ,@ucode ,@ccode ,@replyCount ,@clickCount ,@Tstate ,@Ttime ,@isRecommand ,@isessential ,@customSort ,@belongTo ,@ttcode ,@jieriCode ,@xuanshangjinbi ,@zhidingTime ,@isPingBi ,@editTime) select @insertTopicIdentity=@@identityINSERT INTO [wts_Community].[dbo].[bbsGold]
([uid] ,[bbsGold] ,[datetime] ,[itemtype]) VALUES (@uid ,-10 ,getdate() ,'每日发帖') select @insertGoldIdentity=@@identityINSERT INTO [wts_Community].[dbo].[bbsIntegral] ([uid] ,[bbsIntegral] ,[datetime] ,[itemtype]) VALUES (@uid ,10 ,getdate() ,'每日发帖') select @insertIntegralIdentity=@@identityif(@insertTopicIdentity!=0 and @insertGoldIdentity!=0 and @insertIntegralIdentity!=0)beginprint '您发布的主题帖成功!奖励10积分,扣除10金币'endelsebeginprint '您发布的主题帖失败!'endendelsebeginprint '金币不够'
--raisError('金币不够', 16, 1);--rollback tran;endendelse if(@topictype='提问帖') --发布提问帖一篇支付 - 12金币 +12积分 beginif(@goldSum>=12) --如果金币足够12,那么就可以发帖了begininsert into bbsTopic values(@code ,@title ,@Tcontent ,@uid ,@ucode ,@ccode ,@replyCount ,@clickCount ,@Tstate ,@Ttime ,@isRecommand ,@isessential ,@customSort ,@belongTo ,@ttcode ,@jieriCode ,@xuanshangjinbi ,@zhidingTime ,@isPingBi ,@editTime) select @insertTopicIdentity=@@identityINSERT INTO [wts_Community].[dbo].[bbsGold]
([uid] ,[bbsGold] ,[datetime] ,[itemtype]) VALUES (@uid ,-12 ,getdate() ,'每日发帖') select @insertGoldIdentity=@@identityINSERT INTO [wts_Community].[dbo].[bbsIntegral] ([uid] ,[bbsIntegral] ,[datetime] ,[itemtype]) VALUES (@uid ,12 ,getdate() ,'每日发帖') select @insertIntegralIdentity=@@identityif(@insertTopicIdentity!=0 and @insertGoldIdentity!=0 and @insertIntegralIdentity!=0)beginprint '您发布的提问帖成功!奖励12积分,扣除12金币!'endelsebeginprint '您发布的提问帖失败!'endendelsebeginprint '金币不够'
--raisError('金币不够', 16, 1);--rollback tran; 事务在触发器中结束.批处理已中止.endend END--测试
INSERT INTO [wts_Community].[dbo].[bbsTopic]
([code] ,[title] ,[Tcontent] ,[uid] ,[ucode] ,[ccode] ,[replyCount] ,[clickCount] ,[Tstate] ,[Ttime] ,[isRecommand] ,[isessential] ,[customSort] ,[belongTo] ,[ttcode] ,[jieriCode] ,[xuanshangjinbi] ,[zhidingTime] ,[isPingBi] ,[editTime]) VALUES ('chadao' ,'test' ,'test' ,125 ,'' ,'chadao' ,0 ,0 ,0 ,'2014/10/9 00:00:00' ,0 ,0 ,0 ,0 ,'提问帖' ,'' ,10 ,'2014/10/9 00:00:00' ,0 ,'2014/10/9 00:00:00')