dbd5b03bc4d3a0788f7004c228f853b678583982.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. package com.chinacreator.process.dao;
  2. import com.chinacreator.process.bean.BackBusiOrderRec;
  3. import com.chinacreator.process.bean.BackShareOrderBean;
  4. import com.chinacreator.process.bean.OrderLog;
  5. import com.chinacreator.process.bean.PointShopOrderBean;
  6. import com.chinacreator.process.util.DataSource;
  7. import com.frameworkset.common.poolman.SQLExecutor;
  8. import org.apache.log4j.Logger;
  9. import org.springframework.stereotype.Component;
  10. import java.sql.SQLException;
  11. import java.util.HashMap;
  12. import java.util.List;
  13. @Component
  14. public class VipRetryDao{
  15. private Logger log = Logger.getLogger("pointshop");
  16. public List<HashMap> findSpInfo(String spid)throws SQLException {
  17. String sql = " select cpid, spid, spname, price, vacproductid, spcode, type, feetype, cancancelorder, canorder, "+
  18. " errorhandle,duration,canaccumulation,mutex,relationSp,paytype,needUnifiedAuthSync,spcodename,haslocal "+
  19. " from tb_sp_info where spid = ? ";
  20. return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql, spid);
  21. }
  22. public List<HashMap> findOrderRelaAll(String userid)throws SQLException {
  23. String sql = " SELECT CPID,SPID,USERID, TO_CHAR(ORDERTIME, 'yyyymmddhh24miss') ORDERTIME, "+
  24. " TO_CHAR(endtime, 'yyyymmddhh24miss') endtime, TO_CHAR(CANCELTIME, 'yyyymmddhh24miss') CANCELTIME, "+
  25. " (case when endtime is null then '0' when endtime >= sysdate then '1' else '2' end) STATUS "+
  26. " FROM TD_ORDER_RELATIONS WHERE USERID = ? ";
  27. return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql, userid);
  28. }
  29. /**
  30. * 根据渠道查询密码
  31. * @param channel
  32. * @return
  33. * @throws SQLException
  34. */
  35. public HashMap getChannelPwdByChannel(String channel)throws SQLException {
  36. String sql = " SELECT ID, PASSWORD FROM TB_CHANNEL_ORG where status = 0 and id= ? ";
  37. return SQLExecutor.queryObjectWithDBName(HashMap.class, DataSource.NET3G, sql, channel);
  38. }
  39. /**
  40. * 更新callBack状态
  41. * @param bcstatus
  42. * @param bcinfo
  43. * @param id
  44. * @return
  45. * @throws SQLException
  46. */
  47. // public void updCallBack(String bcstatus,String bcinfo, String id) {
  48. // try {
  49. // String sql = "UPDATE TD_POINTS_ORDER_REC SET BCSTATUS = ?, BCINFO = ? WHERE ID = ?";
  50. // Object obj = SQLExecutor.updateWithDBName(DataSource.NET3G, sql, bcstatus, bcinfo,id);
  51. // } catch (SQLException e) {
  52. // e.printStackTrace();
  53. // log.error("orderId: "+id+", 更新callBack状态出现异常,"+e.getMessage());
  54. // }
  55. // }
  56. // public void updParamsByCb(String cbReqParams,String cbRspParams, String requestId)throws SQLException {
  57. // String sql = "UPDATE TL_POINTS_INOUT_PARAMS SET CBREQPARAMS = ?, CBRESPARAMS = ?, CBTIME = SYSDATE WHERE REQUESTID = ?";
  58. // Object obj = SQLExecutor.updateWithDBName(DataSource.NET3G, sql, cbReqParams, cbRspParams,requestId);
  59. // }
  60. /**
  61. * 根据orderId和orderNo查询订购信息
  62. * @param id
  63. * @return
  64. * @throws SQLException
  65. */
  66. public BackBusiOrderRec getOrderRec(String id) throws SQLException {
  67. String sql = " SELECT "+
  68. " ID,USERID,ORDERID,CHANNEL,CPID,SPID,PROVINCE,AREA,VIPSTATUS,BUSITYPE,RESULTCODE,RESULTINFO,TIMES, "+
  69. " TO_CHAR(INSERTTIME,'YYYYMMDDHH24MISS')INSERTTIME,RETRYCOUNT,TO_CHAR(RETRYTIME,'YYYYMMDDHH24MISS') RETRYTIME,RETRYCHANNEL "+
  70. " FROM TD_BACKBUSI_ORDER_REC WHERE ID = ? ";
  71. return SQLExecutor.queryObjectWithDBName(BackBusiOrderRec.class, DataSource.NET3G, sql, id);
  72. }
  73. /**
  74. * 根据orderId和orderNo查询积分商城订购信息
  75. * @param id
  76. * @return
  77. * @throws SQLException
  78. */
  79. public PointShopOrderBean getPSOrderRec(String id) throws SQLException {
  80. String sql = " SELECT "+
  81. " ID, USERID,PROVINCE,AREA,CPID,SPID,ORDERNO,GOODSCODE,RESULTCODE,RESULTINFO,BUSITYPE,SERVICECODE, "+
  82. " TO_CHAR(INSERTTIME,'YYYYMMDDHH24MISS') INSERTTIME,TO_CHAR(FINISHTIME,'YYYYMMDDHH24MISS') FINISHTIME, "+
  83. " TO_CHAR(ORDERTIME,'YYYYMMDDHH24MISS') ORDERTIME,REQUESTID,VIPSTATUS,APPID "+
  84. " FROM TD_POINTS_ORDER_REC WHERE ID = ? ";
  85. return SQLExecutor.queryObjectWithDBName(PointShopOrderBean.class, DataSource.NET3G, sql, id);
  86. }
  87. /**
  88. * 获取赠送会员状态
  89. * @param orderId
  90. * @return
  91. * @throws SQLException
  92. */
  93. public String getVipstatus(String orderId) throws SQLException {
  94. String sql = "SELECT VIPSTATUS FROM TD_BACKBUSI_ORDER_REC WHERE ID = ? ";
  95. return SQLExecutor.queryObjectWithDBName(String.class, DataSource.NET3G,sql,orderId);
  96. }
  97. /**
  98. * 获取赠送会员处理结果
  99. * @param orderId
  100. * @return
  101. * @throws SQLException
  102. */
  103. // public String getResultCode(String orderId) throws SQLException {
  104. // String sql = "SELECT RESULTCODE FROM TD_POINTS_ORDER_REC WHERE ID = ? ";
  105. // return SQLExecutor.queryObjectWithDBName(String.class, DataSource.NET3G,sql,orderId);
  106. // }
  107. /**
  108. * 更新会员状态
  109. * @param vipstatus
  110. * @param orderId
  111. * @return
  112. * @throws SQLException
  113. */
  114. // public boolean updVipstatus(String vipstatus, String orderId) throws SQLException {
  115. // //赠送会员状态,0成功,1未赠送,2赠送中,3失败,4不赠送
  116. // String sql = " UPDATE TD_POINTS_ORDER_REC SET VIPSTATUS = ? WHERE ID = ? ";
  117. // Object obj = SQLExecutor.updateWithDBName(DataSource.NET3G, sql, vipstatus, orderId);
  118. // return ((Integer)obj)>0 ? true : false;
  119. // }
  120. /**
  121. * 更新业务状态信息
  122. * @param resultCode
  123. * @param resultInfo
  124. * @param id
  125. * @return
  126. * @throws SQLException
  127. */
  128. // public boolean updBusiStatus(String resultCode, String resultInfo, String id) throws SQLException {
  129. // //赠送会员状态,0成功,1未赠送,2赠送中,3失败,4不赠送
  130. // String sql = " UPDATE TD_BACKBUSI_ORDER_REC SET RESULTCODE = ?, RESULTINFO = ? WHERE ID = ? ";
  131. // Object obj = SQLExecutor.updateWithDBName(DataSource.NET3G, sql, resultCode, resultInfo, id);
  132. // return ((Integer)obj)>0 ? true : false;
  133. // }
  134. /**
  135. *
  136. * @param vipStatus
  137. * @param resultCode
  138. * @param resultInfo
  139. * @param id
  140. * @param tabname
  141. * @return
  142. * @throws SQLException
  143. */
  144. public boolean updBusiStatus(BackBusiOrderRec orderBean, String tabname) throws SQLException {
  145. //赠送会员状态,0成功,1未赠送,2赠送中,3失败,4不赠送
  146. String sql = " UPDATE "+tabname+" SET VIPSTATUS = ? , RESULTCODE = ?, RESULTINFO = ? WHERE ID = ? ";
  147. Object obj = SQLExecutor.updateWithDBName(DataSource.NET3G, sql, orderBean.getVipstatus(), orderBean.getResultcode(), orderBean.getResultinfo(), orderBean.getId());
  148. return ((Integer)obj)>0 ? true : false;
  149. }
  150. /**
  151. * 根据条件查询订购关系
  152. * @param userid
  153. * @param cpid
  154. * @param spid
  155. * @return
  156. * @throws SQLException
  157. */
  158. public HashMap findByUserAndSpid(String userid, String cpid, String spid)throws SQLException {
  159. String sql = "SELECT CPID, SPID, USERID, TO_CHAR(ORDERTIME, 'yyyymmddhh24miss') ORDERTIME, "+
  160. " TO_CHAR(ENDTIME, 'yyyymmddhh24miss') ENDTIME, TO_CHAR(CANCELTIME, 'yyyymmddhh24miss') CANCELTIME "+
  161. " FROM TD_ORDER_RELATIONS WHERE USERID= ? and CPID= ? AND SPID= ? ";
  162. return SQLExecutor.queryObjectWithDBName(HashMap.class, DataSource.NET3G, sql, userid,cpid,spid);
  163. }
  164. /**
  165. * 获取赠送会员加密密码
  166. * @param goodsCode
  167. * @return
  168. * @throws SQLException
  169. */
  170. // public String getPwdByGoodsCode(String goodsCode)throws SQLException {
  171. // String sql = " SELECT PWD FROM TB_POINTS_GOODS_CONF WHERE GOODSCODE = ? ";
  172. // return SQLExecutor.queryObjectWithDBName(String.class, DataSource.NET3G,sql,goodsCode);
  173. // }
  174. /**
  175. * 获取当前时间
  176. * @return
  177. * @throws SQLException
  178. */
  179. public String currTime()throws SQLException {
  180. String sql = "SELECT TO_CHAR(SYSDATE,'yyyymmddhh24miss') CURRTIME FROM DUAL";
  181. return SQLExecutor.queryObjectWithDBName(String.class, DataSource.NET3G,sql,null);
  182. }
  183. public static void main(String[] args) throws SQLException {
  184. VipRetryDao dao = new VipRetryDao();
  185. //System.out.println(dao.findSpInfo("1167"));
  186. //System.out.println(dao.getPwdByGoodsCode("pointshop130"));
  187. //System.out.println(dao.getOrderRec("201906211723268662899","d4078706-2ff3-4f1b-9aad-80436a294b22"));
  188. //System.out.println(dao.getBackBusiConf("youtu", "1168"));
  189. System.out.println(dao.getMinNum("20190717002822",2));
  190. BackShareOrderBean bean = new BackShareOrderBean();
  191. bean.setUserid("18673197465");
  192. bean.setErrorcode("0000");
  193. bean.setErrorinfo("OK");
  194. bean.setRemark("dfsdfsa");
  195. bean.setSpid("1168");
  196. bean.setCpid("youtu");
  197. try{
  198. dao.addShareOrderLog(bean);
  199. }catch (Exception e) {
  200. // TODO: handle exception
  201. }
  202. }
  203. /**
  204. * 获取从当天算起31天
  205. * @return
  206. * @throws SQLException
  207. */
  208. public String curr31Day()throws SQLException {
  209. String sql = "SELECT TO_CHAR(30+TRUNC(SYSDATE)+1-1/86400,'yyyymmddhh24miss') curr31Day FROM DUAL";
  210. return SQLExecutor.queryObjectWithDBName(String.class, DataSource.NET3G,sql,null);
  211. }
  212. /**
  213. * 获取从指定时间开始起加31天
  214. * @param endtime
  215. * @return
  216. * @throws SQLException
  217. */
  218. public String endtime31Day(String endtime)throws SQLException {
  219. String sql = "SELECT TO_CHAR(31+TO_DATE(?,'yyyymmddhh24miss'),'yyyymmddhh24miss') endtime31Day FROM DUAL";
  220. return SQLExecutor.queryObjectWithDBName(String.class, DataSource.NET3G,sql,endtime);
  221. }
  222. /**
  223. * 更新订购信息表
  224. * @param BackBusiOrderRec
  225. * @return
  226. * @throws SQLException
  227. */
  228. public void updOrderRecByVipRetry(BackBusiOrderRec orderBean) {
  229. try {
  230. String sql = " UPDATE TD_BACKBUSI_ORDER_REC SET VIPSTATUS = ?, RETRYTIME = SYSDATE, RETRYCHANNEL = ?, RETRYCOUNT = ?, RESULTCODE = ?, RESULTINFO = ? WHERE ID = ? ";
  231. Object obj = SQLExecutor.updateWithDBName(DataSource.NET3G, sql, orderBean.getVipstatus(), orderBean.getRetrychannel(),
  232. orderBean.getRetrycount(),orderBean.getResultcode(),orderBean.getResultinfo(),orderBean.getId());
  233. } catch (SQLException e) {
  234. e.printStackTrace();
  235. log.error("orderId: "+orderBean.getId()+", 更新订购信息表出现异常,"+e.getMessage());
  236. }
  237. }
  238. /**
  239. * 新增或更新订购关系
  240. * @param bean
  241. * @throws SQLException
  242. */
  243. public void order(BackBusiOrderRec orderBean) throws SQLException{
  244. String sql = " MERGE INTO TD_ORDER_RELATIONS a USING (SELECT #[cpid] cpid, #[spid] spid, #[userid] userid FROM DUAL) b "+
  245. " ON(a.cpid = b.cpid and a.spid = b.spid and a.userid = b.userid) "+
  246. " WHEN MATCHED THEN UPDATE "+
  247. " SET status = '0',ENDTIME = TO_DATE(#[endtime],'yyyymmddhh24miss'),ORDERTIME = SYSDATE, effecttime = SYSDATE, ORDERCHANNEL = #[orderchannle],CHANNEL = #[channel],"+
  248. " CDNSUCCEED = '1', SYNCSUCCEED = '1',CDNCOUNT = '0', SYNCCOUNT = '0', CACHESUCCEED = '1' "+
  249. " WHEN NOT MATCHED THEN INSERT(ID,CPID,SPID,USERID,ORDERTIME,EFFECTTIME,ENDTIME,STATUS,PROVINCE,AREA,CHANNEL,ORDERCHANNEL,SYNCCOUNT,SYNCSUCCEED,TYPE,ORDERSTATUS,ORDERTYPE, "+
  250. " ISEXPERIENCE,CACHESUCCEED,CDNSUCCEED,CDNCOUNT) VALUES ( "+
  251. " TO_CHAR(SYSDATE,'yyyyMMddhh24miss')||SEQ_COMMON6.nextval, "+
  252. " #[cpid],#[spid],#[userid],SYSDATE,SYSDATE, "+
  253. " TO_DATE(#[endtime], 'yyyymmddhh24miss'),'0',#[province],#[area],#[channel],#[orderchannle],0,1,1,'3','1',0,1,'1','0') ";
  254. SQLExecutor.insertBean(DataSource.NET3G, sql, orderBean);
  255. }
  256. /**
  257. * 记录订购日志
  258. * @param orderLog
  259. * @throws SQLException
  260. */
  261. public void addOrderLog(OrderLog orderLog) throws SQLException {
  262. String sql = "insert into tl_order_log (id, userid, province, area, apptype, useragent, origin, "
  263. +"channel, cpid, spid, errorcode, errorinfo, status, orderstatus, ordertype, inserttime, isexperience) values ( "
  264. +"to_char(sysdate, 'yyyymmddhh24miss') || SEQ_COMMON6.nextval,"
  265. +"#[userid], #[province], #[area], #[apptype], #[useragent], #[origin], #[channel], #[cpid],"
  266. +"#[spid], #[errorcode], #[errorinfo], #[status], #[orderstatus], #[ordertype],"
  267. +"sysdate, #[isexperience])";
  268. SQLExecutor.insertBean(DataSource.NET3G, sql, orderLog);
  269. }
  270. /**
  271. * 获取业务配置信息
  272. * @param cpid
  273. * @param spid
  274. * @return
  275. * @throws SQLException
  276. */
  277. public List<HashMap> getBackBusiConf(String cpid, String spid) throws SQLException {
  278. String sql = "SELECT * FROM TB_BACKBUSI_CONF WHERE STATUS = '0' AND CPID = ? AND SPID = ? ";
  279. return SQLExecutor.queryListWithDBName(HashMap.class, DataSource.NET3G, sql, cpid, spid);
  280. }
  281. /**
  282. * 获取两个时间相差分钟数
  283. * @param rectime
  284. * @return
  285. * @throws SQLException
  286. */
  287. public boolean getMinNum(String rectime, int minute) throws SQLException {
  288. String sql = "select FLOOR((SYSDATE - TO_DATE(?,'yyyymmddhh24miss'))*24*60) AS FZNUM FROM DUAL";
  289. int num = SQLExecutor.queryObjectWithDBName(Integer.class, DataSource.NET3G,sql, rectime);
  290. if(num < minute){
  291. return false;
  292. }else{
  293. return true;
  294. }
  295. }
  296. /**
  297. * 保存调能力平台接口日志
  298. * @param bean
  299. * @throws SQLException
  300. */
  301. public void addShareOrderLog(BackShareOrderBean bean)throws SQLException {
  302. String sql = "insert into TL_BACKORDER_SHARE_PARMS (id, userid, inserttime,errorcode, errorinfo, cpid, spid, remark) values ("+
  303. " to_char(sysdate, 'yyyymmddhh24miss') || SEQ_COMMON6.nextval, #[userid], sysdate, #[errorcode], #[errorinfo], #[cpid], #[spid], #[remark]) ";
  304. SQLExecutor.insertBean(DataSource.NET3G, sql, bean);
  305. }
  306. }