- Joined
- Aug 14, 2009
- Messages
- 2,304
- Reaction score
- 1,189
Here is "my" version of the bill_get_balance procedure. (I'm a newb in MSSQL, don't judge this), It works (you can enter the shop). But you'll still need the "bill_cancel_purchase" and "bill_purchase_item" procedure. Also I don't think there is currently the actual billing tables for storing these "transactions"
My "bill_purchase_item" procedure
Code:
-- =============================================
-- Author: Lee HyunSung
-- Create date: 2011-05-13
-- Description: Cash 조회.
-- =============================================
ALTER PROCEDURE [dbo].[bill_get_balance]
-- Add the parameters for the stored procedure here
[USER=1335]user[/USER]ID nvarchar(20) out, -- Account ID
[USER=401224]Real[/USER]Cash int out, -- Main cash
[USER=774015]Bon[/USER]usCash int out, -- Some kind of bonus cash?
[USER=286651]ret[/USER]Code int out -- hell idk. Just output 0
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @RC int, @BC int;
select top 1 @RC=RealCash, @BC=BonusCash from dbo.tbl_UserCash WHERE UserID [USER=1335]user[/USER]ID
IF ( @@ROWCOUNT <> 1 )
BEGIN
INSERT INTO dbo.tbl_UserCash VALUES [USER=1335]user[/USER]ID, 0, 0, GetDate(), GetDate(), 0);
set [USER=401224]Real[/USER]Cash = 0;
set [USER=774015]Bon[/USER]usCash = 0;
set [USER=286651]ret[/USER]Code = 0;
SET NOCOUNT OFF;
RETURN 0;
END
set [USER=401224]Real[/USER]Cash = @RC;
set [USER=774015]Bon[/USER]usCash = @BC;
set [USER=286651]ret[/USER]Code = 0;
SET NOCOUNT OFF;
RETURN 0;
END
My "bill_purchase_item" procedure
Code:
ALTER PROCEDURE [dbo].[bill_purchase_item]
-- Add the parameters for the stored procedure here
@WorldIdx tinyint, -- 월드 Index
[USER=1335]user[/USER]ID nvarchar(20) output, -- 계정 아이디
[USER=551894]Char[/USER]Name nvarchar(16), -- 캐릭터 이름
[USER=482628]rec[/USER]vCharOID bigint, -- 케릭터 OID
@BuyType tinyint, -- 구매 타입(1:혼자사용,2:선물하기)
@PurchaseCash int, -- 총가격
@ItemID_array nvarchar(1024), -- 아이템 번호
@ItemAmount_array nvarchar(1024), -- 아이템 개수
@ItemPrice_array nvarchar(1024), -- 아이템 가격
[USER=401224]Real[/USER]Cash int output,
[USER=774015]Bon[/USER]usCash int output,
@BillNo int output,
[USER=286651]ret[/USER]Code int output
AS
BEGIN
declare @t_RealCash int, @t_BonusCash int;
select top 1 @t_RealCash = (RealCash-@PurchaseCash), @t_BonusCash=BonusCash from [dbo].[tbl_UserCash] WHERE UserID [USER=1335]user[/USER]ID;
update [dbo].[tbl_UserCash] SET RealCash=@t_RealCash WHERE UserID [USER=1335]user[/USER]ID;
INSERT INTO [dbo].[tbl_CashItemLog] VALUES(@WorldIdx, [USER=1335]user[/USER]ID, [USER=551894]Char[/USER]Name, [USER=482628]rec[/USER]vCharOID, @BuyType, @PurchaseCash, @t_RealCash, @t_BonusCash, @t_RealCash, @t_BonusCash, 0, 0, GETDATE(), GETDATE());
select [USER=401224]Real[/USER]Cash = @t_RealCash, [USER=774015]Bon[/USER]usCash = @t_BonusCash, @BillNo = @@IDENTITY, [USER=286651]ret[/USER]Code = 0;
END
Last edited: