DeleteOwnerCmd.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package com.java110.user.cmd.owner;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.java110.core.annotation.Java110Cmd;
  5. import com.java110.core.context.ICmdDataFlowContext;
  6. import com.java110.core.event.cmd.AbstractServiceCmdListener;
  7. import com.java110.core.event.cmd.CmdEvent;
  8. import com.java110.dto.RoomDto;
  9. import com.java110.dto.owner.OwnerAppUserDto;
  10. import com.java110.dto.owner.OwnerCarDto;
  11. import com.java110.dto.owner.OwnerDto;
  12. import com.java110.intf.community.IOwnerV1InnerServiceSMO;
  13. import com.java110.intf.community.IRoomInnerServiceSMO;
  14. import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
  15. import com.java110.intf.user.IOwnerAppUserV1InnerServiceSMO;
  16. import com.java110.intf.user.IOwnerCarInnerServiceSMO;
  17. import com.java110.intf.user.IOwnerInnerServiceSMO;
  18. import com.java110.po.owner.OwnerAppUserPo;
  19. import com.java110.po.owner.OwnerPo;
  20. import com.java110.utils.exception.CmdException;
  21. import com.java110.utils.util.Assert;
  22. import com.java110.utils.util.BeanConvertUtil;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import java.util.List;
  25. @Java110Cmd(serviceCode = "owner.deleteOwner")
  26. public class DeleteOwnerCmd extends AbstractServiceCmdListener {
  27. @Autowired
  28. private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
  29. @Autowired
  30. private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
  31. @Autowired
  32. private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
  33. @Autowired
  34. private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
  35. @Autowired
  36. private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMOImpl;
  37. @Autowired
  38. private IOwnerAppUserV1InnerServiceSMO ownerAppUserV1InnerServiceSMOImpl;
  39. @Override
  40. public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
  41. Assert.jsonObjectHaveKey(reqJson, "memberId", "请求报文中未包含memberId");
  42. Assert.jsonObjectHaveKey(reqJson, "communityId", "请求报文中未包含communityId");
  43. if (!"1001".equals(reqJson.getString("ownerTypeCd"))) { //不是业主成员不管
  44. return;
  45. }
  46. OwnerDto ownerDto = new OwnerDto();
  47. ownerDto.setOwnerId(reqJson.getString("memberId"));
  48. ownerDto.setCommunityId(reqJson.getString("communityId"));
  49. ownerDto.setOwnerTypeCds(new String[]{OwnerDto.OWNER_TYPE_CD_MEMBER, OwnerDto.OWNER_TYPE_CD_RENTING});
  50. List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
  51. if (ownerDtos != null && ownerDtos.size() > 0) {
  52. throw new IllegalArgumentException("请先删除业主下的成员");
  53. }
  54. if (OwnerDto.OWNER_TYPE_CD_OWNER.equals(reqJson.getString("ownerTypeCd"))) {
  55. //ownerId 写为 memberId
  56. reqJson.put("ownerId", reqJson.getString("memberId"));
  57. RoomDto roomDto = new RoomDto();
  58. roomDto.setOwnerId(reqJson.getString("ownerId"));
  59. List<RoomDto> roomDtoList = roomInnerServiceSMOImpl.queryRoomsByOwner(roomDto);
  60. if (roomDtoList.size() > 0) {
  61. throw new IllegalArgumentException("删除失败,删除前请先解绑房屋信息");
  62. }
  63. //查询车位信息
  64. OwnerCarDto ownerCarDto = new OwnerCarDto();
  65. ownerCarDto.setOwnerId(reqJson.getString("ownerId"));
  66. List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
  67. if (ownerCarDtos.size() > 0) {
  68. throw new IllegalArgumentException("删除失败,删除前请先解绑车位信息");
  69. }
  70. //小区楼添加到小区中
  71. //ownerBMOImpl.exitCommunityMember(reqJson, context);
  72. }
  73. }
  74. @Override
  75. public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
  76. JSONArray businesses = new JSONArray();
  77. JSONObject businessOwner = new JSONObject();
  78. businessOwner.put("memberId", reqJson.getString("memberId"));
  79. businessOwner.put("communityId", reqJson.getString("communityId"));
  80. OwnerPo ownerPo = BeanConvertUtil.covertBean(businessOwner, OwnerPo.class);
  81. int flag = ownerV1InnerServiceSMOImpl.deleteOwner(ownerPo);
  82. if (flag < 1) {
  83. throw new CmdException("删除失败");
  84. }
  85. OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
  86. ownerAppUserDto.setMemberId(reqJson.getString("ownerId"));
  87. //查询app用户表
  88. List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
  89. if (ownerAppUserDtos != null && ownerAppUserDtos.size() > 0) {
  90. for (OwnerAppUserDto ownerAppUser : ownerAppUserDtos) {
  91. OwnerAppUserPo ownerAppUserPo = BeanConvertUtil.covertBean(ownerAppUser, OwnerAppUserPo.class);
  92. flag = ownerAppUserV1InnerServiceSMOImpl.deleteOwnerAppUser(ownerAppUserPo);
  93. if (flag < 1) {
  94. throw new CmdException("删除失败");
  95. }
  96. }
  97. }
  98. }
  99. }