Merge remote-tracking branch 'origin/dev/3.1_release_merge' into dev/3.1_release_merge

This commit is contained in:
litianxiang
2025-12-19 15:47:36 +08:00
4 changed files with 19 additions and 4 deletions

View File

@@ -3553,7 +3553,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
// 只有当前子账号数量为0时允许批量上传
QueryWrapper<Account> qw = new QueryWrapper<>();
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);
if (!accounts.isEmpty()) {
throw new BusinessException("permit.bulk.creation", ResultEnum.PROMPT.getCode());

View File

@@ -37,10 +37,14 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
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
@Service
@RequiredArgsConstructor
@@ -62,7 +66,7 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
SubscriptionPlan subscriptionPlan = CopyUtil.copyObject(subscriptionPlanDTO, SubscriptionPlan.class);
if (StringUtils.isBlank(subscriptionPlanDTO.getStatus())) {
subscriptionPlan.setStatus(SubscriptionPlan.SubscriptionStatus.PENDING.name());
subscriptionPlan.setStatus(PENDING.name());
}
if (Objects.isNull(subscriptionPlan.getName())) {
subscriptionPlan.setName("DEFAULT_NAME");
@@ -74,6 +78,10 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
}
baseMapper.insert(subscriptionPlan);
if (subscriptionPlanDTO.getStatus().equals(SubscriptionPlan.SubscriptionStatus.ACTIVE.name())) {
// 执行一次激活扫描器
activeSubscriptionPlan();
}
}
private void validateCreatePlanParams(SubscriptionPlanDTO subscriptionPlanDTO) {
@@ -93,6 +101,9 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
if (Objects.isNull(account)) {
throw new BusinessException("unknown.administrator.user");
}
if (account.getSystemUser().equals(8) || account.getSystemUser().equals(6)) {
throw new BusinessException("Sub-accounts.cannot.be.admins");
}
}
// 更新 到期时间、积分总量、已使用积分量
@@ -450,6 +461,7 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
// 查询今天开始生效的订阅计划
QueryWrapper<SubscriptionPlan> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("is_deleted", 0) // 未删除
.in("status", Arrays.asList(PENDING.name(), ACTIVE.name())) // 还未被激活的,或者设置为激活状态但是未被实际激活的
.between("current_period_start", todayStart, todayEnd) // 今天开始生效
.orderByAsc("current_period_start"); // 按开始时间排序
@@ -487,7 +499,7 @@ public class SubscriptionPlanServiceImpl extends ServiceImpl<SubscriptionPlanMap
*/
private void updateAccount(Account account, SubscriptionPlan plan, boolean isAdmin) {
// 如果是管理员的切换,先再次记录一下已使用的积分
if (isAdmin) {
if (isAdmin && Objects.nonNull(account.getSubscriptionPlanId())) {
SubscriptionPlan currentPlan = baseMapper.selectById(account.getSubscriptionPlanId());
if (currentPlan.getCreditUsage().compareTo(account.getCreditsUsage()) < 0) {
updateSubscriptionPlanUsage(currentPlan, account.getCreditsUsage());

View File

@@ -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.
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.
Sub-accounts.cannot.be.admins=Sub-accounts in a subscription cannot be designated as admins.
# 可能会报异常
# Informative:

View File

@@ -204,6 +204,7 @@ page.num.limit=页码必须大于0
end.time.must.be.later.than.the.start.time=订阅结束时间必须晚于开始时间
please.specify.the.organizationId=请指定organizationId
switch.failed.sub-account.not.under.your.active.subscription=切换失败,该子账号不属于您当前管理的订阅计划
Sub-accounts.cannot.be.admins=在订阅中的子账号不能被指定为管理员
# 可能会报异常
# Informative: