|
|
@@ -143,6 +143,13 @@ public class WxH5MpScrmController {
|
|
|
userUpdate.setUpdateTime(new DateTime());
|
|
|
userUpdate.setNickName(wxMpUser.getNickname());
|
|
|
userUpdate.setAvatar(wxMpUser.getHeadImgUrl());
|
|
|
+ // 老用户 - 检查并添加appId(不重复添加)
|
|
|
+ if (StringUtils.isNotEmpty(param.getAppId())) {
|
|
|
+ String updatedAppId = addAppIdIfNotExists(user.getAppId(), param.getAppId());
|
|
|
+ if (!updatedAppId.equals(user.getAppId())) {
|
|
|
+ userUpdate.setAppId(updatedAppId);
|
|
|
+ }
|
|
|
+ }
|
|
|
userService.updateFsUser(userUpdate);
|
|
|
return userUpdate;
|
|
|
} else {
|
|
|
@@ -155,6 +162,10 @@ public class WxH5MpScrmController {
|
|
|
// newUser.setCompanyId(company.getCompanyId());
|
|
|
// newUser.setCompanyUserId(companyUser.getUserId());
|
|
|
newUser.setUnionId(wxMpUser.getUnionId());
|
|
|
+ // 新用户 - 添加 appId
|
|
|
+ if (StringUtils.isNotEmpty(param.getAppId())) {
|
|
|
+ newUser.setAppId(param.getAppId());
|
|
|
+ }
|
|
|
newUser.setCreateTime(new Date());
|
|
|
newUser.setStatus(company != null && company.getFsUserIsDefaultBlack() == 1 ? 0 : 1);
|
|
|
userService.insertFsUser(newUser);
|
|
|
@@ -163,4 +174,26 @@ public class WxH5MpScrmController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加appId到用户的appId列表中(如果不存在)
|
|
|
+ * @param currentAppIds 当前用户已有的appId列表(逗号分隔)
|
|
|
+ * @param newAppId 新的appId
|
|
|
+ * @return 更新后的appId列表
|
|
|
+ */
|
|
|
+ private String addAppIdIfNotExists(String currentAppIds, String newAppId) {
|
|
|
+ if (StringUtils.isEmpty(newAppId)) {
|
|
|
+ return currentAppIds == null ? "" : currentAppIds;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(currentAppIds)) {
|
|
|
+ return newAppId;
|
|
|
+ }
|
|
|
+ String[] appIdArray = currentAppIds.split(",");
|
|
|
+ for (String appId : appIdArray) {
|
|
|
+ if (appId.trim().equals(newAppId.trim())) {
|
|
|
+ return currentAppIds;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return currentAppIds + "," + newAppId;
|
|
|
+ }
|
|
|
+
|
|
|
}
|