Files
Client/Server/Database/DBScript/BillingDB/BillingDB_Tbl_PROC_ALTER_BattleGround.sql
LGram16 dd97ddec92 Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 20:17:20 +09:00

745 lines
22 KiB
Transact-SQL

-- 배틀그라운드 클로스베타 유저를 위한 테이블
CREATE TABLE TblBattleLoginUser
(
strClientID VARCHAR(20) PRIMARY KEY
)
GO
-- 캐릭터 선택창 가기 전에 과금 여부를 체크한다.
-- 캐릭터 선택창에서 다시 실행한다.
ALTER PROC USPCheckBilling_Login @strClientID VARCHAR(20),@UID INT, @Check Int,@ClientIP VARCHAR(15),@ServerID TINYINT
AS
SET NOCOUNT ON
--DECLARE @RegLogInTime
DECLARE @strBillingType CHAR(1) --D,T
DECLARE @strBillingType2 CHAR(2)
DECLARE @PlayTime INT --남은시간(분),남은일자
DECLARE @CanUseTime INT
DECLARE @FLAG INT
SET @strBillingType = 'N'
SET @PlayTime = 0
SET @CanUseTime = 0
SET @FLAG = -1
DECLARE @IPType CHAR(1) --D,T
DECLARE @intCRMIndex1 INT
DECLARE @intCRMIndex2 INT
SET @intCRMIndex1 =0
SET @intCRMIndex2 =0
DECLARE @BillingDate CHAR(1)
DECLARE @BillingTime CHAR(1)
SET @BillingDate = 'D'
SET @BillingTime = 'T'
-- 피시방중 정량제와 정액제를 같이 사용하는 경우 해당 과금의 피시방인덱스를 얻어와야한다.
DECLARE @OutCRMIndex INT
DECLARE @tinyServerID INT
SET @tinyServerID = -1
DECLARE @FreeTime INT
EXEC USPInsertPerson @strClientID,@UID
-- 현재 로그인 된 사용자 인지 아닌지 체크한다.
SELECT @tinyServerID = tinyServerID FROM TblCurrentUser_Temp WHERE strClientid = @strClientID
IF @tinyServerID > -1
BEGIN
SET @FLAG = 1 --중복된 유저임.
SET @intCRMIndex1 = @tinyServerID
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,@PlayTime as PlayTime,@intCRMIndex1 as ServerID
RETURN
END
-- 현재 로그인 된 사용자 인지 아닌지 체크한다.
SELECT @tinyServerID = tinyServerID FROM TblCurrentUser WHERE strClientid = @strClientID
IF @tinyServerID > -1
BEGIN
SET @FLAG = 1 --중복된 유저임.
SET @intCRMIndex1 = @tinyServerID
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,@PlayTime as PlayTime,@intCRMIndex1 as ServerID
RETURN
END
-- 무료계정 여부 체크 -- 나중에 수정해야함.
IF (@Check = 1) --무료계정
BEGIN
SET @FLAG = 0
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
-- 배틀그라운드 클로즈 베타에 따른 인증추가 (2004-04-19)
-- @SERVERID가 7번인 경우는 배틀그라운드에 접속함을 가정한다.
IF (@ServerID = 7 )
BEGIN
IF EXISTS (SELECT * FROM TblBattleLoginUser WHERE strClientID = @strClientID)
BEGIN
SET @FLAG = 0
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
-- 'N' 타입으로 리턴한다.
SET @strBillingType2 = 'B'
SET @FreeTime = DATEDIFF(DAY,GETDATE(),'2030-01-01 00:00:00')
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@FreeTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
END
-- 무료계정인지 아닌지 체크한다
SELECT @FreeTime = DATEDIFF(DAY,GETDATE(),RegLoginTime)
FROM TBLPERSONINFO
WHERE UID = @UID
-- 실제 무료 계정임을 나타냄.
IF (@FreeTime >= 0)
BEGIN
SET @FLAG = 0
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@FreeTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
/*************************************************
* @FLAG = 0,@strBillingType ='D',@PlayTime = 남은일자 --개인정액제 성공
* @FLAG = 0,@strBillingType ='T',@PlayTime = 남은시간 --개인정량제 성공
* @FLAG = 1,@strBillingType ='N',@PlayTime = 0 --과금등록이 되어있지 않음
* @FLAG = 2,@strBillingType ='D',@PlayTime = 0 --개인정액제 과금이 종료된 경우
* @FLAG = 3,@strBillingType ='T',@PlayTime = 0 --개인정량제 과금이 종료된 경우
**************************************************/
EXEC @FLAG = USPCheckBilling_Person @strClientID,@strBillingType OUTPUT,@PlayTime OUTPUT
-- 개인과금이 성공적인경우
IF (@FLAG = 0)
BEGIN
-- 정액제 개인 유저인경우
IF (@strBillingType =@BillingDate)
BEGIN
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
-- 정량제 개인 유저인경우
ELSE IF (@strBillingType =@BillingTime)
BEGIN
SET @FLAG = -1
--AGAIN CHECK ClientIP
/*********************************************
* @FLAG = 0,@intCRMIndex1 = 숫자,@intCRMIndex2 = 숫자 -- 피시방 아이피가 정액과 정량 모두를 사용함
* @FLAG = 0,@intCRMIndex1 = 숫자,@intCRMIndex2 = 0 -- 피시방 아이피가 정액 또는 정량중 하나 임
* @FLAG = 1,@intCRMIndex1 = 0,@intCRMIndex2 = 0 -- 피시방 아이피가 아님
*********************************************/
EXEC @FLAG = USPCheckBilling_ClientIP @ClientIP,@intCRMIndex1 OUTPUT,@intCRMIndex2 OUTPUT
-- PC방이 아닌경우
IF @FLAG <> 0
BEGIN
-- 개인정량제로 리턴한다.
SET @FLAG = 0
SET @intCRMIndex1 = 0
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
-- PC방 아이피인경우
ELSE IF @FLAG = 0
BEGIN
-- 해당 아이피의 과금 방식 가져오기
IF (@intCRMIndex1 <> 0 AND @intCRMIndex2 = 0) -- 하나의 과금 방식만 따른다.
BEGIN
SELECT @IPType = strBillingType
FROM TblPCRoomBillingInfo
WHERE intCRMIndex = @intCRMIndex1
END
ELSE IF (@intCRMIndex1 <> 0 AND @intCRMIndex2 <> 0) -- 두개의 과금 방식을 따른다.
BEGIN
SET @IPType = 'C'
END
-- PC방 과금종류를 체크한다.
-- T:정량제,D:정액제
EXEC @FLAG = USPCheckBilling_GameRoom @intCRMIndex1,@intCRMIndex2,@IPType,@OutCRMIndex OUTPUT,@strBillingType OUTPUT,@canUseTime OUTPUT
IF @FLAG <> 0 --ERROR
BEGIN
-- PC방 과금이 종료된 경우이므로 다시 개인정량제로 과금을 적용시킨다.
SET @intCRMIndex1 = 0
SET @FLAG = 0
SET @strBillingType = @BillingTime
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
ELSE
BEGIN
IF @strBillingType = 'D' -- 정액제
BEGIN
-- 아이피 하나를 사용해서 카운트를 1 더하기 한다.
EXEC USPCheckBilling_UpIPCount @OutCRMIndex
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@OutCRMIndex,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@canUseTime as PlayTime,@OutCRMIndex as CRMIndex
RETURN
END
ELSE IF @strBillingType = 'T' -- 정액제
BEGIN
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@OutCRMIndex,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@canUseTime as PlayTime,@OutCRMIndex as CRMIndex
RETURN
END
END
END
END
END
-- 개인과금이 실패된 경우 다시 과금등록된 피시방인지 아닌지 체크한다.
ELSE
BEGIN
--AGAIN CHECK ClientIP
/*********************************************
* @FLAG = 0,@intCRMIndex1 = 숫자,@intCRMIndex2 = 숫자 -- 피시방 아이피가 정액과 정량 모두를 사용함
* @FLAG = 0,@intCRMIndex1 = 숫자,@intCRMIndex2 = 0 -- 피시방 아이피가 정액 또는 정량중 하나 임
* @FLAG = 1,@intCRMIndex1 = 0,@intCRMIndex2 = 0 -- 피시방 아이피가 아님
*********************************************/
EXEC @FLAG = USPCheckBilling_ClientIP @ClientIP,@intCRMIndex1 OUTPUT,@intCRMIndex2 OUTPUT
-- PC방이 아닌경우
IF @FLAG <> 0
BEGIN
/*********임시 적용 부분 ***********
SET @FLAG = 0
SET @intCRMIndex1 = 0
SET @strBillingType = 'N'
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser_temp(strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
********임시 적용 부분 끝 ************/
-- 에러리턴한다
SET @FLAG = 2
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
ELSE IF @FLAG = 0
BEGIN
-- 해당 아이피의 과금 방식 가져오기
IF (@intCRMIndex1 <> 0 AND @intCRMIndex2 = 0) -- 하나의 과금 방식만 따른다.
BEGIN
SELECT @IPType = strBillingType
FROM TblPCRoomBillingInfo
WHERE intCRMIndex = @intCRMIndex1
END
ELSE IF (@intCRMIndex1 <> 0 AND @intCRMIndex2 <> 0) -- 두개의 과금 방식을 따른다.
BEGIN
SET @IPType = 'C'
END
-- PC방 과금종류를 체크한다.
-- T:정량제,D:정액제
EXEC @FLAG = USPCheckBilling_GameRoom @intCRMIndex1,@intCRMIndex2,@IPType,@OutCRMIndex OUTPUT,@strBillingType OUTPUT,@canUseTime OUTPUT
IF @FLAG <> 0 --ERROR
BEGIN
SET @FLAG = 2
SET @strBillingType = 'N'
-- PC방 과금이 종료된 에러를 리턴한다.
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
ELSE -- SUCCESS
BEGIN
IF @strBillingType = 'D' -- 정액제
BEGIN
-- 아이피 하나를 사용해서 카운트를 1 더하기 한다.
EXEC USPCheckBilling_UpIPCount @OutCRMIndex
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@OutCRMIndex,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@canUseTime as PlayTime,@OutCRMIndex as CRMIndex
RETURN
END
ELSE IF @strBillingType = 'T' -- 정액제
BEGIN
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser_Temp (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@OutCRMIndex,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@canUseTime as PlayTime,@OutCRMIndex as CRMIndex
RETURN
END
END
END
END
GO
-- 캐릭터 선택창 가기 전에 과금 여부를 체크한다.
-- 캐릭터 선택창에서 다시 실행한다.
-- 추가사항 : 블럭된 캐릭터인지 아닌지를 가려야한다.
ALTER PROC USPCheckBilling_CharIDLogin @strClientID VARCHAR(20),@UID INT,@check TINYINT,@ClientIP VARCHAR(15),@ServerID TINYINT
AS
SET NOCOUNT ON
DECLARE @strBillingType CHAR(1) --D,T
DECLARE @strBillingType2 CHAR(2) -- RETURN VALUES
DECLARE @PlayTime INT --남은시간(분),남은일자
DECLARE @CanUseTime INT
DECLARE @FLAG INT
SET @strBillingType = 'N'
SET @PlayTime = 0
SET @CanUseTime = 0
SET @FLAG = -1
DECLARE @IPType CHAR(1) --D,T
DECLARE @intCRMIndex1 INT
DECLARE @intCRMIndex2 INT
SET @intCRMIndex1 =0
SET @intCRMIndex2 =0
DECLARE @BillingDate CHAR(1)
DECLARE @BillingTime CHAR(1)
SET @BillingDate = 'D'
SET @BillingTime = 'T'
-- 피시방중 정량제와 정액제를 같이 사용하는 경우 해당 과금의 피시방인덱스를 얻어와야한다.
DECLARE @OutCRMIndex INT
DECLARE @tinyServerID INT
SET @tinyServerID = -1
DECLARE @FreeTime INT
-- 현재 로그인 된 사용자 인지 아닌지 체크한다.
SELECT @tinyServerID = tinyServerID FROM TblCurrentUser WHERE strClientid = @strClientID
IF @tinyServerID > -1
BEGIN
SET @FLAG = 1 --중복된 유저임.
SET @intCRMIndex1 = @tinyServerID
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,@PlayTime as PlayTime,@intCRMIndex1 as ServerID
RETURN
END
-- 무료계정 여부 체크
IF (@Check = 1) --무료계정
BEGIN
SET @FLAG = 0
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser(strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
-- 배틀그라운드 클로즈 베타에 따른 인증추가 (2004-04-19)
-- @SERVERID가 7번인 경우는 배틀그라운드에 접속함을 가정한다.
IF (@ServerID = 7 )
BEGIN
IF EXISTS (SELECT * FROM TblBattleLoginUser WHERE strClientID = @strClientID)
BEGIN
SET @FLAG = 0
-- 임시테이블 TblCurrentUser_Temp에 입력한다.
INSERT INTO TblCurrentUser (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
-- 'N' 타입으로 리턴한다.
SET @strBillingType2 = 'B'
SET @FreeTime = DATEDIFF(DAY,GETDATE(),'2030-01-01 00:00:00')
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@FreeTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
END
-- 무료계정인지 아닌지 체크한다
SELECT @FreeTime = DATEDIFF(DAY,GETDATE(),RegLoginTime)
FROM TBLPERSONINFO
WHERE UID = @UID
-- 실제 무료 계정임을 나타냄.
IF (@FreeTime >= 0)
BEGIN
SET @FLAG = 0
-- 임시테이블 TblCurrentUser에 입력한다.
INSERT INTO TblCurrentUser (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@FreeTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
/*************************************************
* @FLAG = 0,@strBillingType ='D',@PlayTime = 남은일자 --개인정액제 성공
* @FLAG = 0,@strBillingType ='T',@PlayTime = 남은시간 --개인정량제 성공
* @FLAG = 1,@strBillingType ='N',@PlayTime = 0 --과금등록이 되어있지 않음
* @FLAG = 2,@strBillingType ='D',@PlayTime = 0 --개인정액제 과금이 종료된 경우
* @FLAG = 3,@strBillingType ='T',@PlayTime = 0 --개인정량제 과금이 종료된 경우
**************************************************/
EXEC @FLAG = USPCheckBilling_Person @strClientID,@strBillingType OUTPUT,@PlayTime OUTPUT
-- 개인과금이 성공적인경우
IF (@FLAG = 0)
BEGIN
-- 정액제 개인 유저인경우
IF (@strBillingType =@BillingDate)
BEGIN
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser(strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
-- 정량제 개인 유저인경우
ELSE IF (@strBillingType =@BillingTime)
BEGIN
SET @FLAG = -1
--AGAIN CHECK ClientIP
/*********************************************
* @FLAG = 0,@intCRMIndex1 = 숫자,@intCRMIndex2 = 숫자 -- 피시방 아이피가 정액과 정량 모두를 사용함
* @FLAG = 0,@intCRMIndex1 = 숫자,@intCRMIndex2 = 0 -- 피시방 아이피가 정액 또는 정량중 하나 임
* @FLAG = 1,@intCRMIndex1 = 0,@intCRMIndex2 = 0 -- 피시방 아이피가 아님
*********************************************/
EXEC @FLAG = USPCheckBilling_ClientIP @ClientIP,@intCRMIndex1 OUTPUT,@intCRMIndex2 OUTPUT
-- PC방이 아닌경우
IF @FLAG <> 0
BEGIN
-- 개인정량제로 리턴한다.
SET @FLAG = 0
SET @intCRMIndex1 = 0
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
-- PC방 아이피인경우
ELSE IF @FLAG = 0
BEGIN
-- 해당 아이피의 과금 방식 가져오기
IF (@intCRMIndex1 <> 0 AND @intCRMIndex2 = 0) -- 하나의 과금 방식만 따른다.
BEGIN
SELECT @IPType = strBillingType
FROM TblPCRoomBillingInfo
WHERE intCRMIndex = @intCRMIndex1
END
ELSE IF (@intCRMIndex1 <> 0 AND @intCRMIndex2 <> 0) -- 두개의 과금 방식을 따른다.
BEGIN
SET @IPType = 'C'
END
-- PC방 과금종류를 체크한다.
-- T:정량제,D:정액제
EXEC @FLAG = USPCheckBilling_GameRoom @intCRMIndex1,@intCRMIndex2,@IPType,@OutCRMIndex OUTPUT,@strBillingType OUTPUT,@canUseTime OUTPUT
IF @FLAG <> 0 --ERROR
BEGIN
-- PC방 과금이 종료된 경우이므로 다시 개인정량제로 과금을 적용시킨다.
SET @intCRMIndex1 = 0
SET @FLAG = 0
SET @strBillingType = @BillingTime
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
ELSE
BEGIN
IF @strBillingType = 'D' -- 정액제
BEGIN
-- 아이피 하나를 사용해서 카운트를 1 더하기 한다.
EXEC USPCheckBilling_UpIPCount @OutCRMIndex
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@OutCRMIndex,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@OutCRMIndex as CRMIndex
RETURN
END
ELSE IF @strBillingType = 'T' -- 정액제
BEGIN
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@OutCRMIndex,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@OutCRMIndex as CRMIndex
RETURN
END
END
END
END
END
-- 개인과금이 실패된 경우 다시 과금등록된 피시방인지 아닌지 체크한다.
ELSE
BEGIN
--AGAIN CHECK ClientIP
/*********************************************
* @FLAG = 0,@intCRMIndex1 = 숫자,@intCRMIndex2 = 숫자 -- 피시방 아이피가 정액과 정량 모두를 사용함
* @FLAG = 0,@intCRMIndex1 = 숫자,@intCRMIndex2 = 0 -- 피시방 아이피가 정액 또는 정량중 하나 임
* @FLAG = 1,@intCRMIndex1 = 0,@intCRMIndex2 = 0 -- 피시방 아이피가 아님
*********************************************/
EXEC @FLAG = USPCheckBilling_ClientIP @ClientIP,@intCRMIndex1 OUTPUT,@intCRMIndex2 OUTPUT
-- PC방이 아닌경우
IF @FLAG <> 0
BEGIN
-- 임시 적용 부분
/*
SET @FLAG = 0
SET @intCRMIndex1 = 0
SET @strBillingType = 'N'
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser(strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@intCRMIndex1,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
*/
-- 에러리턴한다.
SET @FLAG = 2
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
ELSE IF @FLAG = 0
BEGIN
-- 해당 아이피의 과금 방식 가져오기
IF (@intCRMIndex1 <> 0 AND @intCRMIndex2 = 0) -- 하나의 과금 방식만 따른다.
BEGIN
SELECT @IPType = strBillingType
FROM TblPCRoomBillingInfo
WHERE intCRMIndex = @intCRMIndex1
END
ELSE IF (@intCRMIndex1 <> 0 AND @intCRMIndex2 <> 0) -- 두개의 과금 방식을 따른다.
BEGIN
SET @IPType = 'C'
END
-- PC방 과금종류를 체크한다.
-- T:정량제,D:정액제
EXEC @FLAG = USPCheckBilling_GameRoom @intCRMIndex1,@intCRMIndex2,@IPType,@OutCRMIndex OUTPUT,@strBillingType OUTPUT,@canUseTime OUTPUT
IF @FLAG <> 0 --ERROR
BEGIN
SET @strBillingType = 'N'
-- PC방 과금이 종료된 에러를 리턴한다.
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@intCRMIndex1 as CRMIndex
RETURN
END
ELSE -- SUCCESS
BEGIN
IF @strBillingType = 'D' -- 정액제
BEGIN
-- 아이피 하나를 사용해서 카운트를 1 더하기 한다.
EXEC USPCheckBilling_UpIPCount @OutCRMIndex
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@OutCRMIndex,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@OutCRMIndex as CRMIndex
RETURN
END
ELSE IF @strBillingType = 'T' -- 정액제
BEGIN
--접속테이블에 입력한다.
INSERT INTO TblCurrentUser (strClientid,UID,intCRMIndex,strip,strBillingType,tinyServerID)
VALUES (@strClientID,@UID,@OutCRMIndex,@ClientIP,@strBillingType,@ServerID)
SET @strBillingType2 = @strBillingType
SELECT @FLAG as FLAG,@strBillingType2 as BillingType,
@PlayTime as PlayTime,@OutCRMIndex as CRMIndex
RETURN
END
END
END
END