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 CsOrderControlDao {

	public boolean provinceControl(String province,String cpid,String spid) throws SQLException{
		String sql = "select count(1) from TB_CHANGSHI_PROVINCE_CONTROL where cpid = ? and spid=? and province=? and status=2";
		return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G,sql, cpid,spid,province))>0;
	}
	 
	public boolean discntCodeControl(String discntcode,String cpid,String spid) throws SQLException{
		String sql = "select count(1) from tb_discntcode_white where cpid = ? and spid=? and discntcode=? and type =0";
		return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G,sql, cpid,spid,discntcode))>0;
	}
	
	public boolean discntFeeControl(String discntcode,String cpid,String spid) throws SQLException{
		String sql = "select count(1) from tb_discntcode_white where cpid = ? and spid=? and discntcode=? and type =2";
		return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G,sql, cpid,spid,discntcode))>0;
	}
}
