默认添加个人端信息

main
cheney 11 months ago
parent 17741ffcce
commit c4b6e0de4e
  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) { public R kindergartenWeChatApplication(AppletCallbackReq appletCallbackReq) {
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);
String accountId = null; Integer accountId ;
String userName = ""; String userName = "";
String accountName = "";
// 根据不同的平台ID设置用户名和账户名 // 根据不同的平台ID设置用户名和账户名
switch (appletCallbackReq.getPlatformId()) { switch (appletCallbackReq.getPlatformId()) {
case 5: case 5:
if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){ if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){
userName = appletCallbackReq.getOrganizationName(); userName = appletCallbackReq.getOrganizationName();
accountName = appletCallbackReq.getOrganizationName();
}else { }else {
userName = "幼儿园" + randomNumbers; userName = "幼儿园" + randomNumbers;
accountName = "幼儿园" + randomNumbers;
} }
break; break;
case 6: case 6:
if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){ if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){
userName = appletCallbackReq.getOrganizationName(); userName = appletCallbackReq.getOrganizationName();
accountName = appletCallbackReq.getOrganizationName();
}else { }else {
userName = "供应商" + randomNumbers; userName = "供应商" + randomNumbers;
accountName = "供应商" + randomNumbers;
} }
break; break;
case 7: case 7:
userName = "个人" + randomNumbers; userName = "个人" + randomNumbers;
accountName = "个人" + randomNumbers;
break; break;
} }
// 创建并设置用户信息 accountId = addUserInfo(userName, appletCallbackReq.getPlatformId(), appletCallbackReq.getOpenId(), appletCallbackReq.getPhone());
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();
// 如果平台ID不是7,添加供应商信息和团队信息 // 如果平台ID不是7,添加供应商/幼儿园信息和团队信息,默认添加个人端信息
if (appletCallbackReq.getPlatformId() != 7) { if (appletCallbackReq.getPlatformId() != 7) {
// 添加供应商信息 //添加个人端信息
String personalUserName = "个人" + randomNumbers;
addUserInfo(personalUserName, 7, appletCallbackReq.getOpenId(), appletCallbackReq.getPhone());
// 添加供应商/幼儿园信息
PlatformTeamAccount platformTeamAccount = new PlatformTeamAccount(); PlatformTeamAccount platformTeamAccount = new PlatformTeamAccount();
platformTeamAccount.setAccountId(userAccount.getId()); platformTeamAccount.setAccountId(accountId);
platformTeamAccount.setPlatformId(appletCallbackReq.getPlatformId()); platformTeamAccount.setPlatformId(appletCallbackReq.getPlatformId());
baseMapper.insert(platformTeamAccount); baseMapper.insert(platformTeamAccount);
// 添加所属供应商分类,分类为空直接新增团队 // 添加所属供应商/幼儿园分类,分类为空直接新增团队
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification(); PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification();
platformTeamClassification.setIsTeam(1); platformTeamClassification.setIsTeam(1);
platformTeamClassification.setParentId(1); platformTeamClassification.setParentId(1);
@ -191,7 +171,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){ if (StringUtils.isNotBlank(appletCallbackReq.getOrganizationName())){
teamName = appletCallbackReq.getOrganizationName(); teamName = appletCallbackReq.getOrganizationName();
}else { }else {
teamName = userAccount.getAccount() + "的团队"; teamName = userName + "的团队";
} }
platformTeamClassification.setClassificationName(teamName); platformTeamClassification.setClassificationName(teamName);
@ -206,11 +186,33 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
} }
// 注册成功返回token // 注册成功返回token
data.put("token", JwtUtils.getJwtToken(accountId)); data.put("token", JwtUtils.getJwtToken(accountId.toString()));
data.put("openId", appletCallbackReq.getOpenId()); data.put("openId", appletCallbackReq.getOpenId());
return R.ok().put("data",data); 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 @Override
public R getTeamsByPlatformId(String accountId, Integer platformId) { public R getTeamsByPlatformId(String accountId, Integer platformId) {
List<TeamAccountResp> teamsByPlatformId = baseMapper.getTeamsByPlatformId(accountId,platformId); List<TeamAccountResp> teamsByPlatformId = baseMapper.getTeamsByPlatformId(accountId,platformId);

Loading…
Cancel
Save