|
|
@ -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; |
|
|
@ -161,35 +162,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); |
|
|
|
} |
|
|
|
} |
|
|
|
//邀请添加用户没有openid,登录更新openId
|
|
|
|
if (userAccountByPhone.getAppOpenId().equals("0")){ |
|
|
|
baseMapper.updateAccountOpenId(appletCallbackReq.getOpenId(),userAccountByPhone.getId()); |
|
|
|
data.put("platformId", platformId); |
|
|
|
//更新登录时间
|
|
|
|
//邀请添加用户没有openid,登录更新openId
|
|
|
|
baseMapper.updateUserInfo(userAccountByPhone.getUserId()); |
|
|
|
baseMapper.updateAccountOpenId(appletCallbackReq.getOpenId(),userAccountByPhone.getId()); |
|
|
|
data.put("token", JwtUtils.getJwtToken(userAccountByPhone.getId().toString(),getShopId(appletCallbackReq.getOpenId(),appletCallbackReq.getPlatformId()),appletCallbackReq.getPlatformId())); |
|
|
|
//查询个人端账号更新openid
|
|
|
|
|
|
|
|
UserAccount userAccount = baseMapper.selectAccount(appletCallbackReq.getPhone(), "7"); |
|
|
|
|
|
|
|
baseMapper.updateAccountOpenId(appletCallbackReq.getOpenId(),userAccount.getId()); |
|
|
|
|
|
|
|
//更新登录时间
|
|
|
|
|
|
|
|
baseMapper.updateUserInfo(userAccountByPhone.getUserId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
@ -216,6 +232,9 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco |
|
|
|
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) { |
|
|
@ -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"); |
|
|
|