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.common.exception.BusinessException;
import com.chinacreator.process.bean.BackShareOrderBean;
import com.chinacreator.process.util.DataSource;
import com.frameworkset.common.poolman.PreparedDBUtil;
import com.frameworkset.common.poolman.SQLExecutor;

/**
 * 后向异步送会员
 * @author xu.zhou
 * @date 20200818
 */
@Component
public class UnicomSmsOrderDao{
	
	private Logger log = Logger.getLogger("smsorder");	
	
	/**
	 * 更新调能力平台状态
	 * @param id
	 * @param resultcode 结果编码，-1待审核，1待处理，2处理中，0处理完成
	 * @param resultinfo
	 * @return
	 * @throws SQLException
	 */
	public void updShareStatus(String id, String resultcode, String resultinfo, String times) throws SQLException {	
		String sql = " UPDATE TD_UNICOMSMS_ORDERREC SET RESULTCODE = ? , RESULTINFO = ?, TIMES = ? WHERE ID = ? ";
		SQLExecutor.updateWithDBName(DataSource.NET3G, sql, resultcode, resultinfo, times, id);
	}
	
	/**
	 * 查询要异步调能力平台的数据
	 * @return
	 */
	public List<HashMap> getInvokeShareData(){
		String sql = " SELECT * FROM (SELECT * FROM TD_UNICOMSMS_ORDERREC "+
						" WHERE INSERTTIME > SYSDATE - 10 "+
						" AND RESULTCODE = '1'  "+
						" ORDER BY INSERTTIME) "+
						" WHERE ROWNUM < 1000 ";
		PreparedDBUtil pdb = new PreparedDBUtil();
		try {
			pdb.preparedSelect(DataSource.NET3G, sql);
			return pdb.executePreparedForList(HashMap.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public static void main(String[] args) {
		UnicomSmsOrderDao dao = new UnicomSmsOrderDao();
		System.out.println(dao.getInvokeShareData());
	}
}
