From 18f32dd969a866224138be314639baaae3d103f5 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期四, 21 三月 2024 21:43:11 +0800
Subject: [PATCH] 优化用户注册流程
---
service-user/src/main/java/com/java110/user/cmd/owner/OwnerRegisterCmd.java | 172 ++++++++++++++++++++++++++++----------------------------
1 files changed, 86 insertions(+), 86 deletions(-)
diff --git a/service-user/src/main/java/com/java110/user/cmd/owner/OwnerRegisterCmd.java b/service-user/src/main/java/com/java110/user/cmd/owner/OwnerRegisterCmd.java
index 00b5420..2714f6e 100644
--- a/service-user/src/main/java/com/java110/user/cmd/owner/OwnerRegisterCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/owner/OwnerRegisterCmd.java
@@ -14,6 +14,8 @@
import com.java110.dto.msg.SmsDto;
import com.java110.dto.owner.OwnerAppUserDto;
import com.java110.dto.owner.OwnerDto;
+import com.java110.dto.user.UserAttrDto;
+import com.java110.dto.user.UserDto;
import com.java110.intf.common.ISmsInnerServiceSMO;
import com.java110.intf.community.ICommunityInnerServiceSMO;
import com.java110.intf.store.IStoreInnerServiceSMO;
@@ -27,6 +29,7 @@
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.slf4j.Logger;
@@ -72,12 +75,21 @@
Assert.hasKeyAndValue(reqJson, "msgCode", "鏈寘鍚仈绯荤數璇濋獙璇佺爜");
Assert.hasKeyAndValue(reqJson, "password", "鏈寘鍚瘑鐮�");
+ UserDto userDto = new UserDto();
+ userDto.setTel(reqJson.getString("link"));
+ userDto.setLevelCd(UserDto.LEVEL_CD_USER);
+ List<UserDto> userDtos = userInnerServiceSMOImpl.getUsers(userDto);
+
+ if (!ListUtil.isNull(userDtos)) {
+ throw new CmdException("鎵嬫満鍙峰凡瀛樺湪锛岃鐧婚檰");
+ }
+
SmsDto smsDto = new SmsDto();
smsDto.setTel(reqJson.getString("link"));
smsDto.setCode(reqJson.getString("msgCode"));
smsDto = smsInnerServiceSMOImpl.validateCode(smsDto);
- if (!smsDto.isSuccess() && "ON".equals(MappingCache.getValue(MappingConstant.SMS_DOMAIN,SendSmsFactory.SMS_SEND_SWITCH))) {
+ if (!smsDto.isSuccess() && "ON".equals(MappingCache.getValue(MappingConstant.SMS_DOMAIN, SendSmsFactory.SMS_SEND_SWITCH))) {
throw new IllegalArgumentException(smsDto.getMsg());
}
}
@@ -86,38 +98,90 @@
@Java110Transactional
public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
- OwnerAppUserDto ownerAppUserDto = BeanConvertUtil.covertBean(reqJson, OwnerAppUserDto.class);
- ownerAppUserDto.setStates(new String[]{"10000", "12000"});
-
- //鏄惁宸茬粡娉ㄥ唽杩�
- List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
-
- if (ownerAppUserDtos != null && ownerAppUserDtos.size() > 0) {
- throw new IllegalArgumentException("宸茬粡娉ㄥ唽杩囩敤鎴�");
- }
OwnerDto ownerDto = new OwnerDto();
ownerDto.setLink(reqJson.getString("link"));
-
List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
+ //璁剧疆榛樿瀵嗙爜
+ String userPassword = reqJson.getString("password");
+ userPassword = AuthenticationFactory.passwdMd5(userPassword);
+ String name = reqJson.getString("link");
+ if (!ListUtil.isNull(ownerDtos)) {
+ name = ownerDtos.get(0).getName();
+ }
+ //todo 娉ㄥ唽鐢ㄦ埛
+ UserPo userPo = new UserPo();
+ userPo.setAddress("鏃�");
+ userPo.setUserId(GenerateCodeFactory.getUserId());
+ userPo.setLevelCd(UserLevelConstant.USER_LEVEL_ORDINARY);
+ userPo.setName(name);
+ userPo.setTel(reqJson.getString("link"));
+ userPo.setPassword(userPassword);
+
+ int flag = userV1InnerServiceSMOImpl.saveUser(userPo);
+ if (flag < 1) {
+ throw new CmdException("娉ㄥ唽澶辫触");
+ }
+ //todo 淇濆瓨openId
+ String openId = reqJson.getString("openId");
+ if (!StringUtil.isEmpty(openId)) {
+ UserAttrPo userAttrPo = new UserAttrPo();
+ userAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId));
+ userAttrPo.setSpecCd(UserAttrDto.SPEC_OPEN_ID);
+ userAttrPo.setUserId(userPo.getUserId());
+ userAttrPo.setValue(openId);
+ flag = userAttrV1InnerServiceSMOImpl.saveUserAttr(userAttrPo);
+ if (flag < 1) {
+ throw new CmdException("娉ㄥ唽澶辫触");
+ }
+ }
+
+ //todo 鏍规嵁鎵嬫満鍙锋湭鍏宠仈鍒颁笟涓荤洿鎺ヨ繑鍥炴垚鍔燂紝鍚庣画閫氳繃璁よ瘉鎴垮眿鐨勬柟寮忔搷浣�
+ if (ListUtil.isNull(ownerDtos)) {
+ return;
+ }
String appId = cmdDataFlowContext.getReqHeaders().get("app-id");
+ String appType = "";
if (AppDto.WECHAT_OWNER_APP_ID.equals(appId)) { //鍏紬鍙�
- reqJson.put("appType", OwnerAppUserDto.APP_TYPE_WECHAT);
+ appType = OwnerAppUserDto.APP_TYPE_WECHAT;
} else if (AppDto.WECHAT_MINA_OWNER_APP_ID.equals(appId)) { //灏忕▼搴�
- reqJson.put("appType", OwnerAppUserDto.APP_TYPE_WECHAT_MINA);
+ appType = OwnerAppUserDto.APP_TYPE_WECHAT_MINA;
} else {//app
- reqJson.put("appType", OwnerAppUserDto.APP_TYPE_APP);
+ appType = OwnerAppUserDto.APP_TYPE_APP;
}
- reqJson.put("userId", GenerateCodeFactory.getUserId());
- if (reqJson.containsKey("openId")) {
- reqJson.put("openId", reqJson.getString("openId"));
- } else {
- reqJson.put("openId", "-1");
+
+ OwnerAppUserPo ownerAppUserPo = null;
+
+ List<CommunityDto> communityDtos = null;
+ for (OwnerDto tmpOwnerDto : ownerDtos) {
+ CommunityDto communityDto = new CommunityDto();
+ communityDto.setState("1100");
+ communityDto.setCommunityId(ownerDto.getCommunityId());
+ communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
+ if (communityDtos == null || communityDtos.size() < 1) {
+ continue;
+ }
+ communityDto = communityDtos.get(0);
+ ownerAppUserPo = new OwnerAppUserPo();
+ ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId));
+ ownerAppUserPo.setMemberId(tmpOwnerDto.getMemberId());
+ ownerAppUserPo.setCommunityId(communityDto.getCommunityId());
+ ownerAppUserPo.setCommunityName(communityDto.getName());
+ ownerAppUserPo.setAppUserName(tmpOwnerDto.getName());
+ ownerAppUserPo.setIdCard(tmpOwnerDto.getIdCard());
+ ownerAppUserPo.setLink(tmpOwnerDto.getLink());
+ ownerAppUserPo.setOpenId("-1");
+ ownerAppUserPo.setAppTypeCd("10010");
+ ownerAppUserPo.setState(OwnerAppUserDto.STATE_AUDIT_SUCCESS);
+ ownerAppUserPo.setRemark("娉ㄥ唽鑷姩鍏宠仈");
+ ownerAppUserPo.setUserId(userPo.getUserId());
+ ownerAppUserPo.setAppType(appType);
+ flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
+ if (flag < 1) {
+ throw new CmdException("娣诲姞鐢ㄦ埛涓氫富鍏崇郴澶辫触");
+ }
}
- //娣诲姞灏忓尯妤�
- addOwnerAppUser(reqJson, ownerDtos);
- registerUser(reqJson, ownerDtos);
cmdDataFlowContext.setResponseEntity(ResultVo.success());
}
@@ -155,32 +219,7 @@
return;
}
- OwnerAppUserPo ownerAppUserPo = null;
- for (OwnerDto ownerDto : ownerDtos) {
- CommunityDto communityDto = new CommunityDto();
- communityDto.setState("1100");
- communityDto.setCommunityId(ownerDto.getCommunityId());
- communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
- if (communityDtos == null || communityDtos.size() < 1) {
- continue;
- }
- tmpCommunityDto = communityDtos.get(0);
- ownerAppUserPo = BeanConvertUtil.covertBean(paramInJson, OwnerAppUserPo.class);
- //鐘舵�佺被鍨嬶紝10000 瀹℃牳涓紝12000 瀹℃牳鎴愬姛锛�13000 瀹℃牳澶辫触
- ownerAppUserPo.setState("12000");
- ownerAppUserPo.setAppTypeCd("10010");
- ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId));
- ownerAppUserPo.setMemberId(ownerDto.getMemberId());
- ownerAppUserPo.setCommunityName(tmpCommunityDto.getName());
- ownerAppUserPo.setCommunityId(tmpCommunityDto.getCommunityId());
- ownerAppUserPo.setAppUserName(ownerDto.getName());
- ownerAppUserPo.setIdCard(ownerDto.getIdCard());
- int flag = ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo);
- if (flag < 1) {
- throw new CmdException("娣诲姞鐢ㄦ埛涓氫富鍏崇郴澶辫触");
- }
- }
}
/**
@@ -188,44 +227,5 @@
*
* @param paramObj
*/
- public void registerUser(JSONObject paramObj, List<OwnerDto> ownerDtos) {
- if (paramObj.containsKey("email") && !StringUtil.isEmpty(paramObj.getString("email"))) {
- Assert.isEmail(paramObj, "email", "涓嶆槸鏈夋晥鐨勯偖绠辨牸寮�");
- }
-
- paramObj.put("levelCd", UserLevelConstant.USER_LEVEL_ORDINARY);
- //璁剧疆榛樿瀵嗙爜
- String userPassword = paramObj.getString("password");
- userPassword = AuthenticationFactory.passwdMd5(userPassword);
- paramObj.put("password", userPassword);
-
- String tel = paramObj.getString("link");
- String name = tel;
- if (ownerDtos != null && ownerDtos.size() > 0) {
- name = ownerDtos.get(0).getName();
- }
- UserPo userPo = BeanConvertUtil.covertBean(paramObj, UserPo.class);
- userPo.setName(name);
- userPo.setTel(tel);
- int flag = userV1InnerServiceSMOImpl.saveUser(userPo);
- if (flag < 1) {
- throw new CmdException("娉ㄥ唽澶辫触");
- }
-
- if (!paramObj.containsKey("openId") || "-1".equals(paramObj.getString("openId"))) {
- return;
- }
- JSONObject userAttrObj = new JSONObject();
- userAttrObj.put("attrId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId));
- userAttrObj.put("specCd", "100201911001");
- userAttrObj.put("value", paramObj.getString("openId"));
- UserAttrPo userAttrPo = BeanConvertUtil.covertBean(userAttrObj, UserAttrPo.class);
- userAttrPo.setUserId(userPo.getUserId());
- flag = userAttrV1InnerServiceSMOImpl.saveUserAttr(userAttrPo);
- if (flag < 1) {
- throw new CmdException("娉ㄥ唽澶辫触");
- }
-
- }
}
--
Gitblit v1.8.0