package jp.agentec.sinaburocast.action.batch;

import java.util.Calendar;

import jp.agentec.sinaburocast.action.AbstractAction;
import jp.agentec.sinaburocast.entity.PointPeriod;
import jp.agentec.sinaburocast.service.PointGetService;
import jp.agentec.sinaburocast.service.PointPeriodService;

import org.apache.log4j.Logger;
import org.apache.velocity.tools.generic.DateTool;
import org.seasar.struts.annotation.Execute;

/**
 * ポイント有効期限を過ぎたポイント削減バッチ
 *
 * @author choi-c
 *
 */
public class PointCutBatchAction extends AbstractAction {
	private final Logger logger = Logger.getLogger(getClass());

	public PointPeriodService pointPeriodService;
	public PointGetService PointGetService;
	
	@Execute(validator=false)
	public String index() {
		PointPeriod pointPeriod = pointPeriodService.findByOnRecode();

		Calendar now = Calendar.getInstance();
		
		now.add(Calendar.YEAR, -pointPeriod.pointPeriod);
		
		PointGetService.cutExpiredPointBySql(new DateTool().format("yyyyMM",now));
		
		return null;
	}

}