package com.chinacreator.process.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import com.chinacreator.process.bean.BackBusiOrderRec;
import com.chinacreator.process.bean.BackShareOrderBean;
import com.chinacreator.process.bean.NetOrderBean;
import com.chinacreator.process.bean.OrderLog;
import com.chinacreator.process.bean.PointShopOrderBean;
import com.chinacreator.process.util.DataSource;
import com.frameworkset.common.poolman.SQLExecutor;

@Component
public class CsmakeupDao{
	/**
	 * 获取配置数据
	 * @param spid
	 * @return
	 * @throws SQLException
	 */
    public List<HashMap> getBusiConf(String spid)throws SQLException {
		String sql = " SELECT * FROM TB_CSMAKEUP_PROD_CONF A WHERE A.STATUS = '0' AND SPID = ? ";
		return  SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql, spid);
    }
    
    /**
     * 添加记录
     * @param hm
     * @throws SQLException
     */
	public Object addOrderRec(HashMap params)throws SQLException {
		String sql = " INSERT INTO TD_CSMAKEUP_ORDER_REC( "+
			" ID,USERID,CHANNEL,CPID,MUSPID,PROVINCE,AREA,VIPRECODE,VIPREINFO,RESULTCODE,RESULTINFO,TIMES,STATUS,INSERTTIME ) "+
			" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE)";
		return SQLExecutor.insertWithDBName( DataSource.NET3G, sql, 
				params.get("SENO"),params.get("USERID"),params.get("CHANNEL"),params.get("CPID"),params.get("MUSPID"),
				params.get("PROVINCE"),params.get("AREA"),params.get("VIPRECODE"),params.get("VIPREINFO"),params.get("RESULTCODE"),
				params.get("RESULTINFO"),params.get("TIMES"),params.get("STATUS"));
    }
	
	/**
	 * 获取流水号
	 * @return
	 */
	public String getNo()throws SQLException {
		String sql = " SELECT TO_CHAR(SYSDATE,'yyyyMMddhh24miss')||SEQ_COMMON6.nextval SENO FROM DUAL";
		return SQLExecutor.queryObjectWithDBName(String.class, DataSource.NET3G, sql);
	}
	
	public static void main(String[] args) throws Exception{
		CsmakeupDao dao = new CsmakeupDao();
		//System.out.println(dao.getBusiConf("99134247"));
		HashMap params = new HashMap();
		params.put("SENO", dao.getNo());
		params.put("USERID", "18673197465");
		params.put("CPID", "fhcp");
		params.put("MUSPID", "ST000001");
		params.put("PROVINCE", "湖南");
		params.put("AREA", "长沙");
		params.put("VIPRECODE", "0");
		params.put("VIPREINFO", "成功");
		params.put("RESULTCODE", "0");
		params.put("RESULTINFO", "ok");
		params.put("TIMES", "2145");
		params.put("STATUS", "0");
		System.out.println(dao.addOrderRec(params));
		
	}
}
