|
|
@@ -55,6 +55,8 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
|
|
|
private final UserBindRelationService userBindRelationService;
|
|
|
|
|
|
+ private final AccountMapper accountMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public String addAccount(Account account) {
|
|
|
@@ -212,6 +214,16 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
*/
|
|
|
private ChatgptUser createChatgptUser(GroupsRelation groupsRelation, GroupsTrips groupsTrips, User user) {
|
|
|
ChatgptSession chatgptSession = chatgptSessionMapper.selectOne(Wrappers.lambdaQuery(ChatgptSession.class).eq(ChatgptSession::getAccountId, groupsTrips.getAccountId()));
|
|
|
+ if (chatgptSession == null) {
|
|
|
+ Account account = accountMapper.selectById(groupsTrips.getAccountId());
|
|
|
+ //升级为镜像账号
|
|
|
+ String gptRefreshToken = addAccount(account);
|
|
|
+ accountMapper.update(null, Wrappers.lambdaUpdate(Account.class).eq(Account::getId, account.getId()).set(Account::getGptRefreshToken, gptRefreshToken));
|
|
|
+ chatgptSession = chatgptSessionMapper.selectOne(Wrappers.lambdaQuery(ChatgptSession.class).eq(ChatgptSession::getAccountId, groupsTrips.getAccountId()));
|
|
|
+ }
|
|
|
+ if (chatgptSession == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("账号异常,请联系客服..");
|
|
|
+ }
|
|
|
ChatgptUser chatgptUser = new ChatgptUser();
|
|
|
chatgptUser.setExpireTime(groupsRelation.getExpiryTime());
|
|
|
chatgptUser.setIsPlus(1);
|