|
|
@@ -161,7 +161,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
private final GroupsRelationChangeService changeTickerRelation;
|
|
|
|
|
|
- private final NetflixTempAccountUserMapper netflixTempAccountUserMapper;
|
|
|
+ private final AccountNetflixStateMapper accountNetflixStateMapper;
|
|
|
|
|
|
@Override
|
|
|
public SearchResult<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize, String customId, String account, String orderNo) {
|
|
|
@@ -1030,7 +1030,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
//若无移至空车队
|
|
|
if (newRelation == null) {
|
|
|
- newRelation = changeTickerRelation.getEmptyGroupsRelation(renewalView.getUserId(), renewalView.getRelationId(), renewalView.getSkuId());
|
|
|
+ newRelation = changeTickerRelation.getEmptyGroupsRelation(renewalView.getRelationId(), renewalView.getUserId(), renewalView.getSkuId());
|
|
|
}
|
|
|
if (newRelation == null) {
|
|
|
throw BusinessRuntimeException.getInstance("更换异常,请重新提交");
|
|
|
@@ -1039,48 +1039,92 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
@Override
|
|
|
public AccountView getTempAccount(long userId, Long relationId) {
|
|
|
- List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
- RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
|
|
|
- .field(RenewalView::getRelationId, relationId)
|
|
|
- .field(RenewalView::getUserId, userIdList).op(Operator.InList)
|
|
|
- .field(RenewalView::getGroupsStatus, GroupsTrips.Status.waiting.name())
|
|
|
- .field(RenewalView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan)
|
|
|
- .build());
|
|
|
- if (renewalView == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("车票不存在");
|
|
|
- }
|
|
|
- AccountView accountView = new AccountView();
|
|
|
- //奈飞超过3帐车票不给看
|
|
|
- Number number = beanSearcher.searchCount(RenewalView.class, MapUtils.builder()
|
|
|
- .field(RenewalView::getUserId, userIdList).op(Operator.InList)
|
|
|
- .field(RenewalView::getGoodsId, 1)
|
|
|
- .field(RenewalView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan)
|
|
|
- .build());
|
|
|
- if (number.intValue() > 2) {
|
|
|
- return accountView;
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncNfAccountState() {
|
|
|
+ List<Account> accounts = accountMapper.selectNetflixAccountLimit(5);
|
|
|
+ if (CollUtil.isEmpty(accounts)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("已同步完成");
|
|
|
}
|
|
|
- NetflixTempAccountUser netflixTempAccountUser = netflixTempAccountUserMapper.selectOne(Wrappers.lambdaQuery(NetflixTempAccountUser.class)
|
|
|
- .eq(NetflixTempAccountUser::getRelationId, relationId)
|
|
|
- .in(NetflixTempAccountUser::getUserId, userIdList)
|
|
|
- .last("limit 1"));
|
|
|
- Account account;
|
|
|
- if (netflixTempAccountUser == null) {
|
|
|
- account = accountMapper.selectNetflixTempAccount();
|
|
|
- if (account != null) {
|
|
|
- netflixTempAccountUser = new NetflixTempAccountUser();
|
|
|
- netflixTempAccountUser.setAccountId(account.getId());
|
|
|
- netflixTempAccountUser.setRelationId(relationId);
|
|
|
- netflixTempAccountUser.setUserId(renewalView.getUserId());
|
|
|
- netflixTempAccountUserMapper.insert(netflixTempAccountUser);
|
|
|
+ accounts.forEach(account -> {
|
|
|
+ try {
|
|
|
+ String taskId = groupsRelationNetflixService.createNetflixAccountStatusTask(account);
|
|
|
+ log.info("任务taskId:{}", taskId);
|
|
|
+ AccountNetflixState accountNetflixState = new AccountNetflixState();
|
|
|
+ accountNetflixState.setAccount(account.getAccount());
|
|
|
+ accountNetflixState.setPassword(account.getPassword());
|
|
|
+ accountNetflixState.setState(0);
|
|
|
+ accountNetflixState.setTaskId(taskId);
|
|
|
+ accountNetflixStateMapper.insert(accountNetflixState);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建检测奈飞账号状态任务失败:{}", StringUtil.getErrorText(e));
|
|
|
}
|
|
|
- } else {
|
|
|
- account = accountMapper.selectById(netflixTempAccountUser.getAccountId());
|
|
|
+ });
|
|
|
+
|
|
|
+ //同步奈飞账号状态
|
|
|
+ List<AccountNetflixState> accountNetflixStates = accountNetflixStateMapper.selectList(Wrappers.lambdaQuery(AccountNetflixState.class)
|
|
|
+ .eq(AccountNetflixState::getState, 0));
|
|
|
+ accountNetflixStates.forEach(accountNetflixState -> {
|
|
|
+ try {
|
|
|
+ Integer status = groupsRelationNetflixService.checkNetflixAccountState(accountNetflixState);
|
|
|
+ while (status == 0) {
|
|
|
+ Thread.sleep(2000);
|
|
|
+ try {
|
|
|
+ status = groupsRelationNetflixService.checkNetflixAccountState(accountNetflixState);
|
|
|
+ } catch (Exception e) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ accountNetflixState.setState(status);
|
|
|
+ accountNetflixStateMapper.updateById(accountNetflixState);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建检测奈飞账号状态任务状态失败:{}", StringUtil.getErrorText(e));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ syncNfAccountState();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncExcelAccountState(String account, String password) {
|
|
|
+ Integer selectCount = accountNetflixStateMapper.selectCount(Wrappers.lambdaQuery(AccountNetflixState.class)
|
|
|
+ .eq(AccountNetflixState::getAccount, account));
|
|
|
+ if (selectCount > 0) {
|
|
|
+ log.info("该账号:{}已经同步", account);
|
|
|
+ return;
|
|
|
}
|
|
|
- if (account != null) {
|
|
|
- accountView.setAccount(account.getAccount());
|
|
|
- accountView.setPassword(account.getPassword());
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ String taskId = groupsRelationNetflixService.createNetflixAccountStatusTask(account, password);
|
|
|
+ log.info("任务taskId:{}", taskId);
|
|
|
+ AccountNetflixState accountNetflixState = new AccountNetflixState();
|
|
|
+ accountNetflixState.setAccount(account);
|
|
|
+ accountNetflixState.setPassword(password);
|
|
|
+ accountNetflixState.setState(0);
|
|
|
+ accountNetflixState.setTaskId(taskId);
|
|
|
+ accountNetflixStateMapper.insert(accountNetflixState);
|
|
|
+
|
|
|
+ try {
|
|
|
+ Integer status = groupsRelationNetflixService.checkNetflixAccountState(accountNetflixState);
|
|
|
+ while (status == 0) {
|
|
|
+ Thread.sleep(2000);
|
|
|
+ try {
|
|
|
+ status = groupsRelationNetflixService.checkNetflixAccountState(accountNetflixState);
|
|
|
+ } catch (Exception e) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ accountNetflixState.setState(status);
|
|
|
+ accountNetflixStateMapper.updateById(accountNetflixState);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建检测奈飞账号状态任务状态失败:{}", StringUtil.getErrorText(e));
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建奈飞账号状态任务失败:{}", StringUtil.getErrorText(e));
|
|
|
}
|
|
|
- return accountView;
|
|
|
}
|
|
|
|
|
|
private DistributePosterGoodsDetailView setGoodsPoster(RenewalView ticket, User user, List<Long> userIds) {
|