wuxw
2024-04-28 4b3dbbd2dcd2da192ab4859ed091598450aa2b0d
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
100
package com.java110.common.bmo.mall.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.common.bmo.mall.IMallCommonApiBmo;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.dto.community.CommunityDto;
import com.java110.dto.community.CommunityMemberDto;
import com.java110.dto.owner.OwnerDto;
import com.java110.dto.store.StoreDto;
import com.java110.intf.community.ICommunityMemberV1InnerServiceSMO;
import com.java110.intf.community.ICommunityV1InnerServiceSMO;
import com.java110.intf.store.IStoreV1InnerServiceSMO;
import com.java110.intf.user.IBuildingOwnerV1InnerServiceSMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.ListUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
public class QueryOwnerCommunityImpl implements IMallCommonApiBmo {
 
    @Autowired
    private IBuildingOwnerV1InnerServiceSMO buildingOwnerV1InnerServiceSMOImpl;
 
    @Autowired
    private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
 
    @Autowired
    private ICommunityMemberV1InnerServiceSMO communityMemberV1InnerServiceSMOImpl;
 
    @Autowired
    private IStoreV1InnerServiceSMO storeV1InnerServiceSMOImpl;
 
    @Override
    public void validate(ICmdDataFlowContext context, JSONObject reqJson) {
 
        Assert.hasKeyAndValue(reqJson, "link", "未包含手机号");
 
    }
 
    @Override
    public void doCmd(ICmdDataFlowContext context, JSONObject reqJson) {
 
        OwnerDto ownerDto = new OwnerDto();
        ownerDto.setLink(reqJson.getString("link"));
        ownerDto.setCommunityId(reqJson.getString("communityId"));
        List<OwnerDto> ownerDtos = buildingOwnerV1InnerServiceSMOImpl.queryBuildingOwners(ownerDto);
 
        if (ListUtil.isNull(ownerDtos)) {
            throw new CmdException("业主不存在");
        }
 
 
        //todo 查询小区
 
        CommunityDto communityDto = new CommunityDto();
        communityDto.setCommunityId(ownerDtos.get(0).getCommunityId());
        List<CommunityDto> communityDtos = communityV1InnerServiceSMOImpl.queryCommunitys(communityDto);
 
        if (ListUtil.isNull(communityDtos)) {
            throw new CmdException("小区不存在");
        }
 
 
        //todo 查询物业信息
        CommunityMemberDto communityMemberDto = new CommunityMemberDto();
        communityMemberDto.setCommunityId(communityDtos.get(0).getCommunityId());
        communityMemberDto.setMemberTypeCd(CommunityMemberDto.MEMBER_TYPE_PROPERTY);
        List<CommunityMemberDto> communityMemberDtos = communityMemberV1InnerServiceSMOImpl.queryCommunityMembers(communityMemberDto);
        if (ListUtil.isNull(communityMemberDtos)) {
            throw new CmdException("物业不存在");
        }
 
 
        StoreDto storeDto = new StoreDto();
        storeDto.setStoreId(communityMemberDtos.get(0).getMemberId());
        List<StoreDto> storeDtos = storeV1InnerServiceSMOImpl.queryStores(storeDto);
 
        if (ListUtil.isNull(storeDtos)) {
            throw new CmdException("物业不存在");
        }
 
        JSONObject data = new JSONObject();
        data.put("ownerId", ownerDtos.get(0).getMemberId());
        data.put("ownerName", ownerDtos.get(0).getName());
        data.put("ownerTel", ownerDtos.get(0).getLink());
        data.put("communityId", communityDtos.get(0).getCommunityId());
        data.put("communityName", communityDtos.get(0).getName());
        data.put("storeId", storeDtos.get(0).getStoreId());
        data.put("storeName", storeDtos.get(0).getName());
 
        context.setResponseEntity(ResultVo.createResponseEntity(data));
 
 
    }
}