package com.chinacreator.process.dao;

import com.chinacreator.process.util.DataSource;
import com.frameworkset.common.poolman.SQLExecutor;
import org.springframework.stereotype.Component;

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

@Component
public class RedeemUserDao {

    public List<HashMap> getRedeemUserList() throws SQLException {
        String sql="select t.id,t.userid,t.retrycnt,t.spid,t.cpid,b.smscof from  TD_REDEEM_USER  t  join  TB_REDEEM_CONF  b on  t.smstype is null and t.spid=b.spid and b.STATUS='0'  where t.status in ('2','3')  and  t.retrycnt<3  and t.updatetime < sysdate-1/144";
        return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql,null);
    }

    public void updateType(String id) throws SQLException {
        String sql="update TD_REDEEM_USER  t set t.smstype='0' where id= ?";
        SQLExecutor.updateWithDBName(DataSource.NET3G,sql,id);
    }
    public void updateRetry(String id,String retry) throws SQLException {
        String sql="update TD_REDEEM_USER  t set t.RETRYCNT= ? where id= ?";
        SQLExecutor.updateWithDBName(DataSource.NET3G,sql,retry,id);
    }
}
