| | |
| | | import com.java110.dto.msg.SmsDto; |
| | | import com.java110.dto.owner.OwnerAppUserDto; |
| | | import com.java110.dto.owner.OwnerDto; |
| | | import com.java110.dto.owner.OwnerRoomRelDto; |
| | | import com.java110.dto.room.RoomDto; |
| | | import com.java110.dto.system.SystemInfoDto; |
| | | import com.java110.dto.user.LoginOwnerResDto; |
| | | import com.java110.dto.user.UserAttrDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.intf.common.ISmsInnerServiceSMO; |
| | | import com.java110.intf.common.ISystemInfoV1InnerServiceSMO; |
| | | import com.java110.intf.community.ICommunityInnerServiceSMO; |
| | | import com.java110.intf.community.IRoomInnerServiceSMO; |
| | | import com.java110.intf.job.IIotInnerServiceSMO; |
| | | import com.java110.intf.job.IMallInnerServiceSMO; |
| | | import com.java110.intf.user.*; |
| | | import com.java110.po.owner.OwnerAppUserPo; |
| | | import com.java110.po.user.UserAttrPo; |
| | |
| | | import com.java110.utils.constant.UserLevelConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.exception.SMOException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.utils.util.ValidatorUtil; |
| | | import com.java110.utils.util.*; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | @Autowired |
| | | private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ISystemInfoV1InnerServiceSMO systemInfoV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IMallInnerServiceSMO mallInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IIotInnerServiceSMO iotInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IRoomInnerServiceSMO roomInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { |
| | |
| | | List<UserDto> userDtos = userInnerServiceSMOImpl.getUsers(userDto); |
| | | |
| | | //todo 1.1 如果验证码登录,自动绑定关系 |
| | | if (userDtos == null || userDtos.size() < 1) { |
| | | if (ListUtil.isNull(userDtos)) { |
| | | userDtos = ifOwnerLoginByPhone(reqJson, context); |
| | | } |
| | | if (userDtos == null || userDtos.size() < 1) { |
| | | throw new CmdException("用户不存在,请先注册"); |
| | | if (ListUtil.isNull(userDtos)) { |
| | | throw new CmdException("密码错误或者用户不存在"); |
| | | } |
| | | |
| | | //todo 1.2 同步物业用户资料给商城 |
| | | mallInnerServiceSMOImpl.sendUserInfo(userDtos.get(0)); |
| | | |
| | | //todo 1.3 同步物业用户资料给物联网 |
| | | iotInnerServiceSMOImpl.sendUserInfo(userDtos.get(0)); |
| | | |
| | | // todo 2.0 校验 业主用户绑定表是否存在记录 |
| | | OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto(); |
| | | ownerAppUserDto.setUserId(userDtos.get(0).getUserId()); |
| | | ownerAppUserDto.setLink(userDtos.get(0).getTel()); |
| | | ownerAppUserDto.setState(OwnerAppUserDto.STATE_AUDIT_SUCCESS); |
| | | List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto); |
| | | |
| | | if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) { |
| | | throw new CmdException("用户未注册,请先注册"); |
| | | LoginOwnerResDto loginOwnerResDto = new LoginOwnerResDto(); |
| | | loginOwnerResDto.setAuditState(userDtos.get(0).getAuditState()); |
| | | String communityId = ""; |
| | | if (!ListUtil.isNull(ownerAppUserDtos)) { |
| | | // todo 4.0 查询小区是否存在 |
| | | communityId = ownerAppUserDtos.get(0).getCommunityId(); |
| | | loginOwnerResDto.setAuditState(ownerAppUserDtos.get(0).getState()); |
| | | } else { |
| | | SystemInfoDto systemInfoDto = new SystemInfoDto(); |
| | | List<SystemInfoDto> systemInfoDtos = systemInfoV1InnerServiceSMOImpl.querySystemInfos(systemInfoDto); |
| | | communityId = systemInfoDtos.get(0).getDefaultCommunityId(); |
| | | } |
| | | |
| | | // todo 3.0 查询业主是否存在 |
| | | OwnerDto ownerDto = null; |
| | | if (ownerAppUserDtos.get(0).getMemberId().startsWith("-1")){ |
| | | //todo 这里考虑游客的情况 |
| | | ownerDto = new OwnerDto(); |
| | | ownerDto.setOwnerId(ownerAppUserDtos.get(0).getMemberId()); |
| | | ownerDto.setMemberId(ownerAppUserDtos.get(0).getMemberId()); |
| | | ownerDto.setName(ownerAppUserDtos.get(0).getAppUserName()); |
| | | ownerDto.setLink(ownerAppUserDtos.get(0).getLink()); |
| | | ownerDto.setCommunityId(ownerAppUserDtos.get(0).getCommunityId()); |
| | | }else { |
| | | ownerDto = new OwnerDto(); |
| | | ownerDto.setMemberId(ownerAppUserDtos.get(0).getMemberId()); |
| | | ownerDto.setCommunityId(ownerAppUserDtos.get(0).getCommunityId()); |
| | | List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto); |
| | | Assert.listOnlyOne(ownerDtos, "业主不存在"); |
| | | ownerDto = ownerDtos.get(0); |
| | | } |
| | | |
| | | |
| | | // todo 4.0 查询小区是否存在 |
| | | CommunityDto communityDto = new CommunityDto(); |
| | | communityDto.setCommunityId(ownerAppUserDtos.get(0).getCommunityId()); |
| | | communityDto.setCommunityId(communityId); |
| | | List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto); |
| | | Assert.listOnlyOne(communityDtos, "小区不存在," + ownerAppUserDtos.get(0).getCommunityId()); |
| | | |
| | | Assert.listOnlyOne(communityDtos, "小区不存在,确保开发者账户配置默认小区" + communityId); |
| | | |
| | | //todo 生成 app 永久登录key |
| | | UserDto tmpUserDto = userDtos.get(0); |
| | |
| | | //todo 生成登录token |
| | | String token = generatorLoginToken(tmpUserDto); |
| | | |
| | | LoginOwnerResDto loginOwnerResDto = new LoginOwnerResDto(); |
| | | loginOwnerResDto.setOwnerId(ownerDto.getOwnerId()); |
| | | loginOwnerResDto.setMemberId(ownerDto.getMemberId()); |
| | | loginOwnerResDto.setOwnerName(ownerDto.getName()); |
| | | |
| | | loginOwnerResDto.setCommunityId(communityDtos.get(0).getCommunityId()); |
| | | loginOwnerResDto.setCommunityName(communityDtos.get(0).getName()); |
| | | loginOwnerResDto.setCommunityTel(communityDtos.get(0).getTel()); |
| | | loginOwnerResDto.setCommunityQrCode(communityDtos.get(0).getQrCode()); |
| | | loginOwnerResDto.setUserId(tmpUserDto.getUserId()); |
| | | loginOwnerResDto.setUserName(tmpUserDto.getName()); |
| | | loginOwnerResDto.setOwnerTel(ownerDto.getLink()); |
| | | loginOwnerResDto.setCommunityId(ownerDto.getCommunityId()); |
| | | loginOwnerResDto.setCommunityName(communityDtos.get(0).getName()); |
| | | loginOwnerResDto.setOwnerTel(tmpUserDto.getTel()); |
| | | loginOwnerResDto.setToken(token); |
| | | loginOwnerResDto.setKey(newKey); |
| | | loginOwnerResDto.setOwnerTypeCd(ownerDto.getOwnerTypeCd()); |
| | | loginOwnerResDto.setAppUserId(ownerAppUserDtos.get(0).getAppUserId()); |
| | | context.setResponseEntity(ResultVo.createResponseEntity(loginOwnerResDto)); |
| | | |
| | | } |
| | |
| | | List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto); |
| | | |
| | | // 说明业主不存在 直接返回跑异常 |
| | | if (ownerDtos == null || ownerDtos.size() < 1) { |
| | | if (ListUtil.isNull(ownerDtos)) { |
| | | return null; |
| | | } |
| | | |
| | |
| | | if (flag < 1) { |
| | | throw new CmdException("注册失败"); |
| | | } |
| | | |
| | | OwnerAppUserPo ownerAppUserPo = new OwnerAppUserPo(); |
| | | //状态类型,10000 审核中,12000 审核成功,13000 审核失败 |
| | | ownerAppUserPo.setState("12000"); |
| | | ownerAppUserPo.setAppTypeCd("10010"); |
| | | ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId)); |
| | | ownerAppUserPo.setMemberId(ownerDtos.get(0).getMemberId()); |
| | | ownerAppUserPo.setCommunityName(tmpCommunityDto.getName()); |
| | | ownerAppUserPo.setCommunityId(ownerDtos.get(0).getCommunityId()); |
| | | ownerAppUserPo.setAppUserName(ownerDtos.get(0).getName()); |
| | | ownerAppUserPo.setIdCard(ownerDtos.get(0).getIdCard()); |
| | | ownerAppUserPo.setAppType("WECHAT"); |
| | | ownerAppUserPo.setLink(ownerDtos.get(0).getLink()); |
| | | ownerAppUserPo.setUserId(userPo.getUserId()); |
| | | ownerAppUserPo.setOpenId("-1"); |
| | | |
| | | flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("添加用户业主关系失败"); |
| | | } |
| | | |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setUserId(userPo.getUserId()); |
| | | List<UserDto> userDtos = userInnerServiceSMOImpl.getUsers(userDto); |
| | | //用userId和手机号查询绑定关系,没有则新增 |
| | | OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto(); |
| | | ownerAppUserDto.setLink(userPo.getTel()); |
| | | ownerAppUserDto.setUserId(userPo.getUserId()); |
| | | List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto); |
| | | if(CollectionUtils.isEmpty(ownerAppUserDtos)){ |
| | | OwnerAppUserPo ownerAppUserPo = new OwnerAppUserPo(); |
| | | //状态类型,10000 审核中, 11000 待认证 ,12000 审核成功,13000 审核失败 |
| | | ownerAppUserPo.setState(OwnerAppUserDto.STATE_NOT_AUDIT); |
| | | ownerAppUserPo.setAppTypeCd("10010"); |
| | | ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId)); |
| | | ownerAppUserPo.setMemberId(ownerDtos.get(0).getMemberId()); |
| | | ownerAppUserPo.setCommunityName(tmpCommunityDto.getName()); |
| | | ownerAppUserPo.setCommunityId(ownerDtos.get(0).getCommunityId()); |
| | | ownerAppUserPo.setAppUserName(ownerDtos.get(0).getName()); |
| | | ownerAppUserPo.setIdCard(ownerDtos.get(0).getIdCard()); |
| | | ownerAppUserPo.setAppType("WECHAT"); |
| | | ownerAppUserPo.setLink(ownerDtos.get(0).getLink()); |
| | | ownerAppUserPo.setUserId(userPo.getUserId()); |
| | | ownerAppUserPo.setOpenId("-1"); |
| | | ownerAppUserPo.setOwnerTypeCd(ownerDtos.get(0).getOwnerTypeCd()); |
| | | queryOwnerRoom(ownerDtos.get(0), ownerAppUserPo); |
| | | flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("添加用户业主关系失败"); |
| | | } |
| | | userDtos.get(0).setAuditState(ownerAppUserPo.getState()); |
| | | } |
| | | return userDtos; |
| | | } |
| | | |
| | | private void queryOwnerRoom(OwnerDto ownerDto, OwnerAppUserPo ownerAppUserPo) { |
| | | |
| | | |
| | | OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto(); |
| | | ownerRoomRelDto.setOwnerId(ownerDto.getOwnerId()); |
| | | |
| | | List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelV1InnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto); |
| | | |
| | | if (ListUtil.isNull(ownerRoomRelDtos)) { |
| | | return; |
| | | } |
| | | |
| | | RoomDto roomDto = new RoomDto(); |
| | | roomDto.setRoomId(ownerRoomRelDtos.get(0).getRoomId()); |
| | | List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | if (ListUtil.isNull(roomDtos)) { |
| | | return; |
| | | } |
| | | |
| | | ownerAppUserPo.setRoomId(roomDtos.get(0).getRoomId()); |
| | | ownerAppUserPo.setRoomName(roomDtos.get(0).getFloorNum() + "-" + roomDtos.get(0).getUnitNum() + "-" + roomDtos.get(0).getRoomNum()); |
| | | } |
| | | |
| | | private UserAttrDto getCurrentUserAttrDto(List<UserAttrDto> userAttrDtos, String specCd) { |
| | | if (userAttrDtos == null) { |
| | | return null; |