package com.style24.batch.biz.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.style24.batch.biz.dao.TsbMonitoringDao;
import com.style24.batch.support.env.TsbConstants;
import com.style24.core.support.env.TscConstants;
import com.style24.persistence.domain.Alarm;

import lombok.extern.slf4j.Slf4j;

/**
 * 모니터링 Service
 * 
 * @author gagamel
 * @since 2020. 11. 13
 */
@Service
@Slf4j
public class TsbMonitoringService {

	@Autowired
	private TsbMonitoringDao monitoringDao;

	/**
	 * 시스템알람SMS 생성
	 * @param alarmId - 알람ID
	 * @return
	 * @author gagamel
	 * @since 2020. 11. 13
	 */
	@Transactional("shopTxnManager")
	public void createSystemAlarmSms(String alarmId) {
		Alarm params = new Alarm();
		params.setAlarmId(alarmId);
		params.setFuserid(String.valueOf(TsbConstants.REG_NO));
		params.setFcallback(TscConstants.CALLCENTER_TEL_NO);
		monitoringDao.createAlarmSms(params);
	}

	/**
	 * 1일내 회원가입건수 조회
	 * @param siteCd - 사이트코드
	 * @return
	 * @author gagamel
	 * @since 2020. 5. 18
	 */
	public int getJoinCountWithinOneDay(String siteCd) {
		return monitoringDao.getJoinCountWithinOneDay(siteCd);
	}

	/**
	 * 1시간내 로그인건수 조회
	 * @param siteCd - 사이트코드
	 * @return
	 * @author gagamel
	 * @since 2020. 5. 18
	 */
	public int getLoginCountWithinOneHour(String siteCd) {
		return monitoringDao.getLoginCountWithinOneHour(siteCd);
	}

	/**
	 * 1시간내 유입건수 조회
	 * @param siteCd - 사이트코드
	 * @return
	 * @author gagamel
	 * @since 2020. 5. 18
	 */
	public int getInthrowCountWithinOneHour(String siteCd) {
		return monitoringDao.getInthrowCountWithinOneHour(siteCd);
	}

	/**
	 * 2시간내 결제건수 조회
	 * @return
	 * @author gagamel
	 * @since 2020. 5. 18
	 */
	public int getPayCountWithinTwoHour() {
		return monitoringDao.getPayCountWithinTwoHour();
	}

	/**
	 * 1일내 외부몰주문수집건수 조회
	 * @return
	 * @author gagamel
	 * @since 2020. 5. 18
	 */
	public int getExtmallOrderCollectionCountWithinOneDay() {
		return monitoringDao.getExtmallOrderCollectionCountWithinOneDay();
	}

}
