package com.bb.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jakarta.servlet.http.HttpServletRequest;

import org.codehaus.jettison.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.bb.dao.CallBackDao;
import com.bb.dao.CreditDao;
import com.bb.dao.SiteDao;
import com.bb.model.BalanceParam;
import com.bb.model.BetParam;
import com.bb.model.BoardSearch;
import com.bb.model.CashParam;
import com.bb.model.CommonParam;
import com.bb.model.Credit;
import com.bb.model.Game;
import com.bb.model.Member;
import com.bb.model.OTPInfo;
import com.bb.model.Site;
import com.bb.model.SitePwdVO;
import com.bb.model.SiteSearch;
import com.bb.model.TrfApiInfo;
import com.bb.model.UserSearch;
import com.bb.model.Vendor;
import com.bb.model.VendorChangeBalanceLogVo;
import com.bb.util.IPKit;

import lombok.extern.slf4j.Slf4j;


@Slf4j
@Service
public class SiteServiceImpl implements SiteService{

	@Autowired
	private SiteDao siteDao;

	@Autowired
	private CreditDao creditDao;

	@Autowired
	private CallBackDao callBackDao;

	@Autowired
	private PointAsyncService pointAsyncService;

	@Autowired
	private  DataSourceTransactionManager transactionManager;


	public Site getSiteInfo(HttpServletRequest request) {
		String Authorization = request.getHeader("Authorization").toString();
		Site site  = 	siteDao.getSiteInfo(Authorization);
		return site;
	}


	public Site getSiteInfoAPI(HttpServletRequest request) {
		String Authorization = request.getHeader("Authorization").toString();
		Site site  = 	siteDao.getSiteInfoAPI(Authorization);
		return site;
	}


	@Override
	public Member getMember(CommonParam commonParam) {
		// TODO Auto-generated method stub
		return siteDao.getMember(commonParam);
	}

	@Override
	public Member getMember2(CashParam param) {
		// TODO Auto-generated method stub
		return siteDao.getMember2(param);
	}

	@Override
	public void insertMember(CommonParam commonParam) {
		// TODO Auto-generated method stub
		 siteDao.insertMember(commonParam);
	}


	@Override
	public HashMap getVenderApiInfo(CommonParam commonParam) {
		return siteDao.getVenderApiInfo(commonParam);
	}


	@Override
	public List<HashMap> getCbList() {
		// TODO Auto-generated method stub
		return  siteDao.getCbList();
	}


	@Override
	public int updateCbApi(HashMap upParam) {
		//TransactionStatus txStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
		int res =0;
		try {

			if("debit".equals(upParam.get("tranType"))) {
				updateCbApiDebit(upParam);
			} else {
				updateCbApiCredit(upParam);
			}

		} catch(Exception e) {
			System.out.println(e.toString());
			//transactionManager.rollback(txStatus);
			res =-1;
		}finally {
			return res;
		}
	}

	@Async
	public void updateCbApiDebit(HashMap upParam) throws Exception {
		log.info("["+upParam.get("tranId").toString()+"]::"+"updateCbApiDebit() start");

		long siteCredit = siteDao.getSiteCredit((String)upParam.get("siteId"));

		String creditRate = siteDao.getCreditRate(upParam);

		// ##--isTransfer 처리-##
		String isTransfer = "N";
		if(upParam.containsKey("isTransfer")) isTransfer = upParam.get("isTransfer").toString();
		String isTie = upParam.get("isTie").toString();		// N:정품, P:파싱
		String vendorCetegory = upParam.get("vendorCetegory").toString();
		
		int gameCategory = 0;
		if(vendorCetegory.equals("CASINO") && isTie.equals("N")) {
			gameCategory = 1;	// 카지노A
		} else if(vendorCetegory.equals("CASINO") && isTie.equals("P")) {
			gameCategory = 2;	// 카지노B
		} else if(vendorCetegory.equals("SLOT") && isTie.equals("N")) {
			gameCategory = 3;	// 슬롯A
		} else if(vendorCetegory.equals("SLOT") && isTie.equals("P")) {
			gameCategory = 4;	// 슬롯B
		} else {
			gameCategory = 5;
		}

		Credit credit = new Credit();
		credit.setSiteIdx(Integer.parseInt(upParam.get("siteIdx").toString()));
		credit.setSiteId(upParam.get("siteId").toString());
		credit.setTranId((String)upParam.get("tranId"));
		credit.setPreCreditAmt(siteCredit);
		credit.setCreditRate(creditRate);
		credit.setCreditStatus(1);
		credit.setRefId(upParam.get("refId").toString());

		if(isTransfer.equals("N")) {
			credit.setTargetSiteIdx(Integer.parseInt(upParam.get("siteIdx").toString()));
			credit.setTargetSiteId(upParam.get("siteId").toString());
			credit.setCreditType("DP");
			credit.setInOut("OUT");
			credit.setCreditAmt((long) Math.ceil(Double.parseDouble(upParam.get("depositAmt").toString())));
			credit.setGameCategory(gameCategory);
			creditDao.insertCredit(credit);
			log.info("["+upParam.get("tranId").toString()+"]::"+"updateCbApiDebit() creditDao.insertCredit()");
		} else {
			credit.setTargetSiteIdx(Integer.parseInt(upParam.get("memberIdx").toString()));
			credit.setTargetSiteId(upParam.get("memberId").toString());
			credit.setCreditType("MDP");
			credit.setInOut("OUT");
			credit.setCreditAmt((long) Math.ceil(Double.parseDouble(upParam.get("depositAmt").toString())));
			credit.setUserAmt((long)  Math.ceil(Double.parseDouble(upParam.get("depositAmt").toString())));
			credit.setPreBalance(Long.parseLong(upParam.get("preBalance").toString()));
			credit.setGameCategory(gameCategory);
			creditDao.insertCreditByCash(credit);
			log.info("["+upParam.get("tranId").toString()+"]::"+"updateCbApiDebit() creditDao.insertCredit()");
		}

		// 포인트 처리 비동기 실행
		if(credit.getCreditAmt() > 0 && isTransfer.equals("N")) {
			HashMap pointParam = new HashMap();
			pointParam.put("siteIdx", Long.parseLong(upParam.get("siteIdx").toString()));
			pointParam.put("siteId", upParam.get("siteId").toString());
			pointParam.put("memberIdx", Long.parseLong(upParam.get("memberIdx").toString()));
			pointParam.put("memberId", upParam.get("memberId").toString());
			pointParam.put("vendor", upParam.get("vendorCode").toString());
			pointParam.put("vendorIdx", Integer.parseInt(upParam.get("vendorIdx").toString()));
			pointParam.put("tranId", upParam.get("tranId").toString());
			pointParam.put("betId", upParam.get("refId").toString());
			pointParam.put("amount", (credit.getCreditAmt()*-1));

			pointAsyncService.processPointAsync(pointParam, "updateCbApiDebit", upParam.get("tranId").toString());
		}

		siteDao.updateCbApi(upParam);
		log.info("["+upParam.get("tranId").toString()+"]::"+"updateCbApiDebit() end");
	}

	@Async
	public void updateCbApiCredit(HashMap upParam) throws Exception {

		log.info("["+upParam.get("tranId").toString()+"]::"+"updateCbApiCredit() start");

		long siteCredit = siteDao.getSiteCredit((String)upParam.get("siteId"));

		String creditRate = siteDao.getCreditRate(upParam);

		// ##--isTransfer 처리-##
		String isTransfer = "N";
		if(upParam.containsKey("isTransfer")) isTransfer = upParam.get("isTransfer").toString();
		String isTie = upParam.get("isTie").toString();		// N:정품, P:파싱
		String vendorCetegory = upParam.get("vendorCetegory").toString();
		
		int gameCategory = 0;
		if(vendorCetegory.equals("CASINO") && isTie.equals("N")) {
			gameCategory = 1;	// 카지노A
		} else if(vendorCetegory.equals("CASINO") && isTie.equals("P")) {
			gameCategory = 2;	// 카지노B
		} else if(vendorCetegory.equals("SLOT") && isTie.equals("N")) {
			gameCategory = 3;	// 슬롯A
		} else if(vendorCetegory.equals("SLOT") && isTie.equals("P")) {
			gameCategory = 4;	// 슬롯B
		} else {
			gameCategory = 5;
		}

		Credit credit = new Credit();
		credit.setSiteIdx(Integer.parseInt(upParam.get("siteIdx").toString()));
		credit.setSiteId(upParam.get("siteId").toString());
		credit.setTranId((String)upParam.get("tranId"));
		credit.setPreCreditAmt(siteCredit);
		credit.setCreditRate(creditRate);
		credit.setCreditStatus(1);
		credit.setRefId(upParam.get("refId").toString());

		if(isTransfer.equals("N")) {
			credit.setTargetSiteIdx(Integer.parseInt(upParam.get("siteIdx").toString()));
			credit.setTargetSiteId(upParam.get("siteId").toString());
			long creditAmt = 0;
			long overCreditAmt = 0;
			credit.setCreditType("CD");
			credit.setInOut("IN");
			if(upParam.containsKey("overCreditAmt")) {
				log.info("["+upParam.get("tranId").toString()+"]::"+"초과당첨금처리 start");
				creditAmt = (long) Math.ceil(Double.parseDouble(upParam.get("creditAmt").toString()));
				overCreditAmt = (long) Math.ceil(Double.parseDouble(upParam.get("overCreditAmt").toString()));
				log.info("["+upParam.get("tranId").toString()+"]::"+"creditAmt : " + creditAmt);
				log.info("["+upParam.get("tranId").toString()+"]::"+"overCreditAmt : " + overCreditAmt);
				creditAmt = creditAmt + overCreditAmt;
				log.info("["+upParam.get("tranId").toString()+"]::"+"합계 : " + creditAmt);
				credit.setCreditAmt(creditAmt);
				log.info("["+upParam.get("tranId").toString()+"]::"+"초과당첨금처리 end");
			} else {
				credit.setCreditAmt((long)  Math.ceil(Double.parseDouble(upParam.get("creditAmt").toString())));
			}
			credit.setGameCategory(gameCategory);
			creditDao.updateCreditYn(credit);
			creditDao.insertCredit(credit);
			log.info("["+upParam.get("tranId").toString()+"]::"+"updateCbApiCredit() creditDao.insertCredit()");
		} else {
			credit.setTargetSiteIdx(Integer.parseInt(upParam.get("memberIdx").toString()));
			credit.setTargetSiteId(upParam.get("memberId").toString());
			long creditAmt = 0;
			long userAmt = 0;
			long overCreditAmt = 0;
			credit.setCreditType("MCD");
			credit.setInOut("IN");
			if(upParam.containsKey("overCreditAmt")) {
				log.info("["+upParam.get("tranId").toString()+"]::"+"초과당첨금처리 start");
				creditAmt = (long) Math.ceil(Double.parseDouble(upParam.get("creditAmt").toString()));
				userAmt = (long) Math.ceil(Double.parseDouble(upParam.get("creditAmt").toString()));
				overCreditAmt = (long) Math.ceil(Double.parseDouble(upParam.get("overCreditAmt").toString()));
				log.info("["+upParam.get("tranId").toString()+"]::"+"creditAmt : " + creditAmt);
				log.info("["+upParam.get("tranId").toString()+"]::"+"userAmt : " + userAmt);
				log.info("["+upParam.get("tranId").toString()+"]::"+"overCreditAmt : " + overCreditAmt);
				creditAmt = creditAmt + overCreditAmt;
				credit.setUserAmt(userAmt);
				log.info("["+upParam.get("tranId").toString()+"]::"+"creditAmt 합계 : " + creditAmt);
				log.info("["+upParam.get("tranId").toString()+"]::"+"userAmt 합계 : " + userAmt);
				credit.setCreditAmt(creditAmt);
				log.info("["+upParam.get("tranId").toString()+"]::"+"초과당첨금처리 end");
			} else {
				credit.setCreditAmt((long)  Math.ceil(Double.parseDouble(upParam.get("creditAmt").toString())));
				credit.setUserAmt((long)  Math.ceil(Double.parseDouble(upParam.get("creditAmt").toString())));
			}
			credit.setPreBalance(Long.parseLong(upParam.get("preBalance").toString()));
			credit.setGameCategory(gameCategory);
			creditDao.updateCreditYn(credit);
			creditDao.insertCreditByCash(credit);
			log.info("["+upParam.get("tranId").toString()+"]::"+"updateCbApiCredit() creditDao.insertCredit()");
		}

		// 포인트 처리 비동기 실행
		if(credit.getCreditAmt() > 0 && isTransfer.equals("N")) {
			HashMap pointParam = new HashMap();
			pointParam.put("siteIdx", Long.parseLong(upParam.get("siteIdx").toString()));
			pointParam.put("siteId", upParam.get("siteId").toString());
			pointParam.put("memberIdx", Long.parseLong(upParam.get("memberIdx").toString()));
			pointParam.put("memberId", upParam.get("memberId").toString());
			pointParam.put("vendor", upParam.get("vendorCode").toString());
			pointParam.put("vendorIdx", Integer.parseInt(upParam.get("vendorIdx").toString()));
			pointParam.put("tranId", upParam.get("tranId").toString());
			pointParam.put("betId", upParam.get("refId").toString());
			pointParam.put("amount", credit.getCreditAmt());

			pointAsyncService.processPointAsync(pointParam, "updateCbApiCredit", upParam.get("tranId").toString());
		}

		siteDao.updateCbApi(upParam);
		log.info("["+upParam.get("tranId").toString()+"]::"+"updateCbApiCredit() end");
	}


	@Override
	public HashMap getSiteApiInfo(HashMap sParam) {
		return  siteDao.getSiteApiInfo(sParam);
	}


	@Override
	public HashMap getSiteApiInfo2(HashMap sParam) {
		return  siteDao.getSiteApiInfo2(sParam);
	}


	@Override
	public void commonBetinsert(HashMap tranParam) {
		// TODO Auto-generated method stub
		siteDao.commonBetinsert(tranParam);

		if("credit".equals(tranParam.get("tranType").toString())) {
			if(tranParam.get("detail") != null) {
				siteDao.insertBetDetail(tranParam);
			}
		}
	}


	@Override
	public void commonBetinsert2(HashMap tranParam) {
		// TODO Auto-generated method stub
		siteDao.commonBetinsert2(tranParam);
	}


	@Override
	public Site getSiteLogin(Authentication authentication) {
		return  siteDao.getSiteLogin(authentication);
	}

	@Override
	public Site getSiteLoginApi(Map site) {
		return  siteDao.getSiteLoginApi(site);
	}


	@Override
	public Site getGuestLogin() {
		return  siteDao.getGuestLogin();
	}


	@Override
	public int getSiteListCnt(SiteSearch search) {
		return  siteDao.getSiteListCnt(search);
	}


	@Override
	public List<HashMap> getSiteList(SiteSearch search) {
		return  siteDao.getSiteList(search);
	}


	@Override
	public void addProc(Site site) {

		TransactionStatus txStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
		try {
			siteDao.addProc(site);
			siteDao.addCreditInfo(site);
			siteDao.addPointInfo(site);
			siteDao.addsiteFlow(site);

			//벤더 설정
			siteDao.insertVendors(site);
			siteDao.insertVendorsRate(site);
			siteDao.insertVendorsCodeRate(site);

			//보험관련
			siteDao.insertinsurance(site);
			siteDao.insertinsurancePoint(site);

			// Add Firewall rule
			try {
				if (site.getSiteIp() != null && !site.getSiteIp().equals("")) {
					log.info("#-super::SITE_ADD_PROC:::Call IPKit.allowInboundTraffic() ips: " + site.getSiteIp());
					IPKit.allowInboundTraffic("#-super::SITE_ADD_PROC:::", site.getSiteIp());
					log.info("#-super::SITE_ADD_PROC:::Call IPKit.allowInboundTraffic() end:");
				}
			} catch (Exception e) {
				System.out.println(e.toString());
				log.error("#-super::SITE_ADD_PROC:::"+ "Exception: "+e.getMessage());
				log.error("#-super::SITE_ADD_PROC:::"+ "Exception: "+e.toString());
			}

			transactionManager.commit(txStatus);
		} catch(Exception e) {
			System.out.println(e.toString());
			transactionManager.rollback(txStatus);
		}
	}

	@Override
	public void addProcAPI(Site site) {

		TransactionStatus txStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
		try {
			siteDao.addProc(site);
			siteDao.addCreditInfo(site);
			siteDao.addPointInfo(site);
			siteDao.addsiteFlow(site);

			//벤더 설정
			siteDao.insertVendors(site);
			siteDao.insertVendorsRate(site);
			siteDao.insertVendorsCodeRate(site);


			//보험관련
			siteDao.insertinsurance(site);
			siteDao.insertinsurancePoint(site);

			//IP테이블 생성
			siteDao.insertCmsIp(site);
			transactionManager.commit(txStatus);
		} catch(Exception e) {
			System.out.println(e.toString());
			transactionManager.rollback(txStatus);
		}
	}


	@Override
	public Site getSiteInfoMypage(Site site) {
		return  siteDao.getSiteInfoMypage(site);
	}


	@Override
	public long getSiteCredit(String siteId) {
		return  siteDao.getSiteCredit(siteId);
	}


	@Override
	public long getUnderSiteCredit(String siteId) {
		return  siteDao.getUnderSiteCredit(siteId);
	}

	@Override
	public long getSitePoint(String siteId) {
		return  siteDao.getSitePoint(siteId);
	}


	@Override
	public HashMap getCreditWait(int siteIdx) {
		return  siteDao.getCreditWait(siteIdx);
	}


	@Override
	public int getSiteUserListCnt(SiteSearch search) {
		return  siteDao.getSiteUserListCnt(search);
	}


	@Override
	public List<HashMap> getSiteUserList(SiteSearch search) {
		return  siteDao.getSiteUserList(search);
	}


	@Override
	public int getTranCheck(String tranId) {
		// TODO Auto-generated method stub
		return  siteDao.getTranCheck(tranId);
	}


	@Override
	public void insertError(HashMap eParam) {
		// TODO Auto-generated method stub
		siteDao.insertError(eParam);
	}


	@Override
	public int getFinalErr(String refId) {
		// TODO Auto-generated method stub
		return  siteDao.getFinalErr(refId);
	}


	@Override
	public void updateSid(Member member) {
		siteDao.updateSid(member);
	}


	@Override
	public long getInsureAmt(String siteId) {
		return siteDao.getInsureAmt(siteId);
	}


	@Override
	public long getInsurePointAmt(String siteId) {
		return siteDao.getInsurePointAmt(siteId);
	}


	@Override
	public List<HashMap> getVenderRateList(Site loginSite) {
		// TODO Auto-generated method stub
		return siteDao.getVenderRateList(loginSite);
	}


	@Override
	public synchronized int getBetCancelCount(String betId) {
		// TODO Auto-generated method stub
		return siteDao.getBetCancelCount(betId);
	}


	@Override
	public void updateBombKey(Member member) {
		// TODO Auto-generated method stub
		siteDao.updateBombKey(member);
	}


	@Override
	public Member getMemByBombAccId(HashMap memParam) {
		return siteDao.getMemByBombAccId(memParam);
	}


	@Override
	public String getBetInfo(BetParam param) {
		// TODO Auto-generated method stub
		return siteDao.getBetInfo(param);
	}


	@Override
	public String getMergedBetRadarLog(String betId) {
		try {
			List<HashMap> radarLogs = callBackDao.getBetRadarLogByBetId(betId);
			if(radarLogs == null || radarLogs.isEmpty()) {
				return null;
			}

			// 베팅과 결과를 구분하여 반환
			JSONObject responseJson = new JSONObject();

			// 첫 번째 row: 베팅 데이터
			if(radarLogs.size() >= 1) {
				String bettingStr = (String) radarLogs.get(0).get("jsonstr");
				if(bettingStr != null && !bettingStr.isEmpty()) {
					JSONObject bettingJson = new JSONObject(bettingStr);
					responseJson.put("betting", bettingJson);
				}
			}

			// 두 번째 row: 결과 데이터 (있는 경우만)
			if(radarLogs.size() >= 2) {
				String resultStr = (String) radarLogs.get(1).get("jsonstr");
				if(resultStr != null && !resultStr.isEmpty()) {
					JSONObject resultJson = new JSONObject(resultStr);
					responseJson.put("result", resultJson);
				}
			}

			return responseJson.toString();
		} catch(Exception e) {
			log.error("getMergedBetRadarLog error: " + e.getMessage());
			return null;
		}
	}


	@Override
	public List<HashMap> getSiteFlow(Site loginSite) {
		// TODO Auto-generated method stub
		return siteDao.getSiteFlow(loginSite);

	}


	@Override
	public void saveVendorRate(HashMap paramMap) {
		// TODO Auto-generated method stub
		siteDao.saveVendorRate(paramMap);
	}


	@Override
	public HashMap getEvoApiInfo() {
		// TODO Auto-generated method stub
		return siteDao.getEvoApiInfo();
	}


	@Override
	public String getSiteIdByRefId(String refId) {
		// TODO Auto-generated method stub
		return siteDao.getSiteIdByRefId(refId);
	}


	@Override
	public void updateDetailLastTime(HashMap evoInfo) {
		// TODO Auto-generated method stub
		siteDao.updateDetailLastTime(evoInfo);
	}


	@Override
	public void insertBetDetail(Map paramDerail) {
		siteDao.insertBetDetail(paramDerail);

	}


	@Override
	public Site getSiteDetail(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getSiteDetail(search);
	}


	@Override
	public Site getSiteSimpleDetail(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getSiteSimpleDetail(search);
	}


	@Override
	public HashMap getVenderApiInfoByToken(Map paramV) {
		// TODO Auto-generated method stub
		return siteDao.getVenderApiInfoByToken(paramV);
	}


	@Override
	public Site getSiteBypassword(Map siteParam) {
		// TODO Auto-generated method stub
		return siteDao.getSiteBypassword(siteParam);
	}


	@Override
	public void updatePass(Map siteParam) {
		siteDao.updatePass(siteParam);

	}


	@Override
	public void siteUpdate(String LOG_PREFIX, Site site) {
		// TODO Auto-generated method stub
		siteDao.siteUpdate(site);

		// Add Firewall rule
		try {
			if (site.getSiteIp() != null && !site.getSiteIp().equals("")) {
				log.info(LOG_PREFIX+ "Call IPKit.allowInboundTraffic() ips: " + site.getSiteIp());
				IPKit.allowInboundTraffic(LOG_PREFIX, site.getSiteIp());
				log.info(LOG_PREFIX+ "Call IPKit.allowInboundTraffic() end:");
			}
		} catch (Exception e) {
			log.error(LOG_PREFIX+ "Exception: "+e.getMessage());
			log.error(LOG_PREFIX+ "Exception: "+e.toString());
		}
	}


	@Override
	public void saveVendorInsurePointRate(HashMap paramMap) {
		// TODO Auto-generated method stub
		siteDao.saveVendorInsurePointRate(paramMap);
	}


	@Override
	public HashMap getDashInfo(Site loginSite) {
		// TODO Auto-generated method stub
		return siteDao.getDashInfo(loginSite);
	}

	@Override
	public HashMap getDashInfo2(Site loginSite) {
		// TODO Auto-generated method stub
		return siteDao.getDashInfo2(loginSite);
	}


	@Override
	public HashMap getMicroApiInfo() {
		// TODO Auto-generated method stub
		return siteDao.getMicroApiInfo();
	}


	@Override
	public int getApiStatus(HashMap tranParam) {
		// TODO Auto-generated method stub
		return siteDao.getApiStatus(tranParam);
	}


	@Override
	public void saveVendorInsureRate(HashMap paramMap) {
		// TODO Auto-generated method stub
		siteDao.saveVendorInsureRate(paramMap);
	}


	@Override
	public void updateVendorUseYn(HashMap paramMap) {
		// TODO Auto-generated method stub
		siteDao.updateVendorUseYn(paramMap);

	}


	@Override
	public List<HashMap> getSiteVendorList(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getSiteVendorList(search);
	}


	@Override
	public List<HashMap> getVendorList(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getVendorList(search);
	}


	@Override
	public void siteVenderUpdate(Vendor vendor) {
		// TODO Auto-generated method stub
		 siteDao.siteVenderUpdate(vendor);
	}


	@Override
	public HashMap getDowinApiInfo() {
		// TODO Auto-generated method stub
		return siteDao.getDowinApiInfo();
	}


	@Override
	public long getSiteMaxBet(HashMap sParam) {
		// TODO Auto-generated method stub
		return siteDao.getSiteMaxBet(sParam);
	}

	@Override
	public Long getUserMaxBet(HashMap sParam) {
		// TODO Auto-generated method stub
		return siteDao.getUserMaxBet(sParam);
	}

	@Override
	public synchronized int getBetCheckByHc(String refId) {
		// TODO Auto-generated method stub
		return siteDao.getBetCheckByHc(refId);
	}


	@Override
	public void updatePragmaticId(Member member) {
		// TODO Auto-generated method stub
		 siteDao.updatePragmaticId(member);
	}


	@Override
	public HashMap getProgmaticApiInfo() {
		// TODO Auto-generated method stub
		return siteDao.getProgmaticApiInfo();
	}

	@Override
	public HashMap getProgmaticApiInfo2() {
		// TODO Auto-generated method stub
		return siteDao.getProgmaticApiInfo2();
	}


	@Override
	public HashMap getSiteApiInfoByPra(HashMap sParam) {
		// TODO Auto-generated method stub
		return siteDao.getSiteApiInfoByPra(sParam);
	}


	@Override
	public String getlastDepostId(HashMap dParam) {
		// TODO Auto-generated method stub
		return siteDao.getlastDepostId(dParam);
	}


	@Override
	public List<HashMap> getNotUseMemberListProgama() {
		// TODO Auto-generated method stub
		return siteDao.getNotUseMemberListProgama();
	}


	@Override
	public List<Game> getGameList(HashMap param) {
		// TODO Auto-generated method stub
		return siteDao.getGameList(param);
	}


	@Override
	public HashMap getOnlyVenderInfo(CommonParam commonParam) {
		// TODO Auto-generated method stub
		return siteDao.getOnlyVenderInfo(commonParam);
	}


	@Override
	public synchronized int getBotaAutoCancelCnt(String tranId) {
		// TODO Auto-generated method stub
		return siteDao.getBotaAutoCancelCnt(tranId);
	}


	@Override
	public synchronized int getBotaBetCnt(String tranId) {
		// TODO Auto-generated method stub
		return siteDao.getBotaBetCnt(tranId);
	}


	@Override
	public List<HashMap> getBotaBetListMinute() {
		// TODO Auto-generated method stub
		return siteDao.getBotaBetListMinute();
	}


	@Override
	public String getSiteIdByRefId2(String string) {
		// TODO Auto-generated method stub
		return siteDao.getSiteIdByRefId2(string);
	}


	@Override
	public int getTranIdCheck(String string) {
		// TODO Auto-generated method stub
		return siteDao.getTranIdCheck(string);
	}


	@Override
	public int getTranIdCheck2(String string) {
		// TODO Auto-generated method stub
		return siteDao.getTranIdCheck2(string);
	}


	@Override
	public HashMap getSiteMember(String string) {
		// TODO Auto-generated method stub
		return siteDao.getSiteMember(string);
	}


	@Override
	public void updateDebitCancel(String refId) {
		// TODO Auto-generated method stub
		siteDao.updateDebitCancel(refId);
	}


	@Override
	public void insertSiteCallBackLog(HashMap logParam) {
		// TODO Auto-generated method stub
		siteDao.insertSiteCallBackLog(logParam);
	}


	@Override
	public List<HashMap> getBetList(BetParam param) {
		// TODO Auto-generated method stub
		return siteDao.getBetList(param);
	}


	@Override
	public List<HashMap> getMonsterGameList() {
		return siteDao.getMonsterGameList();
	}


	@Override
	public HashMap getProgmaticApiInfo3(String code) {
		// TODO Auto-generated method stub
		return siteDao.getProgmaticApiInfo3(code);
	}


	@Override
	public long getBetCancelAmt(String string) {
		// TODO Auto-generated method stub
		return siteDao.getBetCancelAmt(string);
	}


	@Override
	public int getBetIdCheck(String refId) {
		// TODO Auto-generated method stub
		return siteDao.getBetIdCheck(refId);
	}


	@Override
	public int getBetIdCheck2(String refId) {
		// TODO Auto-generated method stub
		return siteDao.getBetIdCheck2(refId);
	}


	@Override
	public int getTranCheck2(String betId) {
		// TODO Auto-generated method stub
		return siteDao.getTranCheck2(betId);
	}


	@Override
	public void insertSlotCity(HashMap slotMap) {
		// TODO Auto-generated method stub
		siteDao.insertSlotCity(slotMap);
	}


	@Override
	public void botaAutoCancel(HashMap tranParam) {
		// TODO Auto-generated method stub
		siteDao.botaAutoCancel(tranParam);
	}


	@Override
	public void seattleCredit() {
		// TODO Auto-generated method stub
		siteDao.seattleCredit();
	}


	@Override
	public void updateDecimal(HashMap decimalParam) {
		// TODO Auto-generated method stub
		siteDao.updateDecimal(decimalParam);
	}


	@Override
	public List<HashMap> getonlyDebitList() {
		// TODO Auto-generated method stub
		return siteDao.getonlyDebitList();
	}


	@Override
	public void insertAutoLose(HashMap loseCredit) {
		// TODO Auto-generated method stub
		siteDao.insertAutoLose(loseCredit);
	}


	@Override
	public HashMap getBetCheck(BetParam param) {
		// TODO Auto-generated method stub
		return siteDao.getBetCheck(param);
	}


	@Override
	public int callbackTokenCheck(String token) {
		// TODO Auto-generated method stub
		return siteDao.callbackTokenCheck(token);
	}


	@Override
	public HashMap getVenderInfo(BalanceParam param) {
		// TODO Auto-generated method stub
		return siteDao.getVenderInfo(param);
	}


	@Override
	public String getRefIdByTranId(String tranId) {
		// TODO Auto-generated method stub
		return siteDao.getRefIdByTranId(tranId);
	}


	@Override
	public List<HashMap> getCreditReSendList() {
		// TODO Auto-generated method stub
		return siteDao.getCreditReSendList();
	}


	@Override
	public void updateMemCancelCnt(long memberIdx) {
		// TODO Auto-generated method stub
		siteDao.updateMemCancelCnt(memberIdx);
	}


	@Override
	public Long getMemberIdx(HashMap memParam) {
		// TODO Auto-generated method stub
		return siteDao.getMemberIdx(memParam);
	}


	@Override
	public int insertVendorChangeBalanceLog(VendorChangeBalanceLogVo logVo) {
		// TODO Auto-generated method stub
		return siteDao.insertVendorChangeBalanceLog(logVo);
	}


	@Override
	public HashMap getGsoftVendorInfo(String gameID) {
		// TODO Auto-generated method stub
		return siteDao.getGsoftVendorInfo(gameID);
	}


	@Override
	public HashMap getDemoByBombAccId(HashMap memParam) {

		return siteDao.getDemoByBombAccId(memParam);
	}


	@Override
	public void inserDemoUSer(String bombToken) {

		 siteDao.inserDemoUSer(bombToken);
	}


	@Override
	public void updateDemoUSer(HashMap memParam) {
		siteDao.updateDemoUSer(memParam);

	}


	@Override
	public List<HashMap> getTrasferVendorList() {

		return siteDao.getTrasferVendorList();
	}


	@Override
	public List<HashMap> getAllMember() {

		return siteDao.getAllMember();
	}

	@Override
	public List<HashMap> getAllMember2() {
		return siteDao.getAllMember2();
	}



	@Override
	public int gethourBetCheck(long member) {

		return siteDao.gethourBetCheck(member);
	}


	@Override
	public HashMap getUserVendorInfo(HashMap memParam) {
		// TODO Auto-generated method stub
		return siteDao.getUserVendorInfo(memParam);
	}



	@Override
	public Member getMemberByToken(Map authParam) {
		// TODO Auto-generated method stub
		return siteDao.getMemberByToken(authParam);
	}


	@Override
	public HashMap getSiteApiInfoByToken(Map authParam) {
		// TODO Auto-generated method stub
		return siteDao.getSiteApiInfoByToken(authParam);
	}


	@Override
	public double getBetDepositAmt(String tranId) {
		return siteDao.getBetDepositAmt(tranId);
	}


	@Override
	public void insertSplusTran(Map trxParam) {
		try {
			siteDao.insertSplusTran(trxParam);
		}catch(Exception e) {
			log.info(e.toString());
		}

	}


	@Override
	public void updateSplusTran(Map trxParam) {
		try {
			siteDao.updateSplusTran(trxParam);
			}catch(Exception e) {
				log.info(e.toString());
			}

	}


	@Override
	public String getCbData(String reserve_id) {
		// TODO Auto-generated method stub
		return siteDao.getCbData(reserve_id);
	}


	@Override
	public void updatesPurchaseId(Map trxParam) {
		siteDao.updatesPurchaseId(trxParam);

	}


	@Override
	public double getBetGapAmt(String pid) {
		// TODO Auto-generated method stub
		return siteDao.getBetGapAmt(pid);
	}


	@Override
	public void insertToken(String base64Token) {
		siteDao.insertToken(base64Token);
	}


	@Override
	public int getSplusToken(String base64Token) {
		return siteDao.getSplusToken(base64Token);
	}


	@Override
	public String getRefIdByPurchaseId(String purchase_id) {
		return siteDao.getRefIdByPurchaseId(purchase_id);
	}


	@Override
	public List<HashMap> getSplusDetailData(BetParam param) {
		// TODO Auto-generated method stub
		return siteDao.getSplusDetailData(param);
	}


	@Override
	public String getKorName(String t, String txt) {
		String resTxt = txt;
		// TODO Auto-generated method stub
		if("T".equals(t)) {
			resTxt= siteDao.getKorNameTeam(txt);
			if(resTxt==null)resTxt = txt;
		}else {
			resTxt= siteDao.getKorNameLeague(txt);
			if(resTxt==null)resTxt = txt;
		}
		return resTxt;
	}


	@Override
	public void forDefaultProc(Site site) {
		// TODO Auto-generated method stub
		TransactionStatus txStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());

		try {
			siteDao.updVendorMapForDefault(site);
			siteDao.updVendorCreditRateForDefault(site);
			siteDao.deleteVendorAccountForDefault(site);

			transactionManager.commit(txStatus);
		} catch(Exception e) {
			System.out.println(e.toString());
			transactionManager.rollback(txStatus);
		}
	}


	@Override
	public HashMap getBetInfoByTranId(String reference) {
		return siteDao.getBetInfoByTranId(reference);
	}


	@Override
	public int getSuccDebitCnt(String betId) {
		// TODO Auto-generated method stub
		return siteDao.getSuccDebitCnt(betId);
	}


	@Override
	public HashMap<String, String> getSiteVendorInfo(HashMap param) {
		// TODO Auto-generated method stub
		return siteDao.getSiteVendorInfo(param);
	}


	@Override
	public int updatePowerballApiInfo(HashMap<String, String> registParam) {
		// TODO Auto-generated method stub
		return siteDao.updatePowerballApiInfo(registParam);
	}


	@Override
	public List<HashMap<String, String>> getPowerBallInfoList(String gameType) {
		// TODO Auto-generated method stub
		return siteDao.getPowerBallInfoList(gameType);
	}

	@Override
	public HashMap<String, String> getSiteApiInfoByApiKey(HashMap param) {
		// TODO Auto-generated method stub
		return siteDao.getSiteApiInfoByApiKey(param);
	}

	@Override
	public HashMap<String, String> getSiteApiInfoByCallbackKey(HashMap param) {
		// TODO Auto-generated method stub
		return siteDao.getSiteApiInfoByCallbackKey(param);
	}


	@Override
	public int updMemLastVendorIdx(HashMap memParam) {
		// TODO Auto-generated method stub
		return siteDao.updMemLastVendorIdx(memParam);
	}


	@Override
	public List<HashMap> getVendorListByVendorKey(HashMap venderInfo) {
		// TODO Auto-generated method stub
		return siteDao.getVendorListByVendorKey(venderInfo);
	}


	@Override
	public void vendorUpdate(HashMap venderInfo) {
		 siteDao.vendorUpdate(venderInfo);

	}


	@Override
	public List<HashMap> getNexusSkinListByVendorKey(HashMap venderInfo) {
		// TODO Auto-generated method stub
		return siteDao.getNexusSkinListByVendorKey(venderInfo);
	}


	@Override
	public void nexusSkinUpdate(HashMap venderInfo) {
		 siteDao.nexusSkinUpdate(venderInfo);
	}


	@Override
	public String getParseTarget() {
		return siteDao.getParseTarget();
	}


	@Override
	public String getParseTargetExtr() {
		return siteDao.getParseTargetExtr();
	}


	@Override
	public HashMap getParseUseYn(int siteIdx) {
		return siteDao.getParseUseYn(siteIdx);
	}


	@Override
	public void insertParseUse(HashMap parseParam) {
		 siteDao.insertParseUse(parseParam);

	}


	@Override
	public List<HashMap> getApiBetVendorList(int siteIdx) {
		// TODO Auto-generated method stub
		return siteDao.getApiBetVendorList(siteIdx);
	}


	@Override
	public int getApiBetTransactionCnt(BetParam param) {
		// TODO Auto-generated method stub
		return siteDao.getApiBetTransactionCnt(param);
	}


	@Override
	public List<HashMap> getApiBetTransactionList(BetParam param) {
		// TODO Auto-generated method stub
		return siteDao.getApiBetTransactionList(param);
	}


	@Override
	public HashMap getParseUserYn(HashMap pum) {
		return siteDao.getParseUserYn(pum);
	}


	@Override
	public void setParseUserYn(HashMap pum) {
		siteDao.setParseUserYn(pum);
	}


	@Override
	public OTPInfo getOtpInfo(long siteIdx) {
		// TODO Auto-generated method stub
		return siteDao.getOtpInfo(siteIdx);
	}


	@Override
	public OTPInfo getOtpInfoByManger(long siteIdx) {
		// TODO Auto-generated method stub
		return siteDao.getOtpInfoByManger(siteIdx);
	}


	@Override
	public int registSuperOtp(OTPInfo param) {
		// TODO Auto-generated method stub
		return siteDao.registSuperOtp(param);
	}


	@Override
	public HashMap<String, String> getSiteOnlyVendorInfo(HashMap vendorParam) {
		// TODO Auto-generated method stub
		return siteDao.getSiteOnlyVendorInfo(vendorParam);
	}


	@Override
	public TrfApiInfo getTrfApiInfo(HashMap mapParam) {
		// TODO Auto-generated method stub
		return siteDao.getTrfApiInfo(mapParam);
	}


	@Override
	public void agentIpsUpdate(Site site) {
		 siteDao.agentIpsUpdate(site);

	}


	@Override
	public int insertEvoDetail(HashMap detailMap) {
		// TODO Auto-generated method stub
		return siteDao.insertEvoDetail(detailMap);
	}


	@Override
	public HashMap getCommonApiInfo(HashMap commonParam) {
		// TODO Auto-generated method stub
		return siteDao.getCommonApiInfo(commonParam);
	}


	@Override
	public HashMap<String, String> getBeforeTranInfo(String vendorTranKey) {
		// TODO Auto-generated method stub
		return siteDao.getBeforeTranInfo(vendorTranKey);
	}


	@Override
	public List<HashMap> getParseTargetGame(String gameType) {
		return siteDao.getParseTargetGame(gameType);
	}


	@Override
	public String getOrgDetailData(BetParam param) {
		// TODO Auto-generated method stub
		return siteDao.getOrgDetailData(param);
	}


	@Override
	public String getParDetailData(BetParam param) {
		// TODO Auto-generated method stub
		return siteDao.getParDetailData(param);
	}


	@Override
	public HashMap<String, Object> getBetInfoByTranKey(String vendorTranKey) {
		// TODO Auto-generated method stub
		return siteDao.getBetInfoByTranKey(vendorTranKey);
	}


	@Override
	public HashMap<String, String> getParseInfo(HashMap param) {
		// TODO Auto-generated method stub
		return siteDao.getParseInfo(param);
	}


	@Override
	public int getBlockParseGameId(String gameId) {
		// TODO Auto-generated method stub
		return siteDao.getBlockParseGameId(gameId);
	}


	@Override
	public HashMap<String, String> getBeforeTranInfo2(String vendorTranKey) {
		// TODO Auto-generated method stub
		return siteDao.getBeforeTranInfo2(vendorTranKey);
	}


	@Override
	public String getMemberByIdx(HashMap memParam) {
		return siteDao.getMemberByIdx(memParam);
	}


	@Override
	public List<HashMap> getSiteVendorList2(int siteIdx) {
		// TODO Auto-generated method stub
		return siteDao.getSiteVendorList2(siteIdx);
	}


	@Override
	public List<HashMap> getVendorList2(int siteIdx) {
		// TODO Auto-generated method stub
		return siteDao.getVendorList2(siteIdx);
	}


	@Override
	public void saveSvcr(HashMap paramMap, int type) {
		// TODO Auto-generated method stub
		siteDao.saveSvcr(paramMap);

		if(type == 0) {
			Vendor vendor = new Vendor();
			vendor.setSiteIdx(Long.parseLong(paramMap.get("siteIdx").toString()));
			vendor.setVendorCode(paramMap.get("vendorCode").toString());
			vendor.setVendorIdx(Long.parseLong(paramMap.get("vendorIdx").toString()));
			siteDao.siteVenderUpdate(vendor);
		} else {
			//현쟈 설전된 코드이면  요율 변경
			int codeCheck = siteDao.siteVenderCodeCheck(paramMap);
			if(codeCheck ==1) {
				 siteDao.saveVendorRate2(paramMap);
			}
		}
	}


	@Override
	public String getSiteKey(HashMap paramMap) {
		// TODO Auto-generated method stub
		return siteDao.getSiteKey(paramMap);
	}


	@Override
	public String getVendorTitle(HashMap paramMap) {
		// TODO Auto-generated method stub
		return siteDao.getVendorTitle(paramMap);
	}


	@Override
	public Long getUserTimeout(HashMap accLog) {
		// TODO Auto-generated method stub
		return siteDao.getUserTimeout(accLog);
	}


	@Override
	public int updateUserTimeout(HashMap accLog) {
		// TODO Auto-generated method stub
		return siteDao.updateUserTimeout(accLog);
	}


	@Override
	public String getGameKeyByNexusGameId(String gameId) {
		// TODO Auto-generated method stub
		return siteDao.getGameKeyByNexusGameId(gameId);
	}


	@Override
	public String getDebitIsParse(String betId) {
		// TODO Auto-generated method stub
		return siteDao.getDebitIsParse(betId);
	}


	@Override
	public int updateParseUseYN(String useYn) {
		// TODO Auto-generated method stub
		return siteDao.updateParseUseYN(useYn);
	}


	@Override
	public int insertTheaTrxId(HashMap param) {
		// TODO Auto-generated method stub
		return siteDao.insertTheaTrxId(param);
	}


	@Override
	public HashMap<String, String> getApiKeyInfo(String vendorTitle) {
		// TODO Auto-generated method stub
		return siteDao.getApiKeyInfo(vendorTitle);
	}


	@Override
	public HashMap<String, String> getApiKeyInfo2(HashMap<String, String> keyParam) {
		// TODO Auto-generated method stub
		return siteDao.getApiKeyInfo2(keyParam);
	}


	@Override
	public HashMap<String, Object> getRefBetInfoByTranId(String tranId) {
		// TODO Auto-generated method stub
		return siteDao.getRefBetInfoByTranId(tranId);
	}


	@Override
	public int updMemberBalance(HashMap balanceMap) {
		// TODO Auto-generated method stub
		return siteDao.updMemberBalance(balanceMap);
	}


	@Override
	public int getMemberBalance(HashMap balanceMap) {
		// TODO Auto-generated method stub
		return siteDao.getMemberBalance(balanceMap);
	}


	@Override
	public HashMap<String, String> getMemberId(String vendorUsername) {
		// TODO Auto-generated method stub
		return siteDao.getMemberId(vendorUsername);
	}


	@Override
	public int checkMemberId(String vendorUsername) {
		// TODO Auto-generated method stub
		return siteDao.checkMemberId(vendorUsername);
	}


	@Override
	public HashMap getNewSiteApiInfo(String vendorUsername) {
		// TODO Auto-generated method stub
		return siteDao.getNewSiteApiInfo(vendorUsername);
	}


	@Override
	public HashMap getNewSiteVendorInfo(HashMap param) {
		// TODO Auto-generated method stub
		return siteDao.getNewSiteVendorInfo(param);
	}


	@Override
	public int updateTestCnt(Site site) {
		// TODO Auto-generated method stub
		return siteDao.updateTestCnt(site);
	}


	@Override
	public int updateParseEvoYn(HashMap param) {
		// TODO Auto-generated method stub
		return siteDao.updateParseEvoYn(param);
	}


	@Override
	public int saveParsEvoAmount(SiteSearch param) {
		// TODO Auto-generated method stub
		return siteDao.saveParsEvoAmount(param);
	}


	@Override
	public int getUserBalance(HashMap balanceMap) {
		// TODO Auto-generated method stub
		return siteDao.getUserBalance(balanceMap);
	}


	@Override
	public List<HashMap> getMyDownSite(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getMyDownSite(search);
	}


	@Override
	public HashMap<String, String> getCreditInfo(String siteId) {
		// TODO Auto-generated method stub
		return siteDao.getCreditInfo(siteId);
	}


	@Override
	public int checkDownSite(Map checkDown) {
		// TODO Auto-generated method stub
		return siteDao.checkDownSite(checkDown);
	}


	@Override
	public List<HashMap> getSiteTreeList(String siteId) {
		// TODO Auto-generated method stub
		return siteDao.getSiteTreeList(siteId);
	}


	@Override
	public int getMyDownSiteCheck(Site targetsite) {
		// TODO Auto-generated method stub
		return siteDao.getMyDownSiteCheck(targetsite);
	}


	@Override
	public void siteUpdateForAPI(Site site) {
		// TODO Auto-generated method stub
		siteDao.siteUpdate(site);
		siteDao.insertParseUseYn(site);
	}


	@Override
	public int updateSitePwd(SitePwdVO sitePwdVO) {
		// TODO Auto-generated method stub
		return siteDao.updateSitePwd(sitePwdVO);
	}


	@Override
	public Site getSite(Site addsite) {
		// TODO Auto-generated method stub
		return siteDao.getSite(addsite);
	}


	@Override
	public void siteVenderLobbyUpdate(Vendor vendor) {
		// TODO Auto-generated method stub
		siteDao.siteVenderLobbyUpdate(vendor);
	}


	@Override
	public List<HashMap> getVendorMapList(SiteSearch search) {
		// TODO Auto-generated method stub
		List<HashMap> getVendorMapList = siteDao.getVendorMapList(search);
		for(HashMap vendorMap : getVendorMapList) {

			search.setSearchValue(vendorMap.get("vendorCode").toString());;
			List<HashMap> lobbylist =  siteDao.geLobbyList(search);

			for(HashMap lobbyinfo : lobbylist) {

				//log.info(lobbyinfo.get("lobbyCode").toString()+ ","+ vendorMap.get("unionGameKey").toString());
				if(lobbyinfo.get("lobbyCode").toString().equals(vendorMap.getOrDefault("unionGameKey", "").toString())){

					lobbyinfo.put("selected", "Y");
				}else {
					lobbyinfo.put("selected", "N");
				}
			}
			vendorMap.put("lobbylist", lobbylist);
		}


		return getVendorMapList;
	}


	@Override
	public String siteVenderRate(Vendor vendor) {
		// TODO Auto-generated method stub
		return siteDao.siteVenderRate(vendor);
	}

	@Override
	public int getBoardListCnt(BoardSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getBoardListCnt(search);
	}


	@Override
	public List<HashMap<String, Object>> getBoardList(BoardSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getBoardList(search);
	}


	@Override
	public HashMap<String, Object> getBoardDetail(long boardIdx) {
		// TODO Auto-generated method stub
		return siteDao.getBoardDetail(boardIdx);
	}


	@Override
	public int getSiteCallbackErrLogListCnt(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getSiteCallbackErrLogListCnt(search);
	}


	@Override
	public List<HashMap> getSiteCallbackErrLogList(SiteSearch search) {
		// TODO Auto-generated method stub
		List<HashMap> list = siteDao.getSiteCallbackErrLogList(search);

		if(search.getTopId() != null && !search.getTopId().equals("")) {
			for(HashMap item : list) {
				HashMap param = new HashMap<>();
				param.put("topId", search.getTopId());
				param.put("siteId", item.get("siteId").toString());
				List<HashMap> treeInfo = siteDao.getSiteTreeInfo(param);
				log.info("treeInfo::"+treeInfo.toString());
				item.put("treeInfo", treeInfo);
			}
		}

		return list;
	}


	@Override
	public int getUserListCnt(UserSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getUserListCnt(search);
	}


	@Override
	public List<HashMap<String, Object>> getUserList(UserSearch search) {
		List<HashMap<String, Object>> list = siteDao.getUserList(search);

		if(search.getTopId() != null && !search.getTopId().equals("")) {
			for(HashMap<String, Object> item : list) {
				HashMap param = new HashMap<>();
				param.put("topId", search.getTopId());
				param.put("siteId", item.get("siteId").toString());
				List<HashMap> treeInfo = siteDao.getSiteTreeInfo(param);
				item.put("treeInfo", treeInfo);
			}
		}

		return list;
	}


	@Override
	public HashMap<String, Object> getUserDetail(UserSearch search) {
		HashMap<String, Object> user = siteDao.getUserDetail(search);

		if(search.getTopId() != null && !search.getTopId().equals("")) {
			HashMap param = new HashMap<>();
			param.put("topId", search.getTopId());
			param.put("siteId", user.get("siteId").toString());
			List<HashMap> treeInfo = siteDao.getSiteTreeInfo(param);
			log.info("treeInfo::"+treeInfo.toString());
			user.put("treeInfo", treeInfo);
		}

		return user;
	}


	@Override
	public int getSiteListCntForApi(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getSiteListCntForApi(search);
	}


	@Override
	public List<HashMap> getSiteListForApi(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getSiteListForApi(search);
	}


	@Override
	public Site getSiteDetailForApi(SiteSearch search) {
		Site site = siteDao.getSiteDetailForApi(search);

		if(search.getTopId() != null && !search.getTopId().equals("")) {
			HashMap param = new HashMap<>();
			param.put("topId", search.getTopId());
			param.put("siteId", site.getSiteId());
			List<HashMap> treeInfo = siteDao.getSiteTreeInfo(param);
			log.info("treeInfo::"+treeInfo.toString());
			site.setTreeInfo(treeInfo);
		}

		return site;
	}


	@Override
	public List<HashMap> getVendorListForApi(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getVendorListForApi(search);
	}


	@Override
	public List<HashMap> getSiteVendorListForApi(SiteSearch search) {
		// TODO Auto-generated method stub
		return siteDao.getSiteVendorListForApi(search);
	}


	@Override
	public HashMap getRefIdByVendorTranKey(String vendorTranKey) {
		// TODO Auto-generated method stub
		return siteDao.getRefIdByVendorTranKey(vendorTranKey);
	}

	@Override
	public int updateUserMaxBet(HashMap param) {
		return siteDao.updateUserMaxBet(param);
	}

	@Override
	public int insertTranLog(HashMap logParam) {
		return siteDao.insertTranLog(logParam);
	}


	@Override
	public HashMap getSiteSubCredit(String siteId) {
		// TODO Auto-generated method stub
		return siteDao.getSiteSubCredit(siteId);
	}


	@Override
	public String getBetAmountByTranParam(HashMap param) {
		// TODO Auto-generated method stub
		return siteDao.getBetAmountByTranParam(param);
	}

}
