7691d6ce3d090826dd84b8e65f16dfe1665b0ee5.svn-base 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. package com.chinacreator.process.dao;
  2. import org.springframework.stereotype.*;
  3. import org.apache.log4j.*;
  4. import java.util.*;
  5. import com.frameworkset.common.poolman.*;
  6. import com.chinacreator.process.bean.*;
  7. import java.sql.*;
  8. @Component
  9. public class TencentBillDao
  10. {
  11. private static Logger logger;
  12. static {
  13. TencentBillDao.logger = Logger.getLogger((Class)TencentBillDao.class);
  14. }
  15. public List<TencentBillOrder> pageQuery(final String cpid, final String spid, final String starttime, final String endtime, final int pageno, final int pagesize) {
  16. final StringBuffer sb = new StringBuffer("");
  17. sb.append(" SELECT");
  18. sb.append(" orderid,");
  19. sb.append(" userid,");
  20. sb.append(" DECODE(busitype,'0','0','1','1','2','2','3','1','4','3') busitype,");
  21. sb.append(" TO_CHAR(DECODE(BUSITYPE, '4',ORDERTIME,INSERTTIME),'yyyyMMddHH24miss') optime,");
  22. sb.append(" resultcode,");
  23. sb.append(" DECODE(busitype,'0','\u8ba2\u8d2d','1','\u9000\u8ba2','2','\u6536\u5230\u9884\u8ba2\u8d2d\u6d88\u606f','3','\u9000\u8ba2','4','\u9884\u8ba2\u8d2d')||DECODE(resultcode,'0','\u6210\u529f','\u5931\u8d25') resultinfo");
  24. sb.append(" FROM TD_PRE_ORDERID_REC ");
  25. sb.append(" WHERE cpid = '" + cpid + "' AND spid = '" + spid + "' AND busitype IN('0','1','2','3','4') ");
  26. if (starttime != null && !"".equals(starttime.trim())) {
  27. sb.append(" AND inserttime>=to_date('" + starttime + "','yyyyMMdd')");
  28. }
  29. sb.append(" AND inserttime <to_date('" + endtime + "','yyyyMMdd')");
  30. sb.append(" ORDER BY inserttime");
  31. final PreparedDBUtil pdb = new PreparedDBUtil();
  32. try {
  33. TencentBillDao.logger.info((Object)sb.toString());
  34. return (List<TencentBillOrder>)pdb.executeSelectForList("net3g", sb.toString(), (long)((pageno - 1) * pagesize), pagesize, (Class)TencentBillOrder.class);
  35. }
  36. catch (Exception e) {
  37. TencentBillDao.logger.error((Object)"\u67e5\u8be2\u6570\u636e\u5931\u8d25", (Throwable)e);
  38. return null;
  39. }
  40. }
  41. public int counts(final String cpid, final String spid, final String starttime, final String endtime) {
  42. final StringBuffer sb = new StringBuffer("");
  43. sb.append(" SELECT count(1) counts FROM TD_PRE_ORDERID_REC ");
  44. sb.append(" WHERE cpid = '" + cpid + "' AND spid = '" + spid + "' AND busitype IN('0','1','2','3','4') ");
  45. if (starttime != null && !"".equals(starttime.trim())) {
  46. sb.append(" AND inserttime>=to_date('" + starttime + "','yyyyMMdd')");
  47. }
  48. sb.append(" AND inserttime <to_date('" + endtime + "','yyyyMMdd')");
  49. final PreparedDBUtil pdb = new PreparedDBUtil();
  50. try {
  51. TencentBillDao.logger.info((Object)sb.toString());
  52. final TencentBillOrder bean = (TencentBillOrder)pdb.executeSelectForObject("net3g", sb.toString(), (Class)TencentBillOrder.class);
  53. return bean.getCounts();
  54. }
  55. catch (Exception e) {
  56. TencentBillDao.logger.error((Object)"\u67e5\u8be2\u6570\u636e\u5931\u8d25", (Throwable)e);
  57. return 0;
  58. }
  59. }
  60. public void saveBillLog(final TencentBillLog bean) {
  61. try {
  62. final String sql = "insert into TD_TENCENT_PRE_ORDER_BILL(id,billdate,billtype,cpid,spid,datacounts,filecounts,files,status,resultcode,errorinfo,inserttime,filepath,history,retry)values(#[id],#[billdate],#[billtype],#[cpid],#[spid],#[datacounts],#[filecounts],#[files],#[status],#[resultcode],#[errorinfo],sysdate,#[filepath],'1','1')";
  63. SQLExecutor.insertBean("net3g", sql, (Object)bean);
  64. }
  65. catch (Exception e) {
  66. TencentBillDao.logger.error((Object)"\u67e5\u8be2\u6570\u636e\u5931\u8d25", (Throwable)e);
  67. }
  68. }
  69. public TencentBillLog existBillLog(final String billdate, final String billtype, final String cpid, final String spid) {
  70. try {
  71. final String sql = "select * from TD_TENCENT_PRE_ORDER_BILL where cpid ='" + cpid + "' and spid = '" + spid + "' and billdate ='" + billdate + "' and billtype = '" + billtype + "' and history='1'";
  72. return (TencentBillLog)SQLExecutor.queryObjectWithDBName((Class)TencentBillLog.class, "net3g", sql, new Object[0]);
  73. }
  74. catch (Exception e) {
  75. TencentBillDao.logger.error((Object)"\u67e5\u8be2\u6570\u636e\u5931\u8d25", (Throwable)e);
  76. return null;
  77. }
  78. }
  79. public List<TencentBillChannel> existChannels() {
  80. try {
  81. final String sql = "select * from TB_TENCENT_PRE_ORDER_BILL where status='0' ";
  82. return (List<TencentBillChannel>)SQLExecutor.queryListBeanWithDBName((Class)TencentBillChannel.class, "net3g", sql, (Object)null);
  83. }
  84. catch (Exception e) {
  85. TencentBillDao.logger.error((Object)"\u67e5\u8be2\u6570\u636e\u5931\u8d25", (Throwable)e);
  86. return null;
  87. }
  88. }
  89. public TencentBillChannel existChannel(final String cpid, final String spid) {
  90. try {
  91. final String sql = "select * from TB_TENCENT_PRE_ORDER_BILL where status='0' and cpid ='" + cpid + "' and spid = '" + spid + "'";
  92. return (TencentBillChannel)SQLExecutor.queryObjectWithDBName((Class)TencentBillChannel.class, "net3g", sql, new Object[0]);
  93. }
  94. catch (Exception e) {
  95. TencentBillDao.logger.error((Object)"\u67e5\u8be2\u6570\u636e\u5931\u8d25", (Throwable)e);
  96. return null;
  97. }
  98. }
  99. public List<TencentBillLog> existBillLogAgain3() {
  100. try {
  101. final String sql = "select * from TD_TENCENT_PRE_ORDER_BILL where retry='3' and history='1'";
  102. return (List<TencentBillLog>)SQLExecutor.queryListBeanWithDBName((Class)TencentBillLog.class, "net3g", sql, (Object)null);
  103. }
  104. catch (Exception e) {
  105. TencentBillDao.logger.error((Object)"\u67e5\u8be2\u6570\u636e\u5931\u8d25", (Throwable)e);
  106. return null;
  107. }
  108. }
  109. public List<TencentBillLog> existBillLogAgain4() {
  110. try {
  111. final String sql = "select * from TD_TENCENT_PRE_ORDER_BILL where retry='4' and history='1' ";
  112. return (List<TencentBillLog>)SQLExecutor.queryListBeanWithDBName((Class)TencentBillLog.class, "net3g", sql, (Object)null);
  113. }
  114. catch (Exception e) {
  115. TencentBillDao.logger.error((Object)"\u67e5\u8be2\u6570\u636e\u5931\u8d25", (Throwable)e);
  116. return null;
  117. }
  118. }
  119. public void updatetBillLog(final String id) {
  120. final String sql = "update TD_TENCENT_PRE_ORDER_BILL set history='0',retry='0' where id='" + id + "' ";
  121. try {
  122. SQLExecutor.updateWithDBName("net3g", sql, new Object[0]);
  123. }
  124. catch (SQLException e) {
  125. TencentBillDao.logger.error((Object)"\u66f4\u6539\u6570\u636e\u5931\u8d25", (Throwable)e);
  126. }
  127. }
  128. public void updatetBillLogFtp(final String id, final String status, final String code, final String info) {
  129. final String sql = "update TD_TENCENT_PRE_ORDER_BILL set history='1',retry='0',status='" + status + "',code='" + code + "',info='" + info + "',ftptime=sysdate where id='" + id + "' ";
  130. try {
  131. SQLExecutor.updateWithDBName("net3g", sql, new Object[0]);
  132. }
  133. catch (SQLException e) {
  134. TencentBillDao.logger.error((Object)"\u66f4\u6539\u6570\u636e\u5931\u8d25", (Throwable)e);
  135. }
  136. }
  137. }