2a69bb97fbcac388ae81c4ac6cb17b3b72e2924a.svn-base 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package com.chinacreator.videoalliance.order.action;
  2. import com.chinacreator.common.exception.BusinessException;
  3. import com.chinacreator.common.pipe.DataOutPipe;
  4. import com.chinacreator.common.util.RequestUtil;
  5. import com.chinacreator.common.util.URLUtil;
  6. import com.chinacreator.videoalliance.common.annotation.DataOut;
  7. import com.chinacreator.videoalliance.common.dao.DictionaryDao;
  8. import com.chinacreator.videoalliance.order.bean.OrderInfo;
  9. import com.chinacreator.videoalliance.order.service.CSNewOrderService;
  10. import com.chinacreator.videoalliance.order.util.JsonUtil;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Controller;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import javax.servlet.http.HttpServletRequest;
  15. import java.util.HashMap;
  16. import java.util.Map;
  17. /**
  18. * 畅视60元办理,当月退订当月不能再订购,只能下月退订,走ECB接口
  19. * 需求名称:畅视60元产品需求.docx 黄一鹰
  20. * @author xu.zhou
  21. * @date 20190815
  22. */
  23. @Controller
  24. public class CSNewOrderAction {
  25. @Autowired
  26. private CSNewOrderService service;
  27. @Autowired
  28. private DictionaryDao dictionaryDao;
  29. @RequestMapping({"/csorder.do"})
  30. @DataOut(callback="order")
  31. public DataOutPipe doOrder(HttpServletRequest request, OrderInfo orderInfo, String channel)
  32. throws Exception{
  33. DataOutPipe pipe = new DataOutPipe();
  34. String userid = orderInfo.getUserid();
  35. orderInfo.setTimes(System.currentTimeMillis()+"");
  36. orderInfo.setApptype(RequestUtil.getMobType(request));
  37. orderInfo.setOrderstatus(2);
  38. if(channel == null || "null".equals(channel)) channel = "";
  39. if(!"1150".equals(orderInfo.getSpid())){
  40. throw new BusinessException("8000", "非指定产品调用", new String[0]);
  41. }
  42. if(0 == orderInfo.getType()){ //订购
  43. orderInfo.setOrderchannel(channel);
  44. orderInfo.setStatus(0);
  45. this.service.checkOrder(orderInfo);
  46. this.service.order(orderInfo);
  47. }else{ //退订
  48. orderInfo.setCancelchannel(channel);
  49. orderInfo.setStatus(1);
  50. this.service.checkCancel(orderInfo);
  51. this.service.cancel(orderInfo);
  52. }
  53. pipe.add("userid", userid);
  54. pipe.add("channel", channel == null ? "" : channel);
  55. pipe.add("endtime", orderInfo.getEndtime() == null ? "" : orderInfo.getEndtime());
  56. if (orderInfo.getOrdertype() == 1) {
  57. pipe.add("videoid", orderInfo.getVideoid());
  58. }
  59. insertOrderMq(orderInfo);
  60. inserSmstMq(orderInfo);
  61. return pipe;
  62. }
  63. /**
  64. * 添加活动关系
  65. * @param orderInfo
  66. */
  67. public void insertOrderMq(OrderInfo orderInfo) {
  68. try{
  69. Map<String,String> map = new HashMap<String, String>();
  70. map.put("userid", orderInfo.getUserid());
  71. map.put("cpid",orderInfo.getCpid());
  72. map.put("spid", orderInfo.getSpid());
  73. map.put("province", orderInfo.getProvince());
  74. map.put("area", orderInfo.getArea());
  75. if(0 == orderInfo.getType()){ //订购成功生成活动关系
  76. map.put("ordertime", orderInfo.getOrdertime());
  77. map.put("canceltime", "");
  78. map.put("status", "0");
  79. map.put("orderchannel", orderInfo.getOrderchannel());
  80. map.put("cancelchannel", "");
  81. }else{
  82. map.put("ordertime", orderInfo.getOrdertime());
  83. map.put("canceltime", orderInfo.getCanceltime());
  84. map.put("status", "1");
  85. map.put("orderchannel", orderInfo.getOrderchannel());
  86. map.put("cancelchannel", orderInfo.getCancelchannel());
  87. }
  88. map.put("videoid", orderInfo.getVideoid());
  89. map.put("type","order");
  90. //开发环境
  91. //URLUtil.post("http://172.16.33.16:8082/mq-service/recive.do", JsonUtil.objectToJson(map));
  92. //测试环境
  93. //URLUtil.post("http://10.199.99.177:86/mq-service/recive.do", JsonUtil.objectToJson(map));
  94. //生产环境
  95. //URLUtil.post("http://10.199.99.144:8090/mq-service/recive.do", JsonUtil.objectToJson(map));
  96. String mqReciveUrl = dictionaryDao.getValue("mqReciveUrl");
  97. URLUtil.post(mqReciveUrl, JsonUtil.objectToJson(map));
  98. }catch(Exception e){
  99. e.printStackTrace();
  100. }
  101. }
  102. /**
  103. * 发送办理成功短信
  104. * @param orderInfo
  105. */
  106. public void inserSmstMq(OrderInfo orderInfo){
  107. try{
  108. Map<String, String> map = new HashMap<String, String>();
  109. map.put("userid", orderInfo.getUserid());
  110. map.put("cpid", orderInfo.getCpid());
  111. map.put("spid", orderInfo.getSpid());
  112. map.put("result", "0");
  113. map.put("channel", "");
  114. map.put("style","0000");
  115. map.put("times", "");
  116. map.put("orderType", "");
  117. map.put("type", "cssms");
  118. if(0 == orderInfo.getType()){ //订购成功生成活动关系
  119. map.put("busiType", "tran_succ");
  120. }else{
  121. map.put("busiType", "cancel_succ");
  122. }
  123. //开发环境
  124. //URLUtil.post("http://172.16.33.16:8082/mq-service/recive.do", JsonUtil.objectToJson(map));
  125. //测试环境
  126. //URLUtil.post("http://10.199.99.177:86/mq-service/recive.do", JsonUtil.objectToJson(map));
  127. //生产环境
  128. //URLUtil.post("http://10.199.99.144:8090/mq-service/recive.do", JsonUtil.objectToJson(map));
  129. String mqReciveUrl = dictionaryDao.getValue("mqReciveUrl");
  130. URLUtil.post(mqReciveUrl, JsonUtil.objectToJson(map));
  131. }catch (Exception e){
  132. e.printStackTrace();
  133. }
  134. }
  135. }