fe3cf92630ccfc2783455ae4a18b883abaa4d4c0.svn-base 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.chinacreator.videoalliance.query.action;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletRequest;
  4. import org.apache.commons.lang.StringUtils;
  5. import org.springframework.beans.factory.annotation.Autowired;
  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.videoalliance.common.annotation.DataOut;
  11. import com.chinacreator.videoalliance.common.util.ConfigUtil;
  12. import com.chinacreator.videoalliance.query.bean.UserMsgInfo;
  13. import com.chinacreator.videoalliance.query.dao.UserMsgDao;
  14. @Controller
  15. public class UserMsgAction {
  16. @Autowired
  17. private UserMsgDao userMsgDao;
  18. @RequestMapping("/getUserMsg.do")
  19. @DataOut(callback = "getUserMsg")
  20. public DataOutPipe doOrder(HttpServletRequest request, UserMsgInfo userMsgInfo) throws Exception {
  21. DataOutPipe pipe = new DataOutPipe();
  22. if(userMsgInfo== null || StringUtils.isEmpty(userMsgInfo.getCpid()) || StringUtils.isEmpty(userMsgInfo.getSpid()) || StringUtils.isEmpty(userMsgInfo.getUserid()) || StringUtils.isEmpty(userMsgInfo.getActiveid()) ){
  23. throw new BusinessException("7002", "参数错误");
  24. }
  25. if(StringUtils.isEmpty(userMsgInfo.getType()) || userMsgInfo.getType().equals("0")){
  26. if(userMsgInfo!= null && StringUtils.isEmpty(userMsgInfo.getMsg1()) && StringUtils.isEmpty(userMsgInfo.getMsg2()) && StringUtils.isEmpty(userMsgInfo.getMsg3()) ){
  27. throw new BusinessException("7003", "缺少用户信息");
  28. }
  29. }
  30. try{
  31. userMsgInfo.setUserid(ConfigUtil.decrypt(userMsgInfo.getUserid(),userMsgInfo.getCpid()));
  32. if (userMsgInfo.getUserid().length() > 11) {
  33. userMsgInfo.setUserid(ConfigUtil.getUserid(userMsgInfo.getUserid(), userMsgInfo.getCpid()));
  34. }
  35. }catch(Exception e){
  36. throw new BusinessException("7002", "手机号码加密错误");
  37. }
  38. List<UserMsgInfo> list = userMsgDao.queryList(userMsgInfo.getUserid(), userMsgInfo.getCpid(), userMsgInfo.getSpid());
  39. if(list != null && list.size()>0){
  40. for (UserMsgInfo userMsgInfo2 : list) {
  41. if(userMsgInfo2.getActiveid().equals(userMsgInfo.getActiveid())){
  42. throw new BusinessException("9040", "用户已绑定信息");
  43. }else{
  44. throw new BusinessException("9041", "用户已参加过活动,不能重复参加");
  45. }
  46. }
  47. }
  48. if(StringUtils.isEmpty(userMsgInfo.getType()) || userMsgInfo.getType().equals("0")){
  49. userMsgDao.insert(userMsgInfo);
  50. }
  51. return pipe;
  52. }
  53. }