88e030b7
王彪总
init project
|
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
|
package com.java110.acct.cmd.account;
import com.alibaba.fastjson.JSONObject;
import com.java110.acct.bmo.account.IGetAccountBMO;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.CmdContextUtils;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.dto.account.AccountDto;
import com.java110.dto.contract.ContractDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.owner.OwnerAppUserDto;
import com.java110.dto.owner.OwnerCarDto;
import com.java110.dto.owner.OwnerDto;
import com.java110.dto.owner.OwnerRoomRelDto;
import com.java110.intf.fee.IFeeInnerServiceSMO;
import com.java110.intf.user.IOwnerAppUserV1InnerServiceSMO;
import com.java110.intf.user.IOwnerV1InnerServiceSMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.ListUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import java.text.ParseException;
import java.util.List;
/**
* 查询业主账户命令类
* 该命令用于处理业主账户查询请求,验证用户身份和权限,并返回业主账户信息
* 服务代码:account.queryOwnerAccount
*/
@Java110Cmd(serviceCode = "account.queryOwnerAccount")
public class QueryOwnerAccountCmd extends Cmd {
@Autowired
private IOwnerAppUserV1InnerServiceSMO ownerAppUserV1InnerServiceSMOImpl;
@Autowired
private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
@Autowired
private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
@Autowired
private IGetAccountBMO getAccountBMOImpl;
/**
* 请求参数验证方法
* 验证请求中是否包含必要的参数,并进行分页信息验证
*
* @param event CmdEvent对象,包含命令事件信息
* @param context ICmdDataFlowContext对象,数据流上下文
* @param reqJson JSONObject对象,请求参数JSON
* @throws CmdException 当命令执行异常时抛出
* @throws ParseException 当参数解析异常时抛出
*/
@Override
public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
// 验证请求中必须包含小区ID
Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区");
// 调用父类方法验证分页信息
super.validatePageInfo(reqJson);
}
/**
* 命令执行方法
* 处理业主账户查询业务逻辑,包括用户认证状态检查、业主信息查询和账户信息获取
*
* @param event CmdEvent对象,包含命令事件信息
* @param context ICmdDataFlowContext对象,数据流上下文
* @param reqJson JSONObject对象,请求参数JSON
* @throws CmdException 当命令执行异常时抛出
* @throws ParseException 当参数解析异常时抛出
*/
@Override
public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
// 从上下文中获取当前用户ID
String userId = CmdContextUtils.getUserId(context);
// 构建业主应用用户查询条件
OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
ownerAppUserDto.setUserId(userId);
ownerAppUserDto.setCommunityId(reqJson.getString("communityId"));
// 查询业主应用用户信息
List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
// 检查用户认证状态:未认证或认证失败
if (ListUtil.isNull(ownerAppUserDtos)
|| OwnerAppUserDto.STATE_AUDIT_ERROR.equals(ownerAppUserDtos.get(0).getState())) {
throw new CmdException("用户未认证,请先认证");
}
// 检查用户认证状态:认证审核中
if (OwnerAppUserDto.STATE_AUDITING.equals(ownerAppUserDtos.get(0).getState())) {
ResultVo resultVo = new ResultVo(-101, "认证审核中");
context.setResponseEntity(ResultVo.createResponseEntity(resultVo));
return;
}
// 构建业主查询条件
OwnerDto ownerDto = new OwnerDto();
ownerDto.setMemberId(ownerAppUserDtos.get(0).getMemberId());
ownerDto.setCommunityId(ownerAppUserDtos.get(0).getCommunityId());
// 查询业主信息
List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto);
// 检查业主是否存在
if (ListUtil.isNull(ownerDtos)) {
throw new CmdException("业主不存在");
}
// 获取第一个业主信息
ownerDto = ownerDtos.get(0);
// 将业主的联系方式和ID添加到请求参数中
reqJson.put("link", ownerDto.getLink());
reqJson.put("ownerId", ownerDto.getOwnerId());
// 将请求参数转换为账户DTO对象
AccountDto accountDto = BeanConvertUtil.covertBean(reqJson, AccountDto.class);
// 调用BMO层方法查询业主账户信息
ResponseEntity<String> responseEntity = getAccountBMOImpl.queryOwnerAccount(accountDto, ownerDto);
// 设置响应结果
context.setResponseEntity(responseEntity);
}
}
|