/** * 删除组织机构 * * @param id * @throws Exception */ @Transactional(readOnly = false) public void deleteOrganization(String id) throws Exception { Customer customer = get(id); if (!CollectionUtils.isEmpty(mediaDao.findByOrganizationId(id))) { throw new Exception("此机构下属有媒体,暂时不能删除!"); } userDao.delete(customer.getUsers()); this.remove(customer); }
/** * 新会员注册. * * @param vo */ @Transactional(readOnly = false) public Customer register(CustomerVO vo) { Date now = new Date(); // 创建客户信息 和 关联账户信息 Customer cust = BeanMapper.map(vo, Customer.class); cust.setCreateTime(now); cust.setModifyTime(now); cust.setStatus(CustStatus.NORMAL); cust.setCredit(0); cust.setCustLevel(custLevelDao.findOne("VIP1")); cust.setCertStatus(Constants.CertStatus.NULL); // 创建客户账户 Account account = createAccount(cust); cust.setAccount(account); getDao().save(cust); // 创建用户信息 createUser(vo, cust); // 奖励 // updateCredit(cust); return cust; }
private Role getUserRole(Customer cust) { String custType = cust.getCustType(); String roleId = null; if (CustType.CUST_ADV.equals(custType)) { roleId = Constants.RoleId.ADVERTISER; } else if (CustType.CUST_PRO.equals(custType)) { roleId = Constants.RoleId.PROVIDER; } else { roleId = Constants.RoleId.ORGANIZATION; } return roleDao.findOne(roleId); }
/** * 创建组织机构. * * @param vo */ @Transactional(readOnly = false) public Customer createOrganization(CustomerVO vo) { Date now = new Date(); // 创建客户信息 Customer org = BeanMapper.map(vo, Customer.class); org.setCreateBy(UserContext.getSystemUser().getId()); org.setCreateTime(now); org.setModifyBy(org.getCreateBy()); org.setModifyTime(now); org.setCredit(0); org.setStatus(CustStatus.NORMAL); org.setCustType(CustType.CUST_ORG); org.setCustProperty(CustProperty.CUST_C); getDao().save(org); // 创建登录账号 createUser(vo, org); return org; }
/** * 修改组织机构 * * @param customer */ @Transactional(readOnly = false) public void updateOrganization(CustomerVO vo) { Customer customer = customerDao.findOne(vo.getId()); customer.setMobPhone(vo.getLoginName()); customer.setName(vo.getName()); customer.setOrgSummary(vo.getOrgSummary()); customer.setOrgType(vo.getOrgType()); Date now = new Date(); customer.setModifyBy(UserContext.getCurrent().getId()); customer.setModifyTime(now); save(customer); User user = userDao.findByCustomerId(customer.getId()); user.setLoginName(vo.getLoginName()); user.setNickname(customer.getName()); String[] hash = Encrypts.hashPassword(vo.getLoginName()); user.setPassword(hash[0]); user.setSalt(hash[1]); userDao.save(user); }
/** 更新用户信息. */ @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 updateLoginName(CustomerVO vo, Customer cust) { User user = userDao.findByLoginName(cust.getMobPhone()); if (user != null) { userDao.updateLoginName(vo.getMobPhone(), cust.getMobPhone()); } }