QueryUserAuthOwnerCmd.java 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package com.java110.user.cmd.owner;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.core.annotation.Java110Cmd;
  4. import com.java110.core.context.CmdContextUtils;
  5. import com.java110.core.context.ICmdDataFlowContext;
  6. import com.java110.core.event.cmd.Cmd;
  7. import com.java110.core.event.cmd.CmdEvent;
  8. import com.java110.dto.community.CommunityDto;
  9. import com.java110.dto.owner.OwnerAppUserDto;
  10. import com.java110.dto.owner.OwnerDto;
  11. import com.java110.dto.user.LoginOwnerResDto;
  12. import com.java110.intf.community.ICommunityInnerServiceSMO;
  13. import com.java110.intf.user.IOwnerAppUserV1InnerServiceSMO;
  14. import com.java110.intf.user.IOwnerV1InnerServiceSMO;
  15. import com.java110.utils.exception.CmdException;
  16. import com.java110.utils.util.Assert;
  17. import com.java110.utils.util.ListUtil;
  18. import com.java110.utils.util.StringUtil;
  19. import com.java110.vo.ResultVo;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import java.text.ParseException;
  22. import java.util.List;
  23. /**
  24. * 查询认证业主信息
  25. */
  26. @Java110Cmd(serviceCode = "owner.queryUserAuthOwner")
  27. public class QueryUserAuthOwnerCmd extends Cmd {
  28. @Autowired
  29. private IOwnerAppUserV1InnerServiceSMO ownerAppUserV1InnerServiceSMOImpl;
  30. @Autowired
  31. private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
  32. @Autowired
  33. private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
  34. @Override
  35. public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
  36. }
  37. @Override
  38. public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
  39. String userId = CmdContextUtils.getUserId(context);
  40. if (StringUtil.isEmpty(userId)) {
  41. throw new CmdException("用户未登录");
  42. }
  43. OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
  44. ownerAppUserDto.setUserId(userId);
  45. ownerAppUserDto.setCommunityId(reqJson.getString("communityId"));
  46. ownerAppUserDto.setState(OwnerAppUserDto.STATE_AUDIT_SUCCESS);
  47. List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
  48. if (ListUtil.isNull(ownerAppUserDtos)) {
  49. throw new CmdException("用户未认证,请先认证");
  50. }
  51. OwnerDto ownerDto = new OwnerDto();
  52. ownerDto.setMemberId(ownerAppUserDtos.get(0).getMemberId());
  53. ownerDto.setCommunityId(ownerAppUserDtos.get(0).getCommunityId());
  54. List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto);
  55. if (ListUtil.isNull(ownerDtos)) {
  56. throw new CmdException("业主不存在");
  57. }
  58. ownerDto = ownerDtos.get(0);
  59. CommunityDto communityDto = new CommunityDto();
  60. communityDto.setCommunityId(ownerDto.getCommunityId());
  61. List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
  62. Assert.listOnlyOne(communityDtos, "小区不存在");
  63. LoginOwnerResDto loginOwnerResDto = new LoginOwnerResDto();
  64. loginOwnerResDto.setOwnerId(ownerDto.getOwnerId());
  65. loginOwnerResDto.setMemberId(ownerDto.getMemberId());
  66. loginOwnerResDto.setOwnerName(ownerDto.getName());
  67. loginOwnerResDto.setUserId(userId);
  68. loginOwnerResDto.setUserName(ownerDto.getName());
  69. loginOwnerResDto.setOwnerTel(ownerDto.getLink());
  70. loginOwnerResDto.setCommunityId(ownerDto.getCommunityId());
  71. loginOwnerResDto.setCommunityName(communityDtos.get(0).getName());
  72. loginOwnerResDto.setCommunityTel(communityDtos.get(0).getTel());
  73. loginOwnerResDto.setOwnerTypeCd(ownerDto.getOwnerTypeCd());
  74. loginOwnerResDto.setAppUserId(ownerAppUserDtos.get(0).getAppUserId());
  75. context.setResponseEntity(ResultVo.createResponseEntity(loginOwnerResDto));
  76. }
  77. }