diff --git a/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java b/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java index 3f80a75..250693a 100644 --- a/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java +++ b/common/src/main/java/com/huoran/common/exception/ExceptionEnum.java @@ -59,7 +59,7 @@ public enum ExceptionEnum { JOB_ID_NOT_EXIST(10021, "工号不存在"), DATA_PLATFORM_ACCOUNT_AVALIABLE_FAIL(10022, "当前用户所在的院校在数据平台的可用账号数量不足,是否继续!"), INVITATION_CODE_EXPIRED(10023, "邀请码已失效"), - USER_ALREADY_EXISTS_GROUP(10024, "用户已存在该团队"), + USER_ALREADY_EXISTS_GROUP(10024, "用户已存在该组织"), CANT_JOIN_TEAM(10025, "无法加入自己的团队"), CANNOT_ADDED_REPEATEDLY(10026, "该用户已经是团队管理员,无法重复添加!"), DEFAULT_ROLE_NOTEXIST(10027, "默认角色不存在"), diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java index 9649304..4fb6eb1 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java @@ -82,7 +82,6 @@ public class PlatformTeamAccountController { } - // @PostMapping("/platformTeamAccountMergeList") // @ApiOperation(value = "平台团队账号列表--合并数据查询(以账号为维度查询合并-后台调用)", response = PlatformTeamAccountResp.class) // public R partnerAccountMergeList(@RequestBody @Valid PlatformTeamAccountListReq req) { @@ -240,5 +239,10 @@ public class PlatformTeamAccountController { return R.ok().put("teamInfo",teamInfo); } + @PostMapping("/inviteJoinOrganization") + @ApiOperation(value = "邀请加入不同平台组织") + public R inviteJoinOrganization(@RequestBody @Valid InviteJoinInfo inviteJoinInfo) { + return platformTeamAccountService.inviteJoinOrganization(inviteJoinInfo); + } } diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java b/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java new file mode 100644 index 0000000..43bfc4a --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java @@ -0,0 +1,24 @@ +package com.huoran.nakadai.entity.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class InviteJoinInfo { + @ApiModelProperty(value = "邀请人账号id") + private String accountId; + + @ApiModelProperty(value = "手机验证码") + private String code; + + @ApiModelProperty(value = "电话") + private String phone; + + @ApiModelProperty(value = "platformId") + private Integer platformId; + + @ApiModelProperty(value = "分类id===团队id") + private Integer classificationId; + + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerAccountMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerAccountMapper.java index 2e43b14..5090fe1 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerAccountMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerAccountMapper.java @@ -7,6 +7,7 @@ import com.huoran.nakadai.entity.PartnerAccount; import com.huoran.nakadai.entity.PartnerTeam; import com.huoran.nakadai.entity.req.PartnerAccountListReq; import com.huoran.nakadai.entity.res.PartnerAccountResp; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.ArrayList; @@ -20,6 +21,7 @@ import java.util.List; * @author chen * @since 2022-05-18 */ +@Mapper public interface PartnerAccountMapper extends BaseMapper { IPage pagePartnerAccountList(Page page, PartnerAccountListReq req); diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java index 54cf0b6..d67d9ba 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java @@ -28,7 +28,7 @@ public interface PlatformTeamAccountMapper extends BaseMapper platformTeamAccountMergeList(Page page, PlatformTeamAccountListReq req); - Integer selectAccount(@Param("phone") String phone,@Param("platformId") String platformId); + UserAccount selectAccount(@Param("phone") String phone,@Param("platformId") String platformId); UserAccount selectAccountByOpenId(@Param("openid") String openid,@Param("platformId") Integer platform); @@ -39,4 +39,8 @@ public interface PlatformTeamAccountMapper extends BaseMapper pagePlatformTeamAccountList(Page page, PlatformTeamAccountListReq req); void updateUserInfo(@Param("userId")Integer userId); + + void updateAccountOpenId(@Param("openid")String openid,@Param("accountId")Integer accountId); + + void updateAccountPhone(@Param("phone")String phone, @Param("accountId")Integer accountId); } diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml index 492dd7f..acba710 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml @@ -6,6 +6,16 @@ SET last_login_time = now(), login_number = login_number + 1 WHERE user_id = #{userId} + + UPDATE hr_user_account + SET app_open_id = #{openid} + WHERE id = #{accountId} + + + UPDATE hr_user_account + SET phone = #{phone} + WHERE id = #{accountId} + - + SELECT * from hr_user_account WHERE is_del = 0 and platform_id = #{platformId} and phone = #{phone} diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java b/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java index 13df417..c4a917c 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java @@ -5,6 +5,7 @@ import com.huoran.nakadai.entity.PlatformTeamAccount; import com.baomidou.mybatisplus.extension.service.IService; import com.huoran.nakadai.entity.req.AccountRegisterReq; import com.huoran.nakadai.entity.req.AppletCallbackReq; +import com.huoran.nakadai.entity.req.InviteJoinInfo; import com.huoran.nakadai.entity.req.PlatformTeamAccountListReq; import javax.servlet.http.HttpServletResponse; @@ -31,4 +32,6 @@ public interface PlatformTeamAccountService extends IService redisTemplate; + + @Autowired + private PartnerAccountMapper partnerAccountMapper; + @Autowired private PlatformTeamClassificationMapper platformTeamClassificationMapper; @@ -99,13 +108,36 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl data = new HashedMap(); String randomNumbers = cn.hutool.core.util.RandomUtil.randomNumbers(6); Integer accountId ; @@ -187,6 +231,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl(). + eq("account_id", userAccount.getId())); + manageId = platformTeamAccount.getManageId(); + + //被邀请人有合伙人账号,判断是否已经存在当前团队中 + if (ObjectUtil.isNotNull(platformTeamAccount)){ + List platformTeamList = platformTeamMapper.selectList(new QueryWrapper(). + eq("manage_id", platformTeamAccount.getManageId())); + + + //查询团队下的成员是否存在团队中 + List teamMeb = platformTeamClassificationMapper.selectList(new QueryWrapper(). + eq("parent_id", inviteJoinInfo.getClassificationId())); + + for (PlatformTeam platformTeam : platformTeamList) { + for (PlatformTeamClassification platformTeamClassification : teamMeb) { + if (platformTeam!=null&&platformTeamClassification!=null){ + if (platformTeam.getClassificationId().equals(platformTeamClassification.getId())){ + throw new CustomException(ExceptionEnum.USER_ALREADY_EXISTS_GROUP); + } + } + } + } + } + }else { + //不存在创建账号,拉入组织 + AppletCallbackReq appletCallbackReq = new AppletCallbackReq(); + appletCallbackReq.setPlatformId(inviteJoinInfo.getPlatformId()); + appletCallbackReq.setPhone(inviteJoinInfo.getPhone()); + appletCallbackReq.setOpenId("0"); + R r = kindergartenWeChatApplication(appletCallbackReq); + Map data =(Map) r.get("data"); + Integer registerId =(Integer) data.get("registerId"); + //添加团队管理账号 + PlatformTeamAccount platformTeamAccount = new PlatformTeamAccount(); + platformTeamAccount.setAccountId(registerId); + platformTeamAccount.setPlatformId(inviteJoinInfo.getPlatformId()); + String username = partnerAccountMapper.selectUsername(inviteJoinInfo.getAccountId()); + platformTeamAccount.setInvitationAccount(username); + baseMapper.insert(platformTeamAccount); + + manageId = platformTeamAccount.getManageId(); + } + + 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(manageId); + platformTeam.setClassificationId(platformTeamMeb.getId()); + platformTeamMapper.insert(platformTeam); + } + return insert > 0 ? R.ok() : R.error(); + + } + throw new CustomException(ExceptionEnum.CODE_ERROR); + } }