CREATE DATABASE  IF NOT EXISTS `mydb` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `mydb`;
--
-- Host: 210.175.73.142    Database: mydb
-- ------------------------------------------------------

 SET NAMES utf8 ;

--
-- Table structure for table `KP_BTCH_HIST`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `KP_BTCH_HIST` (
  `BTCH_HIST_IDX` bigint(21) unsigned NOT NULL AUTO_INCREMENT COMMENT 'IDX',
  `BTCH_PLTF` enum('P','A') NOT NULL DEFAULT 'P' COMMENT '배치 플랫폼 (P : 포털, A: 어드민)',
  `BTCH_NM` varchar(50) NOT NULL COMMENT '배치 명',
  `BTCH_DESC` varchar(500) DEFAULT NULL COMMENT '배치 설명',
  `STRT_DTM` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '시작 일시',
  `END_DTM` datetime(3) DEFAULT current_timestamp(3) COMMENT '종료 일시',
  `IS_SUCC` enum('Y','N') NOT NULL DEFAULT 'N' COMMENT '성공 유무 (Y : 성공, N: 실패)',
  `FAIL_LOG` mediumtext DEFAULT NULL COMMENT '실패 로그',
  `REG_DTM` datetime NOT NULL DEFAULT current_timestamp() COMMENT '등록 일시',
  PRIMARY KEY (`BTCH_HIST_IDX`)
) ENGINE=InnoDB AUTO_INCREMENT=42675 DEFAULT CHARSET=utf8 COMMENT='배치 이력 테이블';

--
-- Table structure for table `KP_CSN_BET_HIST`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `KP_CSN_BET_HIST` (
  `CSN_BET_IDX` bigint(21) unsigned NOT NULL AUTO_INCREMENT COMMENT 'IDX',
  `TYPE` enum('B','W','C','L','I','P','J') NOT NULL DEFAULT 'B' COMMENT '타입 (B: 배팅, W: 승리, C: 취소, L: 낙첨, I: 인게임보너스, P: 프로모션보너스, J: 잭팟보너스 )',
  `MBR_IDX` bigint(21) unsigned NOT NULL COMMENT '회원 IDX',
  `HLD_MNY` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '보유 머니',
  `BET_MNY` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '배팅 머니',
  `RSLT_MNY` int(10) NOT NULL DEFAULT 0 COMMENT '결과 머니 (배팅 : -, 승리 : +, 취소 : 0)',
  `PRD_ID` tinyint(3) unsigned NOT NULL COMMENT 'API 제공 제품 ID',
  `GAME_ID` int(5) unsigned NOT NULL COMMENT 'API 제공 게임 ID',
  `TRX_ID` varchar(500) NOT NULL COMMENT 'API 제공 트랜잭션 ID',
  `REG_DTM` datetime NOT NULL DEFAULT current_timestamp() COMMENT '등록일',
  `MOD_DTM` datetime DEFAULT NULL COMMENT '수정일',
  `IS_CALC` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '정산 유무 (0: 미정산, 1:정산)',
  `CALC_DTM` datetime DEFAULT NULL COMMENT '정산 일시',
  PRIMARY KEY (`CSN_BET_IDX`),
  KEY `MBR_IDX_INDEX` (`CSN_BET_IDX`),
  KEY `TYPE_INDEX` (`TYPE`),
  KEY `REG_DTM_INDEX` (`REG_DTM`),
  KEY `TRX_ID_INDEX` (`TRX_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=48704 DEFAULT CHARSET=utf8 COMMENT='카지노 배팅 테이블';

--
-- Table structure for table `KP_ESPT_BET_HIST`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `KP_ESPT_BET_HIST` (
  `SLOT_BET_IDX` bigint(21) unsigned NOT NULL AUTO_INCREMENT COMMENT 'IDX',
  `TYPE` enum('B','W','C','L','I','P','J') NOT NULL DEFAULT 'B' COMMENT '타입 (B: 배팅, W: 승리, C: 취소, L: 낙첨, I: 인게임보너스, P: 프로모션보너스, J: 잭팟보너스 )',
  `MBR_IDX` bigint(21) unsigned NOT NULL COMMENT '회원 IDX',
  `HLD_MNY` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '보유 머니',
  `BET_MNY` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '배팅 머니',
  `RSLT_MNY` int(10) NOT NULL DEFAULT 0 COMMENT '결과 머니 (배팅 : -, 승리 : +, 취소 : 0)',
  `PRD_ID` tinyint(3) unsigned NOT NULL COMMENT 'API 제공 제품 ID',
  `GAME_ID` int(5) unsigned NOT NULL COMMENT 'API 제공 게임 ID',
  `TRX_ID` varchar(500) NOT NULL COMMENT 'API 제공 트랜잭션 ID',
  `REG_DTM` datetime NOT NULL DEFAULT current_timestamp() COMMENT '등록일',
  `MOD_DTM` datetime DEFAULT NULL COMMENT '수정일',
  `IS_CALC` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '정산 유무 (0: 미정산, 1:정산)',
  `CALC_DTM` datetime DEFAULT NULL COMMENT '정산 일시',
  PRIMARY KEY (`SLOT_BET_IDX`),
  KEY `MBR_IDX_INDEX` (`SLOT_BET_IDX`),
  KEY `REG_DTM_INDEX` (`REG_DTM`),
  KEY `TRX_ID_INDEX` (`TRX_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='슬롯 배팅 테이블';

--
-- Table structure for table `KP_GAME_INF`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `KP_GAME_INF` (
  `GAME_IDX` bigint(21) unsigned NOT NULL AUTO_INCREMENT COMMENT 'IDX',
  `PRD_ID` tinyint(3) unsigned NOT NULL COMMENT 'API 제공 제품 ID',
  `GAME_ID` int(5) unsigned NOT NULL COMMENT 'API 제공 게임 ID',
  `GAME_NM` varchar(50) NOT NULL COMMENT '게임 명 (한글)',
  `IMG_URL` varchar(500) NOT NULL DEFAULT '/images/common/no_image.png' COMMENT '이미지 URL',
  `IS_USE` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '사용 유무 (0: 미사용, 1: 사용)',
  `REG_DTM` datetime NOT NULL DEFAULT current_timestamp() COMMENT '등록일시',
  PRIMARY KEY (`GAME_IDX`)
) ENGINE=InnoDB AUTO_INCREMENT=291 DEFAULT CHARSET=utf8 COMMENT='게임 정보 테이블';

--
-- Table structure for table `KP_MBR_INF`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `KP_MBR_INF` (
  `MBR_IDX` bigint(21) unsigned NOT NULL COMMENT 'member 테이블 idx',
  `KP_ID` bigint(21) unsigned NOT NULL COMMENT 'KPlay user_id',
  `KP_NM` varchar(100) NOT NULL COMMENT 'KPlay user_name',
  `REG_DTM` datetime NOT NULL DEFAULT current_timestamp() COMMENT '등록일',
  PRIMARY KEY (`MBR_IDX`),
  KEY `idx_kp_id` (`KP_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='KPlay 회원 정보 테이블';

--
-- Table structure for table `KP_PRD_INF`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `KP_PRD_INF` (
  `PRD_ID` tinyint(3) unsigned NOT NULL COMMENT 'API 제공 제품 ID',
  `TYPE` enum('C','S','E') NOT NULL COMMENT '타입 (C: 카지노, S: 슬롯, E: 이스포츠)',
  `PRD_NM` varchar(50) NOT NULL COMMENT '제품 명 (한글)',
  `IMG_URL` varchar(500) NOT NULL DEFAULT '/images/common/no_image.png' COMMENT '이미지 URL',
  `IS_USE` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '사용 유무 (0: 미사용, 1: 사용)',
  `SORT_NUM` tinyint(3) unsigned NOT NULL COMMENT '정렬 번호',
  `REG_DTM` datetime NOT NULL DEFAULT current_timestamp() COMMENT '등록일시',
  PRIMARY KEY (`PRD_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='제품 정보 테이블';

--
-- Table structure for table `KP_SLOT_BET_HIST`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `KP_SLOT_BET_HIST` (
  `SLOT_BET_IDX` bigint(21) unsigned NOT NULL AUTO_INCREMENT COMMENT 'IDX',
  `TYPE` enum('B','W','C','L','I','P','J') NOT NULL DEFAULT 'B' COMMENT '타입 (B: 배팅, W: 승리, C: 취소, L: 낙첨, I: 인게임보너스, P: 프로모션보너스, J: 잭팟보너스 )',
  `MBR_IDX` bigint(21) unsigned NOT NULL COMMENT '회원 IDX',
  `HLD_MNY` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '보유 머니',
  `BET_MNY` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '배팅 머니',
  `RSLT_MNY` int(10) NOT NULL DEFAULT 0 COMMENT '결과 머니 (배팅 : -, 승리 : +, 취소 : 0)',
  `PRD_ID` tinyint(3) unsigned NOT NULL COMMENT 'API 제공 제품 ID',
  `GAME_ID` int(5) unsigned NOT NULL COMMENT 'API 제공 게임 ID',
  `TRX_ID` varchar(500) NOT NULL COMMENT 'API 제공 트랜잭션 ID',
  `REG_DTM` datetime NOT NULL DEFAULT current_timestamp() COMMENT '등록일',
  `MOD_DTM` datetime DEFAULT NULL COMMENT '수정일',
  `IS_CALC` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '정산 유무 (0: 미정산, 1:정산)',
  `CALC_DTM` datetime DEFAULT NULL COMMENT '정산 일시',
  PRIMARY KEY (`SLOT_BET_IDX`),
  KEY `MBR_IDX_INDEX` (`SLOT_BET_IDX`),
  KEY `REG_DTM_INDEX` (`REG_DTM`),
  KEY `TRX_ID_INDEX` (`TRX_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=52362 DEFAULT CHARSET=utf8 COMMENT='슬롯 배팅 테이블';

--
-- Table structure for table `OD_HASH_BET_HIST`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `OD_HASH_BET_HIST` (
  `HASH_BET_IDX` bigint(21) unsigned NOT NULL AUTO_INCREMENT COMMENT 'IDX',
  `TYPE` enum('B','W','L') NOT NULL DEFAULT 'B' COMMENT '타입 (B: 배팅, W: 승리, L: 낙첨)',
  `MBR_IDX` bigint(21) unsigned NOT NULL COMMENT '회원 IDX',
  `HLD_MNY` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '보유 머니',
  `BET_MNY` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '배팅 머니',
  `RSLT_MNY` int(10) NOT NULL DEFAULT 0 COMMENT '결과 머니 (배팅 : -, 승리 : +, 취소 : 0)',
  `PRD_TYPE` enum('B','R','H') NOT NULL COMMENT '타입 (B: 바카라, R: 룰렛, H: 하이로우)',
  `WAVE` bigint(21) unsigned NOT NULL COMMENT '게임 회차',
  `REG_DTM` datetime NOT NULL DEFAULT current_timestamp() COMMENT '등록일',
  `MOD_DTM` datetime DEFAULT NULL COMMENT '수정일',
  `IS_CALC` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '정산 유무 (0: 미정산, 1:정산)',
  `CALC_DTM` datetime DEFAULT NULL COMMENT '정산 일시',
  `CH_CODE` varchar(45) DEFAULT NULL COMMENT '채널 : 바카라용',
  `BT_TYPE` varchar(45) DEFAULT NULL COMMENT '배팅타입 : 하이로우',
  `BT_TYPE_LB` varchar(45) DEFAULT NULL COMMENT '베팅타입라벨 : 하이로우',
  PRIMARY KEY (`HASH_BET_IDX`),
  KEY `REG_DTM_INDEX` (`REG_DTM`),
  KEY `MBR_IDX_INDEX` (`MBR_IDX`),
  KEY `WAVE_IDX` (`WAVE`),
  KEY `TYPE_IDX` (`TYPE`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COMMENT='슬롯 배팅 테이블';

--
-- Table structure for table `account`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `account` (
  `idx` int(11) NOT NULL,
  `account_code` varchar(45) DEFAULT NULL,
  `account_name` varchar(45) DEFAULT NULL,
  `bank_id` int(11) DEFAULT 0,
  `bank_code` varchar(45) DEFAULT '',
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='금융기관 기본 코드 테이블 ';

--
-- Table structure for table `account_level_list`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `account_level_list` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `level` int(11) DEFAULT NULL COMMENT '전용 계좌 레벨 (member 레벨) ',
  `account_name` varchar(45) DEFAULT NULL,
  `account_bank` varchar(45) DEFAULT NULL COMMENT '은행명',
  `account_number` varchar(45) DEFAULT NULL COMMENT '계좌 번호 ',
  `display_account_bank` varchar(45) DEFAULT '',
  `bank_id` int(11) DEFAULT 0,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`idx`),
  UNIQUE KEY `UQ_ACCOUNT_LEVEL_01` (`level`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='회원 레벨 별 전용 계좌 목록 ';

--
-- Table structure for table `average_dividend_provider`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `average_dividend_provider` (
  `sports_id` int(11) NOT NULL,
  `provider` varchar(128) NOT NULL COMMENT '제외할 프로바이더',
  PRIMARY KEY (`sports_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='평균베당 제외할 프로바이더';

--
-- Table structure for table `banners`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `banners` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `thumbnail` varchar(1024) DEFAULT '',
  `display_type` tinyint(1) DEFAULT NULL COMMENT '표시 타입 (1: PC, 2: 모바일)',
  `status` tinyint(4) DEFAULT 1 COMMENT '0-미사용, 1-사용',
  `rank` tinyint(1) DEFAULT NULL COMMENT '배너순번',
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`),
  KEY `thumbnail` (`thumbnail`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8 COMMENT='배너 테이블';

--
-- Table structure for table `base_rule`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `base_rule` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `bet_type` int(11) DEFAULT 0 COMMENT '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 ',
  `id` int(11) NOT NULL DEFAULT 0,
  `name` varchar(32) DEFAULT NULL COMMENT '종목명',
  `result_process` varchar(16) NOT NULL COMMENT '결과처리',
  `end_time` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '마감시간',
  `max_dividend` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '최대배당',
  `betting_regulation` text DEFAULT NULL COMMENT '배팅규제',
  PRIMARY KEY (`idx`),
  KEY `idx_bet_type` (`bet_type`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

--
-- Table structure for table `base_rule_2`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `base_rule_2` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(16) DEFAULT NULL COMMENT '구분',
  `contents` text DEFAULT NULL COMMENT '내용',
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Table structure for table `business_type`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `business_type` (
  `id` int(11) NOT NULL DEFAULT 0 COMMENT '1 : 유저,10 : 대총판 , 11 : 총판 , 12 : 하위총판',
  `low_id` int(11) DEFAULT 0,
  `high_id` int(11) DEFAULT NULL,
  `name` varchar(45) DEFAULT '',
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `category_rule`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `category_rule` (
  `category` int(10) unsigned NOT NULL COMMENT '카테고리 (1: 실시간, 2: 스포츠, 3: 미니게임)',
  `sub_category` int(10) unsigned NOT NULL COMMENT '하위 카테고리 (코드 참조)',
  `title` varchar(255) NOT NULL COMMENT '제목',
  `content` mediumtext NOT NULL COMMENT '내용',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp() COMMENT '생성일',
  `update_dt` datetime DEFAULT NULL COMMENT '수정일',
  PRIMARY KEY (`category`,`sub_category`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='종목별 룰';

--
-- Table structure for table `charge_event`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `charge_event` (
  `level` int(11) unsigned NOT NULL COMMENT '레벨 (1 ~ 10)',
  `bonus` int(11) unsigned NOT NULL DEFAULT 1000000 COMMENT '보너스(%)',
  `max_bonus` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`level`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='돌발충전 이벤트';

--
-- Table structure for table `charge_type`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `charge_type` (
  `level` int(11) NOT NULL,
  `charge_type` int(11) NOT NULL COMMENT '0-캐쉬, 1-코인, 2-가상계좌',
  `name` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`level`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='레벨별 충전방식';

--
-- Temporary view structure for view `day_bet_classic`
--

/*!50001 DROP VIEW IF EXISTS `day_bet_classic`*/;
/*!50001 CREATE VIEW `day_bet_classic` AS SELECT 
 1 AS `stype`,
 1 AS `status`,
 1 AS `cnt`,
 1 AS `s_money`,
 1 AS `s_win_money`*/;

--
-- Temporary view structure for view `day_bet_mini`
--

/*!50001 DROP VIEW IF EXISTS `day_bet_mini`*/;
/*!50001 CREATE VIEW `day_bet_mini` AS SELECT 
 1 AS `stype`,
 1 AS `s_money`*/;

--
-- Temporary view structure for view `day_bet_pre`
--

/*!50001 DROP VIEW IF EXISTS `day_bet_pre`*/;
/*!50001 CREATE VIEW `day_bet_pre` AS SELECT 
 1 AS `stype`,
 1 AS `status`,
 1 AS `cnt`,
 1 AS `s_money`,
 1 AS `s_win_money`*/;

--
-- Temporary view structure for view `day_bet_real`
--

/*!50001 DROP VIEW IF EXISTS `day_bet_real`*/;
/*!50001 CREATE VIEW `day_bet_real` AS SELECT 
 1 AS `stype`,
 1 AS `status`,
 1 AS `cnt`,
 1 AS `s_money`,
 1 AS `s_win_money`*/;

--
-- Temporary view structure for view `day_casino_slot_view`
--

/*!50001 DROP VIEW IF EXISTS `day_casino_slot_view`*/;
/*!50001 CREATE VIEW `day_casino_slot_view` AS SELECT 
 1 AS `stype`,
 1 AS `total_bet_money`,
 1 AS `total_win_money`,
 1 AS `total_ing_bet_money`*/;

--
-- Temporary view structure for view `day_ch_ex`
--

/*!50001 DROP VIEW IF EXISTS `day_ch_ex`*/;
/*!50001 CREATE VIEW `day_ch_ex` AS SELECT 
 1 AS `stype`,
 1 AS `status`,
 1 AS `cnt`,
 1 AS `s_money`*/;

--
-- Temporary view structure for view `day_espt_hash_view`
--

/*!50001 DROP VIEW IF EXISTS `day_espt_hash_view`*/;
/*!50001 CREATE VIEW `day_espt_hash_view` AS SELECT 
 1 AS `stype`,
 1 AS `total_bet_money`,
 1 AS `total_win_money`,
 1 AS `total_ing_bet_money`*/;

--
-- Temporary view structure for view `day_now_call_check`
--

/*!50001 DROP VIEW IF EXISTS `day_now_call_check`*/;
/*!50001 CREATE VIEW `day_now_call_check` AS SELECT 
 1 AS `stype`,
 1 AS `status`,
 1 AS `cnt`,
 1 AS `s_money`*/;

--
-- Table structure for table `dist_type`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `dist_type` (
  `id` int(11) NOT NULL DEFAULT 0,
  `name` varchar(45) DEFAULT '',
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Distributor type definition table';

--
-- Table structure for table `dividend_policy`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `dividend_policy` (
  `rank` int(11) unsigned NOT NULL COMMENT '등급 (1 ~ N)',
  `type` tinyint(1) unsigned NOT NULL COMMENT '타입 (1: 프리매치, 2: 실시간)',
  `level` int(11) NOT NULL,
  `amount` int(11) NOT NULL DEFAULT 1000000 COMMENT '등급별 배당 금액',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp() COMMENT '생성일',
  `update_dt` datetime DEFAULT NULL COMMENT '수정일',
  PRIMARY KEY (`rank`,`type`,`level`) USING BTREE,
  KEY `idx_rank` (`rank`),
  KEY `idx_bet_type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='배당 금액 정책 테이블';

--
-- Table structure for table `dividend_policy_innodb`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `dividend_policy_innodb` (
  `rank` int(11) unsigned NOT NULL COMMENT '등급 (1 ~ N)',
  `type` tinyint(1) unsigned NOT NULL COMMENT '타입 (1: 프리매치, 2: 실시간)',
  `level` int(11) NOT NULL,
  `amount` int(11) unsigned NOT NULL DEFAULT 1000000 COMMENT '등급별 배당 금액',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp() COMMENT '생성일',
  `update_dt` datetime DEFAULT NULL COMMENT '수정일',
  PRIMARY KEY (`rank`,`type`,`level`),
  KEY `idx_rank` (`rank`),
  KEY `idx_bet_type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='배당 금액 정책 테이블';

--
-- Table structure for table `events`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `events` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(45) DEFAULT '',
  `thumbnail` varchar(1024) DEFAULT '',
  `detail` text DEFAULT '',
  `status` tinyint(4) DEFAULT 1 COMMENT '0-미사용, 1-사용',
  `del_flag` tinyint(4) DEFAULT 0 COMMENT '0-존재, 1-삭제됨',
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`),
  KEY `thumbnail` (`thumbnail`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8;

--
-- Table structure for table `fixtures_bet_sum`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `fixtures_bet_sum` (
  `member_idx` int(11) NOT NULL,
  `fixture_id` int(11) NOT NULL DEFAULT 0,
  `bet_type` int(11) NOT NULL DEFAULT 0 COMMENT '1 : 스포츠 2 : 실시간 ',
  `sum_bet_money` bigint(20) DEFAULT 0,
  PRIMARY KEY (`fixture_id`,`bet_type`,`member_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='유저들의 경기별 배팅금액을 누적관리하는 테이블이다 스포츠,실시간 각각 관리된다.';

--
-- Table structure for table `fixtures_bet_sum_innodb`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `fixtures_bet_sum_innodb` (
  `member_idx` int(11) NOT NULL,
  `fixture_id` int(11) NOT NULL DEFAULT 0,
  `bet_type` int(11) NOT NULL DEFAULT 0 COMMENT '1 : 스포츠 2 : 실시간 ',
  `sum_bet_money` bigint(20) DEFAULT 0,
  PRIMARY KEY (`fixture_id`,`bet_type`,`member_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='유저들의 경기별 배팅금액을 누적관리하는 테이블이다 스포츠,실시간 각각 관리된다.';

--
-- Table structure for table `help`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `help` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `member_idx` int(11) DEFAULT NULL,
  `admin_idx` int(11) DEFAULT NULL,
  `title` varchar(45) DEFAULT NULL,
  `contents` varchar(45) DEFAULT NULL,
  `status` varchar(45) DEFAULT '대기' COMMENT '‘대기’, ‘완료’',
  `is_delete` varchar(45) DEFAULT NULL,
  `create_datetime` datetime DEFAULT NULL,
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `inspection`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `inspection` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(45) DEFAULT '',
  `contents` varchar(1024) DEFAULT '',
  `start_dt` datetime DEFAULT current_timestamp(),
  `end_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='점검메세지';

--
-- Table structure for table `item`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `item` (
  `id` int(11) NOT NULL DEFAULT 0 COMMENT '고유 아이디',
  `name` varchar(45) DEFAULT NULL COMMENT '아이템 이름',
  `desc` varchar(256) DEFAULT NULL COMMENT '상세설명',
  `type` tinyint(2) DEFAULT 0 COMMENT '1: 환급, 2: 배당up,3:적특 ',
  `value` decimal(6,2) DEFAULT NULL COMMENT '0일 때 적특패치',
  `is_open` varchar(2) DEFAULT 'Y' COMMENT '프론트에 노출여부  Y => 노출 , N => 미노출 ',
  `buy_type` tinyint(2) DEFAULT 0 COMMENT '0 : g_point , 1 : 포인트 2 : 머니,3 : 무료',
  `price` int(11) DEFAULT 0,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='아이템 관리 테이블';

--
-- Table structure for table `join_message`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `join_message` (
  `a_id` varchar(45) NOT NULL COMMENT '작성자',
  `title` varchar(100) DEFAULT NULL,
  `contents` text DEFAULT NULL,
  `update_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`a_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='가입메세지';

--
-- Table structure for table `lsports_bet`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_bet` (
  `bet_id` bigint(20) unsigned NOT NULL COMMENT '배팅 아이디',
  `fixture_id` bigint(20) NOT NULL DEFAULT 0 COMMENT 'lsports_fixtures.fixture_id 참조 ',
  `bet_type` int(11) NOT NULL COMMENT '0:기타, 1:스포츠, 2:실시간',
  `markets_id` int(11) NOT NULL DEFAULT 0 COMMENT 'lsports_markets.id ',
  `providers_id` int(11) DEFAULT NULL COMMENT '공급자 아이디. 공급자는 해당 배팅 정보를 불러오는 원본 정보 제공 업체이다. (대포적으로 bet365)',
  `bet_name` varchar(45) NOT NULL COMMENT '배팅 이름, market_id comment 에 없는 목록은 하지 않는다.  [1:승,첫득점팀 X:무 2:패,첫득점팀, No Goal:첫득점팀 Over:오버 Under: 언더 12:더블찬스 승패 X1:더블찬스 승무 X2:더블찬스 무패 No:양팀득점실패 Yes:양팀득점성공 X/X,1/X,2/X:전반전 및 풀타임 Even:홀 Odd:짝 0-0,1-0,0-1…: 정확한스코어]',
  `bet_status` tinyint(2) NOT NULL DEFAULT 1 COMMENT '배팅 상태 [1:open(배팅가능) 2:Suspended(배팅중단) 3:Settled(결과완료)]',
  `bet_line` varchar(45) DEFAULT NULL COMMENT 'Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
  `bet_base_line` varchar(45) NOT NULL COMMENT 'base_Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
  `bet_settlement` int(11) DEFAULT NULL,
  `bet_price` decimal(7,2) DEFAULT NULL COMMENT '현재 배팅 값 ',
  `admin_bet_status` enum('ON','OFF') DEFAULT 'ON' COMMENT 'ON, OFF',
  `create_dt` datetime DEFAULT current_timestamp() COMMENT 'KST ',
  `update_dt` datetime DEFAULT current_timestamp() COMMENT 'KST',
  `result_p1` int(11) DEFAULT NULL,
  `result_p2` int(11) DEFAULT NULL,
  `result_2_p1` int(11) DEFAULT NULL,
  `result_2_p2` int(11) DEFAULT NULL,
  `bet_price_hit` decimal(7,2) DEFAULT 0.00,
  `passivity_flag` enum('ON','OFF') DEFAULT 'OFF',
  `bet_status_passivity` tinyint(2) DEFAULT NULL,
  `bet_price_passivity` decimal(7,2) DEFAULT NULL,
  `last_update` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`fixture_id`,`bet_type`,`markets_id`,`bet_base_line`,`bet_name`),
  KEY `idx_fix_id` (`fixture_id`),
  KEY `idx_mk_id` (`markets_id`),
  KEY `idx_bt_id` (`bet_type`),
  KEY `idx_b_bsl_id` (`bet_base_line`),
  KEY `idx_b_n` (`bet_name`),
  KEY `idx_bet_id` (`bet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_bet_InnoDB`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_bet_InnoDB` (
  `bet_id` bigint(20) unsigned NOT NULL COMMENT '배팅 아이디',
  `fixture_id` bigint(20) NOT NULL DEFAULT 0 COMMENT 'lsports_fixtures.fixture_id 참조 ',
  `bet_type` int(11) NOT NULL COMMENT '0:기타, 1:스포츠, 2:실시간',
  `markets_id` int(11) NOT NULL DEFAULT 0 COMMENT 'lsports_markets.id ',
  `providers_id` int(11) DEFAULT NULL COMMENT '공급자 아이디. 공급자는 해당 배팅 정보를 불러오는 원본 정보 제공 업체이다. (대포적으로 bet365)',
  `bet_name` varchar(45) NOT NULL DEFAULT '' COMMENT '배팅 이름, market_id comment 에 없는 목록은 하지 않는다.  [1:승,첫득점팀 X:무 2:패,첫득점팀, No Goal:첫득점팀 Over:오버 Under: 언더 12:더블찬스 승패 X1:더블찬스 승무 X2:더블찬스 무패 No:양팀득점실패 Yes:양팀득점성공 X/X,1/X,2/X:전반전 및 풀타임 Even:홀 Odd:짝 0-0,1-0,0-1…: 정확한스코어]',
  `bet_status` tinyint(2) NOT NULL DEFAULT 1 COMMENT '배팅 상태 [1:open(배팅가능) 2:Suspended(배팅중단) 3:Settled(결과완료)]',
  `bet_line` varchar(45) DEFAULT NULL COMMENT 'Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
  `bet_base_line` varchar(45) NOT NULL DEFAULT '' COMMENT 'base_Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
  `bet_settlement` int(11) DEFAULT NULL,
  `bet_price` decimal(7,2) DEFAULT NULL COMMENT '현재 배팅 값 ',
  `admin_bet_status` enum('ON','OFF') DEFAULT 'ON' COMMENT 'ON, OFF',
  `create_dt` datetime DEFAULT current_timestamp() COMMENT 'KST ',
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'KST',
  `result_p1` int(11) DEFAULT NULL,
  `result_p2` int(11) DEFAULT NULL,
  `result_2_p1` int(11) DEFAULT NULL,
  `result_2_p2` int(11) DEFAULT NULL,
  `bet_price_hit` decimal(7,2) DEFAULT 0.00,
  `passivity_flag` enum('ON','OFF') DEFAULT 'OFF',
  `bet_status_passivity` tinyint(2) DEFAULT NULL,
  `bet_price_passivity` decimal(7,2) DEFAULT NULL,
  PRIMARY KEY (`fixture_id`,`bet_type`,`markets_id`,`bet_base_line`,`bet_name`),
  KEY `idx_mk_id` (`markets_id`),
  KEY `idx_bt_id` (`bet_type`),
  KEY `idx_b_bsl_id` (`bet_base_line`),
  KEY `idx_b_n` (`bet_name`),
  KEY `idx_bet_id` (`bet_id`),
  KEY `idx_fix_id` (`fixture_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_bet_backup`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_bet_backup` (
  `bet_id` bigint(20) unsigned NOT NULL COMMENT '배팅 아이디',
  `fixture_id` bigint(20) NOT NULL DEFAULT 0 COMMENT 'lsports_fixtures.fixture_id 참조 ',
  `bet_type` int(11) NOT NULL COMMENT '0:기타, 1:스포츠, 2:실시간',
  `markets_id` int(11) NOT NULL DEFAULT 0 COMMENT 'lsports_markets.id ',
  `providers_id` int(11) DEFAULT NULL COMMENT '공급자 아이디. 공급자는 해당 배팅 정보를 불러오는 원본 정보 제공 업체이다. (대포적으로 bet365)',
  `bet_name` varchar(45) DEFAULT NULL COMMENT '배팅 이름, market_id comment 에 없는 목록은 하지 않는다.  [1:승,첫득점팀 X:무 2:패,첫득점팀, No Goal:첫득점팀 Over:오버 Under: 언더 12:더블찬스 승패 X1:더블찬스 승무 X2:더블찬스 무패 No:양팀득점실패 Yes:양팀득점성공 X/X,1/X,2/X:전반전 및 풀타임 Even:홀 Odd:짝 0-0,1-0,0-1…: 정확한스코어]',
  `bet_status` tinyint(2) NOT NULL DEFAULT 1 COMMENT '배팅 상태 [1:open(배팅가능) 2:Suspended(배팅중단) 3:Settled(결과완료)]',
  `bet_line` varchar(45) DEFAULT NULL COMMENT 'Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
  `bet_base_line` varchar(45) DEFAULT NULL COMMENT 'base_Line (마켓이 핸디캡/언더오버인 경우  해당값으로 정산 결과를 반영, front view 에서도 일부 값을 표현하는데 사용)',
  `bet_settlement` int(11) DEFAULT NULL,
  `bet_price` decimal(7,2) DEFAULT NULL COMMENT '현재 배팅 값 ',
  `admin_bet_status` enum('ON','OFF') DEFAULT 'ON' COMMENT 'ON, OFF',
  `create_dt` datetime DEFAULT current_timestamp() COMMENT 'KST ',
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'KST',
  `result_p1` int(11) DEFAULT NULL,
  `result_p2` int(11) DEFAULT NULL,
  `result_2_p1` int(11) DEFAULT NULL,
  `result_2_p2` int(11) DEFAULT NULL,
  `bet_price_hit` decimal(7,2) DEFAULT 0.00,
  `passivity_flag` enum('ON','OFF') DEFAULT 'OFF',
  `bet_status_passivity` tinyint(2) DEFAULT NULL,
  `bet_price_passivity` decimal(7,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_bookmaker`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_bookmaker` (
  `id` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `lang` varchar(4) DEFAULT NULL,
  `is_use` tinyint(4) DEFAULT 0,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_is_use` (`is_use`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_fixtures`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_fixtures` (
  `fixture_id` int(11) NOT NULL COMMENT 'lsports api 에서 조회한 fixtures_id 값 ',
  `bet_type` int(11) NOT NULL DEFAULT 0 COMMENT '0:기타, 1:스포츠, 2:실시간',
  `fixture_sport_id` int(11) NOT NULL COMMENT 'lsports_sports 테이블 참조 ',
  `fixture_location_id` int(11) NOT NULL COMMENT 'lsports_location 테이블 참조 ',
  `fixture_league_id` int(11) NOT NULL COMMENT 'lsports_league 테이블 참조 ',
  `fixture_start_date` datetime NOT NULL COMMENT '경기 시작 시간  _ KST 기준 ',
  `fixture_status` varchar(2) NOT NULL COMMENT '현재 경기 상태 \n1	Not started yet	\n2	In progress	    \n3	Finished	    \n4	Cancelled	    \n5	Postponed	    \n6	Interrupted	    \n7	Abandoned	    \n8	Coverage lost	\n9	About to start	',
  `fixture_participants_1_id` int(11) DEFAULT NULL,
  `fixture_participants_2_id` int(11) DEFAULT NULL,
  `livescore` varchar(16384) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp() COMMENT 'KST',
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'KST',
  `live_results_p1` int(11) DEFAULT NULL,
  `live_results_p2` int(11) DEFAULT NULL,
  `m_live_results_p1` int(11) DEFAULT NULL,
  `m_live_results_p2` int(11) DEFAULT NULL,
  `admin_bet_status` enum('ON','OFF','RETRY') DEFAULT 'ON',
  `display_status` tinyint(2) DEFAULT 1 COMMENT '1. 베팅가능=> status 1,9 => 픽스처정보에서 배팅가능은 경기시간에서 -1440분을 뺀 시간부터 -1분까지의 경기\\n2. 베팅마감 =>status 2,5,6,7,8  => 경기시간에서 59초를 뺀 경기\\n3. 종료 => status 3,4  =>  결과처리된 경기 또는 4,5,6,7이 들어올시 (경기상세정보에서 적특표기색상으로 해주세요 노란색)\\n',
  `break_dt` datetime DEFAULT NULL,
  `passivity_flag` enum('ON','OFF') DEFAULT 'OFF',
  `fixture_start_date_passivity` datetime DEFAULT NULL,
  `display_status_passivity` tinyint(2) DEFAULT NULL,
  PRIMARY KEY (`fixture_id`,`bet_type`),
  KEY `idx_std` (`fixture_start_date`),
  KEY `idx_fix_id` (`fixture_id`),
  KEY `idx_bet_type` (`bet_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_fixtures_innodb`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_fixtures_innodb` (
  `fixture_id` int(11) NOT NULL COMMENT 'lsports api 에서 조회한 fixtures_id 값 ',
  `bet_type` int(11) NOT NULL DEFAULT 0 COMMENT '0:기타, 1:스포츠, 2:실시간',
  `fixture_sport_id` int(11) NOT NULL COMMENT 'lsports_sports 테이블 참조 ',
  `fixture_location_id` int(11) NOT NULL COMMENT 'lsports_location 테이블 참조 ',
  `fixture_league_id` int(11) NOT NULL COMMENT 'lsports_league 테이블 참조 ',
  `fixture_start_date` datetime NOT NULL COMMENT '경기 시작 시간  _ KST 기준 ',
  `fixture_status` varchar(2) NOT NULL COMMENT '현재 경기 상태 \n1	Not started yet	\n2	In progress	    \n3	Finished	    \n4	Cancelled	    \n5	Postponed	    \n6	Interrupted	    \n7	Abandoned	    \n8	Coverage lost	\n9	About to start	',
  `fixture_participants_1_id` int(11) DEFAULT NULL,
  `fixture_participants_2_id` int(11) DEFAULT NULL,
  `livescore` varchar(16384) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp() COMMENT 'KST',
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'KST',
  `live_results_p1` int(11) DEFAULT NULL,
  `live_results_p2` int(11) DEFAULT NULL,
  `m_live_results_p1` int(11) DEFAULT NULL,
  `m_live_results_p2` int(11) DEFAULT NULL,
  `admin_bet_status` enum('ON','OFF','RETRY') DEFAULT 'ON',
  `display_status` int(11) DEFAULT 1 COMMENT '1. 베팅가능=> status 1,9 => 픽스처정보에서 배팅가능은 경기시간에서 -1440분을 뺀 시간부터 -1분까지의 경기\n2. 베팅마감 =>status 2,5,6,7,8  => 경기시간에서 59초를 뺀 경기\n3. 종료 => status 3,4  =>  결과처리된 경기 또는 4,5,6,7이 들어올시 (경기상세정보에서 적특표기색상으로 해주세요 노란색)\n',
  `break_dt` datetime DEFAULT NULL,
  PRIMARY KEY (`fixture_id`,`bet_type`),
  KEY `idx_std` (`fixture_start_date`),
  KEY `idx_fix_id` (`fixture_id`),
  KEY `idx_bet_type` (`bet_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_game_type`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_game_type` (
  `id` int(11) NOT NULL DEFAULT 0,
  `name` varchar(20) NOT NULL DEFAULT '',
  `ko_name` varchar(20) DEFAULT NULL,
  `status` enum('ON','OFF') NOT NULL DEFAULT 'ON',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `update_dt` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_leagues`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_leagues` (
  `id` int(11) NOT NULL DEFAULT 0,
  `bet_type` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL COMMENT '사용자에게 보여지는 이름 ',
  `location_id` int(11) DEFAULT NULL,
  `sport_id` int(11) DEFAULT NULL,
  `season` varchar(45) DEFAULT NULL,
  `lang` varchar(4) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  `is_use` tinyint(4) DEFAULT 2 COMMENT '리그 사용 여부 0 : 미사용 1 : 사용 2 : 대기 ',
  `deduction_refund_rate` decimal(5,2) DEFAULT 0.00,
  `is_margin_refund` int(11) DEFAULT 0,
  `dividend_rank` int(10) unsigned NOT NULL DEFAULT 1 COMMENT '배당금액 등급',
  `my_league` int(11) DEFAULT 0,
  `quarter_time` int(11) DEFAULT NULL,
  `image_path` varchar(200) DEFAULT '',
  `input_refund_rate` decimal(5,2) DEFAULT 0.00,
  PRIMARY KEY (`id`,`bet_type`),
  KEY `id` (`id`),
  KEY `ch_idx` (`id`,`location_id`,`sport_id`,`is_use`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_leagues_innodb`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_leagues_innodb` (
  `id` int(11) NOT NULL DEFAULT 0,
  `bet_type` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL COMMENT '사용자에게 보여지는 이름 ',
  `location_id` int(11) DEFAULT NULL,
  `sport_id` int(11) DEFAULT NULL,
  `season` varchar(45) DEFAULT NULL,
  `lang` varchar(4) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  `is_use` tinyint(4) DEFAULT 2 COMMENT '리그 사용 여부 0 : 미사용 1 : 사용 2 : 대기 ',
  `deduction_refund_rate` decimal(5,2) DEFAULT 0.00,
  `is_margin_refund` int(11) DEFAULT 0,
  `dividend_rank` int(10) unsigned NOT NULL DEFAULT 1 COMMENT '배당금액 등급',
  `my_league` int(11) DEFAULT 0,
  `quarter_time` int(11) DEFAULT NULL,
  `image_path` varchar(200) DEFAULT '',
  `input_refund_rate` decimal(5,2) DEFAULT 0.00,
  PRIMARY KEY (`id`,`bet_type`),
  KEY `idx_sp_id` (`sport_id`),
  KEY `id` (`id`),
  KEY `ch_idx` (`id`,`location_id`,`sport_id`,`is_use`),
  KEY `idx_use` (`is_use`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_locations`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_locations` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) DEFAULT NULL,
  `name` varchar(45) DEFAULT NULL,
  `name_en` varchar(45) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL COMMENT '사용자에게 보여지는 이름 ',
  `lang` varchar(45) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  `is_use` tinyint(4) DEFAULT 1 COMMENT '지역 사용 여부 ',
  `image_path` varchar(200) DEFAULT NULL COMMENT '지역 이미지 ',
  PRIMARY KEY (`idx`),
  KEY `id_index` (`id`),
  KEY `idx_name` (`name`),
  KEY `idx_isuse` (`is_use`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=256 DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_locations_innodb`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_locations_innodb` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) DEFAULT NULL,
  `name` varchar(45) DEFAULT NULL,
  `name_en` varchar(45) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL COMMENT '사용자에게 보여지는 이름 ',
  `lang` varchar(45) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  `is_use` tinyint(4) DEFAULT 1 COMMENT '지역 사용 여부 ',
  `image_path` varchar(200) DEFAULT NULL COMMENT '지역 이미지 ',
  PRIMARY KEY (`idx`),
  KEY `id_index` (`id`),
  KEY `idx_name` (`name`),
  KEY `idx_isuse` (`is_use`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=511 DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_magin_range`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_magin_range` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `type` int(11) DEFAULT 0,
  `min` decimal(5,2) NOT NULL DEFAULT 0.00,
  `max` decimal(5,2) NOT NULL DEFAULT 0.00,
  `value` decimal(5,2) NOT NULL DEFAULT 0.00,
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_markets`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_markets` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) DEFAULT NULL,
  `bet_group` tinyint(3) unsigned DEFAULT 0 COMMENT '0:기타, 1:스포츠, 2:실시간',
  `sport_id` int(11) DEFAULT NULL,
  `name` varchar(45) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL,
  `lang` varchar(4) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  `is_delete` tinyint(4) DEFAULT 0 COMMENT '1: 삭제 ',
  `main_book_maker` int(11) DEFAULT NULL,
  `sub_book_maker` int(11) DEFAULT NULL,
  `menu` int(11) DEFAULT NULL COMMENT '1: 메인 2 : 오버언더 : 3: 핸디캡 4: 그외 5:쿼터 6: 하프 ',
  `limit_bet_price` decimal(7,2) DEFAULT 0.00,
  `max_bet_price` decimal(7,2) DEFAULT 0.00,
  `not_display_period` int(11) DEFAULT 0 COMMENT '해당 피어리어드 부터 안보이게 처리 not_display_time 컬럼의 시간값 사용 ',
  `not_display_time` int(11) DEFAULT 0 COMMENT 'not_display_period 의값을 기준으로 해당 퍼리어드에서 몇분지났을때 시간 ',
  `not_display_score` int(11) DEFAULT 0 COMMENT '해당 점수로 안보이게 처리 not_display_score_team_type 컬럼의 데이터에 따라 홈,원정,구분없음으로 처리를 한다.',
  `not_display_score_team_type` int(11) DEFAULT 0 COMMENT '0 :  none 1 :  홈팀 2: 원정 3: 구분없음 ',
  `display_order` int(11) DEFAULT 0 COMMENT '프론트 정렬 순서',
  `is_main_menu` tinyint(4) DEFAULT 0 COMMENT '해당 마켓이 메인메뉴에 노출되는지 여부 0 : 비노출 1: 노출 ',
  `main_display_order` int(11) DEFAULT 0,
  PRIMARY KEY (`idx`),
  KEY `id_index` (`id`),
  KEY `g_d_index` (`id`,`bet_group`,`is_delete`,`name`,`sport_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2950 DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_markets_innodb`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_markets_innodb` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) DEFAULT NULL,
  `bet_group` tinyint(3) unsigned DEFAULT 0 COMMENT '0:기타, 1:스포츠, 2:실시간',
  `sport_id` int(11) DEFAULT NULL,
  `name` varchar(45) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL,
  `lang` varchar(4) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  `is_delete` tinyint(4) DEFAULT 0 COMMENT '1: 삭제 ',
  `main_book_maker` int(11) DEFAULT NULL,
  `sub_book_maker` int(11) DEFAULT NULL,
  `menu` int(11) DEFAULT NULL COMMENT '1: 메인 2 : 오버언더 : 3: 핸디캡 4: 그외 5:쿼터 6: 하프 ',
  `limit_bet_price` decimal(7,2) DEFAULT 0.00,
  `max_bet_price` decimal(7,2) DEFAULT 0.00,
  `not_display_period` int(11) DEFAULT 0 COMMENT '해당 피어리어드 부터 안보이게 처리 not_display_time 컬럼의 시간값 사용 ',
  `not_display_time` int(11) DEFAULT 0 COMMENT 'not_display_period 의값을 기준으로 해당 퍼리어드에서 몇분지났을때 시간 ',
  `not_display_score` int(11) DEFAULT 0 COMMENT '해당 점수로 안보이게 처리 not_display_score_team_type 컬럼의 데이터에 따라 홈,원정,구분없음으로 처리를 한다.',
  `not_display_score_team_type` int(11) DEFAULT 0 COMMENT '0 :  none 1 :  홈팀 2: 원정 3: 구분없음 ',
  `display_order` int(11) DEFAULT 0 COMMENT '프론트 정렬 순서',
  `is_main_menu` tinyint(4) DEFAULT 0 COMMENT '해당 마켓이 메인메뉴에 노출되는지 여부 0 : 비노출 1: 노출 ',
  `main_display_order` int(11) DEFAULT 0,
  PRIMARY KEY (`idx`),
  KEY `id_index` (`id`),
  KEY `g_d_index` (`id`,`bet_group`,`is_delete`,`name`,`sport_id`),
  KEY `idx_g_d` (`bet_group`,`is_delete`,`sport_id`,`main_book_maker`)
) ENGINE=InnoDB AUTO_INCREMENT=3385 DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_participant`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_participant` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `fp_id` int(11) NOT NULL COMMENT 'lsports_fixtures. fixture_participants_1(2)_id 와 매칭되는 값 ',
  `sports_id` int(11) DEFAULT NULL COMMENT 'lsports_sports.id',
  `location_id` int(11) DEFAULT NULL COMMENT 'lsports_locations.id',
  `league_id` int(11) DEFAULT NULL COMMENT 'lsports_leagues.id',
  `team_name` varchar(100) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL COMMENT '사용자들에게 보여지는 값 ',
  `is_new` tinyint(4) DEFAULT 1,
  PRIMARY KEY (`idx`,`fp_id`),
  UNIQUE KEY `fp_id_UNIQUE` (`fp_id`)
) ENGINE=InnoDB AUTO_INCREMENT=339376715 DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_participant_innodb`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_participant_innodb` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `fp_id` int(11) NOT NULL COMMENT 'lsports_fixtures. fixture_participants_1(2)_id 와 매칭되는 값 ',
  `sports_id` int(11) DEFAULT NULL COMMENT 'lsports_sports.id',
  `location_id` int(11) DEFAULT NULL COMMENT 'lsports_locations.id',
  `league_id` int(11) DEFAULT NULL COMMENT 'lsports_leagues.id',
  `team_name` varchar(100) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL COMMENT '사용자들에게 보여지는 값 ',
  `is_new` tinyint(4) DEFAULT 1,
  PRIMARY KEY (`idx`,`fp_id`),
  UNIQUE KEY `fp_id_UNIQUE` (`fp_id`),
  KEY `idx_is_new` (`is_new`)
) ENGINE=InnoDB AUTO_INCREMENT=335698430 DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_refund_rate_market`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_refund_rate_market` (
  `sports_id` int(11) NOT NULL,
  `league_id` int(11) NOT NULL,
  `market_id` int(11) NOT NULL,
  `bet_type` int(11) NOT NULL,
  `refund_rate` decimal(5,2) DEFAULT 0.00,
  `deduction_refund_rate` decimal(5,2) DEFAULT 0.00,
  `is_margin_refund` int(11) DEFAULT 0,
  PRIMARY KEY (`market_id`,`sports_id`,`league_id`,`bet_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_sports`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_sports` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) DEFAULT NULL,
  `name` varchar(45) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL,
  `bet_type` int(11) DEFAULT NULL,
  `lang` varchar(4) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` varchar(45) DEFAULT NULL,
  `is_delete` tinyint(4) DEFAULT 0,
  `is_use` tinyint(4) DEFAULT 1,
  `image_path` varchar(90) DEFAULT '',
  `input_refund_rate` decimal(5,2) DEFAULT 0.00,
  `display_order` int(11) DEFAULT 0,
  `deduction_refund_rate` decimal(5,2) DEFAULT 0.00,
  `is_margin_refund` int(11) DEFAULT 0,
  PRIMARY KEY (`idx`),
  KEY `id_idx` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=178 DEFAULT CHARSET=utf8;

--
-- Table structure for table `lsports_sports_innodb`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `lsports_sports_innodb` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `id` int(11) DEFAULT NULL,
  `name` varchar(45) DEFAULT NULL,
  `display_name` varchar(45) DEFAULT NULL,
  `bet_type` int(11) DEFAULT NULL,
  `lang` varchar(4) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` varchar(45) DEFAULT NULL,
  `is_delete` tinyint(4) DEFAULT 0,
  `is_use` tinyint(4) DEFAULT 1,
  `image_path` varchar(90) DEFAULT '',
  `input_refund_rate` decimal(5,2) DEFAULT 0.00,
  `display_order` int(11) DEFAULT 0,
  `deduction_refund_rate` decimal(5,2) DEFAULT 0.00,
  `is_margin_refund` int(11) DEFAULT 0,
  PRIMARY KEY (`idx`),
  KEY `id_idx` (`id`),
  KEY `use_type` (`is_use`,`bet_type`),
  KEY `idx_type` (`bet_type`)
) ENGINE=InnoDB AUTO_INCREMENT=294 DEFAULT CHARSET=utf8;

--
-- Table structure for table `member`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `id` varchar(45) NOT NULL COMMENT '회원가입시 입력하는 아이디 ',
  `is_exchange` int(11) DEFAULT 0,
  `charge_first_per` int(11) DEFAULT 0,
  `password` varchar(200) DEFAULT NULL,
  `login_key` varchar(200) DEFAULT NULL,
  `nick_name` varchar(45) DEFAULT NULL COMMENT '닉네임 ',
  `u_business` tinyint(4) DEFAULT 1 COMMENT '회원 구분, 1:일반 10: 대총판,11 총판,12 하위 \\\\n',
  `money` int(11) DEFAULT 0 COMMENT '충전한 현금 ',
  `point` int(11) DEFAULT 0 COMMENT '게임 후 정산된 포인트. 환전할 수도 있고 배팅도 할수 있다.',
  `betting_p` int(11) DEFAULT 0 COMMENT '낙첨포인트',
  `call` varchar(45) DEFAULT NULL COMMENT '전화 번호',
  `is_recommend` enum('Y','N') DEFAULT 'N' COMMENT '추천, Y:가능, N:불가능',
  `status` tinyint(4) DEFAULT 11 COMMENT '회원상태 ( 1:정상, 2:정지, 3:탈퇴, 11:승인 대기회원 )',
  `level` int(11) DEFAULT 1,
  `auto_level` enum('Y','N') DEFAULT 'Y' COMMENT '자동렙업, Y:on, N:off',
  `last_login` datetime DEFAULT NULL COMMENT '최종 로그인',
  `last_page` varchar(45) DEFAULT NULL COMMENT '마지막 접속 위치 ',
  `MICRO` varchar(10) DEFAULT NULL COMMENT '아직은 사용하지 않을 예정 \n마이크로게이밍과 아시아게이밍이라는 온라인카지노업체에 api게임 연동시 사용',
  `AG` varchar(10) DEFAULT NULL COMMENT '아직은 사용하지 않을 예정 \n마이크로게이밍과 아시아게이밍이라는 온라인카지노업체에 api게임 연동시 사용',
  `recommend_code` varchar(45) DEFAULT NULL COMMENT '추천인 코드',
  `recommend_member` int(11) DEFAULT 0 COMMENT '사용자 입력 추천인 회원 idx ',
  `recommend_code_dt` datetime DEFAULT NULL,
  `account_number` varchar(45) DEFAULT NULL COMMENT '계좌 번호 ',
  `account_name` varchar(45) DEFAULT NULL COMMENT '계좌 소유주 이름 ',
  `account_bank` varchar(45) DEFAULT NULL COMMENT '계좌 은행 ',
  `exchange_password` varchar(200) DEFAULT NULL COMMENT '환전 비밀 번호 ',
  `is_monitor` enum('Y','N') DEFAULT 'N' COMMENT '일반 모니터링 Y:on, N:off',
  `is_monitor_charge` enum('Y','N') DEFAULT 'N' COMMENT '충전 모니터링 Y:on, N:off',
  `is_monitor_security` enum('Y','N') DEFAULT 'N' COMMENT '보안 모니터링 Y:on, N:off',
  `is_monitor_bet` enum('Y','N') DEFAULT 'N' COMMENT '중복베팅 모니터링 Y:on, N:off',
  `dis_id` varchar(45) DEFAULT NULL COMMENT '소속 총판 ID',
  `dis_line_id` varchar(45) DEFAULT NULL COMMENT '소속 총판라인 ID',
  `reg_time` timestamp NULL DEFAULT current_timestamp() COMMENT '등록일',
  `session_key` varchar(100) DEFAULT NULL,
  `random_code` varchar(45) DEFAULT NULL,
  `reg_first_charge` int(11) DEFAULT 0,
  `is_sound` enum('Y','N') DEFAULT 'Y',
  `access_token` varchar(512) DEFAULT '',
  `transaction_key` varchar(45) DEFAULT '',
  `is_coin_guid` enum('Y','N') DEFAULT 'N',
  `coin_password` varchar(200) DEFAULT '',
  `channel` int(11) DEFAULT 0,
  `check_login` datetime DEFAULT current_timestamp(),
  `leave_time` datetime DEFAULT NULL,
  `is_betting_slip` enum('ON','OFF') DEFAULT 'OFF',
  `birth` varchar(8) DEFAULT NULL COMMENT '생년월일',
  `mobile_carrier` tinyint(4) DEFAULT 0 COMMENT '0-sk, 1-kt, 2-lg, 3-skt알뜰, 5-kt알뜰, 6-lg알뜰',
  `g_money` int(11) DEFAULT 0,
  `is_set_day_nt_gm` enum('Y','N') DEFAULT 'N' COMMENT '게시판 활동시 gm 을 하루에 한번 받았는지 체크해준다.',
  `a_ip` varchar(30) DEFAULT NULL,
  `a_before_ip` varchar(30) DEFAULT NULL,
  `keep_login_access_token` varchar(50) DEFAULT NULL,
  `info_change_dt` datetime DEFAULT NULL,
  `dist_type` tinyint(4) DEFAULT 0 COMMENT '총판 유형 : 0 기본, 1: 죽장, 2: 롤링, 3: 배너 ',
  PRIMARY KEY (`idx`),
  UNIQUE KEY `id_UNIQUE` (`id`),
  UNIQUE KEY `nick_name_UNIQUE` (`nick_name`),
  KEY `rc_idx` (`recommend_member`),
  KEY `id` (`id`),
  KEY `dis_id` (`dis_id`),
  KEY `idx_level` (`idx`,`level`)
) ENGINE=InnoDB AUTO_INCREMENT=1157 DEFAULT CHARSET=utf8 COMMENT='회원 테이블';

--
-- Table structure for table `member_bet`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_bet` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `u_key` varchar(64) DEFAULT NULL COMMENT 't_log_cash 연동 키 ',
  `member_idx` int(11) DEFAULT NULL COMMENT '유저 아이디 -MemberModel',
  `bet_type` int(11) DEFAULT 0 COMMENT '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 7: 카지노 8: 슬롯',
  `bet_status` int(11) DEFAULT 1 COMMENT '1: 게임 결과 전\\\\\\\\n2: 적중 - 정산 전 \\\\\\\\n3: 적중 - 정산 완료\\\\\\\\n4: 적중 실패 \\\\\\\\n5: 취소 , \\\\\\\\n 6:적특',
  `game_type` int(11) DEFAULT 0,
  `bonus_price` double DEFAULT 1 COMMENT '3폴더, 5폴더 이상 보너스 처리 위함. 정산시 입력 됨.',
  `total_bet_money` int(11) DEFAULT NULL COMMENT '총 배팅 금액',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `update_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  `calculate_dt` datetime DEFAULT NULL COMMENT '정산처리 시간',
  `folder_type` enum('S','D') DEFAULT NULL COMMENT 'S 싱글 D : 다폴더',
  `round` int(11) DEFAULT 0,
  `take_money` int(11) DEFAULT 0,
  `is_open` tinyint(4) DEFAULT 0 COMMENT '0-운영자 미확인, 1-운영자 확인',
  `is_hide` tinyint(4) DEFAULT 0 COMMENT '0-유저 보이기, 1-유저 숨기기',
  `take_point` int(11) DEFAULT 0,
  `recom_take_point` int(11) DEFAULT 0,
  `cancel_type` tinyint(4) DEFAULT 0 COMMENT '취소타입(0-유저, 1-관리자)',
  `passivity_hit_flag` tinyint(4) DEFAULT 0 COMMENT '0 : 자동 적특 1: 수동적특 ',
  `is_betting_slip` enum('ON','OFF') DEFAULT 'OFF',
  `item_idx` bigint(20) DEFAULT 0 COMMENT 'member_item 의 고유키값 ',
  `flag_bet_sum` varchar(2) DEFAULT 'P' COMMENT 'P : 베팅 , M : 낙첨시 롤백',
  `item_bonus_price` double DEFAULT 0,
  `bet_count` tinyint(4) DEFAULT 0,
  `is_classic` enum('ON','OFF') DEFAULT 'OFF',
  PRIMARY KEY (`idx`),
  KEY `create_dt` (`create_dt`),
  KEY `cal_dt` (`calculate_dt`),
  KEY `idx_member_idx` (`member_idx`),
  KEY `idx_bt` (`bet_type`)
) ENGINE=InnoDB AUTO_INCREMENT=12700 DEFAULT CHARSET=utf8 COMMENT='배팅 내역 ';

--
-- Table structure for table `member_bet_bakup`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_bet_bakup` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `u_key` varchar(64) DEFAULT NULL COMMENT 't_log_cash 연동 키 ',
  `member_idx` int(11) DEFAULT NULL COMMENT '유저 아이디 -MemberModel',
  `bet_type` int(11) DEFAULT 0 COMMENT '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 7: 카지노 8: 슬롯',
  `bet_status` int(11) DEFAULT 1 COMMENT '1: 게임 결과 전\\\\\\\\n2: 적중 - 정산 전 \\\\\\\\n3: 적중 - 정산 완료\\\\\\\\n4: 적중 실패 \\\\\\\\n5: 취소 , \\\\\\\\n 6:적특',
  `game_type` int(11) DEFAULT 0,
  `bonus_price` double DEFAULT 1 COMMENT '3폴더, 5폴더 이상 보너스 처리 위함. 정산시 입력 됨.',
  `total_bet_money` int(11) DEFAULT NULL COMMENT '총 배팅 금액',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `update_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  `calculate_dt` datetime DEFAULT NULL COMMENT '정산처리 시간',
  `folder_type` enum('S','D') DEFAULT NULL COMMENT 'S 싱글 D : 다폴더',
  `round` int(11) DEFAULT 0,
  `take_money` int(11) DEFAULT 0,
  `is_open` tinyint(4) DEFAULT 0 COMMENT '0-운영자 미확인, 1-운영자 확인',
  `is_hide` tinyint(4) DEFAULT 0 COMMENT '0-유저 보이기, 1-유저 숨기기',
  `take_point` int(11) DEFAULT 0,
  `recom_take_point` int(11) DEFAULT 0,
  `cancel_type` tinyint(4) DEFAULT 0 COMMENT '취소타입(0-유저, 1-관리자)',
  `passivity_hit_flag` tinyint(4) DEFAULT 0 COMMENT '0 : 자동 적특 1: 수동적특 ',
  PRIMARY KEY (`idx`),
  KEY `create_dt` (`create_dt`),
  KEY `cal_dt` (`calculate_dt`),
  KEY `idx_member_idx` (`member_idx`),
  KEY `idx_bt` (`bet_type`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='배팅 내역 ';

--
-- Table structure for table `member_bet_detail`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_bet_detail` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `bet_idx` int(11) DEFAULT NULL COMMENT '배팅 아이디 -MemberBetModel',
  `ls_bet_id` bigint(20) DEFAULT NULL COMMENT 'LS 배팅 아이디 -LSportsBetModel',
  `ls_fixture_id` int(11) DEFAULT NULL,
  `ls_markets_id` int(11) DEFAULT NULL,
  `ls_markets_name` varchar(45) DEFAULT NULL,
  `ls_markets_base_line` varchar(45) DEFAULT NULL,
  `bet_type` int(11) DEFAULT 0,
  `bet_price` double DEFAULT NULL COMMENT '배팅 당시 !! 사용자가 배팅 한 !! 마켓에 대한 배당률',
  `bet_status` int(11) DEFAULT 1 COMMENT '1: 게임 결과 전\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n2: 적중 - 정산 전\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n3: 적중 - 정산 완료\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n4: 적중 실패  \\\\\\\\\\\\\\\\n5: 취소, \\\\\\\\\\\\\\\\n 6:적특',
  `bet_name` varchar(50) DEFAULT '',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `update_dt` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `fixture_start_date` datetime DEFAULT current_timestamp(),
  `fixture_sport_id` int(11) DEFAULT 0,
  `fixture_location_id` int(11) DEFAULT 0,
  `fixture_league_id` int(11) DEFAULT 0,
  `fixture_participants_1_id` int(11) DEFAULT 0,
  `fixture_participants_2_id` int(11) DEFAULT 0,
  `result_score` mediumtext DEFAULT '',
  `passivity_hit_flag` tinyint(4) DEFAULT 0 COMMENT '0 : 자동적특  1 : 수동적특',
  PRIMARY KEY (`idx`),
  KEY `index_bet_id` (`bet_idx`),
  KEY `bet_id` (`ls_bet_id`),
  KEY `index_fix_id` (`ls_fixture_id`,`bet_type`,`bet_status`),
  KEY `idx_cr_dt` (`create_dt`)
) ENGINE=InnoDB AUTO_INCREMENT=37712 DEFAULT CHARSET=utf8 COMMENT='배팅 내역 상세';

--
-- Table structure for table `member_bet_detail_backup`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_bet_detail_backup` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `bet_idx` int(11) DEFAULT NULL COMMENT '배팅 아이디 -MemberBetModel',
  `ls_bet_id` bigint(20) DEFAULT NULL COMMENT 'LS 배팅 아이디 -LSportsBetModel',
  `ls_fixture_id` int(11) DEFAULT NULL,
  `ls_markets_id` int(11) DEFAULT NULL,
  `ls_markets_name` varchar(45) DEFAULT NULL,
  `ls_markets_base_line` varchar(45) DEFAULT NULL,
  `bet_type` int(11) DEFAULT 0,
  `bet_price` double DEFAULT NULL COMMENT '배팅 당시 !! 사용자가 배팅 한 !! 마켓에 대한 배당률',
  `bet_status` int(11) DEFAULT 1 COMMENT '1: 게임 결과 전\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n2: 적중 - 정산 전\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n3: 적중 - 정산 완료\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n4: 적중 실패  \\\\\\\\\\\\\\\\n5: 취소, \\\\\\\\\\\\\\\\n 6:적특',
  `bet_name` varchar(50) DEFAULT '',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `update_dt` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `fixture_sport_id` int(11) DEFAULT 0,
  `fixture_location_id` int(11) DEFAULT 0,
  `fixture_league_id` int(11) DEFAULT 0,
  `fixture_participants_1_id` int(11) DEFAULT 0,
  `fixture_participants_2_id` int(11) DEFAULT 0,
  `result_score` mediumtext DEFAULT '',
  `passivity_hit_flag` tinyint(4) DEFAULT 0 COMMENT '0 : 자동적특  1 : 수동적특',
  PRIMARY KEY (`idx`),
  KEY `index_bet_id` (`bet_idx`),
  KEY `bet_id` (`ls_bet_id`),
  KEY `index_fix_id` (`ls_fixture_id`,`bet_type`,`bet_status`),
  KEY `idx_cr_dt` (`create_dt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='배팅 내역 상세';

--
-- Table structure for table `member_game_type`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_game_type` (
  `member_idx` int(11) NOT NULL DEFAULT 0,
  `game_type` int(11) NOT NULL DEFAULT 0,
  `status` enum('ON','OFF') NOT NULL DEFAULT 'ON',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `update_dt` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`member_idx`,`game_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `member_ip_block_history`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_ip_block_history` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `admin_id` varchar(50) DEFAULT NULL,
  `member_idx` int(11) DEFAULT NULL,
  `login_history_idx` int(11) DEFAULT NULL,
  `ip` varchar(45) DEFAULT NULL,
  `country` varchar(45) DEFAULT NULL,
  `memo` varchar(45) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`),
  UNIQUE KEY `UQ_IP_BLOCK_U01` (`ip`),
  KEY `idx_create` (`create_dt`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Table structure for table `member_item`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_item` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'idx',
  `member_idx` int(11) DEFAULT 0 COMMENT '회원 idx',
  `item_id` int(11) DEFAULT 0 COMMENT '구매 아이템 id',
  `item_value` decimal(6,2) DEFAULT 0.00 COMMENT '구매 당시 value, 0일 때 적특패치',
  `status` tinyint(2) DEFAULT 0 COMMENT '0 : 미사용 1 : 사용 ,2: 기간마감 ',
  `create_dt` datetime DEFAULT current_timestamp() COMMENT '등록날짜',
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '수정날짜',
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='유저 보유 아이템';

--
-- Table structure for table `member_level_up`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_level_up` (
  `level` int(11) NOT NULL DEFAULT 0,
  `charge` int(11) DEFAULT 0,
  `exchange` int(11) DEFAULT 0,
  `calcurate` int(11) DEFAULT 0,
  `charge_count` int(11) DEFAULT 0,
  `nonDepositDatePeriod` int(11) DEFAULT 0,
  `flag` enum('ON','OFF') DEFAULT 'ON',
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `create_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`level`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `member_login_history`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_login_history` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `member_idx` int(11) DEFAULT NULL,
  `ip` varchar(45) DEFAULT NULL,
  `country` varchar(45) DEFAULT NULL,
  `block` varchar(45) DEFAULT NULL,
  `login_domain` varchar(100) DEFAULT NULL COMMENT '접속 도메인',
  `agent` text DEFAULT NULL COMMENT 'user agent 정보',
  `agent_hash` varchar(50) DEFAULT NULL,
  `agent_device` varchar(50) DEFAULT NULL COMMENT 'user agent 정보, 디바이스',
  `agent_browser` varchar(50) DEFAULT NULL COMMENT 'user agent 정보, 브라우저',
  `login_yn` enum('Y','N') DEFAULT NULL COMMENT 'login Y: 성공, N:실패',
  `login_datetime` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`),
  KEY `idx_mb_idx` (`member_idx`,`ip`)
) ENGINE=InnoDB AUTO_INCREMENT=27590 DEFAULT CHARSET=utf8 COMMENT='로그인 내역 ';

--
-- Table structure for table `member_money_charge_history`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_money_charge_history` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `u_key` varchar(64) DEFAULT NULL COMMENT 't_log_cash u_key 와 연결 ',
  `member_idx` int(11) DEFAULT NULL COMMENT '충전 신청자 멤버 idx ',
  `admin_idx` int(11) DEFAULT NULL COMMENT '관리자 idx ',
  `deposit_name` varchar(45) DEFAULT NULL COMMENT '입금자 명 ',
  `bank_id` int(11) DEFAULT 0,
  `bank_name` varchar(45) DEFAULT '',
  `account_number` varchar(45) DEFAULT '',
  `account_name` varchar(45) DEFAULT '',
  `money` int(11) DEFAULT NULL COMMENT '충전 금액 ',
  `result_money` int(11) DEFAULT 0,
  `bonus_money` int(11) DEFAULT 0,
  `bonus_point` int(11) DEFAULT 0,
  `set_type` varchar(50) DEFAULT '',
  `status` int(11) DEFAULT NULL COMMENT '1: 입금 전 (신청) 2: 입금 확인 (대기) 3: 충전 완료 (완료) 4: 취소 10: 배팅적중 11:관리자 취소  \\\\n999: 오류',
  `comment` varchar(100) DEFAULT NULL COMMENT 'Status comment ',
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() COMMENT '관리자 처리 일자',
  `delete_dt` datetime DEFAULT NULL,
  `referenceId` varchar(45) DEFAULT '',
  `sms_status` varchar(45) DEFAULT '',
  `is_sound` enum('Y','N') DEFAULT 'Y',
  `sports_bet_s_money` int(11) DEFAULT 0,
  `sports_bet_d_money` int(11) DEFAULT 0,
  `real_bet_s_money` int(11) DEFAULT 0,
  `real_bet_d_money` int(11) DEFAULT 0,
  `mini_bet_money` int(11) DEFAULT 0,
  `casino_bet_money` int(11) DEFAULT 0,
  `slot_bet_money` int(11) DEFAULT 0,
  `esports_bet_money` int(11) DEFAULT 0,
  `hash_bet_money` int(11) DEFAULT 0,
  `charge_point_yn` tinyint(1) unsigned DEFAULT 1 COMMENT '충전포인트 (0-받지않음, 1-받음)',
  PRIMARY KEY (`idx`),
  KEY `status_member_idx` (`status`,`member_idx`),
  KEY `idx_create_dt` (`create_dt`),
  KEY `idx_mb_idx` (`member_idx`),
  KEY `idx_status` (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=7371 DEFAULT CHARSET=utf8 COMMENT='충전 / 환전 내역 ';

--
-- Table structure for table `member_money_charge_sms`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_money_charge_sms` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `deposit_name` varchar(45) DEFAULT NULL COMMENT '입금자 명 ',
  `bank_id` int(11) DEFAULT 0 COMMENT '은행번호',
  `bank_name` varchar(45) DEFAULT '0' COMMENT '은행명',
  `money` int(11) DEFAULT NULL COMMENT '충전 금액 ',
  `status` int(11) DEFAULT NULL COMMENT '1: 입금 전 (신청) 2: 시간초과(완료) 3: 자동충전 완료 (완료) 4: 운영자 완료 \\\\n999: 오류',
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT NULL COMMENT '처리 일자',
  `ori` text DEFAULT '' COMMENT '원문',
  PRIMARY KEY (`idx`),
  KEY `st_bk_idx` (`deposit_name`,`bank_id`,`money`,`create_dt`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='입금sms 내역';

--
-- Table structure for table `member_money_exchange_history`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_money_exchange_history` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `u_key` varchar(64) DEFAULT NULL COMMENT 't_log_cash u_key 와 연결 ',
  `member_idx` int(11) DEFAULT NULL COMMENT '환전 신청자 멤버 idx ',
  `admin_idx` int(11) DEFAULT NULL COMMENT '관리자 idx ',
  `money` int(11) DEFAULT NULL COMMENT '환전 금액 ',
  `result_money` int(11) DEFAULT 0,
  `comment` varchar(100) DEFAULT NULL COMMENT 'Status comment ',
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp(),
  `delete_dt` datetime DEFAULT NULL,
  `set_type` varchar(50) DEFAULT '',
  `is_sound` enum('Y','N') DEFAULT 'Y',
  `status` int(11) DEFAULT NULL COMMENT '1: 환전 신청 (신청)  \\\\\\\\n2: 환전 대기 (대기)  \\\\\\\\n3: 환전 완료 (완료)  \\\\\\\\n11: 관리자 취소  \\\\\\\\n999: 오류',
  PRIMARY KEY (`idx`),
  KEY `idx_s_u_m` (`member_idx`),
  KEY `status_member_idx` (`status`) USING BTREE,
  KEY `idx_create_dt` (`update_dt`)
) ENGINE=InnoDB AUTO_INCREMENT=1651 DEFAULT CHARSET=utf8 COMMENT='환전 내역 ';

--
-- Table structure for table `member_summary`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_summary` (
  `member_idx` int(11) NOT NULL DEFAULT 0 COMMENT '유저번호',
  `total_deposit_money` int(11) DEFAULT NULL COMMENT '총입금액',
  `total_withdraw_money` int(11) DEFAULT NULL COMMENT '총출금액',
  `total_deposit_count` int(11) DEFAULT NULL COMMENT '총입금횟수',
  `total_withdraw_count` int(11) DEFAULT NULL COMMENT '총출금횟수',
  `max_deposit_money` int(11) DEFAULT NULL COMMENT '최대 입금액',
  `max_withdraw_money` int(11) DEFAULT NULL COMMENT '최대 출금액',
  `total_betting_money` int(11) DEFAULT NULL COMMENT '총 배팅금액',
  `total_betting_count` int(11) DEFAULT NULL COMMENT '총 배팅횟수',
  `total_betting_win_money` int(11) DEFAULT NULL COMMENT '총 당첨금액',
  PRIMARY KEY (`member_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='유저 종합내역';

--
-- Table structure for table `member_update_history`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `member_update_history` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `a_id` varchar(50) DEFAULT '',
  `member_idx` int(11) DEFAULT NULL,
  `update_type` varchar(45) DEFAULT NULL COMMENT '변경 항목 ',
  `before_data` text DEFAULT NULL,
  `after_data` text DEFAULT NULL,
  `create_dt` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=1865 DEFAULT CHARSET=utf8 COMMENT='로그인 내역 ';

--
-- Table structure for table `menu_board`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `menu_board` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `member_idx` int(11) DEFAULT NULL COMMENT '글쓴이 (회원) ',
  `a_id` varchar(45) DEFAULT NULL COMMENT '담당자 (관리자) ',
  `nick_name` varchar(45) DEFAULT '',
  `title` varchar(100) DEFAULT NULL,
  `contents` text DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `display` tinyint(4) NOT NULL DEFAULT 0 COMMENT '게시판 타입 (0 : 일반, 1 : 공지, 2 : 베팅내역올리기)',
  PRIMARY KEY (`idx`),
  KEY `member_idx_create_dt` (`member_idx`,`create_dt`),
  KEY `member_idx` (`member_idx`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COMMENT='메뉴 상단 ‘게시판’';

--
-- Table structure for table `menu_board_comment`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `menu_board_comment` (
  `idx` int(10) NOT NULL AUTO_INCREMENT COMMENT '댓글 idx',
  `board_idx` int(11) NOT NULL COMMENT '글번호 idx',
  `member_idx` int(11) NOT NULL COMMENT '작성자 idx',
  `nick_name` varchar(45) NOT NULL COMMENT '닉네임',
  `comment` text NOT NULL COMMENT '댓글',
  `display` tinyint(1) NOT NULL DEFAULT 1 COMMENT '노출 여부 (0: 미노출, 1: 노출)',
  `create_dt` datetime DEFAULT current_timestamp() COMMENT '작성일',
  PRIMARY KEY (`idx`),
  KEY `IDX_BOARD_IDX` (`board_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='게시판 댓글';

--
-- Table structure for table `menu_board_file`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `menu_board_file` (
  `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '게시판 파일 idx',
  `board_idx` int(11) NOT NULL COMMENT '게시판 idx',
  `file_name` varchar(200) DEFAULT NULL COMMENT '파일명',
  `file_path` varchar(200) DEFAULT NULL COMMENT '파일 경로',
  `create_dt` datetime DEFAULT current_timestamp() COMMENT '작성 시간',
  PRIMARY KEY (`idx`),
  KEY `member_idx` (`board_idx`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='게시판 파일';

--
-- Table structure for table `menu_qna`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `menu_qna` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `member_idx` int(11) DEFAULT NULL COMMENT '글쓴이 (회원) ',
  `a_id` varchar(45) DEFAULT NULL COMMENT '담당자 (관리자) ',
  `title` varchar(100) DEFAULT NULL,
  `contents` text DEFAULT NULL,
  `is_answer` enum('Y','N') DEFAULT 'N',
  `is_view` enum('Y','N') DEFAULT 'Y',
  `is_status` enum('Y','D') DEFAULT 'Y',
  `is_sound` enum('Y','N') DEFAULT 'Y' COMMENT '운영툴에서 소리를 낼지 말지 판단',
  `answer` text DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`),
  KEY `member_idx` (`member_idx`),
  KEY `member_idx_create_dt` (`create_dt`)
) ENGINE=InnoDB AUTO_INCREMENT=2841 DEFAULT CHARSET=utf8 COMMENT='메뉴 상단 ‘고객센터’';

--
-- Table structure for table `mini_game`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `mini_game` (
  `game` varchar(16) NOT NULL DEFAULT '' COMMENT '게임',
  `id` int(11) NOT NULL DEFAULT 0 COMMENT '회차',
  `cnt` int(11) DEFAULT 0,
  `bet_type` int(11) NOT NULL COMMENT '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 ',
  `admin_bet_status` enum('ON','OFF','RETRY') DEFAULT 'ON',
  `start_dt` datetime DEFAULT current_timestamp() COMMENT 'KST ',
  `end_dt` datetime DEFAULT current_timestamp() COMMENT 'KST ',
  `result` mediumtext DEFAULT '',
  `result_score` mediumtext DEFAULT '',
  `league` varchar(45) DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `start_dt` (`start_dt`,`end_dt`),
  KEY `end_dt` (`end_dt`,`bet_type`),
  KEY `idx_bet_type` (`bet_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `mini_game_bet`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `mini_game_bet` (
  `game` varchar(16) NOT NULL DEFAULT '' COMMENT '게임',
  `markets_id` int(11) NOT NULL COMMENT '마켓 아이디',
  `markets_name` varchar(45) DEFAULT '0' COMMENT '마켓명',
  `bet_price` double DEFAULT NULL COMMENT '베당률',
  PRIMARY KEY (`game`,`markets_id`),
  KEY `markets_id` (`markets_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='배팅';

--
-- Table structure for table `mini_game_bet_config`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `mini_game_bet_config` (
  `bet_type` int(11) NOT NULL DEFAULT 0 COMMENT '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 ',
  `game` varchar(16) NOT NULL DEFAULT '' COMMENT '게임',
  `level` int(11) NOT NULL DEFAULT 0 COMMENT '레벨',
  `min` int(11) DEFAULT 0 COMMENT '최소',
  `max` int(11) DEFAULT 0 COMMENT '최대',
  `limit` int(11) DEFAULT 0 COMMENT '상한',
  `reward` decimal(5,2) DEFAULT 0.00 COMMENT '리워드%',
  PRIMARY KEY (`bet_type`,`level`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='배팅 설정';

--
-- Table structure for table `mini_game_member_bet`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `mini_game_member_bet` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `u_key` varchar(64) DEFAULT NULL COMMENT 't_log_cash 연동 키 ',
  `member_idx` int(11) DEFAULT 0 COMMENT '유저 아이디 -MemberModel',
  `bet_type` int(11) DEFAULT 0 COMMENT '1 : 프리매치 2: 실시간 3 : 파워볼,4파워사다리 5: 키노사다리 6 : 가상축구 ',
  `bet_status` int(11) DEFAULT 1 COMMENT '1: 게임 결과 전\\\\\\\\n2: 적중 - 정산 전 \\\\\\\\n3: 적중 - 정산 완료\\\\\\\\n4: 적중 실패 \\\\\\\\n5: 취소 , \\\\\\\\n 6:적특',
  `total_bet_money` int(11) DEFAULT 0 COMMENT '총 배팅 금액',
  `bet_price` double DEFAULT 0 COMMENT '배당률',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `update_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `calculate_dt` datetime DEFAULT NULL COMMENT '정산처리 시간',
  `ls_fixture_id` int(11) DEFAULT 0 COMMENT '경기 회차번호',
  `ls_markets_id` int(11) DEFAULT 0,
  `ls_markets_name` varchar(45) DEFAULT NULL,
  `round` int(11) DEFAULT 0 COMMENT '미니게임 회차번호',
  `take_money` int(11) DEFAULT 0,
  `take_point` int(11) DEFAULT 0,
  `is_open` tinyint(4) DEFAULT 0 COMMENT '0-운영자 미확인, 1-운영자 확인',
  `is_hide` tinyint(4) DEFAULT 0 COMMENT '0-유저 보이기, 1-유저 숨기기',
  PRIMARY KEY (`idx`),
  KEY `index_mb_id` (`member_idx`),
  KEY `idx_ct` (`ls_markets_id`,`create_dt`),
  KEY `member_idx_update_dt_bet_status` (`member_idx`,`update_dt`,`bet_status`) USING BTREE,
  KEY `idx_cal_dt` (`calculate_dt`)
) ENGINE=InnoDB AUTO_INCREMENT=8185 DEFAULT CHARSET=utf8 COMMENT='미니게임 배팅내역 ';

--
-- Table structure for table `mobile_carrier_list`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `mobile_carrier_list` (
  `idx` int(11) NOT NULL,
  `name` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='통신사 목록';

--
-- Table structure for table `money_order_history`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `money_order_history` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `type` int(11) DEFAULT NULL COMMENT '1:kwin, 2:asbet, 3:tiger, 4:onoff, 5"bitup',
  `member_idx` int(11) DEFAULT NULL COMMENT '입금 신청자 멤버번호 ',
  `order_name` varchar(45) DEFAULT NULL COMMENT '입금자명(가상계좌 입금자명으로 노출)',
  `order_bank_id` int(11) DEFAULT 0 COMMENT '입금자 은행번호',
  `order_bank_code` varchar(45) DEFAULT '' COMMENT '입금자 은행코드',
  `order_account_number` varchar(45) DEFAULT '' COMMENT '입금할 통장의 계좌번호',
  `with_hp` varchar(45) DEFAULT '' COMMENT '입금자 은행에 등록된 휴대번호',
  `money` int(11) DEFAULT NULL COMMENT '입금액',
  `status` int(11) DEFAULT NULL COMMENT '1: 신청, 2: 완료',
  `virtual_account_bank` varchar(90) DEFAULT '' COMMENT '가상계좌은행명',
  `virtual_account_number` varchar(45) DEFAULT '' COMMENT '가상계좌번호',
  `moid` varchar(60) DEFAULT '' COMMENT '주문번호',
  `tid` varchar(60) DEFAULT '' COMMENT '거래번호',
  `deposit_money` int(11) DEFAULT NULL COMMENT '정산예정금액',
  `consume` int(11) DEFAULT 0 COMMENT '유저계정 입금처리여부',
  `create_dt` datetime DEFAULT current_timestamp(),
  `deposit_dt` datetime DEFAULT current_timestamp() COMMENT '입금일시',
  `update_dt` datetime DEFAULT current_timestamp() COMMENT '처리일자',
  PRIMARY KEY (`idx`),
  KEY `type` (`type`),
  KEY `idx_status` (`status`),
  KEY `idx_create_dt` (`create_dt`),
  KEY `idx_mb_idx` (`member_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='결제현황';

--
-- Table structure for table `notices`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `notices` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(45) DEFAULT '',
  `thumbnail` varchar(1024) DEFAULT '',
  `detail` varchar(1024) DEFAULT '',
  `status` tinyint(4) DEFAULT 1 COMMENT '0-미사용, 1-사용',
  `del_flag` tinyint(4) DEFAULT 0 COMMENT '0-존재, 1-삭제됨',
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 COMMENT='공지테이블';

--
-- Table structure for table `personal_account_number`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `personal_account_number` (
  `member_idx` int(11) NOT NULL DEFAULT 0,
  `account_number_1` varchar(45) DEFAULT '',
  `account_name_1` varchar(45) DEFAULT '',
  `account_bank_1` varchar(45) DEFAULT '',
  `account_number_2` varchar(45) DEFAULT '',
  `account_name_2` varchar(45) DEFAULT '',
  `account_bank_2` varchar(45) DEFAULT '',
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `create_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`member_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `popups`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `popups` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `thumbnail` varchar(1024) DEFAULT '',
  `status` tinyint(4) DEFAULT 1 COMMENT '0-미사용, 1-사용',
  `rank` tinyint(1) DEFAULT NULL COMMENT '팝업순번',
  `create_dt` datetime DEFAULT current_timestamp(),
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `delete_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`),
  KEY `thumbnail` (`thumbnail`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COMMENT='팝업 테이블';

--
-- Table structure for table `rmq_redis_timestamp`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `rmq_redis_timestamp` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT,
  `start_time` bigint(20) NOT NULL DEFAULT 0,
  `start_time_inplay` bigint(20) NOT NULL DEFAULT 0,
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Table structure for table `shop_calculate_result`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `shop_calculate_result` (
  `member_idx` int(11) NOT NULL DEFAULT 0 COMMENT '유저번호(매장)',
  `create_dt` datetime NOT NULL DEFAULT current_timestamp() COMMENT '지급한 날짜',
  `calculate_dt` datetime DEFAULT NULL COMMENT '정산에 사용한 데이터의 날짜',
  `calculate_point` decimal(11,2) DEFAULT 0.00 COMMENT '정산금',
  `low_calculate_point` decimal(11,2) DEFAULT 0.00,
  `be_point` int(11) DEFAULT 0,
  `af_point` int(11) DEFAULT 0,
  `ch_val` decimal(11,2) DEFAULT 0.00 COMMENT '입금',
  `ex_val` decimal(11,2) DEFAULT 0.00 COMMENT '출금',
  `pre_bet_sum_s` decimal(11,2) DEFAULT 0.00 COMMENT '프리싱글 정산금',
  `pre_bet_sum_d_2` decimal(11,2) DEFAULT 0.00,
  `pre_bet_sum_d_3` decimal(11,2) DEFAULT 0.00,
  `pre_bet_sum_d_4` decimal(11,2) DEFAULT 0.00,
  `pre_bet_sum_d_5_more` decimal(11,2) DEFAULT 0.00,
  `real_bet_sum_s` decimal(11,2) DEFAULT 0.00 COMMENT '실시간싱글 정산금',
  `real_bet_sum_d` decimal(11,2) DEFAULT 0.00 COMMENT '실시간멀티 정산금',
  `mini_bet_sum` decimal(11,2) DEFAULT 0.00 COMMENT '미니게임 정산금',
  `total_casino_bet_money` decimal(11,2) DEFAULT 0.00,
  `total_slot_bet_money` decimal(11,2) DEFAULT 0.00,
  `total_hash_bet_money` decimal(11,2) DEFAULT 0.00,
  `total_espt_bet_money` decimal(11,2) DEFAULT 0.00,
  `bet_pre_s_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 프리매치싱글 수수료',
  `bet_pre_d_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 프리매치다폴더 수수료',
  `bet_pre_d_2_fee` decimal(7,2) DEFAULT 0.00,
  `bet_pre_d_3_fee` decimal(7,2) DEFAULT 0.00,
  `bet_pre_d_4_fee` decimal(7,2) DEFAULT 0.00,
  `bet_pre_d_5_more_fee` decimal(7,2) DEFAULT 0.00,
  `bet_real_s_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 실시간싱글 수수료',
  `bet_real_d_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 실시간다폴더 수수료',
  `bet_mini_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 미니게임 수수료',
  `pre_s_fee` decimal(7,2) DEFAULT 0.00 COMMENT '죽장 수수료',
  `bet_casino_fee` decimal(7,2) DEFAULT 0.00,
  `bet_slot_fee` decimal(7,2) DEFAULT 0.00,
  `bet_espt_fee` decimal(7,2) DEFAULT 0.00,
  `bet_hash_fee` decimal(7,2) DEFAULT 0.00,
  `pre_bet_take_s` decimal(11,2) DEFAULT 0.00,
  `pre_bet_take_d_2` decimal(11,2) DEFAULT 0.00,
  `pre_bet_take_d_3` decimal(11,2) DEFAULT 0.00,
  `pre_bet_take_d_4` decimal(11,2) DEFAULT 0.00,
  `pre_bet_take_d_5_more` decimal(11,2) DEFAULT 0.00,
  `real_bet_take_s` decimal(11,2) DEFAULT 0.00,
  `real_bet_take_d` decimal(11,2) DEFAULT 0.00,
  `mini_bet_take` decimal(11,2) DEFAULT 0.00,
  `casino_bet_take` decimal(11,2) DEFAULT 0.00,
  `slot_bet_take` decimal(11,2) DEFAULT 0.00,
  `hash_bet_take` decimal(11,2) DEFAULT 0.00,
  `espt_bet_take` decimal(11,2) DEFAULT 0.00,
  `pre_classic_bet_sum_s` decimal(11,2) DEFAULT 0.00,
  `pre_classic_bet_take_s` decimal(11,2) DEFAULT 0.00,
  `pre_classic_bet_sum_d` decimal(11,2) DEFAULT 0.00,
  `pre_classic_bet_take_d` decimal(11,2) DEFAULT 0.00,
  PRIMARY KEY (`member_idx`,`create_dt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='총판 정산';

--
-- Table structure for table `shop_config`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `shop_config` (
  `member_idx` int(11) NOT NULL DEFAULT 0 COMMENT '유저번호(매장)',
  `bet_pre_s_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 프리매치싱글',
  `bet_pre_d_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 프리매치다폴더',
  `bet_pre_d_2_fee` decimal(7,2) DEFAULT 0.00,
  `bet_pre_d_3_fee` decimal(7,2) DEFAULT 0.00,
  `bet_pre_d_4_fee` decimal(7,2) DEFAULT 0.00,
  `bet_pre_d_5_more_fee` decimal(7,2) DEFAULT 0.00,
  `bet_real_s_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 실시간싱글',
  `bet_real_d_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 실시간다폴더',
  `bet_mini_fee` decimal(7,2) DEFAULT 0.00 COMMENT '베팅롤링 미니게임',
  `pre_s_fee` decimal(7,2) DEFAULT 0.00 COMMENT '죽장 프리매치싱글',
  `bet_casino_fee` decimal(7,2) DEFAULT 0.00,
  `bet_slot_fee` decimal(7,2) DEFAULT 0.00,
  `bet_esports_fee` decimal(7,2) DEFAULT 0.00,
  `bet_hash_fee` decimal(7,2) DEFAULT 0.00,
  PRIMARY KEY (`member_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='매장별 수수료 설정';

--
-- Table structure for table `sms_auth`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `sms_auth` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `phone_number` varchar(45) DEFAULT NULL,
  `auth_number` varchar(45) DEFAULT NULL,
  `create_dt` datetime DEFAULT current_timestamp(),
  `status` int(11) DEFAULT 1 COMMENT '1-요청, 2-인증완료',
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=15726 DEFAULT CHARSET=utf8;

--
-- Table structure for table `sports_rule`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `sports_rule` (
  `id` int(11) NOT NULL DEFAULT 0 COMMENT '종목번호',
  `betting_type` varchar(32) NOT NULL COMMENT '베팅타입',
  `betting_name` varchar(32) DEFAULT NULL COMMENT '종목명',
  `application_time` varchar(16) NOT NULL COMMENT '적용시간',
  `contents` varchar(8) DEFAULT NULL COMMENT '설명',
  PRIMARY KEY (`id`,`betting_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `sports_rule_2`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `sports_rule_2` (
  `id` int(11) NOT NULL DEFAULT 0 COMMENT '종목번호',
  `type` varchar(16) NOT NULL COMMENT '타입 및 경기시간',
  `contents` varchar(8) DEFAULT NULL COMMENT '설명',
  PRIMARY KEY (`id`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_adm_config`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_adm_config` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `a_id` varchar(50) NOT NULL,
  `alarm_name` varchar(50) DEFAULT NULL,
  `alarm_use` enum('Y','N') NOT NULL DEFAULT 'Y',
  `alarm_kind` varchar(50) DEFAULT NULL,
  `alarm_file` varchar(300) DEFAULT NULL,
  `reg_time` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_adm_ip`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_adm_ip` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `type` tinyint(4) DEFAULT 1 COMMENT '1:ipv4, 2:ipv6',
  `a_ip` varchar(60) DEFAULT NULL,
  `a_memo` text DEFAULT NULL,
  `isuse` enum('Y','N') DEFAULT 'Y',
  `reg_time` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`),
  UNIQUE KEY `UQ_t_adm_ip_01` (`a_ip`)
) ENGINE=InnoDB AUTO_INCREMENT=79 DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_adm_log`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_adm_log` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `a_id` varchar(50) NOT NULL,
  `a_ip` varchar(30) DEFAULT NULL,
  `a_country` varchar(50) DEFAULT NULL,
  `is_login` enum('Y','N','') DEFAULT NULL,
  `u_id` varchar(50) DEFAULT NULL,
  `u_nick` varchar(50) DEFAULT NULL,
  `log_data` text DEFAULT NULL,
  `log_type` tinyint(3) unsigned DEFAULT 99 COMMENT '1 운영툴 로그인\\\\\\\\\\\\\\\\n2. 관리자 ip관리, 개별 ip 차단관리\\\\\\\\\\\\\\\\n3. 도메인 코드 관리\\\\\\\\\\\\\\\\n4. 레벨별 계좌설정\\\\\\\\\\\\\\\\n5. 가입첫충\\\\\\\\\\\\\\\\n6. 등급별 베팅금액 설정\\\\\\\\\\\\\\\\n7. 사이트 설정\\\\\\\\\\\\\\\\n11. 관리자 아이디 관리\\\\\\\\n20. 전체수동정산  21. 개별수동정산  22. 전체수동적특  23. 개별수동적특  24. 개별마켓ON/OFF  25. 경기ON/OFF  26. 일괄적용  27. 경기상태변경  28. 추천코드 변경  29. 정산요율\\\\\\\\n30. 회원상세-배팅가능  31. 배팅타입관리  32. 리그관리  33. 미니게임on/off  34. 가상축구on/off  35. 이벤트충전 설정  36. 이벤트충전 상태\\\\\\\\n40. 비밀번호  41. 환전비밀번호  42. 닉네임  43. 전화번호  44. 추천  45. 상태  46. 레벨  47. 자동렙업  48. 추천인  49. 계좌정보\\\\\\\\n50. 계좌이름  51. 은행 52: 경기 수동관리 53 : 경기 자동관리 54 : 경기시작시간 변경 ',
  `reg_time` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`),
  KEY `idx_log_type` (`log_type`)
) ENGINE=InnoDB AUTO_INCREMENT=4521 DEFAULT CHARSET=utf8 COMMENT='관리자 로그';

--
-- Table structure for table `t_adm_user`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_adm_user` (
  `a_id` varchar(50) NOT NULL,
  `a_pw` varchar(200) NOT NULL,
  `a_nick` varchar(100) DEFAULT NULL,
  `a_memo` text DEFAULT NULL,
  `session_key` varchar(100) DEFAULT NULL,
  `last_login` timestamp NULL DEFAULT NULL,
  `a_status` enum('Y','N') DEFAULT 'Y',
  `a_ip` varchar(30) DEFAULT NULL,
  `a_before_ip` varchar(30) DEFAULT NULL,
  `a_reg_id` varchar(30) DEFAULT NULL,
  `a_del_id` varchar(30) DEFAULT NULL,
  `reg_time` timestamp NULL DEFAULT current_timestamp(),
  `is_main_stat` varchar(45) DEFAULT '0' COMMENT '상황판 값을 보여줄지 말지 여부(0-off, 1-on)',
  `grade` tinyint(2) DEFAULT 1 COMMENT '1 : 기본유저 ,2 : 읽기 ',
  PRIMARY KEY (`a_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_domain_code`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_domain_code` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `domain` varchar(100) DEFAULT NULL,
  `domain_code` varchar(100) DEFAULT NULL,
  `is_use` enum('Y','N') DEFAULT 'Y',
  `reg_time` timestamp NOT NULL DEFAULT current_timestamp(),
  `type` tinyint(4) DEFAULT 1 COMMENT '1-본사, 2-총판, 3-가로',
  PRIMARY KEY (`idx`),
  UNIQUE KEY `UQ_DOMAIN_01` (`domain_code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_game_config`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_game_config` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `u_level` tinyint(3) unsigned NOT NULL DEFAULT 0,
  `set_type` varchar(50) NOT NULL,
  `set_type_val` varchar(200) NOT NULL,
  `title` varchar(200) NOT NULL,
  `reg_time` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`),
  UNIQUE KEY `UQ_GAME_CONFIG_01` (`u_level`,`set_type`) USING BTREE,
  KEY `idx_type` (`set_type`)
) ENGINE=InnoDB AUTO_INCREMENT=327 DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_ip_country`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_ip_country` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `country_code` varchar(10) DEFAULT NULL,
  `country` varchar(50) DEFAULT NULL,
  `ip_start` int(10) unsigned NOT NULL,
  `ip_end` int(10) unsigned NOT NULL,
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=190352 DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_log_cash`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_log_cash` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `u_key` varchar(64) DEFAULT NULL,
  `member_idx` int(11) NOT NULL,
  `ac_code` smallint(6) DEFAULT 0 COMMENT '    /*1:충전,2:환전,3:베팅,4:베팅취소,5:포인트전환(추가),6:포인트차감,7:베팅결과처리,8:이벤트충전,9:이벤트차감,10:포인트충전,11 : 낙첨 포인트 지급,101:충전요청,102:환전요청,103:계좌조회,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n             * 111:충전요청취소,112:환전요청취소,113:충전취소,114:환전취소,121:관리자충전,122:관리자회수,123:관리자 포인트 충전, 124:관리자 포인트 회수,125 : 관리자 환전 회수,998:데이터복구,999:기타 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n     \\\\\\\\n201 : 정산 취소,202 : 정산 포인트 취소,203 : 정산 추천인 포인트 취소  ,126 : 재정산으로 인한 정산 ->적특시 이미 지급된 포인트 관리자 회수\\n,127 : 재정산으로 인한 적특 ->정산 시 지급으로 인한 관리자포인트 충전  */',
  `ac_idx` int(11) DEFAULT NULL,
  `r_money` decimal(10,2) NOT NULL DEFAULT 0.00,
  `be_r_money` decimal(11,2) NOT NULL DEFAULT 0.00,
  `af_r_money` decimal(11,2) NOT NULL DEFAULT 0.00,
  `point` int(11) NOT NULL DEFAULT 0,
  `be_point` int(11) NOT NULL DEFAULT 0,
  `af_point` int(11) NOT NULL DEFAULT 0,
  `m_kind` enum('R','P','M') NOT NULL DEFAULT 'R',
  `title_kind` varchar(30) DEFAULT NULL,
  `coment` text DEFAULT NULL,
  `u_ip` varchar(30) DEFAULT NULL,
  `a_country` varchar(45) DEFAULT NULL,
  `a_id` varchar(30) DEFAULT NULL,
  `reg_time` timestamp NOT NULL DEFAULT current_timestamp(),
  `charge_total_count` int(11) DEFAULT 0,
  `loock_up_total_count` int(11) DEFAULT 0,
  `charge_total_money` int(11) DEFAULT 0,
  `g_money` int(11) DEFAULT 0,
  PRIMARY KEY (`idx`) USING BTREE,
  KEY `ac_code` (`ac_code`),
  KEY `member_idx` (`member_idx`),
  KEY `reg_time` (`reg_time`)
) ENGINE=InnoDB AUTO_INCREMENT=213173 DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_log_cash_backup`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_log_cash_backup` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `u_key` varchar(64) DEFAULT NULL,
  `member_idx` int(11) NOT NULL,
  `ac_code` smallint(6) DEFAULT 0 COMMENT '    /*1:충전,2:환전,3:베팅,4:베팅취소,5:포인트전환(추가),6:포인트차감,7:베팅결과처리,8:이벤트충전,9:이벤트차감,10:포인트충전,11 : 낙첨 포인트 지급,101:충전요청,102:환전요청,103:계좌조회,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n             * 111:충전요청취소,112:환전요청취소,113:충전취소,114:환전취소,121:관리자충전,122:관리자회수,123:관리자 포인트 충전, 124:관리자 포인트 회수,125 : 관리자 환전 회수,998:데이터복구,999:기타 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n     \\\\\\\\n201 : 정산 취소,202 : 정산 포인트 취소,203 : 정산 추천인 포인트 취소  ,126 : 재정산으로 인한 정산 ->적특시 이미 지급된 포인트 관리자 회수\\n,127 : 재정산으로 인한 적특 ->정산 시 지급으로 인한 관리자포인트 충전  */',
  `ac_idx` int(11) DEFAULT NULL,
  `r_money` int(11) NOT NULL DEFAULT 0,
  `be_r_money` int(11) NOT NULL DEFAULT 0,
  `af_r_money` int(11) NOT NULL DEFAULT 0,
  `point` int(11) NOT NULL DEFAULT 0,
  `be_point` int(11) NOT NULL DEFAULT 0,
  `af_point` int(11) NOT NULL DEFAULT 0,
  `m_kind` enum('R','P','M') NOT NULL DEFAULT 'R',
  `title_kind` varchar(30) DEFAULT NULL,
  `coment` text DEFAULT NULL,
  `u_ip` varchar(30) DEFAULT NULL,
  `a_id` varchar(30) DEFAULT NULL,
  `reg_time` timestamp NOT NULL DEFAULT current_timestamp(),
  `charge_total_count` int(11) DEFAULT 0,
  `loock_up_total_count` int(11) DEFAULT 0,
  `charge_total_money` int(11) DEFAULT 0,
  PRIMARY KEY (`idx`) USING BTREE,
  KEY `ac_code` (`ac_code`),
  KEY `member_idx` (`member_idx`),
  KEY `reg_time` (`reg_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_member_memo`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_member_memo` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `member_idx` int(10) unsigned NOT NULL DEFAULT 0,
  `m_type` tinyint(4) NOT NULL DEFAULT 1,
  `content` varchar(300) DEFAULT NULL,
  `a_id` varchar(50) DEFAULT NULL,
  `reg_time` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=597 DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_message`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_message` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `msg_idx` int(10) unsigned NOT NULL,
  `member_idx` int(10) unsigned NOT NULL,
  `read_yn` enum('Y','N') NOT NULL DEFAULT 'N',
  `u_ip` varchar(30) DEFAULT NULL,
  `reg_time` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '등록일',
  `read_time` datetime DEFAULT NULL,
  `is_delete` int(10) DEFAULT 0,
  PRIMARY KEY (`idx`),
  KEY `idx_mb_idx` (`member_idx`)
) ENGINE=InnoDB AUTO_INCREMENT=21240 DEFAULT CHARSET=utf8;

--
-- Table structure for table `t_message_list`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_message_list` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `idx_key` char(25) NOT NULL,
  `title` varchar(200) NOT NULL,
  `content` longtext NOT NULL,
  `a_id` varchar(50) DEFAULT NULL,
  `a_view_nick` varchar(100) DEFAULT NULL,
  `w_type` enum('A','H') NOT NULL DEFAULT 'H',
  `reg_time` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '등록일',
  PRIMARY KEY (`idx`) USING BTREE,
  UNIQUE KEY `UQ_MESSAGE_LIST_U01` (`idx_key`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1961 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `t_message_set`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `t_message_set` (
  `idx` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `a_id` varchar(50) NOT NULL,
  `title_view` varchar(200) NOT NULL,
  `title` varchar(200) NOT NULL,
  `content` text NOT NULL,
  `use_kind` enum('Y','N') NOT NULL DEFAULT 'N',
  `send_cnt` int(10) unsigned NOT NULL DEFAULT 0,
  `reg_time` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Table structure for table `temp_account_info`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `temp_account_info` (
  `id` varchar(45) NOT NULL DEFAULT '',
  `account_number` varchar(45) DEFAULT '',
  `account_name` varchar(45) DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `temp_level_up`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `temp_level_up` (
  `day` date NOT NULL DEFAULT current_timestamp(),
  `member_idx` int(11) NOT NULL DEFAULT 0,
  `bf_level` int(11) DEFAULT 0,
  `level` int(11) DEFAULT 0,
  `v_today_total_ch_money` int(11) DEFAULT 0,
  `v_today_total_ex_money` int(11) DEFAULT 0,
  `v_today_total_bet_money` int(11) DEFAULT 0,
  `v_today_total_ch_ex_money_difference` int(11) DEFAULT 0,
  `v_today_total_ch_count` int(11) DEFAULT 0,
  `v_nonDepositDatePeriod` int(11) DEFAULT 0,
  `r_charge_total_money` int(11) DEFAULT 0,
  `r_exchange_total_money` int(11) DEFAULT 0,
  `r_charge_total_count` int(11) DEFAULT 0,
  `r_calcurator` int(11) DEFAULT 0,
  PRIMARY KEY (`day`,`member_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `temp_member`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `temp_member` (
  `id` varchar(20) NOT NULL,
  `nick` varchar(20) DEFAULT NULL,
  `level` int(11) DEFAULT NULL,
  `account_bank` varchar(20) DEFAULT NULL,
  `account_number` varchar(20) DEFAULT NULL,
  `account_name` varchar(20) DEFAULT NULL,
  `hp` varchar(20) DEFAULT NULL,
  `memo` varchar(2048) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `template`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `template` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `type` int(11) NOT NULL COMMENT '0-쪽지, 1-답변',
  `division` varchar(128) DEFAULT NULL COMMENT '분류',
  `title` text DEFAULT NULL COMMENT '내용',
  `content` text DEFAULT NULL,
  `update_dt` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`idx`)
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8;

--
-- Table structure for table `total_member_cash`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `total_member_cash` (
  `member_idx` int(11) NOT NULL DEFAULT 0,
  `charge_total_count` int(11) NOT NULL DEFAULT 0 COMMENT '충전횟수',
  `charge_total_money` bigint(20) NOT NULL DEFAULT 0 COMMENT '조회횟수',
  `exchange_total_count` int(11) NOT NULL DEFAULT 0 COMMENT '충전금액',
  `exchange_total_money` bigint(20) DEFAULT 0,
  `max_charge` bigint(20) DEFAULT 0,
  `bf_max_charge` bigint(20) DEFAULT 0,
  `max_exchange` bigint(20) DEFAULT 0,
  `bf_max_exchange` bigint(20) DEFAULT 0,
  `loock_up_total_count` int(11) DEFAULT 0 COMMENT '계좌 조회 카운트',
  `bet_total_count` int(11) DEFAULT 0,
  `bet_total_money` bigint(20) DEFAULT 0,
  `pre_s_total_money` bigint(20) DEFAULT 0,
  `pre_m_total_money` bigint(20) DEFAULT 0,
  `real_s_total_money` bigint(20) DEFAULT 0,
  `real_m_total_money` bigint(20) DEFAULT 0,
  `mini_total_money` bigint(20) DEFAULT 0,
  `casino_total_money` bigint(20) DEFAULT 0,
  `slot_total_money` bigint(20) DEFAULT 0,
  `take_total_money` bigint(20) DEFAULT 0,
  `take_slot_total_money` bigint(20) DEFAULT 0,
  `take_casino_total_money` bigint(20) DEFAULT 0,
  `take_mini_total_money` bigint(20) DEFAULT 0,
  `take_real_m_total_money` bigint(20) DEFAULT 0,
  `take_real_s_total_money` bigint(20) DEFAULT 0,
  `take_pre_m_total_money` bigint(20) DEFAULT 0,
  `take_pre_s_total_money` bigint(20) DEFAULT 0,
  `update_dt` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `create_dt` datetime NOT NULL DEFAULT current_timestamp(),
  `espt_total_money` bigint(20) DEFAULT 0,
  `take_espt_total_money` bigint(20) DEFAULT 0,
  `hash_total_money` bigint(20) DEFAULT 0,
  `take_hash_total_money` bigint(20) DEFAULT 0,
  PRIMARY KEY (`member_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `total_system`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `total_system` (
  `current_count` int(11) NOT NULL DEFAULT 0,
  `update_dt` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`current_count`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='집계용 테이블';

--
-- Table structure for table `virtual_goods_list`
--

 SET character_set_client = utf8mb4 ;
CREATE TABLE `virtual_goods_list` (
  `p_seq` int(11) NOT NULL DEFAULT 0 COMMENT '상품등록 코드',
  `p_name` varchar(32) DEFAULT NULL COMMENT '종목명',
  `p_price` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '마감시간',
  `p_sell_state` varchar(32) DEFAULT NULL COMMENT '상품 판매 상태 (SELL:판매중, SOLDOUT:판매완료)',
  PRIMARY KEY (`p_seq`),
  KEY `idx_p_price` (`p_price`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping events for database 'mydb'
--

--
-- Dumping routines for database 'mydb'
--
/*!50003 DROP FUNCTION IF EXISTS `FN_ADM_MSG_SEND_ALL` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` FUNCTION `FN_ADM_MSG_SEND_ALL`(`$p_msg_idx` INT
) RETURNS int(11)
BEGIN

	DECLARE $ret 			VARCHAR(50);
	DECLARE $no_more_rows 		BOOL DEFAULT FALSE;

	DECLARE $db_user_idx			INTEGER DEFAULT 0;

	DECLARE cursor_1 CURSOR FOR
		SELECT idx FROM member WHERE status=1;
		
	DECLARE CONTINUE HANDLER FOR NOT FOUND
		SET $no_more_rows := true;

	OPEN cursor_1;
	LOOP1: loop
		FETCH cursor_1 INTO $db_user_idx;

		IF $no_more_rows THEN 
			CLOSE cursor_1;
			LEAVE LOOP1;
		END IF;
		
					
		INSERT INTO t_message(msg_idx,member_idx) VALUES($p_msg_idx,$db_user_idx);
		
	END loop LOOP1;
	
	SET $ret = 1000;

	RETURN $ret;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `FN_GET_IP_COUNTRY` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` FUNCTION `FN_GET_IP_COUNTRY`(`$p_ip` VARCHAR(30)
) RETURNS varchar(50) CHARSET utf8
BEGIN

	DECLARE $ret 			VARCHAR(50);
	DECLARE $v_ip 			INT UNSIGNED DEFAULT 0;
	
	SET $ret = 'local';
	
	SELECT INET_ATON($p_ip) INTO $v_ip;
	SELECT country INTO $ret FROM t_ip_country WHERE $v_ip >= ip_start and $v_ip <= ip_end LIMIT 1;

	RETURN $ret;
END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `FN_STAT_CHARGE_TOTAL` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` FUNCTION `FN_STAT_CHARGE_TOTAL`(`$start_date` DATETIME,

	`$end_date` DATETIME,

	`$member_idx` INT

) RETURNS bigint(20)
    COMMENT '이번달 1일 부터 현재까지 충전합계 반환'
BEGIN

	DECLARE $charge_total BIGINT DEFAULT 0;

	DECLARE $start_time DATETIME;

	DECLARE $end_time DATETIME;

	

	SET $start_time = IFNULL($start_date, LAST_DAY(NOW() - interval 1 month) + interval 1 DAY);

	SET $end_time = IFNULL($end_date, NOW());



	SELECT IFNULL(SUM(MC.money),0)

	FROM member_money_charge_history AS MC WHERE status = 3 

	AND MC.update_dt >= $start_time

	AND MC.update_dt <= $end_time

	AND MC.member_idx = CASE

								WHEN $member_idx IS NULL THEN MC.member_idx

								ELSE $member_idx END

	INTO $charge_total;

	

	RETURN $charge_total;

END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `FN_STAT_DIFF_TOTAL` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` FUNCTION `FN_STAT_DIFF_TOTAL`(`$start_date` DATETIME,

	`$end_date` DATETIME,

	`$member_idx` INT

) RETURNS bigint(20)
    COMMENT '이번달 1일 부터 현재까지  차액 합계 반환'
BEGIN

	DECLARE $diff_total BIGINT DEFAULT 0;

	DECLARE $start_time DATETIME;

	DECLARE $end_time DATETIME;

	

	SET $start_time = IFNULL($start_date, LAST_DAY(NOW() - interval 1 month) + interval 1 DAY);

	SET $end_time = IFNULL($end_date, NOW());



	SELECT IFNULL(SUM(MC.money),0) -

	(SELECT IFNULL(SUM(ME.money),0)

	FROM member_money_exchange_history AS ME 

	WHERE status = 3 

	AND update_dt >= $start_time

	AND update_dt <= $end_time

	AND ME.member_idx = CASE

					WHEN $member_idx IS NULL THEN ME.member_idx

					ELSE $member_idx END)  AS diff_sum

	FROM member_money_charge_history AS MC

	WHERE status = 3 

	AND update_dt >= $start_time

	AND update_dt <= $end_time

	AND MC.member_idx = CASE

						WHEN $member_idx IS NULL THEN MC.member_idx

						ELSE $member_idx END

						

	INTO $diff_total;

	

	RETURN $diff_total;

END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `FN_STAT_EXCHANGE_TOTAL` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` FUNCTION `FN_STAT_EXCHANGE_TOTAL`(`$start_date` DATETIME,

	`$end_date` DATETIME,

	`$member_idx` INT

) RETURNS bigint(20)
    COMMENT '이번달 1일 부터 현재까지 환전합계 반환'
BEGIN

	DECLARE $exchange_total BIGINT DEFAULT 0;

	DECLARE $start_time DATETIME;

	DECLARE $end_time DATETIME;

	

	SET $start_time = IFNULL($start_date, LAST_DAY(NOW() - interval 1 month) + interval 1 DAY);

	SET $end_time = IFNULL($end_date, NOW());



	SELECT IFNULL(SUM(ME.money),0)

	FROM member_money_exchange_history AS ME WHERE status = 3 

	AND ME.update_dt >= $start_time

	AND ME.update_dt <= $end_time

	AND ME.member_idx = CASE

							WHEN $member_idx IS NULL THEN ME.member_idx

							ELSE $member_idx END

	INTO $exchange_total;

	

	RETURN $exchange_total;

END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `FN_STAT_USERS_BET_SUM` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` FUNCTION `FN_STAT_USERS_BET_SUM`(`$start_date` DATETIME,

	`$end_date` DATETIME,

	`$folder_type` CHAR(1),

	`$bet_type` INT,

	`$member_idx` INT

) RETURNS bigint(20)
    COMMENT '1일부터 현재까지 베팅 합계 (프리매치)'
BEGIN

	

	DECLARE $val_sum BIGINT DEFAULT 0;

	

	DECLARE $start_time DATETIME;

	DECLARE $end_time DATETIME;

	

	

	SET $start_time = IFNULL($start_date, LAST_DAY(NOW() - interval 1 month) + interval 1 DAY);

	SET $end_time = IFNULL($end_date, NOW());



	SELECT IFNULL(SUM(total_bet_money),0)

	FROM member_bet AS MB 

	WHERE bet_status = 3 

	AND MB.update_dt >= $start_time

	AND MB.update_dt <= $end_time

	AND MB.folder_type = CASE

				WHEN $folder_type IS NULL THEN MB.folder_type

				ELSE $folder_type END

	AND MB.bet_type = $bet_type

	AND MB.member_idx = CASE

						WHEN $member_idx IS NULL THEN MB.member_idx

						ELSE $member_idx END

	INTO $val_sum;

	

	RETURN $val_sum;

END ;;
DELIMITER ;
/*!50003 DROP FUNCTION IF EXISTS `FN_STAT_USERS_TAKE_SUM` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` FUNCTION `FN_STAT_USERS_TAKE_SUM`(`$start_date` DATETIME,

	`$end_date` DATETIME,

	`$folder_type` CHAR(1),

	`$bet_type` INT,

	`$member_idx` INT

) RETURNS bigint(20)
    COMMENT '1일부터 현재까지 당첨 합계 (프리매치)'
BEGIN

	

	DECLARE $val_sum BIGINT DEFAULT 0;

	

	DECLARE $start_time DATETIME;

	DECLARE $end_time DATETIME;

	

	SET $start_time = IFNULL($start_date, LAST_DAY(NOW() - interval 1 month) + interval 1 DAY);

	SET $end_time = IFNULL($end_date, NOW());



	SELECT IFNULL(SUM(take_money),0)

	FROM member_bet AS MB 

	WHERE bet_status = 3 

	AND MB.update_dt >= $start_time

	AND MB.update_dt <= $end_time

	AND MB.folder_type = CASE

				WHEN $folder_type IS NULL THEN MB.folder_type

				ELSE $folder_type END

	AND MB.bet_type = $bet_type

	AND MB.member_idx = CASE

					WHEN $member_idx IS NULL THEN MB.member_idx

					ELSE $member_idx END

	INTO $val_sum;

	

	RETURN $val_sum;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `backupDataLsports` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `backupDataLsports`(
in in_type varchar(10)
)
BEGIN

IF 'go_bet' = in_type THEN
    truncate lsports_bet_InnoDB;
	INSERT INTO lsports_bet_InnoDB
	SELECT * FROM lsports_bet;
ELSEIF 'go_policy' = in_type THEN
    truncate dividend_policy_innodb;
	INSERT INTO dividend_policy_innodb
	SELECT * FROM dividend_policy;
ELSEIF 'go_bet_sum' = in_type THEN
	truncate fixtures_bet_sum_innodb;
	INSERT INTO fixtures_bet_sum_innodb
	SELECT * FROM fixtures_bet_sum;
ELSEIF 'go_fixtures' = in_type THEN
    truncate lsports_fixtures_innodb;
	INSERT INTO lsports_fixtures_innodb
	SELECT * FROM lsports_fixtures;   
ELSEIF 'go_leagues' = in_type THEN
    truncate lsports_leagues_innodb;
	INSERT INTO lsports_leagues_innodb
	SELECT * FROM lsports_leagues;
ELSEIF 'go_locations' = in_type THEN
    truncate lsports_locations_innodb;
	INSERT INTO lsports_locations_innodb
	SELECT * FROM lsports_locations;
ELSEIF 'go_markets' = in_type THEN
    truncate lsports_markets_innodb;
	INSERT INTO lsports_markets_innodb
	SELECT * FROM lsports_markets;   
ELSEIF 'go_participant' = in_type THEN
    truncate lsports_participant_innodb;
	INSERT INTO lsports_participant_innodb
	SELECT * FROM lsports_participant;   
ELSEIF 'go_sports' = in_type THEN
    truncate lsports_sports_innodb;
	INSERT INTO lsports_sports_innodb
	SELECT * FROM lsports_sports;     
ELSEIF 'go_all' = in_type THEN
	truncate lsports_bet_InnoDB;
	INSERT INTO lsports_bet_InnoDB
	SELECT * FROM lsports_bet;

    truncate dividend_policy_innodb;
	INSERT INTO dividend_policy_innodb
	SELECT * FROM dividend_policy;
  
	truncate fixtures_bet_sum_innodb;
	INSERT INTO fixtures_bet_sum_innodb
	SELECT * FROM fixtures_bet_sum;

    truncate lsports_fixtures_innodb;
	INSERT INTO lsports_fixtures_innodb
	SELECT * FROM lsports_fixtures;   
 
    truncate lsports_leagues_innodb;
	INSERT INTO lsports_leagues_innodb
	SELECT * FROM lsports_leagues;
 
    truncate lsports_locations_innodb;
	INSERT INTO lsports_locations_innodb
	SELECT * FROM lsports_locations;
 
    truncate lsports_markets_innodb;
	INSERT INTO lsports_markets_innodb
	SELECT * FROM lsports_markets;   
 
    truncate lsports_participant_innodb;
	INSERT INTO lsports_participant_innodb
	SELECT * FROM lsports_participant;   

    truncate lsports_sports_innodb;
	INSERT INTO lsports_sports_innodb
	SELECT * FROM lsports_sports;     
 END IF;
 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `backupInnoDBSportsData` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `backupInnoDBSportsData`(
in in_type varchar(10)
)
BEGIN

IF 'go_bet' = in_type THEN
   DROP TABLE  if exists `lsports_bet_backup`;
   CREATE TABLE IF NOT EXISTS `lsports_bet_backup` SELECT * FROM `lsports_bet_InnoDB`;
ELSEIF 'go_policy' = in_type THEN
   DROP TABLE  if exists `dividend_policy_backup`;
   CREATE TABLE IF NOT EXISTS `dividend_policy_backup` SELECT * FROM `dividend_policy_innodb`;
ELSEIF 'go_bet_sum' = in_type THEN
	DROP TABLE  if exists `fixtures_bet_sum_backup`;
   CREATE TABLE IF NOT EXISTS `fixtures_bet_sum_backup` SELECT * FROM `fixtures_bet_sum_innodb`;
ELSEIF 'go_fixtures' = in_type THEN
	DROP TABLE  if exists `lsports_fixtures_backup`;
   CREATE TABLE IF NOT EXISTS `lsports_fixtures_backup` SELECT * FROM `lsports_fixtures_innodb`;
ELSEIF 'go_leagues' = in_type THEN
	DROP TABLE  if exists `lsports_leagues_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_leagues_backup` SELECT * FROM `lsports_leagues_innodb`;
ELSEIF 'go_locations' = in_type THEN
	DROP TABLE  if exists `lsports_locations_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_locations_backup` SELECT * FROM `lsports_locations_innodb`;
ELSEIF 'go_markets' = in_type THEN
	DROP TABLE  if exists `lsports_markets_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_markets_backup` SELECT * FROM `lsports_markets_innodb`;
ELSEIF 'go_participant' = in_type THEN
	DROP TABLE  if exists `lsports_participant_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_participant_backup` SELECT * FROM `lsports_participant_innodb`;
ELSEIF 'go_sports' = in_type THEN
    DROP TABLE  if exists `lsports_sports_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_sports_backup` SELECT * FROM `lsports_sports_innodb`;
ELSEIF 'go_all' = in_type THEN
	DROP TABLE  if exists `lsports_bet_backup`;
	CREATE TABLE IF NOT EXISTS `lsports_bet_backup` SELECT * FROM `lsports_bet_InnoDB`;

	DROP TABLE  if exists `dividend_policy_backup`;
	CREATE TABLE IF NOT EXISTS `dividend_policy_backup` SELECT * FROM `dividend_policy_innodb`;

	DROP TABLE  if exists `fixtures_bet_sum_backup`;
	CREATE TABLE IF NOT EXISTS `fixtures_bet_sum_backup` SELECT * FROM `fixtures_bet_sum_innodb`;

	DROP TABLE  if exists `lsports_fixtures_backup`;
	CREATE TABLE IF NOT EXISTS `lsports_fixtures_backup` SELECT * FROM `lsports_fixtures_innodb`;

	DROP TABLE  if exists `lsports_leagues_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_leagues_backup` SELECT * FROM `lsports_leagues_innodb`;

	DROP TABLE  if exists `lsports_locations_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_locations_backup` SELECT * FROM `lsports_locations_innodb`;

	DROP TABLE  if exists `lsports_markets_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_markets_backup` SELECT * FROM `lsports_markets_innodb`;

	DROP TABLE  if exists `lsports_participant_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_participant_backup` SELECT * FROM `lsports_participant_innodb`;

    DROP TABLE  if exists `lsports_sports_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_sports_backup` SELECT * FROM `lsports_sports_innodb`;
 END IF;
 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `backupSportsData` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `backupSportsData`(
in in_type varchar(10)
)
BEGIN
 
IF 'go_bet' = in_type THEN
   DROP TABLE  if exists `lsports_bet_backup`;
   CREATE TABLE IF NOT EXISTS `lsports_bet_backup` SELECT * FROM `lsports_bet`;
ELSEIF 'go_policy' = in_type THEN
   DROP TABLE  if exists `dividend_policy_backup`;
   CREATE TABLE IF NOT EXISTS `dividend_policy_backup` SELECT * FROM `dividend_policy`;
ELSEIF 'go_bet_sum' = in_type THEN
	DROP TABLE  if exists `fixtures_bet_sum_backup`;
   CREATE TABLE IF NOT EXISTS `fixtures_bet_sum_backup` SELECT * FROM `fixtures_bet_sum`;
ELSEIF 'go_fixtures' = in_type THEN
	DROP TABLE  if exists `lsports_fixtures_backup`;
   CREATE TABLE IF NOT EXISTS `lsports_fixtures_backup` SELECT * FROM `lsports_fixtures`;
ELSEIF 'go_leagues' = in_type THEN
	DROP TABLE  if exists `lsports_leagues_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_leagues_backup` SELECT * FROM `lsports_leagues`;
ELSEIF 'go_locations' = in_type THEN
	DROP TABLE  if exists `lsports_locations_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_locations_backup` SELECT * FROM `lsports_locations`;
ELSEIF 'go_markets' = in_type THEN
	DROP TABLE  if exists `lsports_markets_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_markets_backup` SELECT * FROM `lsports_markets`;
ELSEIF 'go_participant' = in_type THEN
	DROP TABLE  if exists `lsports_participant_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_participant_backup` SELECT * FROM `lsports_participant`;
ELSEIF 'go_sports' = in_type THEN
    DROP TABLE  if exists `lsports_sports_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_sports_backup` SELECT * FROM `lsports_sports`;
ELSEIF 'go_day_cash' = in_type THEN
    DROP TABLE  if exists `total_day_cash_backup`;
    CREATE TABLE IF NOT EXISTS `total_day_cash_backup` SELECT * FROM `total_day_cash`;    
ELSEIF 'go_all' = in_type THEN
	DROP TABLE  if exists `lsports_bet_backup`;
	CREATE TABLE IF NOT EXISTS `lsports_bet_backup` SELECT * FROM `lsports_bet`;

	DROP TABLE  if exists `dividend_policy_backup`;
	CREATE TABLE IF NOT EXISTS `dividend_policy_backup` SELECT * FROM `dividend_policy`;

	DROP TABLE  if exists `fixtures_bet_sum_backup`;
	CREATE TABLE IF NOT EXISTS `fixtures_bet_sum_backup` SELECT * FROM `fixtures_bet_sum`;

	DROP TABLE  if exists `lsports_fixtures_backup`;
	CREATE TABLE IF NOT EXISTS `lsports_fixtures_backup` SELECT * FROM `lsports_fixtures`;

	DROP TABLE  if exists `lsports_leagues_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_leagues_backup` SELECT * FROM `lsports_leagues`;

	DROP TABLE  if exists `lsports_locations_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_locations_backup` SELECT * FROM `lsports_locations`;

	DROP TABLE  if exists `lsports_markets_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_markets_backup` SELECT * FROM `lsports_markets`;

	DROP TABLE  if exists `lsports_participant_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_participant_backup` SELECT * FROM `lsports_participant`;

    DROP TABLE  if exists `lsports_sports_backup`;
    CREATE TABLE IF NOT EXISTS `lsports_sports_backup` SELECT * FROM `lsports_sports`;
    
    DROP TABLE  if exists `total_day_cash_backup`;
    CREATE TABLE IF NOT EXISTS `total_day_cash_backup` SELECT * FROM `total_day_cash`;    
 END IF;
 


END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `channel_roof` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `channel_roof`()
main : BEGIN

	DECLARE ret_code INT;
	DECLARE errno INT;
    DECLARE v_txt_error_msg text;
    
    DECLARE $next TEXT;
	DECLARE $value TEXT;
	DECLARE $DEL char(1) DEFAULT '/';
    
    declare v_idx int;
    DECLARE v_id varchar(20);
    DECLARE v_nick varchar(20);
    DECLARE v_account_bank varchar(20);
    DECLARE v_account_number varchar(20);
    DECLARE v_account_name varchar(20);
    DECLARE v_hp varchar(20);
    DECLARE v_memo varchar(2048);
   
    DECLARE done INTEGER DEFAULT 0;
    DEClARE openCursor CURSOR FOR SELECT id,nick,account_bank,account_number,account_name,hp,memo FROM mydb.temp_member;
 
    
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = true;
    
    DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
		GET CURRENT DIAGNOSTICS CONDITION 1 errno = MYSQL_ERRNO
		, v_txt_error_msg = MESSAGE_TEXT;
        set ret_code = -1000;
		SELECT ret_code,errno AS MYSQL_ERROR,v_txt_error_msg as MESSAGE_TEXT;
		ROLLBACK;
    END;
           
    START TRANSACTION;
        
        OPEN openCursor;

                  
                  read_loop: LOOP
                           
                           FETCH openCursor INTO v_id,v_nick,v_account_bank,v_account_number,v_account_name,v_hp,v_memo;
                           
                           IF done THEN
                                   LEAVE read_loop;
                           END IF;
                       
						   
                           
						   IF (select 1 = 1 from mydb.`member` where id = v_id) then
							   begin
								ITERATE read_loop;
							   end;
                           end if;
                           
                           IF (select 1 = 1 from mydb.`member` where account_bank = v_account_bank AND account_number = v_account_number) then
							   begin
								ITERATE read_loop;
							   end;
                           end if;
                           
                           
                           IF (select 1 = 1 from mydb.`member` where `call` = v_hp) then
							   begin
								ITERATE read_loop;
							   end;
                           end if;
                           
                           IF (select 1 = 1 from mydb.`member` where `nick_name` = v_nick ) then
							   begin
								 set v_nick = concat(v_nick,'_1');
							   end;
                           end if;
                                                      
                           insert into `mydb`.`member`(`id`,`nick_name`,`password`,`recommend_member`,`dis_id`,`call`,`account_bank`,`account_number`,`account_name`,`point`,`channel`,`status`) 
                           values(v_id,v_nick,'$2y$10$B7sJbgrhzpos38KneWa5W.TEDn.2g2ADRMggAQ2icWEsHGdHCG4.e',2849,'te01',v_hp,v_account_bank,v_account_number,v_account_name,20000,1,1);
                           set v_idx = LAST_INSERT_ID();
                           
                           insert into `member_game_type` (`member_idx`, `game_type`) values(v_idx, 1),(v_idx, 2),(v_idx, 3),(v_idx, 4),(v_idx, 5),(v_idx, 6),(v_idx, 7),(v_idx, 8);
                         
													 
							MAIN_BLOCK:
							LOOP
							  
							  IF CHAR_LENGTH(TRIM(v_memo)) = 0 OR v_memo IS NULL THEN
								LEAVE MAIN_BLOCK;
							  END IF;
							 
							  
							  SET $next = SUBSTRING_INDEX(v_memo, $DEL, 1);

							  
							  SET $value = TRIM($next);

							  
							  INSERT INTO t_member_memo (member_idx,content) VALUES (v_idx,$value);

							  
							  SET v_memo = INSERT(v_memo, 1, CHAR_LENGTH($next) + 1, '');
							END LOOP;

             

                  END LOOP read_loop;

         

         CLOSE openCursor;
    
    
	COMMIT;
END main ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `create_account` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `create_account`()
BEGIN
	
	DECLARE i INT DEFAULT 3;
    WHILE (i <= 100) DO 
        insert into member(id, nick_name, u_business, password, recommend_member, dis_id, `call`, account_bank, account_number, account_name, money) 
			values (concat('test_', i), concat('test_', i), 1, '$2y$10$SyAQNrQA/TQOjn1z/j4csONQ6/WA5cEA/U6S2OS9vk/525bOjCKlm', 1, 'test',
					concat('call_', i), concat('test_', i), concat('test_', i), concat('test_', i), 3000000);
        
        
        SET i = i + 1;
    END WHILE;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `day_bet_mini_distributor` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `day_bet_mini_distributor`(
	-- DECLARE ret_code INT;
)
BEGIN
	SELECT 
        'bet_tot_mini_powerball' AS `stype`,
        SUM(`mini_game_member_bet`.`total_bet_money`) AS `s_money`
    FROM
        (`mini_game_member_bet`
        LEFT JOIN `member` ON (`mini_game_member_bet`.`member_idx` = `member`.`idx`))
    WHERE
        `mini_game_member_bet`.`calculate_dt` >= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 00:00:00')
            AND `mini_game_member_bet`.`calculate_dt` <= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 23:59:59')
            AND `mini_game_member_bet`.`bet_type` = 3
            AND `mini_game_member_bet`.`bet_status` = 3
            AND `member`.`level` <> 9
            AND `mini_game_member_bet`.`total_bet_money` <> `mini_game_member_bet`.`take_money` 
    UNION ALL SELECT 
        'bet_tot_mini_powerball_win' AS `stype`,
        SUM(`mini_game_member_bet`.`take_money`) AS `s_money`
    FROM
        (`mini_game_member_bet`
        LEFT JOIN `member` ON (`mini_game_member_bet`.`member_idx` = `member`.`idx`))
    WHERE
        `mini_game_member_bet`.`calculate_dt` >= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 00:00:00')
            AND `mini_game_member_bet`.`calculate_dt` <= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 23:59:59')
            AND `mini_game_member_bet`.`bet_type` = 3
            AND `mini_game_member_bet`.`bet_status` = 3
            AND `mini_game_member_bet`.`take_money` > 0
            AND `member`.`level` <> 9 
    UNION ALL SELECT 
        'bet_tot_mini_pladder' AS `stype`,
        SUM(`mini_game_member_bet`.`total_bet_money`) AS `s_money`
    FROM
        (`mini_game_member_bet`
        LEFT JOIN `member` ON (`mini_game_member_bet`.`member_idx` = `member`.`idx`))
    WHERE
        `mini_game_member_bet`.`calculate_dt` >= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 00:00:00')
            AND `mini_game_member_bet`.`calculate_dt` <= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 23:59:59')
            AND `mini_game_member_bet`.`bet_type` = 4
            AND `mini_game_member_bet`.`bet_status` = 3
            AND `member`.`level` <> 9
            AND `mini_game_member_bet`.`total_bet_money` <> `mini_game_member_bet`.`take_money` 
    UNION ALL SELECT 
        'bet_tot_mini_pladder_win' AS `stype`,
        SUM(`mini_game_member_bet`.`take_money`) AS `s_money`
    FROM
        (`mini_game_member_bet`
        LEFT JOIN `member` ON (`mini_game_member_bet`.`member_idx` = `member`.`idx`))
    WHERE
        `mini_game_member_bet`.`calculate_dt` >= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 00:00:00')
            AND `mini_game_member_bet`.`calculate_dt` <= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 23:59:59')
            AND `mini_game_member_bet`.`bet_type` = 4
            AND `mini_game_member_bet`.`bet_status` = 3
            AND `mini_game_member_bet`.`take_money` > 0
            AND `member`.`level` <> 9 
    UNION ALL SELECT 
        'bet_tot_mini_kladder' AS `stype`,
        SUM(`mini_game_member_bet`.`total_bet_money`) AS `s_money`
    FROM
        (`mini_game_member_bet`
        LEFT JOIN `member` ON (`mini_game_member_bet`.`member_idx` = `member`.`idx`))
    WHERE
        `mini_game_member_bet`.`calculate_dt` >= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 00:00:00')
            AND `mini_game_member_bet`.`calculate_dt` <= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 23:59:59')
            AND `mini_game_member_bet`.`bet_type` = 5
            AND `mini_game_member_bet`.`bet_status` = 3
            AND `member`.`level` <> 9
            AND `mini_game_member_bet`.`total_bet_money` <> `mini_game_member_bet`.`take_money` 
    UNION ALL SELECT 
        'bet_tot_mini_kladder_win' AS `stype`,
        SUM(`mini_game_member_bet`.`take_money`) AS `s_money`
    FROM
        (`mini_game_member_bet`
        LEFT JOIN `member` ON (`mini_game_member_bet`.`member_idx` = `member`.`idx`))
    WHERE
        `mini_game_member_bet`.`calculate_dt` >= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 00:00:00')
            AND `mini_game_member_bet`.`calculate_dt` <= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 23:59:59')
            AND `mini_game_member_bet`.`bet_type` = 5
            AND `mini_game_member_bet`.`bet_status` = 3
            AND `mini_game_member_bet`.`take_money` > 0
            AND `member`.`level` <> 9 
    UNION ALL SELECT 
        'bet_tot_mini_b_soccer' AS `stype`,
        SUM(`mini_game_member_bet`.`total_bet_money`) AS `s_money`
    FROM
        (`mini_game_member_bet`
        LEFT JOIN `member` ON (`mini_game_member_bet`.`member_idx` = `member`.`idx`))
    WHERE
        `mini_game_member_bet`.`calculate_dt` >= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 00:00:00')
            AND `mini_game_member_bet`.`calculate_dt` <= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 23:59:59')
            AND `mini_game_member_bet`.`bet_type` = 6
            AND `mini_game_member_bet`.`bet_status` = 3
            AND `member`.`level` <> 9
            AND `mini_game_member_bet`.`total_bet_money` <> `mini_game_member_bet`.`take_money` 
    UNION ALL SELECT 
        'bet_tot_mini_b_soccer_win' AS `stype`,
        SUM(`mini_game_member_bet`.`take_money`) AS `s_money`
    FROM
        (`mini_game_member_bet`
        LEFT JOIN `member` ON (`mini_game_member_bet`.`member_idx` = `member`.`idx`))
    WHERE
        `mini_game_member_bet`.`calculate_dt` >= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 00:00:00')
            AND `mini_game_member_bet`.`calculate_dt` <= DATE_FORMAT(CURRENT_TIMESTAMP(), '%Y-%m-%d 23:59:59')
            AND `mini_game_member_bet`.`bet_type` = 6
            AND `mini_game_member_bet`.`bet_status` = 3
            AND `mini_game_member_bet`.`take_money` > 0
            AND `member`.`level` <> 9;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `insert_account_number` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `insert_account_number`()
BEGIN
  
		 DECLARE v_id varchar(45);
         DECLARE v_idx int;
         DECLARE v_account_number varchar(45);
         DECLARE v_account_name varchar(45);
         DECLARE done INTEGER DEFAULT 0;
         DEClARE openCursor CURSOR FOR SELECT id,account_number,account_name FROM mydb.temp_account_info;
 
         
         DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = true;

         
         OPEN openCursor;

                  
                  read_loop: LOOP
                           
                           FETCH openCursor INTO v_id,v_account_number,v_account_name;
                           
                           IF done THEN
                                   LEAVE read_loop;
                           END IF;
                           
                           IF (SELECT 1 = 1 FROM `member` where id = v_id limit 1) THEN
							BEGIN
								SELECT idx INTO v_idx from `member` where id = v_id limit 1;
                                
								insert into `personal_account_number` (`member_idx`, `account_number_1`, `account_name_1`) values(v_idx, v_account_number,v_account_name);
                            END;
                           END IF;
                          
				
                  END LOOP read_loop;

         
         CLOSE openCursor;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `insert_game_type` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `insert_game_type`()
BEGIN
  
		 DECLARE v_idx int;
         DECLARE done INTEGER DEFAULT 0;
         DEClARE openCursor CURSOR FOR SELECT idx FROM mydb.member;
 
         
         DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = true;

         
         OPEN openCursor;

                  
                  read_loop: LOOP
                           
                           FETCH openCursor INTO v_idx;

                           

                           IF done THEN

                                   LEAVE read_loop;

                           END IF;
                       
                           
                           insert into `member_game_type` (`member_idx`, `game_type`) values(v_idx, 1),(v_idx, 2),(v_idx, 3),(v_idx, 4),(v_idx, 5),(v_idx, 6),(v_idx, 7),(v_idx, 9),(v_idx, 10),(v_idx, 11),(v_idx, 12),(v_idx, 13);
                           
                           
                           
                           
                           
                           
                           

             

                  END LOOP read_loop;

         

         CLOSE openCursor;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `insert_total_member_cash` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `insert_total_member_cash`(IN dt_start DATETIME, IN dt_end DATETIME)
BEGIN
-- 커서에서사용할Select 테이블선언
		 DECLARE v_member_idx,v_charge_total_count,v_charge_total_money,v_exchange_total_count,v_exchange_total_money, 
         v_loock_up_total_count,v_bet_total_count,v_bet_total_money,v_pre_s_total_money,v_pre_m_total_money,
         v_real_s_total_money,v_real_m_total_money,v_mini_total_money,v_take_total_money,v_take_mini_total_money,
         v_take_real_m_total_money,v_take_real_s_total_money,v_take_pre_m_total_money,v_take_pre_s_total_money,
         v_casino_total_bet_money,v_casino_total_win_money,v_slot_total_bet_money,v_slot_total_win_money,
		 v_espt_total_bet_money, v_espt_total_win_money, v_hash_total_bet_money, v_hash_total_win_money  int;
                          
         DECLARE done INTEGER DEFAULT 0;
         
         DEClARE openCursor CURSOR FOR 
         SELECT 
         mb.idx AS member_idx,
         IFNULL(mb_ch_his.ch_cnt,0) AS charge_total_count,
         IFNULL(mb_ch_his.ch_sum,0) AS charge_total_money,
         IFNULL(mb_ex_his.ex_cnt,0) AS exchange_total_count,
         IFNULL(mb_ex_his.ex_sum, 0) AS exchange_total_money, 
         IFNULL(loock.loock_cnt,0) AS loock_up_total_count,
	     IFNULL(mini_bet.mini_count,0) + IFNULL(mb_cnt_bet.mb_cnt_count,0) + IFNULL(mb_casino.cs_cnt_count,0) + IFNULL(mb_slot.sl_cnt_count,0) + IFNULL(mb_espt.esp_cnt_count,0) + IFNULL(mb_hash.hs_cnt_count,0) AS bet_total_count,
         IFNULL(bet.pre_bet_sum_s, 0) + IFNULL(bet.pre_bet_sum_d, 0) +  IFNULL(bet.real_bet_sum_s, 0) + IFNULL(bet.real_bet_sum_d, 0) 
         AS bet_total_money,
         IFNULL(bet.pre_bet_sum_s, 0) AS pre_s_total_money,
         IFNULL(bet.pre_bet_sum_d, 0) AS pre_m_total_money,
         IFNULL(bet.real_bet_sum_s, 0) AS real_s_total_money,
         IFNULL(bet.real_bet_sum_d, 0) AS real_m_total_money,
         IFNULL(mg_bet.mini_bet_sum_d, 0) AS mini_total_money,
		 IFNULL(bet.pre_take_sum_s, 0) +  IFNULL(bet.pre_take_sum_d, 0)  +  IFNULL(bet.real_take_sum_s, 0) + IFNULL(bet.real_take_sum_d, 0)
         AS take_total_money,
		 IFNULL(mg_bet.mini_take_sum_d, 0) AS take_mini_total_money,
         IFNULL(bet.real_take_sum_d, 0) AS take_real_m_total_money,
	     IFNULL(bet.real_take_sum_s, 0) AS take_real_s_total_money,
         IFNULL(bet.pre_take_sum_d, 0) AS take_pre_m_total_money,
         IFNULL(bet.pre_take_sum_s, 0) AS take_pre_s_total_money,
         
         IFNULL(mb_casino.casino_total_bet_money, 0) AS casino_total_bet_money,
         IFNULL(mb_casino.casino_total_win_money, 0) AS casino_total_win_money,
         
         IFNULL(mb_slot.slot_total_bet_money, 0) AS slot_total_bet_money,
         IFNULL(mb_slot.slot_total_win_money, 0) AS slot_total_win_money,

         IFNULL(mb_espt.espt_total_bet_money, 0) AS espt_total_bet_money,
         IFNULL(mb_espt.espt_total_win_money, 0) AS espt_total_win_money,
         IFNULL(mb_hash.hash_total_bet_money, 0) AS hash_total_bet_money,
         IFNULL(mb_hash.hash_total_win_money, 0) AS hash_total_win_money
		FROM (SELECT m.idx, m.id, m.nick_name from member AS m ) AS mb
    LEFT JOIN 
        (SELECT IFNULL(sum(ch_his.money), 0) AS ch_sum,
            count(idx) AS ch_cnt,
            ch_his.member_idx AS member_idx
            FROM member_money_charge_history AS ch_his 
            WHERE ch_his.status = 3
             AND ch_his.update_dt >= dt_start
             AND ch_his.update_dt <= dt_end
            GROUP BY ch_his.member_idx) AS mb_ch_his 
    ON 
    mb.idx =  mb_ch_his.member_idx
    LEFT JOIN 
        (SELECT IFNULL(sum(ex_his.money), 0) AS ex_sum,
            count(idx) AS ex_cnt,
            ex_his.member_idx AS member_idx
            FROM member_money_exchange_history AS ex_his 
            WHERE ex_his.status = 3
            AND ex_his.update_dt >= dt_start
            AND ex_his.update_dt <= dt_end
            GROUP BY ex_his.member_idx) AS mb_ex_his
    ON mb.idx =  mb_ex_his.member_idx
    LEFT JOIN 
	    (SELECT 
        mb_bet.member_idx AS member_idx,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 1 AND mb_bet.folder_type = 'S'
                        THEN mb_bet.total_bet_money ELSE 0 END), 0) AS pre_bet_sum_s,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 1 AND mb_bet.folder_type = 'S'
                        THEN mb_bet.take_money ELSE 0 END), 0) AS pre_take_sum_s,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 1 AND mb_bet.folder_type = 'S'
                        THEN mb_bet.total_bet_money ELSE 0 END), 0)
            - 	IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 1 AND mb_bet.folder_type = 'S'
                        THEN mb_bet.take_money ELSE 0 END), 0) AS pre_sum_s,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 1 AND mb_bet.folder_type = 'D'
                        THEN mb_bet.total_bet_money ELSE 0 END), 0) AS pre_bet_sum_d,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 1 AND mb_bet.folder_type = 'D'
                        THEN mb_bet.take_money ELSE 0 END), 0) AS pre_take_sum_d,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 1 AND mb_bet.folder_type = 'D'
                        THEN mb_bet.total_bet_money ELSE 0 END), 0)
            - 	IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 1 AND mb_bet.folder_type = 'D'
                        THEN mb_bet.take_money ELSE 0 END), 0) AS pre_sum_d,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 2 AND mb_bet.folder_type = 'S'
                        THEN mb_bet.total_bet_money ELSE 0 END), 0) AS real_bet_sum_s,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 2 AND mb_bet.folder_type = 'S'
                        THEN mb_bet.take_money ELSE 0 END), 0) AS real_take_sum_s,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 2 AND mb_bet.folder_type = 'S'
                        THEN mb_bet.total_bet_money ELSE 0 END), 0)
            - 	IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 2 AND mb_bet.folder_type = 'S'
                        THEN mb_bet.take_money ELSE 0 END), 0) AS real_sum_s,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 2 AND mb_bet.folder_type = 'D'
                        THEN mb_bet.total_bet_money ELSE 0 END), 0) AS real_bet_sum_d,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 2 AND mb_bet.folder_type = 'D'
                        THEN mb_bet.take_money ELSE 0 END), 0) AS real_take_sum_d,
            IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 2 AND mb_bet.folder_type = 'D'
                        THEN mb_bet.total_bet_money ELSE 0 END), 0)
            - 	IFNULL(SUM(CASE 
                        WHEN mb_bet.bet_type = 2 AND mb_bet.folder_type = 'D'
                        THEN mb_bet.take_money ELSE 0 END), 0) AS real_sum_d
	FROM member_bet AS mb_bet
        WHERE mb_bet.bet_status = 3
        AND mb_bet.calculate_dt >= dt_start
        AND mb_bet.calculate_dt <= dt_end
        AND total_bet_money != take_money
	GROUP BY mb_bet.member_idx) AS bet
    ON 
    mb.idx =  bet.member_idx
 LEFT JOIN 
	(SELECT mg.member_idx AS member_idx,
	    IFNULL(sum(mg.total_bet_money), 0) AS mini_bet_sum_d,
        IFNULL(sum(mg.take_money), 0) AS mini_take_sum_d,
        IFNULL(sum(mg.total_bet_money), 0) - IFNULL(sum(mg.take_money), 0) AS mini_sum_d
	FROM mini_game_member_bet AS mg
	WHERE mg.bet_status = 3  
        AND mg.calculate_dt >= dt_start
        AND mg.calculate_dt <= dt_end
        AND mg.total_bet_money != take_money
    GROUP BY mg.member_idx) AS mg_bet
    ON 
    mb.idx =  mg_bet.member_idx  
 LEFT JOIN
  (SELECT count(idx) as loock_cnt
  ,member_idx
  FROM t_log_cash
  WHERE   ac_code IN(103) 
         AND t_log_cash.reg_time >= dt_start
         AND t_log_cash.reg_time <= dt_end
        ) as loock
   ON mb.idx = loock.member_idx      
 LEFT JOIN 
	(SELECT count(idx) as mini_count
    ,member_idx
	FROM mini_game_member_bet AS mg
	WHERE mg.bet_status = 3  
         AND mg.calculate_dt >= dt_start
         AND mg.calculate_dt <= dt_end
    
    GROUP BY mg.member_idx) AS mini_bet
    ON 
    mb.idx =  mini_bet.member_idx    
 LEFT JOIN 
	(SELECT count(idx) as mb_cnt_count
    ,member_idx
	FROM member_bet AS mg
	WHERE mg.bet_status = 3  
         AND mg.calculate_dt >= dt_start
         AND mg.calculate_dt <= dt_end
    
    GROUP BY mg.member_idx) AS mb_cnt_bet
    ON 
    mb.idx =  mb_cnt_bet.member_idx 
 LEFT JOIN  -- 카지노 
    (SELECT count(CSN_BET_IDX) as cs_cnt_count,
		MBR_IDX,
        IFNULL(SUM(`BET_MNY`), 0) AS `casino_total_bet_money`,
        IFNULL(SUM(CASE
                    WHEN `TYPE` = 'W' THEN `BET_MNY` + `RSLT_MNY`
                END),
                0) AS `casino_total_win_money`
    FROM `KP_CSN_BET_HIST` 
    WHERE 
         `CALC_DTM` >= dt_start
         AND `CALC_DTM` <= dt_end
      ) AS mb_casino
    ON 
    mb.idx =  mb_casino.MBR_IDX 
    LEFT JOIN  -- 슬롯 
    (SELECT count(SLOT_BET_IDX) as sl_cnt_count,
		MBR_IDX,
        IFNULL(SUM(`BET_MNY`), 0) AS `slot_total_bet_money`,
        IFNULL(SUM(CASE
                    WHEN `TYPE` = 'W' THEN `BET_MNY` + `RSLT_MNY`
                END),
                0) AS `slot_total_win_money`
    FROM `KP_SLOT_BET_HIST` 
    WHERE 
         `CALC_DTM` >= dt_start
         AND `CALC_DTM` <= dt_end
      ) AS mb_slot
    ON 
    mb.idx =  mb_slot.MBR_IDX
    LEFT JOIN  -- 이스포츠
    (SELECT count(SLOT_BET_IDX) as esp_cnt_count,
		MBR_IDX,
        IFNULL(SUM(`BET_MNY`), 0) AS `espt_total_bet_money`,
        IFNULL(SUM(CASE
                    WHEN `TYPE` = 'W' THEN `BET_MNY` + `RSLT_MNY`
                END),
                0) AS `espt_total_win_money`
    FROM `KP_ESPT_BET_HIST`
    WHERE
         `CALC_DTM` >= dt_start
         AND `CALC_DTM` <= dt_end
      ) AS mb_espt
    ON
    mb.idx =  mb_espt.MBR_IDX
    LEFT JOIN  -- 해시
    (SELECT count(HASH_BET_IDX) as hs_cnt_count,
		MBR_IDX,
        IFNULL(SUM(`BET_MNY`), 0) AS `hash_total_bet_money`,
        IFNULL(SUM(CASE
                    WHEN `TYPE` = 'W' THEN `BET_MNY` + `RSLT_MNY`
                END),
                0) AS `hash_total_win_money`
    FROM `OD_HASH_BET_HIST`
    WHERE
         `CALC_DTM` >= dt_start
         AND `CALC_DTM` <= dt_end
      ) AS mb_hash
    ON
    mb.idx =  mb_hash.MBR_IDX
     
   GROUP BY mb.idx; 
         
         -- 반복문핸들러선언
         DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = true;

         -- 커서오픈
         OPEN openCursor;

                  -- 반복문시작
                  read_loop: LOOP
                           -- 커서에서데이터가져옴
                           FETCH openCursor INTO v_member_idx,v_charge_total_count,v_charge_total_money,v_exchange_total_count,v_exchange_total_money, 
												 v_loock_up_total_count,v_bet_total_count,v_bet_total_money,v_pre_s_total_money,v_pre_m_total_money,
												 v_real_s_total_money,v_real_m_total_money,v_mini_total_money,v_take_total_money,v_take_mini_total_money,
												 v_take_real_m_total_money,v_take_real_s_total_money,v_take_pre_m_total_money,v_take_pre_s_total_money,v_casino_total_bet_money,
                                                 v_casino_total_win_money,v_slot_total_bet_money,v_slot_total_win_money,v_espt_total_bet_money,v_espt_total_win_money,
                                                 v_hash_total_bet_money,v_hash_total_win_money;
                           -- 반복문종료시조건
                           IF done THEN
                                   LEAVE read_loop;
                           END IF;
                       
                           -- 테이블에저장
                           insert into `total_member_cash` ( member_idx,charge_total_count,charge_total_money,exchange_total_count,exchange_total_money, 
												 loock_up_total_count,bet_total_count,bet_total_money,pre_s_total_money,pre_m_total_money,
												 real_s_total_money,real_m_total_money,mini_total_money,take_total_money,take_mini_total_money,
												 take_real_m_total_money,take_real_s_total_money,take_pre_m_total_money,take_pre_s_total_money,casino_total_money,
                                                 take_casino_total_money,slot_total_money,take_slot_total_money,espt_total_money,take_espt_total_money,
                                                 hash_total_money,take_hash_total_money)
						   values(v_member_idx,v_charge_total_count,v_charge_total_money,v_exchange_total_count,v_exchange_total_money, 
												 v_loock_up_total_count,v_bet_total_count,v_bet_total_money,v_pre_s_total_money,v_pre_m_total_money,
												 v_real_s_total_money,v_real_m_total_money,v_mini_total_money,v_take_total_money,v_take_mini_total_money,
												 v_take_real_m_total_money,v_take_real_s_total_money,v_take_pre_m_total_money,v_take_pre_s_total_money,v_casino_total_bet_money,
                                                 v_casino_total_win_money,v_slot_total_bet_money,v_slot_total_win_money,v_espt_total_bet_money,v_espt_total_win_money,
                                                 v_hash_total_bet_money,v_hash_total_win_money)
                                                 ON DUPLICATE KEY UPDATE
                                                 charge_total_count  = charge_total_count + VALUES(charge_total_count),
                                                 charge_total_money = charge_total_money + VALUES(charge_total_money),
                                                 exchange_total_count = exchange_total_count + VALUES(exchange_total_count),
                                                 exchange_total_money  = exchange_total_money + VALUES(exchange_total_money), 
												 loock_up_total_count  = loock_up_total_count + VALUES(loock_up_total_count),
                                                 bet_total_count  = bet_total_count + VALUES(bet_total_count),
                                                 bet_total_money  = bet_total_money + VALUES(bet_total_money),
                                                 pre_s_total_money  = pre_s_total_money + VALUES(pre_s_total_money),
                                                 pre_m_total_money  = pre_m_total_money + VALUES(pre_m_total_money),
												 real_s_total_money  = real_s_total_money + VALUES(real_s_total_money),
                                                 real_m_total_money  = real_m_total_money + VALUES(real_m_total_money),
                                                 mini_total_money  = mini_total_money + VALUES(mini_total_money),
                                                 take_total_money  = take_total_money + VALUES(take_total_money),
                                                 take_mini_total_money  = take_mini_total_money + VALUES(take_mini_total_money),
												 take_real_m_total_money  = take_real_m_total_money + VALUES(take_real_m_total_money),
                                                 take_real_s_total_money  = take_real_s_total_money + VALUES(take_real_s_total_money),
                                                 take_pre_m_total_money  = take_pre_m_total_money + VALUES(take_pre_m_total_money),
                                                 take_pre_s_total_money   = take_pre_s_total_money + VALUES(take_pre_s_total_money),

                                                 casino_total_money  = casino_total_money + VALUES(casino_total_money),
                                                 take_casino_total_money  = take_casino_total_money + VALUES(take_casino_total_money),
                                                 slot_total_money  = slot_total_money + VALUES(slot_total_money),
                                                 take_slot_total_money   = take_slot_total_money + VALUES(take_slot_total_money),
                                                 espt_total_money  = espt_total_money + VALUES(espt_total_money),
                                                 take_espt_total_money  = take_espt_total_money + VALUES(take_espt_total_money),
                                                 hash_total_money  = hash_total_money + VALUES(hash_total_money),
                                                 take_hash_total_money   = take_hash_total_money + VALUES(take_hash_total_money)
                                                 ;

             -- 반복문끝

                  END LOOP read_loop;

         -- 커서해제

         CLOSE openCursor;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `rollbackBetInfo` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `rollbackBetInfo`(
in in_idx int
)
main: BEGIN
	
    declare ret_idx int default 0;
    declare ret_member_idx int default 0;
    declare ret_bet_status int default 0;
    declare ret_bet_type int default 0;
    declare ret_total_bet_money int default 0;
    declare ret_folder_type int default 0;
    declare ret_take_money int default 0;
    declare ret_take_point int default 0;
    declare ret_create_dt datetime default null;
    
   	DECLARE ret_code INT;
	DECLARE errno INT;
    DECLARE v_txt_error_msg text;


    BEGIN
		GET CURRENT DIAGNOSTICS CONDITION 1 errno = MYSQL_ERRNO
		, v_txt_error_msg = MESSAGE_TEXT;
        set ret_code = -1000;
		SELECT ret_code,errno AS MYSQL_ERROR,v_txt_error_msg as MESSAGE_TEXT;
		ROLLBACK;
    END;
           
    START TRANSACTION;
    
    select idx     , member_idx,    bet_status,     bet_type,     total_bet_money,     folder_type,     take_money,     take_point,     create_dt
    into   ret_idx, ret_member_idx, ret_bet_status, ret_bet_type, ret_total_bet_money, ret_folder_type, ret_take_money, ret_take_point, ret_create_dt
    from member_bet where idx = in_idx;
    
    if 3 <> ret_bet_status OR ret_take_money <> 0 then
		leave main;
    end if;
    
    INSERT INTO `member_bet_bakup` SELECT * FROM `member_bet` where idx = ret_idx;
    INSERT INTO `member_bet_detail_backup` SELECT * FROM `member_bet_detail` where bet_idx = ret_idx;
    INSERT INTO `t_log_cash_backup` SELECT * FROM `t_log_cash` where ac_idx = ret_idx;
    
    DELETE FROM `member_bet` WHERE idx = ret_idx;
    DELETE FROM `member_bet_detail` where bet_idx = ret_idx;
    DELETE FROM `t_log_cash` where ac_idx = ret_idx;
    
    UPDATE member SET money = money + ret_total_bet_money WHERE idx = ret_member_idx;
    
    COMMIT;
END main ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `rollbackDataSports` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `rollbackDataSports`(
in in_type varchar(10)
)
BEGIN

IF 'go_bet' = in_type THEN
    truncate lsports_bet;
	INSERT INTO lsports_bet
	SELECT * FROM lsports_bet_InnoDB;
ELSEIF 'go_policy' = in_type THEN
    truncate dividend_policy;
	INSERT INTO dividend_policy
	SELECT * FROM dividend_policy_innodb;
ELSEIF 'go_bet_sum' = in_type THEN
	truncate fixtures_bet_sum;
	INSERT INTO fixtures_bet_sum
	SELECT * FROM fixtures_bet_sum_innodb;
ELSEIF 'go_fixtures' = in_type THEN
    truncate lsports_fixtures;
	INSERT INTO lsports_fixtures
	SELECT * FROM lsports_fixtures_innodb;   
ELSEIF 'go_leagues' = in_type THEN
    truncate lsports_leagues;
	INSERT INTO lsports_leagues
	SELECT * FROM lsports_leagues_innodb;
ELSEIF 'go_locations' = in_type THEN
    truncate lsports_locations;
	INSERT INTO lsports_locations
	SELECT * FROM lsports_locations_innodb;
ELSEIF 'go_markets' = in_type THEN
    truncate lsports_markets;
	INSERT INTO lsports_markets
	SELECT * FROM lsports_markets_innodb;   
ELSEIF 'go_participant' = in_type THEN
    truncate lsports_participant;
	INSERT INTO lsports_participant
	SELECT * FROM lsports_participant_innodb;   
ELSEIF 'go_sports' = in_type THEN
    truncate lsports_sports;
	INSERT INTO lsports_sports
	SELECT * FROM lsports_sports_innodb;     
ELSEIF 'go_all' = in_type THEN
	truncate lsports_bet;
	INSERT INTO lsports_bet
	SELECT * FROM lsports_bet_InnoDB;

    truncate dividend_policy;
	INSERT INTO dividend_policy
	SELECT * FROM dividend_policy_innodb;
  
	truncate fixtures_bet_sum;
	INSERT INTO fixtures_bet_sum
	SELECT * FROM fixtures_bet_sum_innodb;

    truncate lsports_fixtures;
	INSERT INTO lsports_fixtures
	SELECT * FROM lsports_fixtures_innodb;   
 
    truncate lsports_leagues;
	INSERT INTO lsports_leagues
	SELECT * FROM lsports_leagues_innodb;
 
    truncate lsports_locations;
	INSERT INTO lsports_locations
	SELECT * FROM lsports_locations_innodb;
 
    truncate lsports_markets;
	INSERT INTO lsports_markets
	SELECT * FROM lsports_markets_innodb;   
 
    truncate lsports_participant;
	INSERT INTO lsports_participant
	SELECT * FROM lsports_participant_innodb;   

    truncate lsports_sports;
	INSERT INTO lsports_sports
	SELECT * FROM lsports_sports_innodb;     
 END IF;
 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `rollbackToMemoryDB` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `rollbackToMemoryDB`(
in in_type varchar(10)
)
BEGIN
	
IF 'go_bet' = in_type THEN
    truncate lsports_bet;
	truncate lsports_bet_InnoDB;
	INSERT INTO lsports_bet
	SELECT * FROM lsports_bet_backup;
	
ELSEIF 'go_policy' = in_type THEN
    truncate dividend_policy;
	truncate dividend_policy_innodb;
	INSERT INTO dividend_policy
	SELECT * FROM dividend_policy_backup;
    
ELSEIF 'go_bet_sum' = in_type THEN
	truncate fixtures_bet_sum;
	truncate fixtures_bet_sum_innodb;
	INSERT INTO fixtures_bet_sum
	SELECT * FROM fixtures_bet_sum_backup;
    
ELSEIF 'go_fixtures' = in_type THEN
    truncate lsports_fixtures;
    truncate lsports_fixtures_innodb;
	INSERT INTO lsports_fixtures
	SELECT * FROM lsports_fixtures_backup;   
    
ELSEIF 'go_leagues' = in_type THEN
    truncate lsports_leagues;
	INSERT INTO lsports_leagues
	SELECT * FROM lsports_leagues_innodb;
    
ELSEIF 'go_locations' = in_type THEN
    truncate lsports_locations;
	truncate lsports_locations_innodb;
	INSERT INTO lsports_locations
	SELECT * FROM lsports_locations_backup;
    
ELSEIF 'go_markets' = in_type THEN
    truncate lsports_markets;
	truncate lsports_markets_innodb;
	INSERT INTO lsports_markets
	SELECT * FROM lsports_markets_backup;   
    
ELSEIF 'go_participant' = in_type THEN
    truncate lsports_participant;
	truncate lsports_participant_innodb;
	INSERT INTO lsports_participant
	SELECT * FROM lsports_participant_backup;   
    
ELSEIF 'go_sports' = in_type THEN
    truncate lsports_sports;
	truncate lsports_sports_innodb;
	INSERT INTO lsports_sports
	SELECT * FROM lsports_sports_backup;     
    
    
ELSEIF 'go_day_cash' = in_type THEN
    truncate total_day_cash;
	INSERT INTO total_day_cash
	SELECT * FROM total_day_cash_backup;     
    
ELSEIF 'go_all' = in_type THEN
	truncate lsports_bet;
    truncate lsports_bet_InnoDB;
	INSERT INTO lsports_bet
	SELECT * FROM lsports_bet_backup;
	
    
    truncate dividend_policy;
    truncate dividend_policy_innodb;
	INSERT INTO dividend_policy
	SELECT * FROM dividend_policy_backup;
    
    
	truncate fixtures_bet_sum;
    truncate fixtures_bet_sum_innodb;
	INSERT INTO fixtures_bet_sum
	SELECT * FROM fixtures_bet_sum_backup;
    
    
    truncate lsports_fixtures;
    truncate lsports_fixtures_innodb;
	INSERT INTO lsports_fixtures
	SELECT * FROM lsports_fixtures_backup;   
    
    
    truncate lsports_leagues;
	truncate lsports_leagues_innodb;
	INSERT INTO lsports_leagues
	SELECT * FROM lsports_leagues_backup;
    
    
    truncate lsports_locations;
    truncate lsports_locations_innodb;
	INSERT INTO lsports_locations
	SELECT * FROM lsports_locations_backup;
    
    
    truncate lsports_markets;
    truncate lsports_markets_innodb;
	INSERT INTO lsports_markets
	SELECT * FROM lsports_markets_backup;   
    
    
    truncate lsports_participant;
    truncate lsports_participant_innodb;
	INSERT INTO lsports_participant
	SELECT * FROM lsports_participant_backup;   
    
    
    truncate lsports_sports;
    truncate lsports_sports_innodb;
	INSERT INTO lsports_sports
	SELECT * FROM lsports_sports_backup;     
    
    
	truncate total_day_cash;
	INSERT INTO total_day_cash
	SELECT * FROM total_day_cash_backup;     
    
 END IF;
 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `spInsertUpdateODDLeagueInfo` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `spInsertUpdateODDLeagueInfo`(
	IN Iid INT
    , Iname VARCHAR(45)
    , IlocationId INT
    , IsportId INT
    , Iseason VARCHAR(45)
)
main: BEGIN

	INSERT INTO `mydb`.`lsports_leagues` (id, bet_type, `name`, location_id, sport_id, season, lang)
	VALUES (Iid, 1, Iname, IlocationId, IsportId, Iseason, 'ko')
	ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), location_id = VALUES(location_id), sport_id = VALUES(sport_id), season = VALUES(season), lang = VALUES(lang);
		
	INSERT INTO `mydb`.`lsports_leagues` (id, bet_type, `name`, location_id, sport_id, season, lang)
	VALUES (Iid, 2, Iname, IlocationId, IsportId, Iseason, 'ko')
	ON DUPLICATE KEY UPDATE `name` = VALUES(`name`), location_id = VALUES(location_id), sport_id = VALUES(sport_id), season = VALUES(season), lang = VALUES(lang);
     
END main ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `spSelectFixtureMarketsBetType3Table` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `spSelectFixtureMarketsBetType3Table`(
	IN IbetType TINYINT
    , IfixtureId INT
)
main: BEGIN

    
	
    IF 1 = IbetType THEN
		SELECT fix.display_status, fix.fixture_start_date,
        fix.fixture_sport_id, fix.fixture_league_id,
        sports.deduction_refund_rate as sp_deduction_refund_rate, leagues.deduction_refund_rate as lg_deduction_refund_rate
		FROM lsports_fixtures as fix
		LEFT JOIN   lsports_sports as sports
		ON   fix.fixture_sport_id = sports.id   
		LEFT JOIN   lsports_leagues as leagues
		ON   fix.fixture_league_id = leagues.id   
		WHERE fix.fixture_id = IfixtureId AND fix.bet_type = IbetType
		AND sports.is_use = 1 AND sports.bet_type = IbetType AND leagues.bet_type = IbetType AND leagues.is_use = 1;
    ELSE
		SELECT fix.display_status, fix.fixture_start_date, fix.fixture_sport_id,
        fix.fixture_league_id,
        sports.deduction_refund_rate as sp_deduction_refund_rate, leagues.deduction_refund_rate as lg_deduction_refund_rate
		FROM lsports_fixtures as fix
		LEFT JOIN   lsports_sports as sports
		ON   fix.fixture_sport_id = sports.id   
		LEFT JOIN   lsports_leagues as leagues
		ON   fix.fixture_league_id = leagues.id   
		WHERE fix.fixture_id = IfixtureId AND fix.bet_type = IbetType
		AND sports.is_use = 1 AND sports.bet_type = IbetType AND leagues.bet_type = IbetType;
    END IF;
     
END main ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `spUpdateFixturesDataType2` */;
DELIMITER ;;
CREATE DEFINER=`chosunadmin`@`%` PROCEDURE `spUpdateFixturesDataType2`(
	IN IbetType TINYINT
    , IfixtureId INT
    , IliveTime VARCHAR(45)
    , IliveCurrentPeriod INT
    , Istatus VARCHAR(2)
    , IdisplayStatus INT
    , Ivalue1 INT
    , Ivalue2 INT
    , IliveScore MEDIUMTEXT 
)
main: BEGIN

	DECLARE retcode INT DEFAULT 0;
	DECLARE tDisplayStatus INT DEFAULT 0;
	DECLARE tFixtureStartDate DATETIME DEFAULT 0;
	DECLARE tFixtureSportsId INT DEFAULT 0;
    
	IF 1 = IbetType THEN
		SELECT fixtures.display_status, fixtures.fixture_start_date, fixtures.fixture_sport_id INTO tDisplayStatus, tFixtureStartDate, tFixtureSportsId from `mydb`.`lsports_fixtures` as fixtures
		LEFT JOIN `mydb`.`lsports_leagues` as leagues ON fixtures.fixture_league_id = leagues.id AND fixtures.fixture_sport_id = leagues.sport_id
		WHERE fixtures.fixture_id = IfixtureId AND fixtures.display_status IN (1,2) AND fixtures.bet_type = IbetType AND leagues.is_use = 1 ORDER BY fixtures.fixture_start_date DESC LIMIT 1;
    ELSE
		SELECT fixtures.display_status,fixtures.fixture_start_date,fixtures.fixture_sport_id INTO tDisplayStatus, tFixtureStartDate, tFixtureSportsId from `mydb`.`lsports_fixtures` as fixtures
		WHERE fixtures.fixture_id = IfixtureId AND fixtures.display_status IN (1,2) AND fixtures.bet_type = IbetType ORDER BY fixtures.fixture_start_date DESC LIMIT 1;
    END IF;
    
    IF 0 != IdisplayStatus THEN
		SET tDisplayStatus = IdisplayStatus;
    END IF;


    IF 0 = tDisplayStatus AND 0 = tFixtureStartDate AND 0 = tFixtureSportsId THEN
		SET retcode = -1;
		SELECT retcode;
		LEAVE main;
    END IF;

    IF (1 = IdisplayStatus OR 2 = IdisplayStatus) AND 3 = tDisplayStatus THEN
		SET retcode = -2;
		SELECT retcode;
		LEAVE main;
    END IF;
    
    IF '2' = Istatus OR '3' = Istatus THEN
		IF now() < tFixtureStartDate THEN
			SET retcode = -3;
			SELECT retcode;
			LEAVE main;
		END IF;
    END IF;

    
	UPDATE `mydb`.`lsports_fixtures` 
    SET live_time_x = IliveTime, live_current_period_x = IliveCurrentPeriod, display_status = tDisplayStatus, fixture_status = Istatus, live_results_p1 = Ivalue1, live_results_p2 = Ivalue2,
	livescore = IliveScore
    WHERE fixture_id = IfixtureId AND bet_type = IbetType;
    
    SELECT retcode;
     
END main ;;
DELIMITER ;

--
-- Final view structure for view `day_bet_classic`
--

/*!50001 DROP VIEW IF EXISTS `day_bet_classic`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`chosunadmin`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `day_bet_classic` AS select 'bet_tot_ing' AS `stype`,`member_bet`.`bet_status` AS `status`,count(0) AS `cnt`,sum(`member_bet`.`total_bet_money`) AS `s_money`,0 AS `s_win_money` from (`member_bet` left join `member` on(`member_bet`.`member_idx` = `member`.`idx`)) where `member_bet`.`bet_type` = 1 and `member_bet`.`is_classic` = 'ON' and `member_bet`.`bet_status` = 1 and `member`.`level` <> 9 union all select 'bet_tot' AS `stype`,`member_bet`.`bet_status` AS `status`,count(0) AS `cnt`,`member_bet`.`total_bet_money` AS `s_money`,`member_bet`.`take_money` AS `s_win_money` from (`member_bet` left join `member` on(`member_bet`.`member_idx` = `member`.`idx`)) where `member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member_bet`.`bet_type` = 1 and `member_bet`.`bet_status` = 3 and `member_bet`.`is_classic` = 'ON' and `member`.`level` <> 9 and `member_bet`.`total_bet_money` <> `member_bet`.`take_money` group by `member_bet`.`idx` union all select 'bet_tot_sports' AS `stype`,`member_bet`.`bet_status` AS `status`,count(0) AS `cnt`,`member_bet`.`total_bet_money` AS `s_money`,sum(`member_bet`.`take_money`) AS `s_win_money` from (`member_bet` left join `member` on(`member_bet`.`member_idx` = `member`.`idx`)) where `member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member_bet`.`bet_type` = 1 and `member_bet`.`bet_status` = 3 and `member_bet`.`is_classic` = 'ON' and `member_bet`.`total_bet_money` <> `member_bet`.`take_money` and `member`.`level` <> 9 */;

--
-- Final view structure for view `day_bet_mini`
--

/*!50001 DROP VIEW IF EXISTS `day_bet_mini`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`chosunadmin`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `day_bet_mini` AS select 'bet_tot_mini_eos_powerball' AS `stype`,sum(`mini_game_member_bet`.`total_bet_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 3 and `mini_game_member_bet`.`bet_status` = 3 and `member`.`level` <> 9 and `mini_game_member_bet`.`total_bet_money` <> `mini_game_member_bet`.`take_money` union all select 'bet_tot_mini_eos_powerball_win' AS `stype`,sum(`mini_game_member_bet`.`take_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 3 and `mini_game_member_bet`.`bet_status` = 3 and `mini_game_member_bet`.`take_money` > 0 and `member`.`level` <> 9 union all select 'bet_tot_mini_powerball' AS `stype`,sum(`mini_game_member_bet`.`total_bet_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 3 and `mini_game_member_bet`.`bet_status` = 3 and `member`.`level` <> 9 and `mini_game_member_bet`.`total_bet_money` <> `mini_game_member_bet`.`take_money` union all select 'bet_tot_mini_powerball_win' AS `stype`,sum(`mini_game_member_bet`.`take_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 3 and `mini_game_member_bet`.`bet_status` = 3 and `mini_game_member_bet`.`take_money` > 0 and `member`.`level` <> 9 union all select 'bet_tot_mini_pladder' AS `stype`,sum(`mini_game_member_bet`.`total_bet_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 4 and `mini_game_member_bet`.`bet_status` = 3 and `member`.`level` <> 9 and `mini_game_member_bet`.`total_bet_money` <> `mini_game_member_bet`.`take_money` union all select 'bet_tot_mini_pladder_win' AS `stype`,sum(`mini_game_member_bet`.`take_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 4 and `mini_game_member_bet`.`bet_status` = 3 and `mini_game_member_bet`.`take_money` > 0 and `member`.`level` <> 9 union all select 'bet_tot_mini_kladder' AS `stype`,sum(`mini_game_member_bet`.`total_bet_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 5 and `mini_game_member_bet`.`bet_status` = 3 and `member`.`level` <> 9 and `mini_game_member_bet`.`total_bet_money` <> `mini_game_member_bet`.`take_money` union all select 'bet_tot_mini_kladder_win' AS `stype`,sum(`mini_game_member_bet`.`take_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 5 and `mini_game_member_bet`.`bet_status` = 3 and `mini_game_member_bet`.`take_money` > 0 and `member`.`level` <> 9 union all select 'bet_tot_mini_b_soccer' AS `stype`,sum(`mini_game_member_bet`.`total_bet_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 6 and `mini_game_member_bet`.`bet_status` = 3 and `member`.`level` <> 9 and `mini_game_member_bet`.`total_bet_money` <> `mini_game_member_bet`.`take_money` union all select 'bet_tot_mini_b_soccer_win' AS `stype`,sum(`mini_game_member_bet`.`take_money`) AS `s_money` from (`mini_game_member_bet` left join `member` on(`mini_game_member_bet`.`member_idx` = `member`.`idx`)) where `mini_game_member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mini_game_member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `mini_game_member_bet`.`bet_type` = 6 and `mini_game_member_bet`.`bet_status` = 3 and `mini_game_member_bet`.`take_money` > 0 and `member`.`level` <> 9 */;

--
-- Final view structure for view `day_bet_pre`
--

/*!50001 DROP VIEW IF EXISTS `day_bet_pre`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`chosunadmin`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `day_bet_pre` AS select 'bet_tot_ing' AS `stype`,`member_bet`.`bet_status` AS `status`,count(0) AS `cnt`,sum(`member_bet`.`total_bet_money`) AS `s_money`,0 AS `s_win_money` from (`member_bet` left join `member` on(`member_bet`.`member_idx` = `member`.`idx`)) where `member_bet`.`bet_type` = 1 and `member_bet`.`is_classic` = 'OFF' and `member_bet`.`bet_status` = 1 and `member`.`level` <> 9 union all select 'bet_tot' AS `stype`,`member_bet`.`bet_status` AS `status`,count(0) AS `cnt`,`member_bet`.`total_bet_money` AS `s_money`,`member_bet`.`take_money` AS `s_win_money` from (`member_bet` left join `member` on(`member_bet`.`member_idx` = `member`.`idx`)) where `member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member_bet`.`bet_type` = 1 and `member_bet`.`bet_status` = 3 and `member_bet`.`is_classic` = 'OFF' and `member`.`level` <> 9 and `member_bet`.`total_bet_money` <> `member_bet`.`take_money` group by `member_bet`.`idx` union all select 'bet_tot_sports' AS `stype`,`member_bet`.`bet_status` AS `status`,count(0) AS `cnt`,`member_bet`.`total_bet_money` AS `s_money`,sum(`member_bet`.`take_money`) AS `s_win_money` from (`member_bet` left join `member` on(`member_bet`.`member_idx` = `member`.`idx`)) where `member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member_bet`.`bet_type` = 1 and `member_bet`.`bet_status` = 3 and `member_bet`.`is_classic` = 'OFF' and `member_bet`.`total_bet_money` <> `member_bet`.`take_money` and `member`.`level` <> 9 */;

--
-- Final view structure for view `day_bet_real`
--

/*!50001 DROP VIEW IF EXISTS `day_bet_real`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`chosunadmin`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `day_bet_real` AS select 'bet_tot_ing' AS `stype`,`member_bet`.`bet_status` AS `status`,count(0) AS `cnt`,sum(`member_bet`.`total_bet_money`) AS `s_money`,0 AS `s_win_money` from (`member_bet` left join `member` on(`member_bet`.`member_idx` = `member`.`idx`)) where `member_bet`.`bet_type` = 2 and `member_bet`.`bet_status` = 1 and `member`.`level` <> 9 union all select 'bet_tot' AS `stype`,`member_bet`.`bet_status` AS `status`,count(0) AS `cnt`,`member_bet`.`total_bet_money` AS `s_money`,`member_bet`.`take_money` AS `s_win_money` from (`member_bet` left join `member` on(`member_bet`.`member_idx` = `member`.`idx`)) where `member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member_bet`.`bet_type` = 2 and `member_bet`.`bet_status` = 3 and `member`.`level` <> 9 and `member_bet`.`total_bet_money` <> `member_bet`.`take_money` group by `member_bet`.`u_key` union all select 'bet_tot_real' AS `stype`,`member_bet`.`bet_status` AS `status`,count(0) AS `cnt`,`member_bet`.`total_bet_money` AS `s_money`,sum(`member_bet`.`take_money`) AS `s_win_money` from (`member_bet` left join `member` on(`member_bet`.`member_idx` = `member`.`idx`)) where `member_bet`.`calculate_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member_bet`.`calculate_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member_bet`.`bet_type` = 2 and `member_bet`.`bet_status` = 3 and `member_bet`.`total_bet_money` <> `member_bet`.`take_money` and `member`.`level` <> 9 */;

--
-- Final view structure for view `day_casino_slot_view`
--

/*!50001 DROP VIEW IF EXISTS `day_casino_slot_view`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`chosunadmin`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `day_casino_slot_view` AS select 'bet_tot_casino' AS `stype`,ifnull(sum(`CBH`.`BET_MNY`),0) AS `total_bet_money`,ifnull(sum(case when `CBH`.`TYPE` = 'W' then `CBH`.`BET_MNY` + `CBH`.`RSLT_MNY` end),0) AS `total_win_money`,ifnull(sum(case when `CBH`.`TYPE` = 'B' then `CBH`.`BET_MNY` end),0) AS `total_ing_bet_money` from (`member` `MB` left join `KP_CSN_BET_HIST` `CBH` on(`MB`.`idx` = `CBH`.`MBR_IDX`)) where `CBH`.`MOD_DTM` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `CBH`.`MOD_DTM` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `MB`.`level` <> 9 and `MB`.`u_business` = 1 and `CBH`.`TYPE` in ('W','L') union all select 'bet_tot_slot' AS `stype`,ifnull(sum(`CBH`.`BET_MNY`),0) AS `total_bet_money`,ifnull(sum(case when `CBH`.`TYPE` = 'W' then `CBH`.`BET_MNY` + `CBH`.`RSLT_MNY` end),0) AS `total_win_money`,ifnull(sum(case when `CBH`.`TYPE` = 'B' then `CBH`.`BET_MNY` end),0) AS `total_ing_bet_money` from (`member` `MB` left join `KP_SLOT_BET_HIST` `CBH` on(`MB`.`idx` = `CBH`.`MBR_IDX`)) where `CBH`.`MOD_DTM` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `CBH`.`MOD_DTM` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `MB`.`level` <> 9 and `MB`.`u_business` = 1 and `CBH`.`TYPE` in ('W','L') */;

--
-- Final view structure for view `day_ch_ex`
--

/*!50001 DROP VIEW IF EXISTS `day_ch_ex`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`chosunadmin`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `day_ch_ex` AS select 'ch' AS `stype`,`mch`.`status` AS `status`,count(0) AS `cnt`,sum(`mch`.`money`) AS `s_money` from (`member_money_charge_history` `mch` left join `member` on(`mch`.`member_idx` = `member`.`idx`)) where `mch`.`update_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mch`.`update_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member`.`level` <> 9 group by `mch`.`status` union all select 'ex' AS `stype`,`meh`.`status` AS `status`,count(0) AS `cnt`,sum(`meh`.`money`) AS `s_money` from (`member_money_exchange_history` `meh` left join `member` on(`meh`.`member_idx` = `member`.`idx`)) where cast(`meh`.`update_dt` as date) >= cast(current_timestamp() as date) and `member`.`level` <> 9 group by `meh`.`status` union all select 'ch_tot' AS `stype`,`mch`.`status` AS `status`,count(0) AS `cnt`,sum(`mch`.`money`) AS `s_money` from (`member_money_charge_history` `mch` left join `member` on(`mch`.`member_idx` = `member`.`idx`)) where `mch`.`update_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `mch`.`update_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member`.`level` <> 9 group by `mch`.`status` union all select 'ex_tot' AS `stype`,`meh`.`status` AS `status`,count(0) AS `cnt`,sum(`meh`.`money`) AS `s_money` from (`member_money_exchange_history` `meh` left join `member` on(`meh`.`member_idx` = `member`.`idx`)) where `meh`.`update_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `meh`.`update_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member`.`level` <> 9 group by `meh`.`status` */;

--
-- Final view structure for view `day_espt_hash_view`
--

/*!50001 DROP VIEW IF EXISTS `day_espt_hash_view`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`chosunadmin`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `day_espt_hash_view` AS select 'bet_tot_espt' AS `stype`,ifnull(sum(`CBH`.`BET_MNY`),0) AS `total_bet_money`,ifnull(sum(case when `CBH`.`TYPE` = 'W' then `CBH`.`BET_MNY` + `CBH`.`RSLT_MNY` end),0) AS `total_win_money`,ifnull(sum(case when `CBH`.`TYPE` = 'B' then `CBH`.`BET_MNY` end),0) AS `total_ing_bet_money` from (`member` `MB` left join `KP_ESPT_BET_HIST` `CBH` on(`MB`.`idx` = `CBH`.`MBR_IDX`)) where `CBH`.`MOD_DTM` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `CBH`.`MOD_DTM` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `MB`.`level` <> 9 and `MB`.`u_business` = 1 and `CBH`.`TYPE` in ('W','L') union all select 'bet_tot_hash' AS `stype`,ifnull(sum(`CBH`.`BET_MNY`),0) AS `total_bet_money`,ifnull(sum(case when `CBH`.`TYPE` = 'W' then `CBH`.`BET_MNY` + `CBH`.`RSLT_MNY` end),0) AS `total_win_money`,ifnull(sum(case when `CBH`.`TYPE` = 'B' then `CBH`.`BET_MNY` end),0) AS `total_ing_bet_money` from (`member` `MB` left join `OD_HASH_BET_HIST` `CBH` on(`MB`.`idx` = `CBH`.`MBR_IDX`)) where `CBH`.`MOD_DTM` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `CBH`.`MOD_DTM` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `MB`.`level` <> 9 and `MB`.`u_business` = 1 and `CBH`.`TYPE` in ('W','L') */;

--
-- Final view structure for view `day_now_call_check`
--

/*!50001 DROP VIEW IF EXISTS `day_now_call_check`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`chosunadmin`@`%` SQL SECURITY DEFINER */
/*!50001 VIEW `day_now_call_check` AS select 'mem' AS `stype`,`member`.`status` AS `status`,count(0) AS `cnt`,'0' AS `s_money` from `member` where `member`.`reg_time` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member`.`reg_time` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member`.`status` in (1,11) group by `member`.`status` union all select 'mem_leave' AS `stype`,`member`.`status` AS `status`,count(0) AS `cnt`,'0' AS `s_money` from `member` where `member`.`leave_time` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member`.`leave_time` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member`.`status` = 3 union all select 'mem_sound' AS `stype`,`member`.`status` AS `status`,count(0) AS `cnt`,'0' AS `s_money` from `member` where `member`.`reg_time` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member`.`reg_time` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member`.`is_sound` = 'Y' and `member`.`status` = 11 union all select 'sms_cnt' AS `stype`,`member_money_charge_sms`.`status` AS `status`,count(0) AS `cnt`,'0' AS `s_money` from `member_money_charge_sms` where `member_money_charge_sms`.`create_dt` >= date_format(current_timestamp(),'%Y-%m-%d 00:00:00') and `member_money_charge_sms`.`create_dt` <= date_format(current_timestamp(),'%Y-%m-%d 23:59:59') and `member_money_charge_sms`.`status` = 1 */;


