• 团队触发器


    USE [MogoData355]
    GO
    /****** 对象:  Trigger [dbo].[UserWithdrawOrderStatus]    脚本日期: 07/05/2013 14:17:51 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER TRIGGER [dbo].[UserWithdrawOrderStatus] 
       ON  [dbo].[User_Withdraw_Detail] 
       AFTER UPDATE
    AS 
    BEGIN    
        SET NOCOUNT ON;
        DECLARE @Count int;
        DECLARE @FinishCount int;
        DECLARE @FailCount int;
        DECLARE @Woid int;
       if (update(Status))
           BEGIN
           SELECT @Woid = WOID from inserted;
           select @Count =count(*) from User_Withdraw_Detail where woid = @Woid ;
           select @FinishCount=count(*) from User_Withdraw_Detail where woid =  @Woid and (Status =3 or Status =4) ;
           select @FailCount=count(*) from User_Withdraw_Detail where woid =  @Woid and Status =4;
            if (@Count = @FinishCount)
            BEGIN
                    if (@FailCount > 0)
                    BEGIN
                        update User_Withdraw_Order set Status = 4 where ID = @Woid
                    END
                    else
                    BEGIN
                        update User_Withdraw_Order set Status = 3 where ID = @Woid
                    END
            END
    
    --        if (@FailCount > 0)
    --            BEGIN
    --                update User_Withdraw_Order set Status = 4 where ID = @Woid
    --            END
      END
    END   
    --------------------------------------------------------------
    USE [MogoData355]
    GO
    /****** 对象:  Trigger [dbo].[UserWithdrawDetailSuccess]    脚本日期: 07/05/2013 14:17:48 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    
    
    ALTER TRIGGER [dbo].[UserWithdrawDetailSuccess] 
       ON  [dbo].[User_Withdraw_Detail] 
       AFTER UPDATE
    AS 
    BEGIN    
        SET NOCOUNT ON;
        DECLARE @Status int;
        DECLARE @UID uniqueidentifier;
        DECLARE @Amount money;
        DECLARE @NoteNum varchar(20);
        DECLARE @WOID int;
        DECLARE @ID int
       if (update(Status))
       BEGIN
       SELECT @UID=UID, @Status=Status,@Amount=Amount,@NoteNum =WOID+'0'+ID, @ID=ID,@WOID =WOID from inserted 
        if (@Status=3)
          BEGIN
            --UPDATE User_Income SET Withdraw=(select sum(Amount) as Amount from User_Withdraw 
            --where UID=@UID and Status=3)*1000 where UID=@UID
            INSERT INTO User_Income_Detail(UID,Date,Type,Amount,Note,Summed)
            VALUES (@UID,CONVERT(VARCHAR(10),GETDATE(),120),-1,-@Amount,@NoteNum,1)
          END
         if (@Status=4)
          BEGIN
            --UPDATE User_Income SET Withdraw=(select sum(Amount) as Amount from User_Withdraw 
            --where UID=@UID and Status=3)*1000 where UID=@UID
            update  User_Withdraw_Detail set Tax =0,RealityAmount=0 where ID = @ID and WOID = @WOID
          END
       END   
    END
    
    
    ---------------------------------------------------------------------
    USE [MogoData355]
    GO
    /****** 对象:  Trigger [dbo].[UserWithdrawOrderRealityAmoun]    脚本日期: 07/05/2013 14:19:22 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER TRIGGER [dbo].[UserWithdrawOrderRealityAmoun] 
       ON  [dbo].[User_Withdraw_Order] 
       AFTER UPDATE
    AS 
    BEGIN    
        SET NOCOUNT ON;
        DECLARE @Status tinyint;
        DECLARE @WOID int;
       if (update(Status))
           BEGIN
             SELECT @Status = [Status], @WOID = ID from inserted;
             if(@Status = 3 or @Status = 4)
                BEGIN
                    update User_Withdraw_Order set RealityAmount =
                    (select isnull(sum(RealityAmount),0.0) from User_Withdraw_Detail where WOID = @WOID and Status=3),
                    Tax =
                    (select isnull (sum(Tax),0.0) from User_Withdraw_Detail where WOID = @WOID and Status=3)
                    where ID = @WOID
                END
           END
    END   
  • 相关阅读:
    es6中promise的实现及原理
    移动端
    javascript知识点复习
    html和css基本常识总结
    kafka,查看指定group下topic的堆积数量
    解决问题:Android设备运行自动化脚本报错 ioerror RPC server not started
    linux下安装python3
    使用vsftpd搭建FTP服务
    前端性能监控平台showslow+Yslow搭建
    学习笔记-- Python网络编程
  • 原文地址:https://www.cnblogs.com/l25321937/p/3191080.html
Copyright © 2020-2023  润新知