From c434ece53b249ae10f20f9fd552d03ca671c5b11 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期四, 11 四月 2024 17:08:48 +0800
Subject: [PATCH] 加入电梯相机功能,支持电梯非机动车检车

---
 service-user/src/main/java/com/java110/user/cmd/user/OwnerUserLoginByOpenIdCmd.java |  157 +++++++++++++---------------------------------------
 1 files changed, 40 insertions(+), 117 deletions(-)

diff --git a/service-user/src/main/java/com/java110/user/cmd/user/OwnerUserLoginByOpenIdCmd.java b/service-user/src/main/java/com/java110/user/cmd/user/OwnerUserLoginByOpenIdCmd.java
index ba2cf2d..0371d53 100644
--- a/service-user/src/main/java/com/java110/user/cmd/user/OwnerUserLoginByOpenIdCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/user/OwnerUserLoginByOpenIdCmd.java
@@ -13,10 +13,12 @@
 import com.java110.dto.msg.SmsDto;
 import com.java110.dto.owner.OwnerAppUserDto;
 import com.java110.dto.owner.OwnerDto;
+import com.java110.dto.system.SystemInfoDto;
 import com.java110.dto.user.LoginOwnerResDto;
 import com.java110.dto.user.UserAttrDto;
 import com.java110.dto.user.UserDto;
 import com.java110.intf.common.ISmsInnerServiceSMO;
+import com.java110.intf.common.ISystemInfoV1InnerServiceSMO;
 import com.java110.intf.community.ICommunityInnerServiceSMO;
 import com.java110.intf.user.*;
 import com.java110.po.owner.OwnerAppUserPo;
@@ -26,10 +28,7 @@
 import com.java110.utils.constant.UserLevelConstant;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.exception.SMOException;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.utils.util.StringUtil;
-import com.java110.utils.util.ValidatorUtil;
+import com.java110.utils.util.*;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -56,6 +55,7 @@
     @Autowired
     private IUserAttrV1InnerServiceSMO userAttrV1InnerServiceSMOImpl;
 
+
     @Autowired
     private ISmsInnerServiceSMO smsInnerServiceSMOImpl;
 
@@ -71,6 +71,11 @@
     @Autowired
     private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
 
+    @Autowired
+    private ISystemInfoV1InnerServiceSMO systemInfoV1InnerServiceSMOImpl;
+
+
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
         Assert.hasKeyAndValue(reqJson, "openId", "璇锋眰鎶ユ枃涓湭鍖呭惈openId");
@@ -81,18 +86,38 @@
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
 
-        // todo  2.0 鏍¢獙 涓氫富鐢ㄦ埛缁戝畾琛ㄦ槸鍚﹀瓨鍦ㄨ褰�
-        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
-        ownerAppUserDto.setOpenId(reqJson.getString("openId"));
-        List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+        UserAttrDto userAttrDto = new UserAttrDto();
+        userAttrDto.setSpecCd(UserAttrDto.SPEC_OPEN_ID);
+        userAttrDto.setValue(reqJson.getString("openId"));
+        List<UserAttrDto> userAttrDtos = userAttrV1InnerServiceSMOImpl.queryUserAttrs(userAttrDto);
 
-        if (ownerAppUserDtos == null || ownerAppUserDtos.size() < 1) {
+        if(ListUtil.isNull(userAttrDtos)){
             throw new CmdException("鏈壘鍒扮敤鎴蜂俊鎭�");
         }
 
+        // todo  2.0 鏍¢獙 涓氫富鐢ㄦ埛缁戝畾琛ㄦ槸鍚﹀瓨鍦ㄨ褰�
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setUserId(userAttrDtos.get(0).getUserId());
+        List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+
+        String communityId = "";
+        if (!ListUtil.isNull(ownerAppUserDtos)) {
+            // todo 4.0 鏌ヨ灏忓尯鏄惁瀛樺湪
+            communityId = ownerAppUserDtos.get(0).getCommunityId();
+        } else {
+            SystemInfoDto systemInfoDto = new SystemInfoDto();
+            List<SystemInfoDto> systemInfoDtos = systemInfoV1InnerServiceSMOImpl.querySystemInfos(systemInfoDto);
+            communityId = systemInfoDtos.get(0).getDefaultCommunityId();
+        }
+        CommunityDto communityDto = new CommunityDto();
+        communityDto.setCommunityId(communityId);
+        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
+        Assert.listOnlyOne(communityDtos, "灏忓尯涓嶅瓨鍦紝纭繚寮�鍙戣�呰处鎴烽厤缃粯璁ゅ皬鍖�" + communityId);
+
+
         UserDto userDto = new UserDto();
         userDto.setLevelCd(UserDto.LEVEL_CD_USER);
-        userDto.setUserId(ownerAppUserDtos.get(0).getUserId());
+        userDto.setUserId(userAttrDtos.get(0).getUserId());
 
         //todo 1.0 鏌ヨ鐢ㄦ埛鏄惁瀛樺湪
         List<UserDto> userDtos = userInnerServiceSMOImpl.getUsers(userDto);
@@ -101,43 +126,22 @@
             throw new CmdException("涓氫富涓嶅瓨鍦紝璇峰厛娉ㄥ唽");
         }
 
-
-        // todo 3.0 鏌ヨ涓氫富鏄惁瀛樺湪
-        OwnerDto ownerDto = new OwnerDto();
-        ownerDto.setMemberId(ownerAppUserDtos.get(0).getMemberId());
-        ownerDto.setCommunityId(ownerAppUserDtos.get(0).getCommunityId());
-        List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto);
-
-        Assert.listOnlyOne(ownerDtos, "涓氫富涓嶅瓨鍦�");
-
-        // todo 4.0 鏌ヨ灏忓尯鏄惁瀛樺湪
-        CommunityDto communityDto = new CommunityDto();
-        communityDto.setCommunityId(ownerAppUserDtos.get(0).getCommunityId());
-        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
-        Assert.listOnlyOne(communityDtos, "灏忓尯涓嶅瓨鍦紝" + ownerAppUserDtos.get(0).getCommunityId());
-
-
-        //todo 鐢熸垚 app 姘镐箙鐧诲綍key
         UserDto tmpUserDto = userDtos.get(0);
         String newKey = generatorLoginKey(tmpUserDto);
 
         //todo 鐢熸垚鐧诲綍token
         String token = generatorLoginToken(tmpUserDto);
-
         LoginOwnerResDto loginOwnerResDto = new LoginOwnerResDto();
-        loginOwnerResDto.setOwnerId(ownerDtos.get(0).getOwnerId());
-        loginOwnerResDto.setMemberId(ownerDtos.get(0).getMemberId());
-        loginOwnerResDto.setOwnerName(ownerDtos.get(0).getName());
+
+        loginOwnerResDto.setCommunityId(communityDtos.get(0).getCommunityId());
+        loginOwnerResDto.setCommunityName(communityDtos.get(0).getName());
+        loginOwnerResDto.setCommunityTel(communityDtos.get(0).getTel());
         loginOwnerResDto.setUserId(tmpUserDto.getUserId());
         loginOwnerResDto.setUserName(tmpUserDto.getName());
-        loginOwnerResDto.setOwnerTel(ownerDtos.get(0).getLink());
-        loginOwnerResDto.setCommunityId(ownerDtos.get(0).getCommunityId());
-        loginOwnerResDto.setCommunityName(communityDtos.get(0).getName());
+        loginOwnerResDto.setOwnerTel(tmpUserDto.getTel());
         loginOwnerResDto.setToken(token);
         loginOwnerResDto.setKey(newKey);
-        loginOwnerResDto.setAppUserId(ownerAppUserDtos.get(0).getAppUserId());
         context.setResponseEntity(ResultVo.createResponseEntity(loginOwnerResDto));
-
     }
 
     /**
@@ -179,87 +183,6 @@
             userAttrV1InnerServiceSMOImpl.saveUserAttr(userAttrPo);
         }
         return newKey;
-    }
-
-    /**
-     * 楠岃瘉鐮佺櫥褰曪紝鍒ゆ柇鏄惁鏄惁涓氫富锛屽苟涓旀槸鍚︾粦瀹氬叧绯� 濡傛灉娌℃湁 鑷姩缁戝畾鍏崇郴
-     *
-     * @param reqJson
-     * @param context
-     */
-    private List<UserDto> ifOwnerLoginByPhone(JSONObject reqJson, ICmdDataFlowContext context) {
-        if (!reqJson.containsKey("loginByPhone") || !reqJson.getBoolean("loginByPhone")) {
-            return null;
-        }
-        String appId = context.getReqHeaders().get("app-id");
-
-        //todo 涓氫富鎵嬫満绔�
-        if (!AppDto.WECHAT_OWNER_APP_ID.equals(appId)
-                && !AppDto.WECHAT_MINA_OWNER_APP_ID.equals(appId)
-                && !AppDto.OWNER_APP_APP_ID.equals(appId)) {
-            return null;
-        }
-
-        if (StringUtil.isEmpty(reqJson.getString("userName"))) {
-            return null;
-        }
-
-        // todo 鏌ヨ涓氫富鎴栨垚鍛�
-        OwnerDto ownerDto = new OwnerDto();
-        ownerDto.setLink(reqJson.getString("userName"));
-        ownerDto.setPage(1);
-        ownerDto.setRow(1);
-        List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto);
-
-        // 璇存槑涓氫富涓嶅瓨鍦� 鐩存帴杩斿洖璺戝紓甯�
-        if (ownerDtos == null || ownerDtos.size() < 1) {
-            return null;
-        }
-
-        CommunityDto communityDto = new CommunityDto();
-        communityDto.setCommunityId(ownerDtos.get(0).getCommunityId());
-        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
-        Assert.listNotNull(communityDtos, "鏈寘鍚皬鍖轰俊鎭�");
-        CommunityDto tmpCommunityDto = communityDtos.get(0);
-
-        UserPo userPo = new UserPo();
-        userPo.setUserId(GenerateCodeFactory.getUserId());
-        userPo.setName(ownerDtos.get(0).getName());
-        userPo.setTel(ownerDtos.get(0).getLink());
-        userPo.setPassword(AuthenticationFactory.passwdMd5(reqJson.getString("password")));
-        userPo.setLevelCd(UserLevelConstant.USER_LEVEL_ORDINARY);
-        userPo.setAge(ownerDtos.get(0).getAge());
-        userPo.setAddress(ownerDtos.get(0).getAddress());
-        userPo.setSex(ownerDtos.get(0).getSex());
-        int flag = userV1InnerServiceSMOImpl.saveUser(userPo);
-        if (flag < 1) {
-            throw new CmdException("娉ㄥ唽澶辫触");
-        }
-
-        OwnerAppUserPo ownerAppUserPo = new OwnerAppUserPo();
-        //鐘舵�佺被鍨嬶紝10000 瀹℃牳涓紝12000 瀹℃牳鎴愬姛锛�13000 瀹℃牳澶辫触
-        ownerAppUserPo.setState("12000");
-        ownerAppUserPo.setAppTypeCd("10010");
-        ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId));
-        ownerAppUserPo.setMemberId(ownerDtos.get(0).getMemberId());
-        ownerAppUserPo.setCommunityName(tmpCommunityDto.getName());
-        ownerAppUserPo.setCommunityId(ownerDtos.get(0).getCommunityId());
-        ownerAppUserPo.setAppUserName(ownerDtos.get(0).getName());
-        ownerAppUserPo.setIdCard(ownerDtos.get(0).getIdCard());
-        ownerAppUserPo.setAppType("WECHAT");
-        ownerAppUserPo.setLink(ownerDtos.get(0).getLink());
-        ownerAppUserPo.setUserId(userPo.getUserId());
-        ownerAppUserPo.setOpenId("-1");
-
-        flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
-        if (flag < 1) {
-            throw new CmdException("娣诲姞鐢ㄦ埛涓氫富鍏崇郴澶辫触");
-        }
-
-        UserDto userDto = new UserDto();
-        userDto.setUserId(userPo.getUserId());
-        List<UserDto> userDtos = userInnerServiceSMOImpl.getUsers(userDto);
-        return userDtos;
     }
 
     private UserAttrDto getCurrentUserAttrDto(List<UserAttrDto> userAttrDtos, String specCd) {

--
Gitblit v1.8.0