86389afae5ef70502ea37b0b1913df7d38a2f8e2.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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.TdPreOrderRecBean;
  14. import com.chinacreator.videoalliance.order.bean.TdPreOrderidRecBean;
  15. import com.chinacreator.videoalliance.order.bean.TdYoutuOrderRecBean;
  16. import com.frameworkset.common.poolman.SQLExecutor;
  17. /**
  18. * 优酷后向产品
  19. * @author xu.zhou
  20. * @date 20190516
  21. */
  22. @Component
  23. public class TcPreDao extends ExecutorDao {
  24. private static Logger logger = Logger.getLogger("orderError");
  25. /**
  26. * 订购
  27. * @param orderInfo
  28. * @throws BusinessException
  29. */
  30. public void order(OrderInfo orderInfo) throws SQLException {
  31. getExecutor().insertBean("net3g", "order", orderInfo);
  32. }
  33. /**
  34. * 退订
  35. * @param orderInfo
  36. * @throws BusinessException
  37. */
  38. public void cancelOrder(OrderInfo orderInfo) throws SQLException {
  39. getExecutor().insertBean("net3g", "cancelOrder", orderInfo);
  40. }
  41. public HashMap getCpSp(String cpid, String spid) throws SQLException{
  42. return (HashMap)getExecutor().queryObjectWithDBName(HashMap.class, "net3g", "getCpSp", new Object[] { cpid, spid });
  43. }
  44. /**
  45. * 查询本地订购关系表数据
  46. * @param userid
  47. * @param cpid
  48. * @param spid
  49. * @return
  50. * @throws SQLException
  51. */
  52. public HashMap findOrderRela(String userid, String cpid, String spid) throws SQLException {
  53. return (HashMap)getExecutor().queryObjectWithDBName(HashMap.class, "net3g", "findOrderRela", new Object[] { userid, cpid, spid });
  54. }
  55. /**
  56. * 查询预订购表数据
  57. * @param userid
  58. * @param cpid
  59. * @param spid
  60. * @return
  61. * @throws SQLException
  62. */
  63. public HashMap findPreOrderRela(String userid, String cpid,String spid) throws SQLException {
  64. return (HashMap)getExecutor().queryObjectWithDBName(HashMap.class, "net3g", "findPreOrderRela", new Object[] { userid, cpid,spid });
  65. }
  66. /**
  67. * 根据手机号码获得所有本地订购关系表数据
  68. * @param userid
  69. * @return
  70. * @throws SQLException
  71. */
  72. public List<HashMap> findOrderRelaAll(String userid) throws SQLException {
  73. return getExecutor().queryListWithDBName(HashMap.class, "net3g", "findOrderRelaAll", new Object[] { userid });
  74. }
  75. /**
  76. * 根据手机号码获得所有预订购表数据
  77. * @param userid
  78. * @return
  79. * @throws SQLException
  80. */
  81. public List<HashMap> findPreOrderRelaAll(String userid) throws SQLException {
  82. return getExecutor().queryListWithDBName(HashMap.class, "net3g", "findPreOrderRelaAll", new Object[] { userid });
  83. }
  84. /**
  85. * 查询是否有相同订单
  86. * @param orderid
  87. * @return
  88. * @throws SQLException
  89. */
  90. public List<HashMap> findOrderId(String orderid) throws SQLException {
  91. return getExecutor().queryListWithDBName(HashMap.class, "net3g", "findOrderId", new Object[] { orderid });
  92. }
  93. /**
  94. * 添加订单ID记录
  95. * @param bean
  96. * @throws SQLException
  97. */
  98. public void addOrderRec(TdPreOrderidRecBean bean) throws SQLException {
  99. this.getExecutor().insertBean(DataSource.NET3G, "addOrderRec", bean);
  100. }
  101. /**
  102. * 保存订购日志
  103. * @param orderLog
  104. * @throws BusinessException
  105. */
  106. public void addOrderLog(OrderLog orderLog) {
  107. try {
  108. this.getExecutor().insertBean(DataSource.NET3G, "addOrderLog", orderLog);
  109. } catch (SQLException e) {
  110. e.printStackTrace();
  111. logger.error(orderLog.getUserid()+"=>保存订购日志失败", e);
  112. }
  113. }
  114. /**
  115. * 获取当月最后一天
  116. * @return
  117. * @throws SQLException
  118. */
  119. public String getEndDayOfCurrentMonth() throws SQLException {
  120. String sql = "select to_char(trunc(last_day(sysdate))+1-1/86400, 'yyyymmddhh24miss') from dual";
  121. return SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql);
  122. }
  123. /**
  124. * 获取当前时间
  125. * @return
  126. * @throws SQLException
  127. */
  128. public String getCurrTime() throws SQLException {
  129. return getExecutor().queryFieldWithDBName(DataSource.NET3G, "getCurrTime", new Object[] {});
  130. }
  131. /**
  132. * 获取预订购ID
  133. * @return
  134. * @throws SQLException
  135. */
  136. public String getPreOrderId() throws SQLException{
  137. return getExecutor().queryFieldWithDBName(DataSource.NET3G, "getPreOrderId", new Object[] {});
  138. }
  139. /**
  140. * 预订购
  141. * @param bean
  142. * @throws SQLException
  143. */
  144. public void orderPre(OrderInfo orderInfo) throws SQLException{
  145. this.getExecutor().insertBean(DataSource.NET3G, "orderPre", orderInfo);
  146. }
  147. /**
  148. * 预退订
  149. * @param bean
  150. * @throws SQLException
  151. */
  152. public void cancelOrderPre(OrderInfo orderInfo) throws SQLException{
  153. this.getExecutor().insertBean(DataSource.NET3G, "cancelOrderPre", orderInfo);
  154. }
  155. /**
  156. * 生成ID
  157. * @return
  158. * @throws SQLException
  159. */
  160. public String generateID() throws SQLException {
  161. String sql = "SELECT TO_CHAR(SYSDATE,'yyyyMMddhh24miss')||SEQ_COMMON6.NEXTVAL FROM DUAL";
  162. return SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql);
  163. }
  164. /**
  165. * 获取累加月最后一秒的时间
  166. * @param
  167. * @return
  168. * @throws SQLException
  169. */
  170. public String endtimeMonthLastDay(String month)throws SQLException{
  171. return getExecutor().queryFieldWithDBName(DataSource.NET3G, "endtimeMonthLastDay", new Object[] {month});
  172. }
  173. /**
  174. * 查询是否有配置业务
  175. * @param orderInfo
  176. * @return
  177. * @throws SQLException
  178. */
  179. public boolean valiBusi(OrderInfo orderInfo) throws SQLException {
  180. String sql = "SELECT COUNT(1) CNT FROM TB_TCPRE_CONF WHERE STATUS = '0' AND SPID = ? "+
  181. " AND (PROVINCE IS NULL OR PROVINCE = '0' OR PROVINCE = ?) "+
  182. " AND (CHANNEL IS NULL OR CHANNEL = '0' OR CHANNEL = ?) ";
  183. if(1 == orderInfo.getType()){//退订,只要有配置的都查出来,业务下线不影响退订
  184. sql = "SELECT COUNT(1) CNT FROM TB_TCPRE_CONF WHERE SPID = ? "+
  185. " AND (PROVINCE IS NULL OR PROVINCE = '0' OR PROVINCE = ?) "+
  186. " AND (CHANNEL IS NULL OR CHANNEL = '0' OR CHANNEL = ?) ";
  187. }
  188. String count = (String)SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, new Object[] {orderInfo.getSpid(),orderInfo.getProvince(),orderInfo.getChannel()});
  189. return Integer.parseInt(count) > 0 ? true : false;
  190. }
  191. /**
  192. * 更新上海2元权益报文表
  193. * @param orderno
  194. * @param logid
  195. * @throws SQLException
  196. */
  197. public void updShInPaInfo(TdPreOrderidRecBean bean)throws SQLException {
  198. this.getExecutor().updateWithDBName(DataSource.NET3G, "updShInPaInfo", new Object[] {bean.getId(),bean.getLogid()});
  199. }
  200. /**
  201. * 订购次月生效的产品
  202. * @param orderInfo
  203. * @throws BusinessException
  204. */
  205. public void nmaOrder(OrderInfo orderInfo) throws SQLException {
  206. getExecutor().insertBean(DataSource.NET3G, "nmaOrder", orderInfo);
  207. }
  208. /**
  209. * 订购次月生效的产品
  210. * @param orderInfo
  211. * @throws BusinessException
  212. */
  213. public void nmaCancel(OrderInfo orderInfo) throws SQLException {
  214. getExecutor().insertBean(DataSource.NET3G, "nmaCancel", orderInfo);
  215. }
  216. /**
  217. * 获取配置数据
  218. * @param spid
  219. * @return
  220. * @throws SQLException
  221. */
  222. public List<HashMap> qryAopConf(OrderInfo orderInfo) throws SQLException {
  223. return getExecutor().queryListWithDBName(HashMap.class, DataSource.NET3G, "qryAopConf", orderInfo.getSpid());
  224. }
  225. /**
  226. * 获取已有订购关系
  227. * @param orderInfo
  228. * @return
  229. * @throws SQLException
  230. */
  231. public List<HashMap> qryNmaOrder(OrderInfo orderInfo) throws SQLException {
  232. return getExecutor().queryListWithDBName(HashMap.class, DataSource.NET3G, "qryNmaOrder", orderInfo.getUserid(), orderInfo.getCpid(), orderInfo.getSpid());
  233. }
  234. /**
  235. * 获取生效时间,下月第一天0时0分0秒
  236. * @return
  237. * @throws SQLException
  238. */
  239. public String getEffecttime() throws SQLException {
  240. String sql = "SELECT TO_CHAR(LAST_DAY(SYSDATE)+1,'YYYYMMDD')||'000000' EFFECTTIME FROM DUAL";
  241. return SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql);
  242. }
  243. /**
  244. * 添加订购日志
  245. * @param orderLog
  246. * @throws SQLException
  247. */
  248. public void addNmaOrderLog(OrderLog orderLog) throws SQLException {
  249. try {
  250. this.getExecutor().insertBean(DataSource.NET3G, "addNmaOrderLog", orderLog);
  251. } catch (SQLException e) {
  252. e.printStackTrace();
  253. logger.error(orderLog.getUserid()+"=>保存订购日志失败", e);
  254. }
  255. }
  256. public static void main(String[] args) {
  257. try {
  258. TcPreDao dao = new TcPreDao();
  259. // System.out.println(dao.findByUserAndSpid("18673197465", "youtu", "1167"));
  260. //System.out.println(dao.findOrderRecByUserid("18673197465"));
  261. OrderInfo orderInfo = new OrderInfo();
  262. orderInfo.setOrdertime(dao.getCurrTime());
  263. orderInfo.setCanceltime(dao.getCurrTime());
  264. orderInfo.setEffecttime(dao.getEffecttime());
  265. orderInfo.setOrderchannel("test");
  266. orderInfo.setCancelchannel("test2");
  267. orderInfo.setSubchannel("aaaaaaa");
  268. orderInfo.setUserid("18673197465");
  269. orderInfo.setProvince("湖南");
  270. orderInfo.setArea("长沙");
  271. orderInfo.setOrderid("123456789");
  272. orderInfo.setType(1);
  273. orderInfo.setCpid("changshi");
  274. orderInfo.setSpid("1261");
  275. System.out.println(dao.qryNmaOrder(orderInfo));
  276. //System.out.println(dao.valiBusi(orderInfo));
  277. //dao.nmaCancel(orderInfo);
  278. //System.out.println(dao.findOrderRela(orderInfo.getUserid(), orderInfo.getCpid(), orderInfo.getSpid()));
  279. //dao.addOrderRec(orderInfo);
  280. //System.out.println(dao.findOrderId("20190524103510000001"));
  281. //System.out.println(dao.findPreOrderRela("18673197465", "youtu", "1167"));
  282. //System.out.println(dao.findPreOrderRelaAll("18673197465"));
  283. //System.out.println(dao.findOrderId("123456"));
  284. //System.out.println(dao.getCpSp("youtu", "1167"));
  285. //System.out.println(dao.getActivityInfo("youtu", "1167", "湖南"));
  286. // TdPreOrderidRecBean torBean = new TdPreOrderidRecBean();
  287. // torBean.setArea("长沙");
  288. // torBean.setOrderpreid("1111111111111111");
  289. // torBean.setOrdertime("20190524104125");
  290. // torBean.setOrderid("20190524103510000001");
  291. // torBean.setProvince("湖南");
  292. // torBean.setResultcode("0");
  293. // torBean.setResultinfo("成功");
  294. // torBean.setBusitype("0");
  295. // torBean.setUserid("18673197465");
  296. //dao.addOrderRec(torBean);
  297. //System.out.println(dao.getCurrTime());
  298. // TdPreOrderRecBean bean = new TdPreOrderRecBean();
  299. // bean.setArea("长沙");
  300. // bean.setProvince("湖南");
  301. // bean.setCpid("youtu");
  302. // bean.setSpid("1167");
  303. // bean.setStatus("0");
  304. // bean.setUserid("18673197465");
  305. //
  306. // bean.setOrderida("2019052410351");
  307. // bean.setOrdertime("20190524104125");
  308. // bean.setOrderchannel("ttest");
  309. //
  310. // bean.setCancelchannel("test");
  311. // bean.setCanceltime("20190524111321");
  312. // bean.setOrderidb("refesddfsfd");
  313. // bean.setStatus("1");
  314. //dao.orderPre(bean);
  315. //dao.cancelOrderPre(bean);
  316. // bean.setOrderida("2019052");
  317. // bean.setOrdertime("20190524104129");
  318. // bean.setOrderchannel("t");
  319. //dao.orderPre(bean);
  320. //dao.updShInPaInfo("kkkkkkk","a9b60c753eb341f09c988d70759e8768");
  321. } catch (Exception e) {
  322. e.printStackTrace();
  323. }
  324. }
  325. }