cgf
2025-08-23 9ec0a61f90ac2464eebc643bfe2d93ac9ba6e569
service-user/src/main/java/com/java110/user/cmd/owner/OwnerRegisterCmd.java
@@ -14,10 +14,14 @@
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.user.UserAttrDto;
import com.java110.dto.user.UserDto;
import com.java110.intf.common.ISmsInnerServiceSMO;
import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.intf.community.IRoomInnerServiceSMO;
import com.java110.intf.community.IRoomV1InnerServiceSMO;
import com.java110.intf.store.IStoreInnerServiceSMO;
import com.java110.intf.user.*;
import com.java110.po.owner.OwnerAppUserPo;
@@ -35,6 +39,7 @@
import org.slf4j.Logger;
import com.java110.core.log.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import java.util.List;
@@ -67,6 +72,12 @@
    @Autowired
    private IOwnerAppUserV1InnerServiceSMO ownerAppUserV1InnerServiceSMOImpl;
    @Autowired
    private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl;
    @Autowired
    private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
    @Override
@@ -155,28 +166,38 @@
        List<CommunityDto> communityDtos = null;
        for (OwnerDto tmpOwnerDto : ownerDtos) {
            //用userId和手机号查询绑定关系,没有则新增
            OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
            ownerAppUserDto.setLink(reqJson.getString("link"));
            ownerAppUserDto.setUserId(tmpOwnerDto.getUserId());
            List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
            if(!CollectionUtils.isEmpty(ownerAppUserDtos)){
                continue;
            }
            CommunityDto communityDto = new CommunityDto();
            communityDto.setState("1100");
            communityDto.setCommunityId(ownerDto.getCommunityId());
            communityDto.setCommunityId(tmpOwnerDto.getCommunityId());
            communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
            if (communityDtos == null || communityDtos.size() < 1) {
            if (ListUtil.isNull(communityDtos)) {
                continue;
            }
            communityDto = communityDtos.get(0);
            ownerAppUserPo = new OwnerAppUserPo();
            ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId));
            ownerAppUserPo.setMemberId(tmpOwnerDto.getMemberId());
            ownerAppUserPo.setCommunityId(communityDto.getCommunityId());
            ownerAppUserPo.setCommunityId(tmpOwnerDto.getCommunityId());
            ownerAppUserPo.setCommunityName(communityDto.getName());
            ownerAppUserPo.setAppUserName(tmpOwnerDto.getName());
            ownerAppUserPo.setIdCard(tmpOwnerDto.getIdCard());
            ownerAppUserPo.setLink(tmpOwnerDto.getLink());
            ownerAppUserPo.setOpenId("-1");
            ownerAppUserPo.setAppTypeCd("10010");
            ownerAppUserPo.setState(OwnerAppUserDto.STATE_AUDIT_SUCCESS);
            ownerAppUserPo.setState(OwnerAppUserDto.STATE_NOT_AUDIT);
            ownerAppUserPo.setRemark("注册自动关联");
            ownerAppUserPo.setUserId(userPo.getUserId());
            ownerAppUserPo.setAppType(appType);
            ownerAppUserPo.setOwnerTypeCd(tmpOwnerDto.getOwnerTypeCd());
            queryOwnerRoom(tmpOwnerDto, ownerAppUserPo);
            flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
            if (flag < 1) {
                throw new CmdException("添加用户业主关系失败");
@@ -186,46 +207,28 @@
        cmdDataFlowContext.setResponseEntity(ResultVo.success());
    }
    private void addOwnerAppUser(JSONObject paramInJson, List<OwnerDto> ownerDtos) {
        List<CommunityDto> communityDtos = null;
        CommunityDto tmpCommunityDto = null;
        String communityName = "无";
    private void queryOwnerRoom(OwnerDto ownerDto, OwnerAppUserPo ownerAppUserPo) {
        if (ownerDtos == null || ownerDtos.size() < 1) {
            CommunityDto communityDto = new CommunityDto();
            communityDto.setState("1100");
            communityDto.setCommunityId(paramInJson.getString("defaultCommunityId"));
            communityDto.setPage(1);
            communityDto.setRow(1);
            communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
            if (communityDtos != null && communityDtos.size() > 0) {
                communityName = communityDtos.get(0).getName();
            }
            OwnerAppUserPo ownerAppUserPo = BeanConvertUtil.covertBean(paramInJson, OwnerAppUserPo.class);
            //状态类型,10000 审核中,12000 审核成功,13000 审核失败
            ownerAppUserPo.setState("12000");
            ownerAppUserPo.setAppTypeCd("10010");
            ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId));
            ownerAppUserPo.setMemberId("-1");
            ownerAppUserPo.setCommunityName(communityName);
            ownerAppUserPo.setCommunityId(paramInJson.getString("defaultCommunityId"));
            ownerAppUserPo.setAppUserName("游客");
            ownerAppUserPo.setIdCard("无");
            int flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
            if (flag < 1) {
                throw new CmdException("添加用户业主关系失败");
            }
        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());
    }
    /**
     * 注册用户
     *
     * @param paramObj
     */
}