ba1a1cada34dea9b900695e97e1e70b9933cb308.svn-base 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. package com.chinacreator.process.dao;
  2. import com.chinacreator.process.bean.OrderConfigBean;
  3. import com.chinacreator.process.bean.SDKOrderInfo;
  4. import com.chinacreator.process.exception.ServiceException;
  5. import com.chinacreator.process.util.DataSource;
  6. import com.frameworkset.common.poolman.PreparedDBUtil;
  7. import com.frameworkset.common.poolman.SQLExecutor;
  8. import org.apache.commons.lang.StringUtils;
  9. import org.springframework.stereotype.Component;
  10. import java.sql.SQLException;
  11. import java.text.SimpleDateFormat;
  12. import java.util.Date;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. @Component
  16. public class JiYueOrderDao {
  17. public List<HashMap> queryList() throws SQLException {
  18. String sql = " select id,type,usermob,productid,to_char(ordertime,'yyyymmddhh24miss') ordertime, to_char(canceltime,'yyyymmddhh24miss') canceltime, to_char(endtime,'yyyymmddhh24miss') endtime from TD_JIYUE_ORDER_WAIT where resultcode = '1' order by inserttime";
  19. List<HashMap> hashMaps = SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql);
  20. return hashMaps;
  21. }
  22. public void updataQueryList(String id,String resultcode) throws SQLException {
  23. String sql = "update TD_JIYUE_ORDER_WAIT set resultcode = ?,updatetime = sysdate where id = ?";
  24. SQLExecutor.updateWithDBName(DataSource.NET3G, sql,resultcode,id);
  25. }
  26. public void updataQueryList(String id,String resultcode,String errorinfo) throws SQLException {
  27. String sql = "update TD_JIYUE_ORDER_WAIT set resultcode = ?,errorinfo = ?,updatetime = sysdate where id = ?";
  28. SQLExecutor.updateWithDBName(DataSource.NET3G, sql,resultcode,errorinfo,id);
  29. }
  30. public int updatalongdata() throws SQLException {
  31. String sql = "update TD_JIYUE_ORDER_WAIT set resultcode = '1',errorinfo = '超时',updatetime = sysdate where resultcode = '2' and updatetime < sysdate-1/24/30";
  32. Object res = SQLExecutor.updateWithDBName(DataSource.NET3G, sql);
  33. return (Integer)res;
  34. }
  35. public HashMap getCpSp(String productid) throws SQLException {
  36. String sql = " select cpid,spid,authstatus from tb_intensive_productid_conf where productid = ?";
  37. HashMap hashMaps = SQLExecutor.queryObjectWithDBName(HashMap.class, DataSource.NET3G, sql,productid);
  38. return hashMaps;
  39. }
  40. public int isOrder(String cpid, String spid, String userid) {
  41. int isOrder = 1;
  42. PreparedDBUtil pdb = new PreparedDBUtil();
  43. String sql = "select count(*) from TD_ORDER_RELATIONS where cpid=? and spid=? and userid=? and status='0'";
  44. try {
  45. pdb.preparedSelect(DataSource.NET3G, sql);
  46. pdb.setString(1, cpid);
  47. pdb.setString(2, spid);
  48. pdb.setString(3, userid);
  49. pdb.executePrepared();
  50. if (pdb.getInt(0, 0) > 0)
  51. isOrder = 0;
  52. } catch (Exception e) {
  53. e.printStackTrace();
  54. }
  55. return isOrder;
  56. }
  57. /**
  58. * 特殊复合产品结束时间
  59. * @return
  60. */
  61. public Date getLastYearDay(Date time){
  62. PreparedDBUtil pdb = new PreparedDBUtil();
  63. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  64. String sql = "select TO_DATE(TO_CHAR(trunc(add_months(?,13),'MM') - 1/24/60/60,'yyyyMMddhh24miss'), 'yyyyMMddhh24miss') from dual";
  65. try {
  66. pdb.preparedSelect(DataSource.NET3G, sql);
  67. pdb.setDate(1,time);
  68. String endtime = pdb.executePreparedForList(String.class).get(0);
  69. Date d = sdf.parse(endtime);
  70. return d;
  71. } catch (Exception e) {
  72. e.printStackTrace();
  73. }
  74. return null;
  75. }
  76. /**
  77. * 特殊复合产品结束时间
  78. * @return
  79. */
  80. public Date getLastYearDayFirst(Date time){
  81. PreparedDBUtil pdb = new PreparedDBUtil();
  82. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  83. String sql = "select TO_DATE(TO_CHAR(trunc(add_months(?,12),'MM') - 1/24/60/60,'yyyyMMddhh24miss'), 'yyyyMMddhh24miss') from dual";
  84. try {
  85. pdb.preparedSelect(DataSource.NET3G, sql);
  86. pdb.setDate(1,time);
  87. String endtime = pdb.executePreparedForList(String.class).get(0);
  88. Date d = sdf.parse(endtime);
  89. return d;
  90. } catch (Exception e) {
  91. e.printStackTrace();
  92. }
  93. return null;
  94. }
  95. //获得券码活动配置
  96. public HashMap getCouponConfig(String spid ){
  97. PreparedDBUtil pdb = new PreparedDBUtil();
  98. String sql = "SELECT ID, CPID,SPID,TO_CHAR(STARTTIME,'YYYYMMDDHH24MISS') STARTTIME, " +
  99. "TO_CHAR(ENDTIME,'YYYYMMDDHH24MISS') ENDTIME,ACTIVITYCODE,COUPONTYPE,REMARK,CHANNEL,EXTEND1 " +
  100. " from TB_ACPRODUCT_CONFIG where sysdate between STARTTIME and ENDTIME and status = '0' and activitycode = 'telecomActivity' and spid = ? ";
  101. try {
  102. pdb.preparedSelect(DataSource.NET3G, sql);
  103. pdb.setString(1,spid);
  104. // return pdb.executePreparedForList(HashMap.class)==null?null:pdb.executePreparedForList(HashMap.class).get(0);
  105. List<HashMap> list = pdb.executePreparedForList(HashMap.class);
  106. if (list != null && list.size() > 0) {
  107. HashMap map = list.get(0);
  108. return map;
  109. }
  110. } catch (SQLException e) {
  111. e.printStackTrace();
  112. }
  113. return null;
  114. }
  115. public Date getFhcpEndtime(String userid,String cpid,String spid){
  116. PreparedDBUtil pdb = new PreparedDBUtil();
  117. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  118. String sql = "select endtime from TD_ORDER_RELATIONS where userid = ? and cpid = ? and spid = ?";
  119. try {
  120. String endtime = SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, new Object[] { userid, cpid, spid });
  121. Date d = sdf.parse(endtime);
  122. return d;
  123. } catch (Exception e) {
  124. e.printStackTrace();
  125. }
  126. return null;
  127. }
  128. /*采集需要订购后再下发其他短信的产品*/
  129. public List<String> querySendSmsProduct(){
  130. PreparedDBUtil pdb = new PreparedDBUtil();
  131. String sql = "select spid from tb_sendsms_product where status = '0' ";
  132. try {
  133. pdb.preparedSelect(DataSource.NET3G, sql);
  134. return pdb.executePreparedForList(String.class);
  135. } catch (SQLException e) {
  136. e.printStackTrace();
  137. }
  138. return null;
  139. }
  140. public OrderConfigBean findBySpid(String spid){
  141. PreparedDBUtil pdb = new PreparedDBUtil();
  142. String sql = "select cpid,spid,productid vacproductid,authstatus type from tb_intensive_productid_conf where spid = ?";
  143. try {
  144. pdb.preparedSelect(DataSource.NET3G, sql);
  145. pdb.setString(1, spid);
  146. return (OrderConfigBean) pdb.executePreparedForObject(OrderConfigBean.class);
  147. } catch (SQLException e) {
  148. e.printStackTrace();
  149. }
  150. return null;
  151. }
  152. }