/** * 导入广告主 * * @param vo * @throws Exception */ public void importAdivertiser(CustomerVO vo) throws Exception { if (this.countBy("mobPhone", vo.getMobPhone()) > 0) { throw new Exception("手机号码已经存在:" + vo.getMobPhone()); } vo.setCustType(Constants.CustType.CUST_ADV); this.register(vo); }
/** 更新用户信息. */ @Transactional(readOnly = false) public void updateUserInfo(CustomerVO vo, Customer cust) { if (!cust.getMobPhone().equals(vo.getMobPhone())) { updateLoginName(vo, cust); cust.setMobPhone(vo.getMobPhone()); } if (null != vo.getName()) { cust.setName(vo.getName()); } cust.setLinkman(vo.getLinkman()); cust.setEmail(vo.getEmail()); cust.setQq(vo.getQq()); getDao().save(cust); }
private void createUser(CustomerVO vo, Customer cust) { User user = new User(); Date now = new Date(); user.setLoginName(vo.getLoginName()); String[] hash = Encrypts.hashPassword(vo.getPassword()); user.setPassword(hash[0]); user.setSalt(hash[1]); user.setNickname(getNickname(vo)); user.setSecMobile(vo.getMobPhone()); user.setCustomer(cust); user.setType(UserType.MEMBER); user.setStatus(UserStatus.ENABLED); user.setCreateTime(now); user.setRole(getUserRole(cust)); // 创建用户角色关系 userDao.save(user); }
/** 更新登录名. */ private void updateLoginName(CustomerVO vo, Customer cust) { User user = userDao.findByLoginName(cust.getMobPhone()); if (user != null) { userDao.updateLoginName(vo.getMobPhone(), cust.getMobPhone()); } }
private String getNickname(CustomerVO vo) { if (StringUtils.isNotBlank(vo.getName())) return vo.getName(); else return vo.getMobPhone(); }