IF object_id('dbo.PChangeMemberCardState','P') IS NOT NULL BEGIN DROP PROCEDURE dbo.PChangeMemberCardState END GO CREATE PROCEDURE dbo.PChangeMemberCardState ( @SessionId INT, @MemId BIGINT, @CardId BIGINT, @State INT ) AS BEGIN IF @MemId = 0 BEGIN RAISERROR('会员ID不能为0',18,1) RETURN -1 END IF @CardId = 0 BEGIN RAISERROR('卡ID不能为0',18,1) RETURN -1 END IF @State != 4 BEGIN RAISERROR('只支持停用',18,1) RETURN -1 END DECLARE @MemNo VARCHAR(50) DECLARE @CardNo VARCHAR(100) SELECT @MemNo = FNo FROM TMember WITH(NOLOCK) WHERE FId = @MemId IF @MemNo IS NULL BEGIN RAISERROR('会员ID不存在',18,1) RETURN -1 END IF @CardId = 6 BEGIN SELECT @CardNo = '疗程卡'; END ELSE IF @CardId = 1 BEGIN SELECT @CardNo = '全部子卡'; END ELSE BEGIN SELECT @CardNo = FNo FROM TMemberCard WHERE FId = @CardId END DECLARE @LogDesc VARCHAR(20) DECLARE @LogFunc VARCHAR(20) DECLARE @LogText VARCHAR(1024) DECLARE @LogIndexes VARCHAR(200) DECLARE @StateName VARCHAR(20) IF @State = 4 BEGIN SET @StateName = '已停用'; END SELECT @LogFunc = 'WMember'; SELECT @LogDesc = '更改卡状态'; SELECT @LogText = '会员主卡:'+@MemNo + ',会员子卡:' + @CardNo + ',状态:' + @StateName; SELECT @LogIndexes = 'MemNo=' + @MemNo; IF @CardId = 6 OR @CardId = 1 BEGIN print '' --UPDATE TMemberCourse END IF @CardId != 6 OR @CardId = 1 BEGIN UPDATE TMemberCard SET FState = @State WHERE FMemId = @MemId END EXEC PAddBizLogEx @SessionId=@SessionId,@Function=@LogFunc,@Operation='Modify',@Description=@LogDesc, @ContentType='Text',@Content=@LogText,@Version=1,@Indexes=@LogIndexes END GO UPDATE TMemberCard SET FTypeId = (SELECT FId FROM TMemberCardType WHERE FNo = '类别编号') WHERE FNo = '储值卡号'