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

main
rong.liu 11 months ago
commit 48a150ab9a
  1. 66
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java

@ -124,65 +124,45 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
public R kindergartenWeChatApplication(AppletCallbackReq appletCallbackReq) {
Map<String, Object> data = new HashedMap<String, Object>();
String randomNumbers = cn.hutool.core.util.RandomUtil.randomNumbers(6);
String accountId = null;
Integer accountId ;
String userName = "";
String accountName = "";
// 根据不同的平台ID设置用户名和账户名
switch (appletCallbackReq.getPlatformId()) {
case 5:
if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){
userName = appletCallbackReq.getOrganizationName();
accountName = appletCallbackReq.getOrganizationName();
}else {
userName = "幼儿园" + randomNumbers;
accountName = "幼儿园" + randomNumbers;
}
break;
case 6:
if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){
userName = appletCallbackReq.getOrganizationName();
accountName = appletCallbackReq.getOrganizationName();
}else {
userName = "供应商" + randomNumbers;
accountName = "供应商" + randomNumbers;
}
break;
case 7:
userName = "个人" + randomNumbers;
accountName = "个人" + randomNumbers;
break;
}
// 创建并设置用户信息
UserInfo userInfo = new UserInfo();
userInfo.setUserName(userName);
userInfo.setLoginNumber(1);
userInfo.setLastLoginTime(new Date());
staffMapper.addUserInfo(userInfo);
// 创建并设置用户账户
UserAccount userAccount = new UserAccount();
userAccount.setPhone(appletCallbackReq.getPhone());
userAccount.setPhoneBindingTime(new Date());
userAccount.setPassword(MD5.encrypt("1122aa"));
userAccount.setUserId(userInfo.getUserId());
userAccount.setType(2); // 平台端区分:0->教师端 1->学生端 2->无端
userAccount.setPlatformId(appletCallbackReq.getPlatformId().toString());
userAccount.setAppOpenId(appletCallbackReq.getOpenId());
userAccount.setAccount(accountName);
staffMapper.addUserAccount(userAccount);
accountId = userAccount.getId().toString();
accountId = addUserInfo(userName, appletCallbackReq.getPlatformId(), appletCallbackReq.getOpenId(), appletCallbackReq.getPhone());
// 如果平台ID不是7,添加供应商信息和团队信息
// 如果平台ID不是7,添加供应商/幼儿园信息和团队信息,默认添加个人端信息
if (appletCallbackReq.getPlatformId() != 7) {
// 添加供应商信息
//添加个人端信息
String personalUserName = "个人" + randomNumbers;
addUserInfo(personalUserName, 7, appletCallbackReq.getOpenId(), appletCallbackReq.getPhone());
// 添加供应商/幼儿园信息
PlatformTeamAccount platformTeamAccount = new PlatformTeamAccount();
platformTeamAccount.setAccountId(userAccount.getId());
platformTeamAccount.setAccountId(accountId);
platformTeamAccount.setPlatformId(appletCallbackReq.getPlatformId());
baseMapper.insert(platformTeamAccount);
// 添加所属供应商分类,分类为空直接新增团队
// 添加所属供应商/幼儿园分类,分类为空直接新增团队
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification();
platformTeamClassification.setIsTeam(1);
platformTeamClassification.setParentId(1);
@ -191,7 +171,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){
teamName = appletCallbackReq.getOrganizationName();
}else {
teamName = userAccount.getAccount() + "的团队";
teamName = userName + "的团队";
}
platformTeamClassification.setClassificationName(teamName);
@ -206,11 +186,33 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
}
// 注册成功返回token
data.put("token", JwtUtils.getJwtToken(accountId));
data.put("token", JwtUtils.getJwtToken(accountId.toString()));
data.put("openId", appletCallbackReq.getOpenId());
return R.ok().put("data",data);
}
public Integer addUserInfo(String userName,Integer platformId,String openId,String phone){
// 创建并设置用户信息
UserInfo userInfo = new UserInfo();
userInfo.setUserName(userName);
userInfo.setLoginNumber(1);
userInfo.setLastLoginTime(new Date());
staffMapper.addUserInfo(userInfo);
// 创建并设置用户账户
UserAccount userAccount = new UserAccount();
userAccount.setPhone(phone);
userAccount.setPhoneBindingTime(new Date());
userAccount.setPassword(MD5.encrypt("1122aa"));
userAccount.setUserId(userInfo.getUserId());
userAccount.setType(2); // 平台端区分:0->教师端 1->学生端 2->无端
userAccount.setPlatformId(platformId.toString());
userAccount.setAppOpenId(openId);
userAccount.setAccount(userName);
staffMapper.addUserAccount(userAccount);
return userAccount.getId();
}
@Override
public R getTeamsByPlatformId(String accountId, Integer platformId) {
List<TeamAccountResp> teamsByPlatformId = baseMapper.getTeamsByPlatformId(accountId,platformId);

Loading…
Cancel
Save