b548eefaa14dbd95a1d29c129754b3da1be6767e.svn-base 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. package com.chinacreator.videoalliance.order.dao;
  2. import java.sql.SQLException;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import org.apache.log4j.Logger;
  7. import org.springframework.stereotype.Component;
  8. import com.chinacreator.common.dao.ExecutorDao;
  9. import com.chinacreator.common.exception.BusinessException;
  10. import com.chinacreator.videoalliance.common.util.DataSource;
  11. import com.chinacreator.videoalliance.order.bean.OrderInfo;
  12. import com.chinacreator.videoalliance.order.bean.OrderLog;
  13. import com.chinacreator.videoalliance.order.bean.TdYoutuOrderRecBean;
  14. import com.frameworkset.common.poolman.SQLExecutor;
  15. /**
  16. * 优酷后向产品
  17. * @author xu.zhou
  18. * @date 20190516
  19. */
  20. @Component
  21. public class YoutuDao extends ExecutorDao {
  22. private static Logger logger = Logger.getLogger("orderError");
  23. public List<OrderInfo> findByUser(String userid) throws SQLException {
  24. return getExecutor().queryListWithDBName(OrderInfo.class, "net3g", "findByUser", new Object[] { userid });
  25. }
  26. public void order(OrderInfo orderInfo) throws Exception {
  27. getExecutor().insertBean("net3g", "order", orderInfo);
  28. }
  29. public HashMap getCpSp(String cpid, String spid) throws SQLException{
  30. return (HashMap)getExecutor().queryObjectWithDBName(HashMap.class, "net3g", "getCpSp", new Object[] { cpid, spid });
  31. }
  32. public HashMap findByUserAndSpid(String userid, String cpid, String spid) throws SQLException {
  33. return (HashMap)getExecutor().queryObjectWithDBName(HashMap.class, "net3g", "findByUserAndSpid", new Object[] { userid, cpid, spid });
  34. }
  35. public List<OrderInfo> findByUserAndCpid(String userid, String cpid) throws SQLException {
  36. return getExecutor().queryListWithDBName(OrderInfo.class, "net3g", "findByUserAndCpid", new Object[] { userid, cpid });
  37. }
  38. public List<TdYoutuOrderRecBean> findOrderRecByUserid(String userid) throws SQLException {
  39. return getExecutor().queryListWithDBName(TdYoutuOrderRecBean.class, "net3g", "findOrderRecByUserid", new Object[] { userid });
  40. }
  41. /**
  42. * 根据订单ID查询订单信息
  43. * @param orderid
  44. * @return
  45. * @throws SQLException
  46. */
  47. public List<TdYoutuOrderRecBean> findOrderRecByOrderid(String orderid) throws SQLException {
  48. return getExecutor().queryListWithDBName(TdYoutuOrderRecBean.class, "net3g", "findOrderRecByOrderid", new Object[] { orderid });
  49. }
  50. /**
  51. * 保存订购日志
  52. * @param orderLog
  53. * @throws BusinessException
  54. */
  55. public void addOrderLog(OrderLog orderLog) {
  56. try {
  57. this.getExecutor().insertBean(DataSource.NET3G, "addOrderLog", orderLog);
  58. } catch (SQLException e) {
  59. e.printStackTrace();
  60. logger.error(orderLog.getUserid()+"=>保存订购日志失败", e);
  61. }
  62. }
  63. /**
  64. * 添加订购记录
  65. * @param orderInfo
  66. * @throws BusinessException
  67. */
  68. public void addOrderRec(TdYoutuOrderRecBean bean) throws Exception {
  69. this.getExecutor().insertBean(DataSource.NET3G, "addOrderRec", bean);
  70. }
  71. /**
  72. * 订购成功更新CDN和CP同步状态
  73. * @param orderInfo
  74. * @return
  75. */
  76. /*
  77. public int orderSuccess(OrderInfo orderInfo) throws Exception{
  78. int result = 0;
  79. result = (Integer)this.getExecutor().updateWithDBName(DataSource.NET3G, "orderSuccess", new Object[] { orderInfo.getUserid(),orderInfo.getCpid(),orderInfo.getSpid()});
  80. return result;
  81. }
  82. */
  83. /**
  84. * 设置订单rollback
  85. * @param orderid
  86. * @return
  87. */
  88. /*
  89. public int orderRecRollback(OrderInfo orderInfo) throws Exception {
  90. int result = 0;
  91. result = (Integer)this.getExecutor().updateWithDBName(DataSource.NET3G, "orderRecRollback", new Object[] { orderInfo.getOrderid()});
  92. return result;
  93. }
  94. */
  95. /**
  96. * 设置赠送会员成功
  97. * @param orderid
  98. * @return
  99. */
  100. /*
  101. public int orderRecVipstatus(OrderInfo orderInfo)throws Exception {
  102. int result = 0;
  103. result = (Integer)this.getExecutor().updateWithDBName(DataSource.NET3G, "orderRecVipstatus", new Object[] { orderInfo.getOrderid()});
  104. return result;
  105. }
  106. */
  107. /**
  108. * 订购失败,ENDTIME回滚
  109. * @param orderInfo
  110. * @return
  111. * @throws BusinessException
  112. */
  113. /*
  114. public int orderFail(OrderInfo orderInfo,String oldEndTime)throws Exception {
  115. int result = 0;
  116. result = (Integer)this.getExecutor().updateWithDBName(DataSource.NET3G, "orderFail", new Object[] { oldEndTime, orderInfo.getUserid(),orderInfo.getCpid(),orderInfo.getSpid()});
  117. return result;
  118. }
  119. */
  120. /**
  121. * 删除新增订购关系
  122. * @param orderInfo
  123. * @return
  124. * @throws BusinessException
  125. */
  126. /*
  127. public int orderFailDel(OrderInfo orderInfo)throws Exception {
  128. int result = 0;
  129. result = (Integer)this.getExecutor().updateWithDBName(DataSource.NET3G, "orderFailDel", new Object[] {orderInfo.getUserid(),orderInfo.getCpid(),orderInfo.getSpid()});
  130. return result;
  131. }
  132. */
  133. /**
  134. * 获取当前时间
  135. * @return
  136. * @throws SQLException
  137. */
  138. public String getCurrentTime() throws SQLException {
  139. String sql = "select to_char(sysdate, 'yyyymmddhh24miss') from dual";
  140. return SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql);
  141. }
  142. /**
  143. * 获取从当前天起31天的有效期
  144. * @return
  145. * @throws SQLException
  146. */
  147. public String curr31Day() throws SQLException{
  148. return getExecutor().queryFieldWithDBName(DataSource.NET3G, "curr31Day", new Object[] {});
  149. }
  150. /**
  151. * 获取从指定时间加31天有效期
  152. * @param endtime
  153. * @return
  154. * @throws SQLException
  155. */
  156. public String endtime31Day(String endtime) throws SQLException{
  157. return getExecutor().queryFieldWithDBName(DataSource.NET3G, "endtime31Day", new Object[] {endtime});
  158. }
  159. /**
  160. * 生成ID
  161. * @return
  162. * @throws SQLException
  163. */
  164. public String generateID() throws SQLException {
  165. String sql = "SELECT TO_CHAR(SYSDATE,'yyyyMMddhh24miss')||SEQ_COMMON6.NEXTVAL FROM DUAL";
  166. return SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql);
  167. }
  168. /**
  169. * 获取活动配置表数据
  170. * @param cpid
  171. * @param spid
  172. * @param province
  173. * @return
  174. * @throws SQLException
  175. */
  176. public Map getActivityInfo(String cpid, String spid, String province) throws SQLException{
  177. String sql = "select cpid,spid,to_char(begintime,'yyyymmddhh24miss') begintime,to_char(endtime,'yyyymmddhh24miss') endtime,to_char(endtime,'yyyymmddhh24miss') cancelendtime ,activetype,province from TB_ACTIVITY_CONFIG where cpid = ? and spid = ? and province in ('0',?) and status =0 ";
  178. return SQLExecutor.queryObjectWithDBName(HashMap.class, DataSource.NET3G, sql,new Object[] { cpid, spid, province});
  179. }
  180. /**
  181. * 根据ORDERID查询会员赠送状态
  182. * @param orderid
  183. * @return
  184. * @throws SQLException
  185. */
  186. public String getVipstatus(String orderid) throws SQLException{
  187. String sql = "SELECT VIPSTATUS FROM TD_YOUTU_ORDER_REC WHERE ORDERID = ? ";
  188. return SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, new Object[] {orderid});
  189. }
  190. public static void main(String[] args) {
  191. try {
  192. YoutuDao dao = new YoutuDao();
  193. // System.out.println(dao.findByUserAndSpid("18673197465", "youtu", "1167"));
  194. //System.out.println(dao.findOrderRecByUserid("18673197465"));
  195. OrderInfo orderInfo = new OrderInfo();
  196. orderInfo.setUserid("18673197465");
  197. orderInfo.setProvince("湖南");
  198. orderInfo.setArea("长沙");
  199. orderInfo.setOrderid("123456789");
  200. orderInfo.setType(0);
  201. //dao.addOrderRec(orderInfo);
  202. //System.out.println(dao.endtime31Day("20190620235959"));
  203. //System.out.println(dao.findByUserAndSpid("18673197465", "youtu", "1167"));
  204. //System.out.println(dao.getCpSp("youtu", "1167"));
  205. //System.out.println(dao.getActivityInfo("youtu", "1167", "湖南"));
  206. //System.out.println(dao.generateID());
  207. String vipstatus = dao.getVipstatus("028b4f73-14bc-4450-afaa-81a323ef9d24");
  208. System.out.println(vipstatus);
  209. } catch (Exception e) {
  210. // TODO Auto-generated catch block
  211. e.printStackTrace();
  212. }
  213. }
  214. }