chengf
2025-12-11 f29e6f31e4f2d533124fc68346b7cc072f427c9b
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package com.java110.community.cmd.community;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.dto.community.CommunityMemberDto;
import com.java110.dto.store.StoreDto;
import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.intf.store.IStoreInnerServiceSMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.api.community.ApiCommunityDataVo;
import com.java110.vo.api.community.ApiCommunityVo;
import org.slf4j.Logger;
import com.java110.core.log.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 查询 入驻审核小区
 * add by 吴学文 2021-09-18
 */
@Java110Cmd(serviceCode = "community.listAuditEnterCommunitys")
public class ListAuditEnterCommunitysCmd extends Cmd {
    private final static Logger logger = LoggerFactory.getLogger(ListAuditEnterCommunitysCmd.class);
 
 
    @Autowired
    private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
 
    @Autowired
    private IStoreInnerServiceSMO storeInnerServiceSMOImpl;
 
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
 
    }
 
    @Override
    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
        if (StringUtil.jsonHasKayAndValue(reqJson, "name") || StringUtil.jsonHasKayAndValue(reqJson, "tel")) {
            getInfoByStore(cmdDataFlowContext, reqJson);
        } else {
            getInfoByCommunity(cmdDataFlowContext, reqJson);
        }
    }
 
    private void getInfoByStore(ICmdDataFlowContext context, JSONObject reqJson) {
        StoreDto storeDto = new StoreDto();
        storeDto.setName(reqJson.getString("name"));
        storeDto.setTel(reqJson.getString("tel"));
        List<StoreDto> storeDtos = storeInnerServiceSMOImpl.getStores(storeDto);
 
        List<ApiCommunityDataVo> communitys = null;
        int count = 0;
        if (storeDtos.size() > 0) {
            CommunityMemberDto communityMemberDto = BeanConvertUtil.covertBean(reqJson, CommunityMemberDto.class);
            communityMemberDto.setNeedCommunityInfo(true);
            communityMemberDto.setNoAuditEnterCommunity(true);
            communityMemberDto.setMemberId(reqJson.getString("memberId"));
            communityMemberDto.setSubMemberId(storeDtos.get(0).getStoreId());
 
            count = communityInnerServiceSMOImpl.getCommunityMemberCount(communityMemberDto);
 
            if (count > 0) {
                communitys = BeanConvertUtil.covertBeanList(communityInnerServiceSMOImpl.getCommunityMembers(communityMemberDto), ApiCommunityDataVo.class);
            } else {
                communitys = new ArrayList<>();
            }
        } else {
            communitys = new ArrayList<>();
        }
 
        //刷入 商户信息
        if (communitys.size() > 0) {
            freshCommunityInfo(communitys);
        }
 
        ApiCommunityVo apiCommunityVo = new ApiCommunityVo();
 
        apiCommunityVo.setTotal(count);
        apiCommunityVo.setRecords((int) Math.ceil((double) count / (double) reqJson.getInteger("row")));
        apiCommunityVo.setCommunitys(communitys);
 
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiCommunityVo), HttpStatus.OK);
 
        context.setResponseEntity(responseEntity);
    }
 
    /**
     * 刷新 小区 商户信息
     *
     * @param communityDataVos
     */
    private void freshCommunityInfo(List<ApiCommunityDataVo> communityDataVos) {
        for (ApiCommunityDataVo apiCommunityDataVo : communityDataVos) {
            StoreDto storeDto = new StoreDto();
            storeDto.setStoreId(apiCommunityDataVo.getMemberId());
            List<StoreDto> storeDtos = storeInnerServiceSMOImpl.getStores(storeDto);
 
            if (storeDtos.size() != 1) {
                continue;
            }
            //BeanConvertUtil.covertBean(storeDtos.get(0), apiCommunityDataVo);
 
            apiCommunityDataVo.setStoreName(storeDtos.get(0).getStoreName());
            apiCommunityDataVo.setStoreTypeCd(storeDtos.get(0).getStoreTypeCd());
            apiCommunityDataVo.setStoreTypeName(storeDtos.get(0).getStoreTypeName());
            apiCommunityDataVo.setTel(storeDtos.get(0).getTel());
            apiCommunityDataVo.setAddress(storeDtos.get(0).getAddress());
        }
    }
 
    private void getInfoByCommunity(ICmdDataFlowContext context, JSONObject reqJson) {
        CommunityMemberDto communityMemberDto = BeanConvertUtil.covertBean(reqJson, CommunityMemberDto.class);
 
        communityMemberDto.setNeedCommunityInfo(true);
        communityMemberDto.setNoAuditEnterCommunity(true);
 
        int count = communityInnerServiceSMOImpl.getCommunityMemberCount(communityMemberDto);
 
        List<ApiCommunityDataVo> communitys = null;
 
        if (count > 0) {
            communitys = BeanConvertUtil.covertBeanList(communityInnerServiceSMOImpl.getCommunityMembers(communityMemberDto), ApiCommunityDataVo.class);
        } else {
            communitys = new ArrayList<>();
        }
 
        //刷入 商户信息
        if (communitys.size() > 0) {
            freshCommunityInfo(communitys);
        }
 
        ApiCommunityVo apiCommunityVo = new ApiCommunityVo();
 
        apiCommunityVo.setTotal(count);
        apiCommunityVo.setRecords((int) Math.ceil((double) count / (double) reqJson.getInteger("row")));
        apiCommunityVo.setCommunitys(communitys);
 
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiCommunityVo), HttpStatus.OK);
 
        context.setResponseEntity(responseEntity);
    }
}