123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- package com.chinacreator.videoalliance.order.action;
- import com.chinacreator.common.exception.BusinessException;
- import com.chinacreator.common.pipe.DataOutPipe;
- import com.chinacreator.common.util.RequestUtil;
- import com.chinacreator.common.util.URLUtil;
- import com.chinacreator.videoalliance.common.annotation.DataOut;
- import com.chinacreator.videoalliance.common.dao.DictionaryDao;
- import com.chinacreator.videoalliance.order.bean.OrderInfo;
- import com.chinacreator.videoalliance.order.service.CSNewOrderService;
- import com.chinacreator.videoalliance.order.util.JsonUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import javax.servlet.http.HttpServletRequest;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * 畅视60元办理,当月退订当月不能再订购,只能下月退订,走ECB接口
- * 需求名称:畅视60元产品需求.docx 黄一鹰
- * @author xu.zhou
- * @date 20190815
- */
- @Controller
- public class CSNewOrderAction {
-
- @Autowired
- private CSNewOrderService service;
-
- @Autowired
- private DictionaryDao dictionaryDao;
- @RequestMapping({"/csorder.do"})
- @DataOut(callback="order")
- public DataOutPipe doOrder(HttpServletRequest request, OrderInfo orderInfo, String channel)
- throws Exception{
- DataOutPipe pipe = new DataOutPipe();
- String userid = orderInfo.getUserid();
- orderInfo.setTimes(System.currentTimeMillis()+"");
- orderInfo.setApptype(RequestUtil.getMobType(request));
- orderInfo.setOrderstatus(2);
- if(channel == null || "null".equals(channel)) channel = "";
- if(!"1150".equals(orderInfo.getSpid())){
- throw new BusinessException("8000", "非指定产品调用", new String[0]);
- }
- if(0 == orderInfo.getType()){ //订购
- orderInfo.setOrderchannel(channel);
- orderInfo.setStatus(0);
- this.service.checkOrder(orderInfo);
- this.service.order(orderInfo);
- }else{ //退订
- orderInfo.setCancelchannel(channel);
- orderInfo.setStatus(1);
- this.service.checkCancel(orderInfo);
- this.service.cancel(orderInfo);
- }
-
- pipe.add("userid", userid);
- pipe.add("channel", channel == null ? "" : channel);
- pipe.add("endtime", orderInfo.getEndtime() == null ? "" : orderInfo.getEndtime());
- if (orderInfo.getOrdertype() == 1) {
- pipe.add("videoid", orderInfo.getVideoid());
- }
- insertOrderMq(orderInfo);
- inserSmstMq(orderInfo);
- return pipe;
- }
- /**
- * 添加活动关系
- * @param orderInfo
- */
- public void insertOrderMq(OrderInfo orderInfo) {
- try{
- Map<String,String> map = new HashMap<String, String>();
- map.put("userid", orderInfo.getUserid());
- map.put("cpid",orderInfo.getCpid());
- map.put("spid", orderInfo.getSpid());
- map.put("province", orderInfo.getProvince());
- map.put("area", orderInfo.getArea());
- if(0 == orderInfo.getType()){ //订购成功生成活动关系
- map.put("ordertime", orderInfo.getOrdertime());
- map.put("canceltime", "");
- map.put("status", "0");
- map.put("orderchannel", orderInfo.getOrderchannel());
- map.put("cancelchannel", "");
- }else{
- map.put("ordertime", orderInfo.getOrdertime());
- map.put("canceltime", orderInfo.getCanceltime());
- map.put("status", "1");
- map.put("orderchannel", orderInfo.getOrderchannel());
- map.put("cancelchannel", orderInfo.getCancelchannel());
- }
- map.put("videoid", orderInfo.getVideoid());
- map.put("type","order");
- //开发环境
- //URLUtil.post("http://172.16.33.16:8082/mq-service/recive.do", JsonUtil.objectToJson(map));
- //测试环境
- //URLUtil.post("http://10.199.99.177:86/mq-service/recive.do", JsonUtil.objectToJson(map));
- //生产环境
- //URLUtil.post("http://10.199.99.144:8090/mq-service/recive.do", JsonUtil.objectToJson(map));
- String mqReciveUrl = dictionaryDao.getValue("mqReciveUrl");
- URLUtil.post(mqReciveUrl, JsonUtil.objectToJson(map));
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- /**
- * 发送办理成功短信
- * @param orderInfo
- */
- public void inserSmstMq(OrderInfo orderInfo){
- try{
- Map<String, String> map = new HashMap<String, String>();
- map.put("userid", orderInfo.getUserid());
- map.put("cpid", orderInfo.getCpid());
- map.put("spid", orderInfo.getSpid());
- map.put("result", "0");
- map.put("channel", "");
- map.put("style","0000");
- map.put("times", "");
- map.put("orderType", "");
- map.put("type", "cssms");
- if(0 == orderInfo.getType()){ //订购成功生成活动关系
- map.put("busiType", "tran_succ");
- }else{
- map.put("busiType", "cancel_succ");
- }
-
- //开发环境
- //URLUtil.post("http://172.16.33.16:8082/mq-service/recive.do", JsonUtil.objectToJson(map));
- //测试环境
- //URLUtil.post("http://10.199.99.177:86/mq-service/recive.do", JsonUtil.objectToJson(map));
- //生产环境
- //URLUtil.post("http://10.199.99.144:8090/mq-service/recive.do", JsonUtil.objectToJson(map));
- String mqReciveUrl = dictionaryDao.getValue("mqReciveUrl");
- URLUtil.post(mqReciveUrl, JsonUtil.objectToJson(map));
- }catch (Exception e){
- e.printStackTrace();
- }
- }
- }
|