package com.chinacreator.process.dao;

import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import com.frameworkset.common.poolman.PreparedDBUtil;
import com.frameworkset.common.poolman.SQLExecutor;

@Component
public class ActiveMango3Dao{
	
	private static Logger logger = Logger.getLogger(ActiveMango3Dao.class);
	
	@SuppressWarnings("unchecked")
	public List<String> queryNeedSmsDeal(){
		String sql = " select userid from TD_BUSSINESS_HANDLE_MANGO3 where inserttime>=sysdate-10 and inserttime<sysdate-3 and smsstatus='1' ";
		
		PreparedDBUtil pdb = new PreparedDBUtil();
		try {
			return pdb.executeSelectForList("net3g", sql, 0L, 500, String.class);
		} catch (Exception e) {
			logger.error("查询需要发短信处理的数据失败", e);
		}
		return null;
	}
	
	public void sendSmsSuccess(String userid) {
		String sql = "update net3g.TD_BUSSINESS_HANDLE_MANGO3 set smsstatus='0',smstime=sysdate where userid=?";
		try {
			SQLExecutor.updateWithDBName("net3g", sql, new Object[] { userid });
		} catch (SQLException e) {
			logger.error("更改TB_USERID_FAKEID失败", e);
		}
	}
	
	public void sendSmsfail(String userid) {
		String sql = "update net3g.TD_BUSSINESS_HANDLE_MANGO3 set smsstatus='2',smstime=sysdate where userid=?";
		try {
			SQLExecutor.updateWithDBName("net3g", sql, new Object[] { userid });
		} catch (SQLException e) {
			logger.error("更改TB_USERID_FAKEID失败", e);
		}
	}
  
}