package com.chinacreator.process.dao;

import java.sql.SQLException;

import org.apache.commons.lang.math.NumberUtils;
import org.springframework.stereotype.Component;
import com.chinacreator.process.util.DataSource;
import com.frameworkset.common.poolman.SQLExecutor;

@Component
public class VacControlDao {

	public boolean isOrder(String userid, String cpid,String spid) throws SQLException {
		String sql = "SELECT count(1) from  td_vacorder_control where userid=? and cpid=? and spid=? and to_char(ordertime,'yyyymm')=to_char(sysdate,'yyyymm')";
		return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, userid, cpid,spid), 0) > 0;
	}
	
	
	public void saveOrde(String userid, String cpid,String spid) throws SQLException{
		String sql = "insert into td_vacorder_control(userid,cpid,spid,ordertime) values(?,?,?,sysdate)";
		SQLExecutor.insertWithDBName(DataSource.NET3G, sql, userid, cpid,spid);
	}
	
	public static void main(String[] args) throws SQLException {
		VacControlDao  dao = new VacControlDao();
		dao.saveOrde("18574414678", "tencent", "84");
	}
}
