|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.huoran.nakadai.service.impl; |
|
|
|
package com.huoran.nakadai.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
@ -109,6 +110,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
if (platformId == 7) { // 如果个人账号被禁用,抛出异常
|
|
|
|
if (platformId == 7) { // 如果个人账号被禁用,抛出异常
|
|
|
|
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED); |
|
|
|
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
data.put("tips", "你已被组织禁止登录,现为您切回个人端"); |
|
|
|
continue; // 如果组织账号被禁用,跳过当前循环
|
|
|
|
continue; // 如果组织账号被禁用,跳过当前循环
|
|
|
|
} |
|
|
|
} |
|
|
|
if (platformId == 7) { // 如果是个人账号,保存信息并跳过当前循环
|
|
|
|
if (platformId == 7) { // 如果是个人账号,保存信息并跳过当前循环
|
|
|
@ -161,35 +163,50 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public R kindergartenWeChatApplication(AppletCallbackReq appletCallbackReq) { |
|
|
|
public R getUserAccountByPhone(AppletCallbackReq appletCallbackReq) { |
|
|
|
Map<String, Object> data = new HashedMap<String, Object>(); |
|
|
|
Map<String, Object> data = new HashedMap<String, Object>(); |
|
|
|
UserAccount userAccount = baseMapper.selectAccountByOpenId(appletCallbackReq.getOpenId(), appletCallbackReq.getPlatformId()); |
|
|
|
|
|
|
|
//该平台已经注册
|
|
|
|
|
|
|
|
if (userAccount != null){ |
|
|
|
|
|
|
|
data.put("registerId", userAccount.getId()); |
|
|
|
|
|
|
|
data.put("openId", appletCallbackReq.getOpenId()); |
|
|
|
|
|
|
|
return R.ok().put("data",data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (appletCallbackReq.getPhone()!= null){ |
|
|
|
ArrayList<String> arrayList = new ArrayList<>(); |
|
|
|
UserAccount userAccountByPhone = baseMapper.selectAccount(appletCallbackReq.getPhone(),appletCallbackReq.getPlatformId().toString()); |
|
|
|
arrayList.add("5"); |
|
|
|
|
|
|
|
arrayList.add("6"); |
|
|
|
|
|
|
|
for (String platformId : arrayList) { |
|
|
|
|
|
|
|
UserAccount userAccountByPhone = baseMapper.selectAccount(appletCallbackReq.getPhone(), platformId); |
|
|
|
//根据手机号查询用户
|
|
|
|
//根据手机号查询用户
|
|
|
|
if (userAccountByPhone != null){ |
|
|
|
if (userAccountByPhone != null){ |
|
|
|
if (!userAccountByPhone.getIsEnable()){ |
|
|
|
if (!userAccountByPhone.getIsEnable()){ |
|
|
|
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED); |
|
|
|
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (userAccountByPhone.getAppOpenId().equals("0")){ |
|
|
|
|
|
|
|
data.put("platformId", platformId); |
|
|
|
//邀请添加用户没有openid,登录更新openId
|
|
|
|
//邀请添加用户没有openid,登录更新openId
|
|
|
|
baseMapper.updateAccountOpenId(appletCallbackReq.getOpenId(),userAccountByPhone.getId()); |
|
|
|
baseMapper.updateAccountOpenId(appletCallbackReq.getOpenId(),userAccountByPhone.getId()); |
|
|
|
|
|
|
|
//查询个人端账号更新openid
|
|
|
|
|
|
|
|
UserAccount userAccount = baseMapper.selectAccount(appletCallbackReq.getPhone(), "7"); |
|
|
|
|
|
|
|
baseMapper.updateAccountOpenId(appletCallbackReq.getOpenId(),userAccount.getId()); |
|
|
|
//更新登录时间
|
|
|
|
//更新登录时间
|
|
|
|
baseMapper.updateUserInfo(userAccountByPhone.getUserId()); |
|
|
|
baseMapper.updateUserInfo(userAccountByPhone.getUserId()); |
|
|
|
data.put("token", JwtUtils.getJwtToken(userAccountByPhone.getId().toString(),getShopId(appletCallbackReq.getOpenId(),appletCallbackReq.getPlatformId()),appletCallbackReq.getPlatformId())); |
|
|
|
} |
|
|
|
|
|
|
|
data.put("token", JwtUtils.getJwtToken(userAccountByPhone.getId().toString(),getShopId(appletCallbackReq.getOpenId(),Integer.valueOf(platformId)),Integer.valueOf(platformId))); |
|
|
|
data.put("openId", appletCallbackReq.getOpenId()); |
|
|
|
data.put("openId", appletCallbackReq.getOpenId()); |
|
|
|
//TODO 团队信息待处理
|
|
|
|
|
|
|
|
// data.put("teamId",platformTeamClassification.getId());
|
|
|
|
|
|
|
|
// data.put("teamName",teamName);
|
|
|
|
|
|
|
|
return R.ok().put("data",data); |
|
|
|
return R.ok().put("data",data); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.ok(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public R kindergartenWeChatApplication(AppletCallbackReq appletCallbackReq) { |
|
|
|
|
|
|
|
Map<String, Object> data = new HashedMap<String, Object>(); |
|
|
|
|
|
|
|
UserAccount userAccount = baseMapper.selectAccountByOpenId(appletCallbackReq.getOpenId(), appletCallbackReq.getPlatformId()); |
|
|
|
|
|
|
|
//该平台已经注册
|
|
|
|
|
|
|
|
if (userAccount != null){ |
|
|
|
|
|
|
|
data.put("registerId", userAccount.getId()); |
|
|
|
|
|
|
|
data.put("openId", appletCallbackReq.getOpenId()); |
|
|
|
|
|
|
|
return R.ok().put("data",data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String randomNumber5 = cn.hutool.core.util.RandomUtil.randomNumbers(5); |
|
|
|
String randomNumber5 = cn.hutool.core.util.RandomUtil.randomNumbers(5); |
|
|
|
String randomNumber6 = cn.hutool.core.util.RandomUtil.randomNumbers(6); |
|
|
|
String randomNumber6 = cn.hutool.core.util.RandomUtil.randomNumbers(6); |
|
|
|
String randomNumber7 = cn.hutool.core.util.RandomUtil.randomNumbers(7); |
|
|
|
String randomNumber7 = cn.hutool.core.util.RandomUtil.randomNumbers(7); |
|
|
@ -213,9 +230,12 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 7: |
|
|
|
case 7: |
|
|
|
userName = "个人" + randomNumber7; |
|
|
|
userName = "用户" + randomNumber7; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (appletCallbackReq.getName()!=null){ |
|
|
|
|
|
|
|
userName = appletCallbackReq.getName(); |
|
|
|
|
|
|
|
} |
|
|
|
//企业认证获取个人平台手机号进行绑定
|
|
|
|
//企业认证获取个人平台手机号进行绑定
|
|
|
|
UserAccount account = baseMapper.selectAccountByOpenId(appletCallbackReq.getOpenId(), 7); |
|
|
|
UserAccount account = baseMapper.selectAccountByOpenId(appletCallbackReq.getOpenId(), 7); |
|
|
|
if (account != null) { |
|
|
|
if (account != null) { |
|
|
@ -228,7 +248,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
if (appletCallbackReq.getPlatformId() != 7) { |
|
|
|
if (appletCallbackReq.getPlatformId() != 7) { |
|
|
|
//添加个人端信息,判断是否重复,为空添加
|
|
|
|
//添加个人端信息,判断是否重复,为空添加
|
|
|
|
if (account == null){ |
|
|
|
if (account == null){ |
|
|
|
String personalUserName = "个人" + randomNumber7; |
|
|
|
String personalUserName = "用户" + randomNumber7; |
|
|
|
addUserInfo(personalUserName, 7, appletCallbackReq.getOpenId(), appletCallbackReq.getPhone()); |
|
|
|
addUserInfo(personalUserName, 7, appletCallbackReq.getOpenId(), appletCallbackReq.getPhone()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -290,7 +310,6 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
UserInfo userInfo = new UserInfo(); |
|
|
|
UserInfo userInfo = new UserInfo(); |
|
|
|
userInfo.setUserName(userName); |
|
|
|
userInfo.setUserName(userName); |
|
|
|
userInfo.setLoginNumber(1); |
|
|
|
userInfo.setLoginNumber(1); |
|
|
|
userInfo.setLastLoginTime(new Date()); |
|
|
|
|
|
|
|
staffMapper.addUserInfo(userInfo); |
|
|
|
staffMapper.addUserInfo(userInfo); |
|
|
|
|
|
|
|
|
|
|
|
// 创建并设置用户账户
|
|
|
|
// 创建并设置用户账户
|
|
|
@ -373,7 +392,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
//查询邀请用户是否存在账号
|
|
|
|
//查询邀请用户是否存在账号
|
|
|
|
UserAccount userAccount = baseMapper.selectAccount(inviteJoinInfo.getPhone(),inviteJoinInfo.getPlatformId().toString()); |
|
|
|
UserAccount userAccount = baseMapper.selectAccount(inviteJoinInfo.getPhone(),inviteJoinInfo.getPlatformId().toString()); |
|
|
|
|
|
|
|
|
|
|
|
Integer manageId ; |
|
|
|
Integer manageId = 0; |
|
|
|
//邀请人为成员且账号存在,则直接拉入该团队,不可重复拉入
|
|
|
|
//邀请人为成员且账号存在,则直接拉入该团队,不可重复拉入
|
|
|
|
if (userAccount != null) { |
|
|
|
if (userAccount != null) { |
|
|
|
//无法加入自己的团队
|
|
|
|
//无法加入自己的团队
|
|
|
@ -384,14 +403,14 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
//查询合伙人账号
|
|
|
|
//查询合伙人账号
|
|
|
|
PlatformTeamAccount platformTeamAccount = baseMapper.selectOne(new QueryWrapper<PlatformTeamAccount>(). |
|
|
|
PlatformTeamAccount platformTeamAccount = baseMapper.selectOne(new QueryWrapper<PlatformTeamAccount>(). |
|
|
|
eq("account_id", userAccount.getId())); |
|
|
|
eq("account_id", userAccount.getId())); |
|
|
|
manageId = platformTeamAccount.getManageId(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//被邀请人有合伙人账号,判断是否已经存在当前团队中
|
|
|
|
|
|
|
|
|
|
|
|
//被邀请人有团队账号,判断是否已经存在当前团队中
|
|
|
|
if (ObjectUtil.isNotNull(platformTeamAccount)){ |
|
|
|
if (ObjectUtil.isNotNull(platformTeamAccount)){ |
|
|
|
|
|
|
|
manageId = platformTeamAccount.getManageId(); |
|
|
|
List<PlatformTeam> platformTeamList = platformTeamMapper.selectList(new QueryWrapper<PlatformTeam>(). |
|
|
|
List<PlatformTeam> platformTeamList = platformTeamMapper.selectList(new QueryWrapper<PlatformTeam>(). |
|
|
|
eq("manage_id", platformTeamAccount.getManageId())); |
|
|
|
eq("manage_id", platformTeamAccount.getManageId())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询团队下的成员是否存在团队中
|
|
|
|
//查询团队下的成员是否存在团队中
|
|
|
|
List<PlatformTeamClassification> teamMeb = platformTeamClassificationMapper.selectList(new QueryWrapper<PlatformTeamClassification>(). |
|
|
|
List<PlatformTeamClassification> teamMeb = platformTeamClassificationMapper.selectList(new QueryWrapper<PlatformTeamClassification>(). |
|
|
|
eq("parent_id", inviteJoinInfo.getClassificationId())); |
|
|
|
eq("parent_id", inviteJoinInfo.getClassificationId())); |
|
|
@ -405,6 +424,51 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//不存在加入当前组织
|
|
|
|
|
|
|
|
PlatformTeamClassification platformTeamAdmin = platformTeamClassificationMapper.selectById(inviteJoinInfo.getClassificationId()); |
|
|
|
|
|
|
|
//新增团队成员
|
|
|
|
|
|
|
|
PlatformTeamClassification platformTeamMeb = new PlatformTeamClassification(); |
|
|
|
|
|
|
|
platformTeamMeb.setIsTeam(0); |
|
|
|
|
|
|
|
platformTeamMeb.setParentId(inviteJoinInfo.getClassificationId()); |
|
|
|
|
|
|
|
platformTeamMeb.setLevel(platformTeamAdmin.getLevel() + 1); |
|
|
|
|
|
|
|
platformTeamMeb.setClassificationName(platformTeamAdmin.getClassificationName()); |
|
|
|
|
|
|
|
int insert = platformTeamClassificationMapper.insert(platformTeamMeb); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//团队分类
|
|
|
|
|
|
|
|
if (insert > 0) { |
|
|
|
|
|
|
|
PlatformTeam platformTeam = new PlatformTeam(); |
|
|
|
|
|
|
|
platformTeam.setManageId(platformTeamAccount.getManageId()); |
|
|
|
|
|
|
|
platformTeam.setClassificationId(platformTeamMeb.getId()); |
|
|
|
|
|
|
|
platformTeamMapper.insert(platformTeam); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return insert > 0 ? R.ok() : R.error(); |
|
|
|
|
|
|
|
//拉入当前团队
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
//添加团队管理账号
|
|
|
|
|
|
|
|
PlatformTeamAccount platformTeamAccount1 = new PlatformTeamAccount(); |
|
|
|
|
|
|
|
platformTeamAccount1.setAccountId(userAccount.getId()); |
|
|
|
|
|
|
|
platformTeamAccount1.setPlatformId(inviteJoinInfo.getPlatformId()); |
|
|
|
|
|
|
|
String username = partnerAccountMapper.selectUsername(inviteJoinInfo.getAccountId()); |
|
|
|
|
|
|
|
platformTeamAccount1.setInvitationAccount(username); |
|
|
|
|
|
|
|
baseMapper.insert(platformTeamAccount1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PlatformTeamClassification platformTeamAdmin = platformTeamClassificationMapper.selectById(inviteJoinInfo.getClassificationId()); |
|
|
|
|
|
|
|
//新增团队成员
|
|
|
|
|
|
|
|
PlatformTeamClassification platformTeamMeb = new PlatformTeamClassification(); |
|
|
|
|
|
|
|
platformTeamMeb.setIsTeam(0); |
|
|
|
|
|
|
|
platformTeamMeb.setParentId(inviteJoinInfo.getClassificationId()); |
|
|
|
|
|
|
|
platformTeamMeb.setLevel(platformTeamAdmin.getLevel() + 1); |
|
|
|
|
|
|
|
platformTeamMeb.setClassificationName(platformTeamAdmin.getClassificationName()); |
|
|
|
|
|
|
|
int insert = platformTeamClassificationMapper.insert(platformTeamMeb); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//团队分类
|
|
|
|
|
|
|
|
if (insert > 0) { |
|
|
|
|
|
|
|
PlatformTeam platformTeam = new PlatformTeam(); |
|
|
|
|
|
|
|
platformTeam.setManageId(platformTeamAccount1.getManageId()); |
|
|
|
|
|
|
|
platformTeam.setClassificationId(platformTeamMeb.getId()); |
|
|
|
|
|
|
|
platformTeamMapper.insert(platformTeam); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return insert > 0 ? R.ok() : R.error(); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
//不存在创建账号,拉入组织
|
|
|
|
//不存在创建账号,拉入组织
|
|
|
@ -412,6 +476,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
appletCallbackReq.setPlatformId(inviteJoinInfo.getPlatformId()); |
|
|
|
appletCallbackReq.setPlatformId(inviteJoinInfo.getPlatformId()); |
|
|
|
appletCallbackReq.setPhone(inviteJoinInfo.getPhone()); |
|
|
|
appletCallbackReq.setPhone(inviteJoinInfo.getPhone()); |
|
|
|
appletCallbackReq.setOpenId("0"); |
|
|
|
appletCallbackReq.setOpenId("0"); |
|
|
|
|
|
|
|
appletCallbackReq.setName(inviteJoinInfo.getName()); |
|
|
|
R r = kindergartenWeChatApplication(appletCallbackReq); |
|
|
|
R r = kindergartenWeChatApplication(appletCallbackReq); |
|
|
|
Map<String, Object> data =(Map<String, Object>) r.get("data"); |
|
|
|
Map<String, Object> data =(Map<String, Object>) r.get("data"); |
|
|
|
Integer registerId =(Integer) data.get("registerId"); |
|
|
|
Integer registerId =(Integer) data.get("registerId"); |
|
|
|