884ccb7cb8768aaec8be2a19253322926b974c39.svn-base 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.chinacreator.process.dao;
  2. import com.chinacreator.process.util.DataSource;
  3. import com.frameworkset.common.poolman.SQLExecutor;
  4. import org.apache.log4j.Logger;
  5. import org.springframework.stereotype.Component;
  6. import java.sql.SQLException;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. @Component
  10. public class OrderKsPreDao {
  11. private Logger log = Logger.getLogger("ksPre");
  12. public void updateKsPre(String status, String resultCode, String resultMsg, String userid, String spid, String cpid) throws SQLException {
  13. String sql = "update td_order_ks_pre set status= ? , result_code= ? , result_info= ? ,CANCEL_SUBMIT=sysdate where status='1' and userid=? and spid=? and cpid=? ";
  14. SQLExecutor.updateWithDBName(DataSource.NET3G, sql, status, resultCode, resultMsg, userid, spid, cpid);
  15. }
  16. public void updateErrorKsPre(String status, String resultCode, String resultMsg, String userid, String spid, String cpid, Integer retryNub) throws SQLException {
  17. String sql = "update td_order_ks_pre set status= ? , result_code= ? , result_info= ? , retry_nub=retry_nub+? , RETRY_TIME=sysdate where status='1' and userid=? and spid=? and cpid=? ";
  18. SQLExecutor.updateWithDBName(DataSource.NET3G, sql, status, resultCode, resultMsg, retryNub, userid, spid, cpid);
  19. }
  20. public boolean findRetryNub(String userid, String spid, String cpid) throws SQLException {
  21. String sql = "select retry_nub from td_order_ks_pre where userid= ? and spid= ? and cpid=? and status='1'";
  22. return Integer.parseInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, userid, spid, cpid)) < 3;
  23. }
  24. public void updateStatus(String status, String userid, String spid, String cpid) throws SQLException {
  25. String sql = "update td_order_ks_pre set status= ? where status='0' and userid=? and spid=? and cpid=? ";
  26. SQLExecutor.updateWithDBName(DataSource.NET3G, sql, status, userid, spid, cpid);
  27. }
  28. public List<HashMap> queryKsPreList() throws SQLException {
  29. String sql = "select * from td_order_ks_pre where status='0' and sysdate>cancel_time";
  30. return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql);
  31. }
  32. public void addOrderLog(String userid, String cpid, String spid, String resultCode, String resultInfo, String channel, String status) {
  33. String sql = "insert into NET3G.TL_ORDER_LOG(ID,USERID,CPID,SPID,ERRORCODE,ERRORINFO,INSERTTIME,CHANNEL,STATUS) \n" +
  34. "VALUES(to_char(sysdate, 'yyyymmddhh24miss') || SEQ_COMMON6.nextval,?,?,?,?,?,sysdate,?,?)";
  35. try {
  36. SQLExecutor.insertWithDBName(DataSource.NET3G, sql, userid, cpid, spid, resultCode, resultInfo, channel, status);
  37. } catch (SQLException e) {
  38. e.printStackTrace();
  39. log.info(userid+"===添加日志失败==="+e.getMessage());
  40. }
  41. }
  42. }