日期:2014-05-17 浏览次数:20614 次
ALTER PROC [dbo].[setRechargeSuccess]
(
@id INT,
@pay INT
)
AS
DECLARE @userId INT
DECLARE @status INT
--判断订单处
SELECT @status=status,@userId=userId FROM Recharge WHERE id=@id
IF(@status=1)
RETURN 65;--已处理了
ELSE
BEGIN
set xact_abort ON
BEGIN TRAN
UPDATE Recharge SET status=1 WHERE id=@id
UPDATE Users SET balance=balance+@pay WHERE ID=@userId
COMMIT TRAN
RETURN 66;--处理成功
END
ALTER PROC [dbo].[setRechargeSuccess]
(
@id INT,
@pay INT
)
AS
DECLARE @return_code INT
BEGIN
set xact_abort ON
BEGIN TRAN
UPDATE Recharge SET status=1 WHERE id=@id and status<>1
if @@rowcount>0 BEGIN
UPDATE Users SET balance=balance+@pay WHERE ID=(SELECT userId FROM Recharge WHERE id=@id)
SET @return_code=66
END
ELSE SET @return_code=65
COMMIT TRAN
RETURN @return_code;--处理成功
END