获取当前平台用户的团队信息

main
cheney 11 months ago
parent c5cd561a66
commit 1284780625
  1. 77
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java

@ -135,11 +135,13 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
@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){
return R.error("该用户已存在");
data.put("registerId", userAccount.getId());
data.put("openId", appletCallbackReq.getOpenId());
return R.ok().put("data",data);
}
Map<String, Object> data = new HashedMap<String, Object>();
if (appletCallbackReq.getPhone()!= null){
UserAccount userAccountByPhone = baseMapper.selectAccount(appletCallbackReq.getPhone(),appletCallbackReq.getPlatformId().toString());
@ -202,33 +204,49 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
addUserInfo(personalUserName, 7, appletCallbackReq.getOpenId(), appletCallbackReq.getPhone());
}
// 添加供应商/幼儿园信息
PlatformTeamAccount platformTeamAccount = new PlatformTeamAccount();
platformTeamAccount.setAccountId(accountId);
platformTeamAccount.setPlatformId(appletCallbackReq.getPlatformId());
baseMapper.insert(platformTeamAccount);
// 添加所属供应商/幼儿园分类,分类为空直接新增团队
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification();
platformTeamClassification.setIsTeam(1);
platformTeamClassification.setParentId(1);
platformTeamClassification.setLevel(1);
PlatformTeamAccount platformTeamAccount1 = baseMapper.selectOne(new QueryWrapper<PlatformTeamAccount>().
eq("account_id", accountId).
eq("platform_id", appletCallbackReq.getPlatformId()));
String teamName = "";
if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){
teamName = appletCallbackReq.getOrganizationName();
}else {
teamName = userName + "的团队";
}
Integer classificationId = null;
if (platformTeamAccount1 == null){
// 添加供应商/幼儿园信息
PlatformTeamAccount platformTeamAccount = new PlatformTeamAccount();
platformTeamAccount.setAccountId(accountId);
platformTeamAccount.setPlatformId(appletCallbackReq.getPlatformId());
baseMapper.insert(platformTeamAccount);
platformTeamClassification.setClassificationName(teamName);
int insert = platformTeamClassificationMapper.insert(platformTeamClassification);
if (insert > 0) {
PlatformTeam platformTeam = new PlatformTeam();
platformTeam.setManageId(platformTeamAccount.getManageId());
platformTeam.setClassificationId(platformTeamClassification.getId());
platformTeamMapper.insert(platformTeam);
// 添加所属供应商/幼儿园分类,分类为空直接新增团队
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification();
platformTeamClassification.setIsTeam(1);
platformTeamClassification.setParentId(1);
platformTeamClassification.setLevel(1);
if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){
teamName = appletCallbackReq.getOrganizationName();
}else {
teamName = userName + "的团队";
}
classificationId = platformTeamClassification.getId();
platformTeamClassification.setClassificationName(teamName);
int insert = platformTeamClassificationMapper.insert(platformTeamClassification);
if (insert > 0) {
PlatformTeam platformTeam = new PlatformTeam();
platformTeam.setManageId(platformTeamAccount.getManageId());
platformTeam.setClassificationId(platformTeamClassification.getId());
platformTeamMapper.insert(platformTeam);
}
}else {
List<PlatformTeam> platformTeamList = platformTeamMapper.selectList(new QueryWrapper<PlatformTeam>()
.eq("manage_id", platformTeamAccount1.getManageId()));
PlatformTeamClassification platformTeamClassification = platformTeamClassificationMapper.selectOne(new QueryWrapper<PlatformTeamClassification>().
eq("is_team", 1).
in("id", platformTeamList.stream().map(PlatformTeam::getClassificationId).collect(Collectors.toList())));
classificationId = platformTeamClassification.getId();
teamName = platformTeamClassification.getClassificationName();
}
data.put("teamId",platformTeamClassification.getId());
data.put("teamId",classificationId);
data.put("teamName",teamName);
}
@ -265,7 +283,12 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
public R getTeamsByPlatformId(String accountId, Integer platformId) {
List<TeamAccountResp> teamsByPlatformId = baseMapper.getTeamsByPlatformId(accountId,platformId);
teamsByPlatformId.forEach(teamAccountResp -> {
PlatformTeamClassification platformTeamClassification = platformTeamClassificationMapper.getParentInformationBasedOnChild(teamAccountResp.getClassificationId());
PlatformTeamClassification platformTeamClassification;
if (teamAccountResp.getIsTeam().equals("0")){
platformTeamClassification = platformTeamClassificationMapper.getParentInformationBasedOnChild(teamAccountResp.getClassificationId());
}else {
platformTeamClassification = platformTeamClassificationMapper.selectById(teamAccountResp.getClassificationId());
}
teamAccountResp.setPlatformTeamClassificationList(platformTeamClassification);
});
return R.ok().put("data", teamsByPlatformId);

Loading…
Cancel
Save