diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java index d9d6ed3..a8cef32 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java @@ -135,11 +135,13 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl data = new HashedMap(); 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 data = new HashedMap(); if (appletCallbackReq.getPhone()!= null){ UserAccount userAccountByPhone = baseMapper.selectAccount(appletCallbackReq.getPhone(),appletCallbackReq.getPlatformId().toString()); @@ -202,33 +204,49 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl(). + 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 platformTeamList = platformTeamMapper.selectList(new QueryWrapper() + .eq("manage_id", platformTeamAccount1.getManageId())); + + PlatformTeamClassification platformTeamClassification = platformTeamClassificationMapper.selectOne(new QueryWrapper(). + 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 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);