d356136e83f0d4abf8c0f791609b73fd00e80ebc.svn-base 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. package com.chinacreator.process.dao;
  2. import java.sql.SQLException;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import org.apache.log4j.Logger;
  6. import org.springframework.stereotype.Component;
  7. import com.chinacreator.common.exception.BusinessException;
  8. import com.chinacreator.process.bean.BackShareOrderBean;
  9. import com.chinacreator.process.util.DataSource;
  10. import com.frameworkset.common.poolman.PreparedDBUtil;
  11. import com.frameworkset.common.poolman.SQLExecutor;
  12. /**
  13. * 后向异步送会员
  14. * @author xu.zhou
  15. * @date 20200818
  16. */
  17. @Component
  18. public class BackBusiVipAsynDao{
  19. private Logger log = Logger.getLogger("backbusivipsyn");
  20. /**
  21. * 保存订购日志
  22. * @param backShareOrder
  23. * @throws SQLException
  24. * @throws BusinessException
  25. */
  26. public void addShareOrderLog(BackShareOrderBean backShareOrder) throws SQLException {
  27. String sql = " INSERT INTO TL_BACKORDER_SHARE_PARMS (ID, USERID,ERRORCODE, ERRORINFO, CPID, SPID, REMARK) VALUES ( "+
  28. " TO_CHAR(SYSDATE, 'yyyymmddhh24miss')||SEQ_COMMON6.nextval, ?, ?, ?, ?, ?, ?)";
  29. SQLExecutor.insertWithDBName(DataSource.NET3G, sql,
  30. backShareOrder.getUserid(),
  31. backShareOrder.getErrorcode(),
  32. backShareOrder.getErrorinfo(),
  33. backShareOrder.getCpid(),
  34. backShareOrder.getSpid(),
  35. backShareOrder.getRemark());
  36. }
  37. /**
  38. * 更新调能力平台状态
  39. * @param id
  40. * @param resultcode
  41. * @param resultinfo
  42. * @return
  43. * @throws SQLException
  44. */
  45. public void updShareStatus(String id, String resultcode, String resultinfo) throws SQLException {
  46. String sql = " UPDATE TD_BACKBUSI_ORDER_REC SET RESULTCODE = ? , RESULTINFO = ? WHERE ID = ? ";
  47. SQLExecutor.updateWithDBName(DataSource.NET3G, sql, resultcode, resultinfo, id);
  48. }
  49. /**
  50. * 查询要异步调能力平台的数据
  51. * @return
  52. */
  53. public List<HashMap> getInvokeShareData(){
  54. String sql = " SELECT * FROM (SELECT ID, USERID, ORDERID,CHANNEL, CPID, SPID, BUSITYPE FROM TD_BACKBUSI_ORDER_REC "+
  55. " WHERE INSERTTIME > SYSDATE - 10 "+
  56. " AND CHANNEL <> 'CHSvideoD00' "+
  57. " AND RESULTCODE = '3' "+
  58. " AND BUSITYPE IN ('2', '3') "+
  59. " ORDER BY INSERTTIME) "+
  60. " WHERE ROWNUM < 1000 ";
  61. PreparedDBUtil pdb = new PreparedDBUtil();
  62. try {
  63. pdb.preparedSelect(DataSource.NET3G, sql);
  64. return pdb.executePreparedForList(HashMap.class);
  65. } catch (Exception e) {
  66. e.printStackTrace();
  67. }
  68. return null;
  69. }
  70. /**
  71. * 查询要异步赠送会员的数据
  72. * @param trycount
  73. * @return
  74. */
  75. public List<HashMap> getVipAsynData(String trycount){
  76. //赠送会员状态,0成功,1待赠送,2赠送中,3失败,8已冻结
  77. String sql = " SELECT * FROM (SELECT ID, USERID, ORDERID,CHANNEL, CPID, SPID, VIPSTATUS, BUSITYPE, RETRYCOUNT FROM TD_BACKBUSI_ORDER_REC WHERE INSERTTIME > SYSDATE - 10 "+
  78. " AND CHANNEL <> 'CHSvideoD00' "+
  79. " AND RESULTCODE = '0' "+
  80. " AND (VIPSTATUS = '1' OR VIPSTATUS = '3') "+
  81. " AND (BUSITYPE = '1' OR BUSITYPE = '3') "+
  82. " AND RETRYCOUNT < ? "+
  83. " AND (RETRYTIME IS NULL OR TO_NUMBER((SYSDATE - RETRYTIME)*24*60) >=2) "+
  84. " ORDER BY INSERTTIME) "+
  85. " WHERE ROWNUM < 1000 ";
  86. PreparedDBUtil pdb = new PreparedDBUtil();
  87. try {
  88. pdb.preparedSelect(DataSource.NET3G, sql);
  89. pdb.setInt(1, Integer.parseInt(trycount));
  90. return pdb.executePreparedForList(HashMap.class);
  91. } catch (Exception e) {
  92. e.printStackTrace();
  93. }
  94. return null;
  95. }
  96. /**
  97. * 获取业务配置信息
  98. * @param cpid
  99. * @param spid
  100. * @return
  101. * @throws SQLException
  102. */
  103. public List<HashMap> getBackBusiConf(String cpid, String spid) throws SQLException {
  104. String sql = "SELECT * FROM TB_BACKBUSI_CONF WHERE STATUS = '0' AND CPID = ? AND SPID = ? ";
  105. return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql, cpid, spid);
  106. }
  107. /**
  108. * 更新赠送会员状态为正在赠送
  109. * @param vipstatus
  110. * @param id
  111. * @return
  112. * @throws SQLException
  113. */
  114. public void updVipSendStatus(String id) throws SQLException {
  115. String sql = " UPDATE TD_BACKBUSI_ORDER_REC SET VIPSTATUS = 2 WHERE ID = ? ";
  116. SQLExecutor.updateWithDBName(DataSource.NET3G, sql, id);
  117. }
  118. /**
  119. * 更新赠送会员结果
  120. * @param id
  121. * @param vipstatus
  122. * @return
  123. * @throws SQLException
  124. */
  125. public void updVipSendStatus(String id, String vipstatus, String time) throws SQLException {
  126. String sql = " UPDATE TD_BACKBUSI_ORDER_REC SET VIPSTATUS = ?, RETRYCOUNT = RETRYCOUNT+1, RETRYTIME = SYSDATE, TIMES = ? WHERE ID = ? ";
  127. SQLExecutor.updateWithDBName(DataSource.NET3G, sql, vipstatus, time, id);
  128. }
  129. /**
  130. * 根据渠道查询密码
  131. * @param channel
  132. * @return
  133. * @throws SQLException
  134. */
  135. public HashMap getChannelPwdByChannel(String channel)throws SQLException {
  136. String sql = " SELECT ID, PASSWORD FROM TB_CHANNEL_ORG where status = 0 and id= ? ";
  137. return SQLExecutor.queryObjectWithDBName(HashMap.class, DataSource.NET3G, sql, channel);
  138. }
  139. /**
  140. * 当调会员赠送接口为失败时反查赠送会员结果,防止调接口超时获取不到真实赠送会员的结果
  141. * @param orderid
  142. * @return true 赠送成功,false 赠送失败
  143. * @throws SQLException
  144. */
  145. public boolean getVipSendRes(String orderid){
  146. String sql = "SELECT COUNT(1) CNT FROM TL_VIP_LOG WHERE REQUESTID = ? AND RESULTCODE = '0' ";
  147. int cnt = 0;
  148. try {
  149. cnt = (int)SQLExecutor.queryObjectWithDBName(Integer.class, DataSource.NET3G, sql, orderid);
  150. } catch (SQLException e) {
  151. e.printStackTrace();
  152. }
  153. if(cnt > 0){
  154. return true;
  155. }else{
  156. return false;
  157. }
  158. }
  159. public static void main(String[] args) {
  160. BackBusiVipAsynDao dao = new BackBusiVipAsynDao();
  161. //System.out.println(dao.getVipAsynData("1"));
  162. System.out.println(dao.getVipSendRes("201811191529237555154"));
  163. }
  164. }