From 9ec0a61f90ac2464eebc643bfe2d93ac9ba6e569 Mon Sep 17 00:00:00 2001
From: cgf <2156125618@qq.com>
Date: 星期六, 23 八月 2025 10:59:18 +0800
Subject: [PATCH] 折扣已完成现有需求2025/08/09

---
 service-user/src/main/java/com/java110/user/cmd/owner/AuthOwnerCmd.java |   92 +++++++++++++++++++++++++++++----------------
 1 files changed, 59 insertions(+), 33 deletions(-)

diff --git a/service-user/src/main/java/com/java110/user/cmd/owner/AuthOwnerCmd.java b/service-user/src/main/java/com/java110/user/cmd/owner/AuthOwnerCmd.java
index bb27db8..b42583e 100644
--- a/service-user/src/main/java/com/java110/user/cmd/owner/AuthOwnerCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/owner/AuthOwnerCmd.java
@@ -18,10 +18,15 @@
 import com.java110.intf.community.IRoomV1InnerServiceSMO;
 import com.java110.intf.user.*;
 import com.java110.po.owner.OwnerAppUserPo;
+import com.java110.po.owner.OwnerPo;
+import com.java110.po.user.UserPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.ListUtil;
+import com.java110.utils.util.StringUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
 
 import java.text.ParseException;
 import java.util.List;
@@ -65,8 +70,8 @@
         Assert.hasKeyAndValue(reqJson, "communityId", "鏈寘鍚皬鍖�");
         Assert.hasKeyAndValue(reqJson, "roomName", "鏈寘鍚埧灞�");
         Assert.hasKeyAndValue(reqJson, "roomId", "鏈寘鍚埧灞�");
-        Assert.hasKeyAndValue(reqJson, "link", "鏈寘鍚墜鏈哄彿");
-        Assert.hasKeyAndValue(reqJson, "ownerName", "鏈寘鍚汉鍛樺悕绉�");
+        Assert.hasKeyAndValue(reqJson, "link", "鎵嬫満鍙蜂笉鑳戒负绌�");
+//        Assert.hasKeyAndValue(reqJson, "ownerName", "鏈寘鍚汉鍛樺悕绉�");
         Assert.hasKeyAndValue(reqJson, "ownerTypeCd", "鏈寘鍚汉鍛樼被鍨�");
 
         //todo 鏍规嵁鎵嬫満鍙锋煡璇� 鏄惁宸茬粡璁よ瘉杩囷紝濡傛灉璁よ瘉杩囧垯涓嶈兘鍐嶆璁よ瘉
@@ -84,12 +89,15 @@
         userDto.setUserId(userId);
         List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto);
         Assert.listOnlyOne(userDtos, "鐢ㄦ埛鏈櫥褰�");
-        if (!userDtos.get(0).getTel().equals(reqJson.getString("link"))) {
-            throw new CmdException("鎵嬫満鍙烽敊璇紝涓嶆槸娉ㄥ唽鏃剁殑鎵嬫満鍙�");
+        if(!StringUtils.isEmpty(userDtos.get(0).getTel())){
+            if (!userDtos.get(0).getTel().equals(reqJson.getString("link"))) {
+                throw new CmdException("鎵嬫満鍙烽敊璇紝涓嶆槸娉ㄥ唽鏃剁殑鎵嬫満鍙�");
+            }
         }
-
         OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
-        ownerAppUserDto.setLink(reqJson.getString("link"));
+        //鐢变簬鎵嬫満鍙锋槸闈炲繀濉紝鎵�鏈夋湁鍙兘鏌ュ嚭鏉ュぇ閲忕敤鎴凤紝鎵�浠ヤ笉鑳戒娇鐢ㄦ墜鏈哄彿鏌ヨ锛岃鐢╱serId鏌ヨ
+//        ownerAppUserDto.setLink(reqJson.getString("link"));
+        ownerAppUserDto.setUserId(userId);
         ownerAppUserDto.setCommunityId(reqJson.getString("communityId"));
         ownerAppUserDto.setStates(new String[]{
                 OwnerAppUserDto.STATE_AUDITING,
@@ -154,34 +162,52 @@
         List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
         Assert.listNotNull(communityDtos, "鏈寘鍚皬鍖轰俊鎭�");
         CommunityDto tmpCommunityDto = communityDtos.get(0);
-
-
         OwnerAppUserPo ownerAppUserPo = new OwnerAppUserPo();
-        //鐘舵�佺被鍨嬶紝10000 瀹℃牳涓紝12000 瀹℃牳鎴愬姛锛�13000 瀹℃牳澶辫触
-        ownerAppUserPo.setState(OwnerAppUserDto.STATE_AUDITING);
-        ownerAppUserPo.setAppTypeCd("10010");
-        ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId));
-        ownerAppUserPo.setMemberId("-1");
-        ownerAppUserPo.setCommunityName(tmpCommunityDto.getName());
-        ownerAppUserPo.setCommunityId(tmpCommunityDto.getCommunityId());
-        ownerAppUserPo.setAppUserName(reqJson.getString("ownerName"));
-        ownerAppUserPo.setAppType("WECHAT");
-        ownerAppUserPo.setLink(reqJson.getString("link"));
-        ownerAppUserPo.setUserId(userId);
-        ownerAppUserPo.setOpenId("-1");
-        ownerAppUserPo.setRoomId(reqJson.getString("roomId"));
-        ownerAppUserPo.setRoomName(reqJson.getString("roomName"));
-        ownerAppUserPo.setOwnerTypeCd(reqJson.getString("ownerTypeCd"));
-
-        UserAttrDto userAttrDto = new UserAttrDto();
-        userAttrDto.setUserId(userId);
-        userAttrDto.setSpecCd(UserAttrDto.SPEC_OPEN_ID);
-        List<UserAttrDto> userAttrDtos = userAttrV1InnerServiceSMOImpl.queryUserAttrs(userAttrDto);
-        if (!ListUtil.isNull(userAttrDtos)) {
-            ownerAppUserPo.setOpenId(userAttrDtos.get(0).getValue());
-
+        //鐢╱serId鏌ヨ鏄惁鏈夊緟璁よ瘉璁板綍锛屾病鏈夋柊澧烇紝鏈夌殑璇濈洿鎺ユ洿鏂扮姸鎬�
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setUserId(userId);
+        List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+        if(CollectionUtils.isEmpty(ownerAppUserDtos)){
+            //鐘舵�佺被鍨嬶紝10000 瀹℃牳涓紝 11000 寰呰璇� ,12000 瀹℃牳鎴愬姛锛�13000 瀹℃牳澶辫触
+            ownerAppUserPo.setState(OwnerAppUserDto.STATE_AUDIT_SUCCESS);
+            ownerAppUserPo.setAppTypeCd("10010");
+            ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId));
+            ownerAppUserPo.setMemberId("-1");
+            ownerAppUserPo.setCommunityName(tmpCommunityDto.getName());
+            ownerAppUserPo.setCommunityId(tmpCommunityDto.getCommunityId());
+            ownerAppUserPo.setAppUserName(reqJson.getString("ownerName"));
+            ownerAppUserPo.setAppType("WECHAT");
+            ownerAppUserPo.setLink(reqJson.getString("link"));
+            ownerAppUserPo.setUserId(userId);
+            ownerAppUserPo.setOpenId("-1");
+            ownerAppUserPo.setRoomId(reqJson.getString("roomId"));
+            ownerAppUserPo.setRoomName(reqJson.getString("roomName"));
+            ownerAppUserPo.setOwnerTypeCd(reqJson.getString("ownerTypeCd"));
+            UserAttrDto userAttrDto = new UserAttrDto();
+            userAttrDto.setUserId(userId);
+            userAttrDto.setSpecCd(UserAttrDto.SPEC_OPEN_ID);
+            List<UserAttrDto> userAttrDtos = userAttrV1InnerServiceSMOImpl.queryUserAttrs(userAttrDto);
+            if (!ListUtil.isNull(userAttrDtos)) {
+                ownerAppUserPo.setOpenId(userAttrDtos.get(0).getValue());
+            }
+            ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
+        }else{
+            for(OwnerAppUserDto ownerAppUser : ownerAppUserDtos){
+                ownerAppUserPo.setAppUserId(ownerAppUser.getAppUserId());
+                ownerAppUserPo.setLink(reqJson.getString("link"));
+                ownerAppUserPo.setState(OwnerAppUserDto.STATE_AUDIT_SUCCESS);
+                ownerAppUserV1InnerServiceSMOImpl.updateOwnerAppUser(ownerAppUserPo);
+                //鏇存柊building_owner琛ㄧ殑link瀛楁
+                OwnerPo ownerPo = new OwnerPo();
+                ownerPo.setMemberId(ownerAppUser.getMemberId());
+                ownerPo.setLink(reqJson.getString("link"));
+                ownerV1InnerServiceSMOImpl.updateOwner(ownerPo);
+                //鏇存柊u_user鐨則el瀛楁
+                UserPo userPo = new UserPo();
+                userPo.setUserId(ownerAppUser.getUserId());
+                userPo.setTel(reqJson.getString("link"));
+                userV1InnerServiceSMOImpl.updateUser(userPo);
+            }
         }
-
-        ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
     }
 }

--
Gitblit v1.8.0