Merge remote-tracking branch 'origin/main' into main

main
rong.liu 11 months ago
commit 884c4f6172
  1. 2
      common/src/main/java/com/huoran/common/exception/ExceptionEnum.java
  2. 6
      nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java
  3. 24
      nakadai/src/main/java/com/huoran/nakadai/entity/req/InviteJoinInfo.java
  4. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/PartnerAccountMapper.java
  5. 6
      nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java
  6. 14
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml
  7. 3
      nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamAccountService.java
  8. 148
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java

@ -59,7 +59,7 @@ public enum ExceptionEnum {
JOB_ID_NOT_EXIST(10021, "工号不存在"), JOB_ID_NOT_EXIST(10021, "工号不存在"),
DATA_PLATFORM_ACCOUNT_AVALIABLE_FAIL(10022, "当前用户所在的院校在数据平台的可用账号数量不足,是否继续!"), DATA_PLATFORM_ACCOUNT_AVALIABLE_FAIL(10022, "当前用户所在的院校在数据平台的可用账号数量不足,是否继续!"),
INVITATION_CODE_EXPIRED(10023, "邀请码已失效"), INVITATION_CODE_EXPIRED(10023, "邀请码已失效"),
USER_ALREADY_EXISTS_GROUP(10024, "用户已存在该团队"), USER_ALREADY_EXISTS_GROUP(10024, "用户已存在该组织"),
CANT_JOIN_TEAM(10025, "无法加入自己的团队"), CANT_JOIN_TEAM(10025, "无法加入自己的团队"),
CANNOT_ADDED_REPEATEDLY(10026, "该用户已经是团队管理员,无法重复添加!"), CANNOT_ADDED_REPEATEDLY(10026, "该用户已经是团队管理员,无法重复添加!"),
DEFAULT_ROLE_NOTEXIST(10027, "默认角色不存在"), DEFAULT_ROLE_NOTEXIST(10027, "默认角色不存在"),

@ -82,7 +82,6 @@ public class PlatformTeamAccountController {
} }
// @PostMapping("/platformTeamAccountMergeList") // @PostMapping("/platformTeamAccountMergeList")
// @ApiOperation(value = "平台团队账号列表--合并数据查询(以账号为维度查询合并-后台调用)", response = PlatformTeamAccountResp.class) // @ApiOperation(value = "平台团队账号列表--合并数据查询(以账号为维度查询合并-后台调用)", response = PlatformTeamAccountResp.class)
// public R partnerAccountMergeList(@RequestBody @Valid PlatformTeamAccountListReq req) { // public R partnerAccountMergeList(@RequestBody @Valid PlatformTeamAccountListReq req) {
@ -240,5 +239,10 @@ public class PlatformTeamAccountController {
return R.ok().put("teamInfo",teamInfo); return R.ok().put("teamInfo",teamInfo);
} }
@PostMapping("/inviteJoinOrganization")
@ApiOperation(value = "邀请加入不同平台组织")
public R inviteJoinOrganization(@RequestBody @Valid InviteJoinInfo inviteJoinInfo) {
return platformTeamAccountService.inviteJoinOrganization(inviteJoinInfo);
}
} }

@ -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;
}

@ -7,6 +7,7 @@ import com.huoran.nakadai.entity.PartnerAccount;
import com.huoran.nakadai.entity.PartnerTeam; import com.huoran.nakadai.entity.PartnerTeam;
import com.huoran.nakadai.entity.req.PartnerAccountListReq; import com.huoran.nakadai.entity.req.PartnerAccountListReq;
import com.huoran.nakadai.entity.res.PartnerAccountResp; import com.huoran.nakadai.entity.res.PartnerAccountResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.ArrayList; import java.util.ArrayList;
@ -20,6 +21,7 @@ import java.util.List;
* @author chen * @author chen
* @since 2022-05-18 * @since 2022-05-18
*/ */
@Mapper
public interface PartnerAccountMapper extends BaseMapper<PartnerAccount> { public interface PartnerAccountMapper extends BaseMapper<PartnerAccount> {
IPage<PartnerAccountResp> pagePartnerAccountList(Page<PartnerAccountResp> page, PartnerAccountListReq req); IPage<PartnerAccountResp> pagePartnerAccountList(Page<PartnerAccountResp> page, PartnerAccountListReq req);

@ -28,7 +28,7 @@ public interface PlatformTeamAccountMapper extends BaseMapper<PlatformTeamAccoun
IPage<PlatformTeamAccountResp> platformTeamAccountMergeList(Page<PlatformTeamAccountResp> page, PlatformTeamAccountListReq req); IPage<PlatformTeamAccountResp> platformTeamAccountMergeList(Page<PlatformTeamAccountResp> 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); UserAccount selectAccountByOpenId(@Param("openid") String openid,@Param("platformId") Integer platform);
@ -39,4 +39,8 @@ public interface PlatformTeamAccountMapper extends BaseMapper<PlatformTeamAccoun
IPage<PlatformTeamAccountResp> pagePlatformTeamAccountList(Page<PlatformTeamAccountResp> page, PlatformTeamAccountListReq req); IPage<PlatformTeamAccountResp> pagePlatformTeamAccountList(Page<PlatformTeamAccountResp> page, PlatformTeamAccountListReq req);
void updateUserInfo(@Param("userId")Integer userId); 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);
} }

@ -6,6 +6,16 @@
SET last_login_time = now(), login_number = login_number + 1 SET last_login_time = now(), login_number = login_number + 1
WHERE user_id = #{userId} WHERE user_id = #{userId}
</update> </update>
<update id="updateAccountOpenId">
UPDATE hr_user_account
SET app_open_id = #{openid}
WHERE id = #{accountId}
</update>
<update id="updateAccountPhone">
UPDATE hr_user_account
SET phone = #{phone}
WHERE id = #{accountId}
</update>
<select id="platformTeamAccountMergeList" <select id="platformTeamAccountMergeList"
resultType="com.huoran.nakadai.entity.res.PlatformTeamAccountResp"> resultType="com.huoran.nakadai.entity.res.PlatformTeamAccountResp">
@ -41,8 +51,8 @@
ORDER BY ORDER BY
hpa.manage_id DESC hpa.manage_id DESC
</select> </select>
<select id="selectAccount" resultType="java.lang.Integer"> <select id="selectAccount" resultType="com.huoran.nakadai.entity.UserAccount">
SELECT id SELECT *
from hr_user_account from hr_user_account
WHERE is_del = 0 and platform_id = #{platformId} and phone = #{phone} WHERE is_del = 0 and platform_id = #{platformId} and phone = #{phone}
</select> </select>

@ -5,6 +5,7 @@ import com.huoran.nakadai.entity.PlatformTeamAccount;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.huoran.nakadai.entity.req.AccountRegisterReq; import com.huoran.nakadai.entity.req.AccountRegisterReq;
import com.huoran.nakadai.entity.req.AppletCallbackReq; import com.huoran.nakadai.entity.req.AppletCallbackReq;
import com.huoran.nakadai.entity.req.InviteJoinInfo;
import com.huoran.nakadai.entity.req.PlatformTeamAccountListReq; import com.huoran.nakadai.entity.req.PlatformTeamAccountListReq;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -31,4 +32,6 @@ public interface PlatformTeamAccountService extends IService<PlatformTeamAccount
R getTeamsByPlatformId(String accountId, Integer platformId); R getTeamsByPlatformId(String accountId, Integer platformId);
R pagePlatformTeamAccountList(PlatformTeamAccountListReq req); R pagePlatformTeamAccountList(PlatformTeamAccountListReq req);
R inviteJoinOrganization(InviteJoinInfo inviteJoinInfo);
} }

@ -2,27 +2,29 @@ package com.huoran.nakadai.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huoran.common.constant.SMSTemplate;
import com.huoran.common.exception.CustomException; import com.huoran.common.exception.CustomException;
import com.huoran.common.exception.ExceptionEnum; import com.huoran.common.exception.ExceptionEnum;
import com.huoran.common.response.R; import com.huoran.common.response.R;
import com.huoran.common.utils.HttpClientUtils; import com.huoran.common.utils.HttpClientUtils;
import com.huoran.common.utils.JwtUtils; import com.huoran.common.utils.JwtUtils;
import com.huoran.common.utils.MD5; import com.huoran.common.utils.MD5;
import com.huoran.common.utils.TokenUtils;
import com.huoran.nakadai.entity.*; import com.huoran.nakadai.entity.*;
import com.huoran.nakadai.entity.req.AccountRegisterReq; import com.huoran.nakadai.entity.req.AccountRegisterReq;
import com.huoran.nakadai.entity.req.AppletCallbackReq; import com.huoran.nakadai.entity.req.AppletCallbackReq;
import com.huoran.nakadai.entity.req.InviteJoinInfo;
import com.huoran.nakadai.entity.req.PlatformTeamAccountListReq; import com.huoran.nakadai.entity.req.PlatformTeamAccountListReq;
import com.huoran.nakadai.entity.res.PartnerAccountResp; import com.huoran.nakadai.entity.res.PartnerAccountResp;
import com.huoran.nakadai.entity.res.PlatformTeamAccountResp; import com.huoran.nakadai.entity.res.PlatformTeamAccountResp;
import com.huoran.nakadai.entity.res.TeamAccountResp; import com.huoran.nakadai.entity.res.TeamAccountResp;
import com.huoran.nakadai.mapper.HrStaffMapper; import com.huoran.nakadai.mapper.*;
import com.huoran.nakadai.mapper.PlatformTeamAccountMapper;
import com.huoran.nakadai.mapper.PlatformTeamClassificationMapper;
import com.huoran.nakadai.mapper.PlatformTeamMapper;
import com.huoran.nakadai.service.PlatformTeamAccountService; import com.huoran.nakadai.service.PlatformTeamAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huoran.nakadai.utils.QrCodeUtil; import com.huoran.nakadai.utils.QrCodeUtil;
@ -31,6 +33,7 @@ import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -51,6 +54,12 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
@Autowired @Autowired
private HrStaffMapper staffMapper; private HrStaffMapper staffMapper;
@Autowired
private RedisTemplate<String, String> redisTemplate;
@Autowired
private PartnerAccountMapper partnerAccountMapper;
@Autowired @Autowired
private PlatformTeamClassificationMapper platformTeamClassificationMapper; private PlatformTeamClassificationMapper platformTeamClassificationMapper;
@ -99,13 +108,36 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
if (!userAccount.getIsEnable()){ if (!userAccount.getIsEnable()){
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED); throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED);
} }
if (userAccount.getPhone()== null){
//登录更新手机号
baseMapper.updateAccountPhone(appletCallbackReq.getPhone(),userAccount.getId());
}
//更新登录时间 //更新登录时间
baseMapper.updateUserInfo(userAccount.getUserId()); baseMapper.updateUserInfo(userAccount.getUserId());
data.put("state", "login"); data.put("state", "login");
data.put("teamName", userAccount.getAccount() + "的团队");
data.put("platformId", platformId); data.put("platformId", platformId);
data.put("token", JwtUtils.getJwtToken(userAccount.getId().toString())); data.put("token", JwtUtils.getJwtToken(userAccount.getId().toString()));
userExists = true; // 如果用户存在,将标志位设为true userExists = true; // 如果用户存在,将标志位设为true
break; // 如果找到用户,就不需要继续查找 break; // 如果找到用户,就不需要继续查找
}else {
//根据手机号查询用户
UserAccount userAccountByPhone = baseMapper.selectAccount(appletCallbackReq.getPhone(),platformId.toString());
if (userAccountByPhone!= null){
if (!userAccount.getIsEnable()){
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED);
}
//邀请添加用户没有openid,登录更新openId
baseMapper.updateAccountOpenId(openid,userAccountByPhone.getId());
//更新登录时间
baseMapper.updateUserInfo(userAccount.getUserId());
data.put("state", "login");
data.put("teamName", userAccount.getAccount() + "的团队");
data.put("platformId", platformId);
data.put("token", JwtUtils.getJwtToken(userAccount.getId().toString()));
userExists = true; // 如果用户存在,将标志位设为true
break; // 如果找到用户,就不需要继续查找
}
} }
} }
@ -122,6 +154,18 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
@Override @Override
public R kindergartenWeChatApplication(AppletCallbackReq appletCallbackReq) { public R kindergartenWeChatApplication(AppletCallbackReq appletCallbackReq) {
UserAccount userAccount = baseMapper.selectAccountByOpenId(appletCallbackReq.getOpenId(), appletCallbackReq.getPlatformId());
if (userAccount != null){
return R.error("该用户已存在");
}
if (appletCallbackReq.getPhone()!= null){
UserAccount userAccountByPhone = baseMapper.selectAccount(appletCallbackReq.getPhone(),appletCallbackReq.getPlatformId().toString());
//根据手机号查询用户
if (userAccountByPhone != null){
return R.error("该用户已存在");
}
}
Map<String, Object> data = new HashedMap<String, Object>(); Map<String, Object> data = new HashedMap<String, Object>();
String randomNumbers = cn.hutool.core.util.RandomUtil.randomNumbers(6); String randomNumbers = cn.hutool.core.util.RandomUtil.randomNumbers(6);
Integer accountId ; Integer accountId ;
@ -187,6 +231,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
// 注册成功返回token // 注册成功返回token
data.put("token", JwtUtils.getJwtToken(accountId.toString())); data.put("token", JwtUtils.getJwtToken(accountId.toString()));
data.put("registerId", accountId);
data.put("openId", appletCallbackReq.getOpenId()); data.put("openId", appletCallbackReq.getOpenId());
return R.ok().put("data",data); return R.ok().put("data",data);
} }
@ -246,4 +291,99 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
String result = HttpClientUtils.doPost(REQUEST_URL, requestUrlParam); String result = HttpClientUtils.doPost(REQUEST_URL, requestUrlParam);
return JSON.parseObject(result); return JSON.parseObject(result);
} }
@Override
public R inviteJoinOrganization(InviteJoinInfo inviteJoinInfo) {
//验证邀请码是否过期
String uniqueIdentification = inviteJoinInfo.getPlatformId()+ inviteJoinInfo.getAccountId()+"kindergartenInvitationCode";
String code = redisTemplate.opsForValue().get(uniqueIdentification);
if (StringUtils.isEmpty(code)) {
throw new CustomException(ExceptionEnum.INVITATION_CODE_EXPIRED);
}
String key = StringUtils.join(inviteJoinInfo.getPhone(), SMSTemplate.AUTHENTICATION_CODE);
String value = redisTemplate.opsForValue().get(key);
if (StringUtils.isEmpty(value)) {
throw new CustomException(ExceptionEnum.CODE_EXPIRED);
}
//验证手机验证码
if (inviteJoinInfo.getCode().equals(value)) {
//查询邀请用户是否存在账号
UserAccount userAccount = baseMapper.selectAccount(inviteJoinInfo.getPlatformId().toString(), inviteJoinInfo.getPhone());
Integer manageId ;
//邀请人为成员且账号存在,则直接拉入该团队,不可重复拉入
if (userAccount != null) {
//无法加入自己的团队
if (inviteJoinInfo.getAccountId().equals(userAccount.getId().toString())) {
throw new CustomException(ExceptionEnum.CANT_JOIN_TEAM);
}
//查询合伙人账号
PlatformTeamAccount platformTeamAccount = baseMapper.selectOne(new QueryWrapper<PlatformTeamAccount>().
eq("account_id", userAccount.getId()));
manageId = platformTeamAccount.getManageId();
//被邀请人有合伙人账号,判断是否已经存在当前团队中
if (ObjectUtil.isNotNull(platformTeamAccount)){
List<PlatformTeam> platformTeamList = platformTeamMapper.selectList(new QueryWrapper<PlatformTeam>().
eq("manage_id", platformTeamAccount.getManageId()));
//查询团队下的成员是否存在团队中
List<PlatformTeamClassification> teamMeb = platformTeamClassificationMapper.selectList(new QueryWrapper<PlatformTeamClassification>().
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<String, Object> data =(Map<String, Object>) 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);
}
} }

Loading…
Cancel
Save