package com.chinacreator.videoalliance.order.action; import javax.servlet.http.HttpServletRequest; import com.chinacreator.common.exception.BusinessException; import com.chinacreator.common.pipe.DataOutPipe; import com.chinacreator.common.util.DESUtil; import com.chinacreator.common.util.RequestUtil; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.chinacreator.videoalliance.common.annotation.DataOut; import com.chinacreator.videoalliance.order.bean.ChannelOrgBean; import com.chinacreator.videoalliance.order.bean.OrderInfo; import com.chinacreator.videoalliance.order.dao.ChannelDao; import com.chinacreator.videoalliance.order.service.OrderService; @Controller public class ChannelOrderAction { @Autowired private OrderService orderService; @Autowired private ChannelDao channelDao; @RequestMapping({ "/channelOrgOrder.do" }) @DataOut(callback = "channelOrgOrder") public DataOutPipe doOrder(HttpServletRequest request, OrderInfo orderInfo, String channel) throws Exception { DataOutPipe pipe = new DataOutPipe(); orderInfo.setTimes(System.currentTimeMillis() + ""); if (StringUtils.isEmpty(orderInfo.getUserid()) || StringUtils.isEmpty(channel)) { throw new BusinessException("9003", "参数错误"); } ChannelOrgBean channelOrgBean = channelDao.findByChannelId(channel); if (channelOrgBean == null || channelOrgBean.getStatus().equals("1")) { throw new BusinessException("9001", "渠道参数错误"); } try { orderInfo.setUserid(DESUtil.decode(orderInfo.getUserid(), channelOrgBean.getPassword())); } catch (Exception e) { throw new BusinessException("9002", "手机号码解析错误"); } orderInfo.setApptype(RequestUtil.getMobType(request)); orderInfo.setStatus(0); orderInfo.setOrderchannel(channel); orderInfo.setOrderstatus(2); this.orderService.checkOrder(orderInfo); this.orderService.order(orderInfo); return pipe; } public String getRemortIP(HttpServletRequest request) { if (request.getHeader("x-forwarded-for") == null) { return request.getRemoteAddr(); } return request.getHeader("x-forwarded-for"); } }