/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.wechat.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wechat.dao.AdCtrRedisDao;
import com.wechat.model.requestDto.AdCtrReq;

/**
 * 单表生成Service
 * 
 * @author Jadyn
 * @version 2022-02-23
 */
@Service
public class MdeAdImagesService {
	@Autowired
	private AdCtrRedisDao adCtrRDao;

	// log 处理
	protected static final Log log = LogFactory.getLog(MdeAdImagesService.class);
	
	/**
	 * 广告的点击量统计
	 * 
	 * @param list
	 * @return
	 */
	public int recodeAdCtr(AdCtrReq adCtrReq) {
		int result = 0;
		try {
			//记录展现量
			adCtrRDao.insertAdShow(String.valueOf(adCtrReq.getAdId()), adCtrReq.getShowNum());
			//记录点击量
			adCtrRDao.insertAdClick(String.valueOf(adCtrReq.getAdId()), adCtrReq.getClickNum());
		} catch (Exception e) {
			result = 1;
			log.error("****************************** 广告的点击量统计异常******************************", e);
		}
		return result;
	}
	
	/**
	 * 广告的点击验证
	 * 
	 * @return
	 */
	public boolean checkAdsCtr(AdCtrReq adCtrReq) {
		boolean result = true;
		if(adCtrReq.getShowNum()>9 || adCtrReq.getClickNum() > 9) {
			result = false;
		}
		return result;
	}

}