wuxw
2024-03-22 c93a86960454d18c0e4cb61b65df651849fe50e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.java110.user.bmo.owner.impl;
 
import com.java110.core.factory.AuthenticationFactory;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.dto.community.CommunityDto;
import com.java110.dto.user.UserDto;
import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.intf.user.IOwnerAppUserV1InnerServiceSMO;
import com.java110.intf.user.IUserV1InnerServiceSMO;
import com.java110.po.owner.OwnerAppUserPo;
import com.java110.po.owner.OwnerPo;
import com.java110.po.user.UserPo;
import com.java110.user.bmo.owner.IGeneratorOwnerUserBMO;
import com.java110.utils.cache.MappingCache;
import com.java110.utils.constant.MappingConstant;
import com.java110.utils.constant.UserLevelConstant;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.ListUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
public class GeneratorOwnerUserBMOImpl implements IGeneratorOwnerUserBMO {
 
 
    @Autowired
    private IOwnerAppUserV1InnerServiceSMO ownerAppUserV1InnerServiceSMOImpl;
 
    @Autowired
    private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
    @Autowired
    private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
 
    @Override
    public void generator(OwnerPo ownerPo) {
        String autoUser = MappingCache.getValue(MappingConstant.DOMAIN_SYSTEM_SWITCH, "AUTO_GENERATOR_OWNER_USER");
 
        if (!"ON".equals(autoUser)) {
            return;
        }
 
        int flag = 0;
 
        CommunityDto communityDto = new CommunityDto();
        communityDto.setCommunityId(ownerPo.getCommunityId());
        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
        Assert.listNotNull(communityDtos, "未包含小区信息");
        CommunityDto tmpCommunityDto = communityDtos.get(0);
 
        UserDto userDto = new UserDto();
        userDto.setTel(ownerPo.getLink());
        userDto.setLevelCd(UserLevelConstant.USER_LEVEL_ORDINARY);
        List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto);
        String userId = "";
        if (ListUtil.isNull(userDtos)) {
            UserPo userPo = new UserPo();
            userPo.setUserId(GenerateCodeFactory.getUserId());
            userPo.setName(ownerPo.getName());
            userPo.setTel(ownerPo.getLink());
            userPo.setPassword(AuthenticationFactory.passwdMd5(ownerPo.getLink()));
            userPo.setLevelCd(UserLevelConstant.USER_LEVEL_ORDINARY);
            userPo.setAge(ownerPo.getAge());
            userPo.setAddress(ownerPo.getAddress());
            userPo.setSex(ownerPo.getSex());
            flag = userV1InnerServiceSMOImpl.saveUser(userPo);
            if (flag < 1) {
                throw new CmdException("注册失败");
            }
            userId = userPo.getUserId();
        } else {
            userId = userDtos.get(0).getUserId();
 
        }
 
        OwnerAppUserPo ownerAppUserPo = new OwnerAppUserPo();
        //状态类型,10000 审核中,12000 审核成功,13000 审核失败
        ownerAppUserPo.setState("12000");
        ownerAppUserPo.setAppTypeCd("10010");
        ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId));
        ownerAppUserPo.setMemberId(ownerPo.getMemberId());
        ownerAppUserPo.setCommunityName(tmpCommunityDto.getName());
        ownerAppUserPo.setCommunityId(ownerPo.getCommunityId());
        ownerAppUserPo.setAppUserName(ownerPo.getName());
        ownerAppUserPo.setIdCard(ownerPo.getIdCard());
        ownerAppUserPo.setAppType("WECHAT");
        ownerAppUserPo.setLink(ownerPo.getLink());
        ownerAppUserPo.setUserId(userId);
        ownerAppUserPo.setOpenId("-1");
        ownerAppUserPo.setOwnerTypeCd(ownerPo.getOwnerTypeCd());
 
        flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
        if (flag < 1) {
            throw new CmdException("添加用户业主关系失败");
        }
    }
}