432f374da96cee837ece3374c61a87a9d7100be3.svn-base 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package com.chinacreator.videoalliance.smc.action;
  2. import java.net.URLEncoder;
  3. import javax.servlet.http.HttpServletRequest;
  4. import javax.servlet.http.HttpServletResponse;
  5. import org.apache.commons.lang.StringUtils;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import com.chinacreator.common.exception.BusinessException;
  9. import com.chinacreator.common.pipe.DataOutPipe;
  10. import com.chinacreator.common.util.DESUtil;
  11. import com.chinacreator.common.util.URLUtil;
  12. import com.chinacreator.videoalliance.common.annotation.DataOut;
  13. import com.chinacreator.videoalliance.common.util.ConfigUtil;
  14. import com.chinacreator.videoalliance.smc.dao.SmsNumberDao;
  15. /**
  16. * 短信取号接口控制类
  17. * @author lizhiyong
  18. *
  19. */
  20. @Controller
  21. public class ChannelSmsNumberAction {
  22. /**
  23. * 检查用户取号是否成功
  24. * @param request
  25. * @param response
  26. * @return 加密手机号值、流量提醒标识
  27. * @throws Exception
  28. */
  29. @RequestMapping("/channelSmsNumber.do")
  30. @DataOut(callback="channelSmsNumber")
  31. public DataOutPipe doNet(HttpServletRequest request, HttpServletResponse response) throws Exception {
  32. DataOutPipe dap = new DataOutPipe();
  33. String cpid=request.getParameter("cpid");
  34. String userid=request.getParameter("userid");
  35. String vcode=request.getParameter("vcode");
  36. String channel = "txvip";
  37. if(StringUtils.isEmpty(channel)){
  38. throw new BusinessException("8002", "渠道短信验证接口,参数错误");
  39. }
  40. //解密手机号
  41. String phone = "";
  42. try{
  43. phone=ConfigUtil.decrypt(userid, cpid);
  44. }catch(Exception e){
  45. throw new BusinessException("8002", "渠道短信验证接口,参数错误");
  46. }
  47. //转换成伪码
  48. phone = ConfigUtil.getUserid(phone, cpid);
  49. SmsNumberDao snd=new SmsNumberDao();
  50. if(!snd.checkVcode(phone, vcode,channel,cpid)){
  51. throw new BusinessException("7003", "渠道短信验证接口,参数错误");
  52. }
  53. return dap;
  54. }
  55. public static void main(String[] args) throws Exception {
  56. System.out.println(DESUtil.encode("18684857907", "eb0b1e2b"));
  57. System.out.println(URLEncoder.encode(DESUtil.encode("18684857907", "eb0b1e2b"),"utf-8"));
  58. }
  59. }