|
@@ -204,21 +204,22 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
|
|
if (student == null) {
|
|
if (student == null) {
|
|
throw new BizException("学生不存在");
|
|
throw new BizException("学生不存在");
|
|
}
|
|
}
|
|
- Long tenantId = -1L;
|
|
|
|
- if (student.getTenantId() != null) {
|
|
|
|
- tenantId = student.getTenantId();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- TenantActivationCode code = this.lambdaQuery().eq(TenantActivationCode::getTenantId, tenantId)
|
|
|
|
- .eq(TenantActivationCode::getActivationCode, activationCode)
|
|
|
|
- .last("limit 1").one();
|
|
|
|
|
|
+ TenantActivationCode code = this.lambdaQuery().eq(TenantActivationCode::getActivationCode, activationCode).last("limit 1").one();
|
|
if (code == null) {
|
|
if (code == null) {
|
|
throw new BizException("激活码不存在");
|
|
throw new BizException("激活码不存在");
|
|
}
|
|
}
|
|
|
|
+ if (Boolean.TRUE.equals(code.getActivationStatus())) {
|
|
|
|
+ throw new BizException("激活码已经被使用");
|
|
|
|
+ }
|
|
|
|
|
|
- // 线下发放,有账号,则校验机构
|
|
|
|
- if (EActivationCode.WAIT.equals(code.getSendStatus())) {
|
|
|
|
- // 校验该激活码的来源小组专辑是否和该学生的小组是一致
|
|
|
|
|
|
+ // 判断激活码是否已经发送给学生
|
|
|
|
+ SysUser sysUser = sysUserService.getDao().selectById(studentId);
|
|
|
|
+ if (!sysUser.getPhone().equals(code.getActivationPhone())) { // 发给自己不校验,可以直接用,未发放需要校验
|
|
|
|
+ if (EActivationCode.SEND.equals(code.getSendStatus())) { //已经发送给别人
|
|
|
|
+ throw new BizException("激活码不可用");
|
|
|
|
+ }
|
|
|
|
+ // 未发放,线下抄送
|
|
|
|
+ // 校验小组专辑的小组和机构是否和学生一致,并且小组专辑是启用状态
|
|
Long tenantAlbumId = code.getTenantAlbumId();
|
|
Long tenantAlbumId = code.getTenantAlbumId();
|
|
List<Long> tenantGroupIds = tenantGroupAlbumService.lambdaQuery()
|
|
List<Long> tenantGroupIds = tenantGroupAlbumService.lambdaQuery()
|
|
.eq(TenantGroupAlbum::getTenantAlbumId, tenantAlbumId)
|
|
.eq(TenantGroupAlbum::getTenantAlbumId, tenantAlbumId)
|
|
@@ -230,12 +231,6 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- SysUser sysUser = sysUserService.getDao().selectById(studentId);
|
|
|
|
- // 如果码已经激活或者发放给别人
|
|
|
|
- if (Boolean.TRUE.equals(code.getActivationStatus()) || (EActivationCode.SEND.equals(code.getSendStatus()) &&
|
|
|
|
- !sysUser.getPhone().equals(code.getActivationPhone()))) {
|
|
|
|
- throw new BizException("激活码已经被使用");
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
// 通过状态和ID同时判断更新是否存在竞争
|
|
// 通过状态和ID同时判断更新是否存在竞争
|
|
@@ -256,6 +251,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
|
|
|
|
|
|
addUserTenantAlbumRecord(student.getUserId(), purchase, null);
|
|
addUserTenantAlbumRecord(student.getUserId(), purchase, null);
|
|
|
|
|
|
|
|
+ Long tenantId = Optional.ofNullable(student.getTenantId()).orElse(-1L);
|
|
// 更新购买记录中激活码使用统计数量值
|
|
// 更新购买记录中激活码使用统计数量值
|
|
Integer activeCodeNumber = this.lambdaQuery()
|
|
Integer activeCodeNumber = this.lambdaQuery()
|
|
.eq(TenantActivationCode::getTenantId, tenantId)
|
|
.eq(TenantActivationCode::getTenantId, tenantId)
|