Merge remote-tracking branch 'origin/dev/3.1_release_merge' into dev/3.1_release_merge
This commit is contained in:
@@ -3553,7 +3553,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
// 只有当前子账号数量为0时允许批量上传
|
// 只有当前子账号数量为0时允许批量上传
|
||||||
QueryWrapper<Account> qw = new QueryWrapper<>();
|
QueryWrapper<Account> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(Account::getSystemUser, 8)
|
qw.lambda().eq(Account::getSystemUser, 8)
|
||||||
.eq(Account::getOrganizationId, parent.getOrganizationId());
|
.eq(Account::getOrganizationId, parent.getOrganizationId())
|
||||||
|
.eq(Account::getSubscriptionPlanId, parent.getSubscriptionPlanId());
|
||||||
List<Account> accounts = accountMapper.selectList(qw);
|
List<Account> accounts = accountMapper.selectList(qw);
|
||||||
if (!accounts.isEmpty()) {
|
if (!accounts.isEmpty()) {
|
||||||
throw new BusinessException("permit.bulk.creation", ResultEnum.PROMPT.getCode());
|
throw new BusinessException("permit.bulk.creation", ResultEnum.PROMPT.getCode());
|
||||||
|
|||||||
@@ -37,10 +37,14 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static com.ai.da.mapper.primary.entity.SubscriptionPlan.SubscriptionStatus.ACTIVE;
|
||||||
|
import static com.ai.da.mapper.primary.entity.SubscriptionPlan.SubscriptionStatus.PENDING;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -62,7 +66,7 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
|
|||||||
|
|
||||||
SubscriptionPlan subscriptionPlan = CopyUtil.copyObject(subscriptionPlanDTO, SubscriptionPlan.class);
|
SubscriptionPlan subscriptionPlan = CopyUtil.copyObject(subscriptionPlanDTO, SubscriptionPlan.class);
|
||||||
if (StringUtils.isBlank(subscriptionPlanDTO.getStatus())) {
|
if (StringUtils.isBlank(subscriptionPlanDTO.getStatus())) {
|
||||||
subscriptionPlan.setStatus(SubscriptionPlan.SubscriptionStatus.PENDING.name());
|
subscriptionPlan.setStatus(PENDING.name());
|
||||||
}
|
}
|
||||||
if (Objects.isNull(subscriptionPlan.getName())) {
|
if (Objects.isNull(subscriptionPlan.getName())) {
|
||||||
subscriptionPlan.setName("DEFAULT_NAME");
|
subscriptionPlan.setName("DEFAULT_NAME");
|
||||||
@@ -74,6 +78,10 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
baseMapper.insert(subscriptionPlan);
|
baseMapper.insert(subscriptionPlan);
|
||||||
|
if (subscriptionPlanDTO.getStatus().equals(SubscriptionPlan.SubscriptionStatus.ACTIVE.name())) {
|
||||||
|
// 执行一次激活扫描器
|
||||||
|
activeSubscriptionPlan();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateCreatePlanParams(SubscriptionPlanDTO subscriptionPlanDTO) {
|
private void validateCreatePlanParams(SubscriptionPlanDTO subscriptionPlanDTO) {
|
||||||
@@ -93,6 +101,9 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
|
|||||||
if (Objects.isNull(account)) {
|
if (Objects.isNull(account)) {
|
||||||
throw new BusinessException("unknown.administrator.user");
|
throw new BusinessException("unknown.administrator.user");
|
||||||
}
|
}
|
||||||
|
if (account.getSystemUser().equals(8) || account.getSystemUser().equals(6)) {
|
||||||
|
throw new BusinessException("Sub-accounts.cannot.be.admins");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新 到期时间、积分总量、已使用积分量
|
// 更新 到期时间、积分总量、已使用积分量
|
||||||
@@ -449,7 +460,8 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
|
|||||||
|
|
||||||
// 查询今天开始生效的订阅计划
|
// 查询今天开始生效的订阅计划
|
||||||
QueryWrapper<SubscriptionPlan> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<SubscriptionPlan> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("is_deleted", 0) // 未删除
|
queryWrapper.eq("is_deleted", 0) // 未删除
|
||||||
|
.in("status", Arrays.asList(PENDING.name(), ACTIVE.name())) // 还未被激活的,或者设置为激活状态但是未被实际激活的
|
||||||
.between("current_period_start", todayStart, todayEnd) // 今天开始生效
|
.between("current_period_start", todayStart, todayEnd) // 今天开始生效
|
||||||
.orderByAsc("current_period_start"); // 按开始时间排序
|
.orderByAsc("current_period_start"); // 按开始时间排序
|
||||||
|
|
||||||
@@ -487,7 +499,7 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
|
|||||||
*/
|
*/
|
||||||
private void updateAccount(Account account, SubscriptionPlan plan, boolean isAdmin) {
|
private void updateAccount(Account account, SubscriptionPlan plan, boolean isAdmin) {
|
||||||
// 如果是管理员的切换,先再次记录一下已使用的积分
|
// 如果是管理员的切换,先再次记录一下已使用的积分
|
||||||
if (isAdmin) {
|
if (isAdmin && Objects.nonNull(account.getSubscriptionPlanId())) {
|
||||||
SubscriptionPlan currentPlan = baseMapper.selectById(account.getSubscriptionPlanId());
|
SubscriptionPlan currentPlan = baseMapper.selectById(account.getSubscriptionPlanId());
|
||||||
if (currentPlan.getCreditUsage().compareTo(account.getCreditsUsage()) < 0) {
|
if (currentPlan.getCreditUsage().compareTo(account.getCreditsUsage()) < 0) {
|
||||||
updateSubscriptionPlanUsage(currentPlan, account.getCreditsUsage());
|
updateSubscriptionPlanUsage(currentPlan, account.getCreditsUsage());
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ page.num.limit=The page number must be greater than 0.
|
|||||||
end.time.must.be.later.than.the.start.time=The subscription end time must be later than the start time.
|
end.time.must.be.later.than.the.start.time=The subscription end time must be later than the start time.
|
||||||
please.specify.the.organizationId=Please specify the organizationId.
|
please.specify.the.organizationId=Please specify the organizationId.
|
||||||
switch.failed.sub-account.not.under.your.active.subscription=Switch failed. Sub-account not under your active subscription.
|
switch.failed.sub-account.not.under.your.active.subscription=Switch failed. Sub-account not under your active subscription.
|
||||||
|
Sub-accounts.cannot.be.admins=Sub-accounts in a subscription cannot be designated as admins.
|
||||||
|
|
||||||
# 可能会报异常
|
# 可能会报异常
|
||||||
# Informative:
|
# Informative:
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ page.num.limit=页码必须大于0
|
|||||||
end.time.must.be.later.than.the.start.time=订阅结束时间必须晚于开始时间
|
end.time.must.be.later.than.the.start.time=订阅结束时间必须晚于开始时间
|
||||||
please.specify.the.organizationId=请指定organizationId
|
please.specify.the.organizationId=请指定organizationId
|
||||||
switch.failed.sub-account.not.under.your.active.subscription=切换失败,该子账号不属于您当前管理的订阅计划
|
switch.failed.sub-account.not.under.your.active.subscription=切换失败,该子账号不属于您当前管理的订阅计划
|
||||||
|
Sub-accounts.cannot.be.admins=在订阅中的子账号不能被指定为管理员
|
||||||
|
|
||||||
# 可能会报异常
|
# 可能会报异常
|
||||||
# Informative:
|
# Informative:
|
||||||
|
|||||||
Reference in New Issue
Block a user