|
|
@@ -107,6 +107,9 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
conversation.setChannelId(properties.get("discordChannelId") == null ? null : Long.parseLong(properties.get("discordChannelId").toString()))
|
|
|
.setInstanceId(properties.get("discordInstanceId") == null ? null : Long.parseLong(properties.get("discordInstanceId").toString()));
|
|
|
}
|
|
|
+ if (conversation.getInstanceId() == null) {
|
|
|
+ conversation.setInstanceId(result.getInstanceId());
|
|
|
+ }
|
|
|
conversationMapper.insert(conversation);
|
|
|
return conversation;
|
|
|
}
|
|
|
@@ -261,8 +264,9 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
if (code == 3) {
|
|
|
if(mode == 2 && StringUtils.isNotBlank(accountWithMinUsage)){
|
|
|
redisService.hdel(RedisService.key.MIDJOURNEY_ACCOUNT.getName(),accountWithMinUsage);
|
|
|
+ String finalAccountWithMinUsage = accountWithMinUsage;
|
|
|
TASK_EXECUTOR.execute(() -> {
|
|
|
- MidjourneyAccount account = midjourneyAccountService.getOne(Wrappers.lambdaQuery(MidjourneyAccount.class).eq(MidjourneyAccount::getInstanceId, instanceId).last("limit 1"));
|
|
|
+ MidjourneyAccount account = midjourneyAccountService.getOne(Wrappers.lambdaQuery(MidjourneyAccount.class).eq(MidjourneyAccount::getInstanceId, finalAccountWithMinUsage).last("limit 1"));
|
|
|
midjourneyAccountService.updateStatus(account.getId());
|
|
|
});
|
|
|
}
|
|
|
@@ -277,6 +281,11 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
log.error("action:" + action + " error message:" + submitResult.getDescription());
|
|
|
throw BusinessRuntimeException.getInstance("队列已满,请稍后尝试");
|
|
|
}
|
|
|
+ submitResult.setInstanceId(Long.valueOf(accountWithMinUsage));
|
|
|
+ // 增加使用次数
|
|
|
+ if (StringUtils.isNotBlank(accountWithMinUsage) && mode == 2) {
|
|
|
+ redisService.hincr(RedisService.key.MIDJOURNEY_ACCOUNT.getName(), accountWithMinUsage, 1.0);
|
|
|
+ }
|
|
|
return submitResult;
|
|
|
}
|
|
|
|
|
|
@@ -306,10 +315,6 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 增加使用次数
|
|
|
- if (minAccountId != null) {
|
|
|
- redisService.hincr(key, minAccountId, 1.0);
|
|
|
- }
|
|
|
return minAccountId;
|
|
|
} catch (Exception e) {
|
|
|
throw BusinessRuntimeException.getInstance("获取账号失败");
|