|
@@ -1,14 +1,24 @@
|
|
|
package com.cyksj.service.mange.account;
|
|
package com.cyksj.service.mange.account;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
import com.cyksj.common.constant.Constant;
|
|
|
|
|
+import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
|
|
+import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.mapper.AccountMapper;
|
|
import com.cyksj.mapper.AccountMapper;
|
|
|
|
|
+import com.cyksj.mapper.AccountNetflixStateMapper;
|
|
|
import com.cyksj.model.entity.Account;
|
|
import com.cyksj.model.entity.Account;
|
|
|
|
|
+import com.cyksj.model.entity.AccountNetflixState;
|
|
|
import com.cyksj.service.mange.AccountCommonService;
|
|
import com.cyksj.service.mange.AccountCommonService;
|
|
|
|
|
+import com.cyksj.service.relation.GroupsRelationNetflixService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
*项目名: netflix
|
|
*项目名: netflix
|
|
|
*文件名: AccountCommonServiceImpl
|
|
*文件名: AccountCommonServiceImpl
|
|
@@ -17,10 +27,15 @@ import org.springframework.stereotype.Service;
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
|
|
+@Slf4j
|
|
|
public class AccountCommonServiceImpl implements AccountCommonService {
|
|
public class AccountCommonServiceImpl implements AccountCommonService {
|
|
|
|
|
|
|
|
private final AccountMapper accountMapper;
|
|
private final AccountMapper accountMapper;
|
|
|
|
|
|
|
|
|
|
+ private final AccountNetflixStateMapper accountNetflixStateMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final GroupsRelationNetflixService groupsRelationNetflixService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean checkIsDupAccount(Long goodsId, String account) {
|
|
public Boolean checkIsDupAccount(Long goodsId, String account) {
|
|
|
LambdaQueryWrapper<Account> wrapper = Wrappers.lambdaQuery(Account.class)
|
|
LambdaQueryWrapper<Account> wrapper = Wrappers.lambdaQuery(Account.class)
|
|
@@ -34,4 +49,45 @@ public class AccountCommonServiceImpl implements AccountCommonService {
|
|
|
if (count > 0) return true;
|
|
if (count > 0) return true;
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void syncDonwNF() {
|
|
|
|
|
+ List<Account> accounts = accountMapper.selectAccountDonw();
|
|
|
|
|
+ if (CollUtil.isEmpty(accounts)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("已同步完成");
|
|
|
|
|
+ }
|
|
|
|
|
+ accounts.forEach(account -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ AccountNetflixState exist = accountNetflixStateMapper.selectOne(Wrappers.lambdaQuery(AccountNetflixState.class)
|
|
|
|
|
+ .eq(AccountNetflixState::getAccount, account.getAccount())
|
|
|
|
|
+ .lt(AccountNetflixState::getCreatedTime, DateUtil.parse("2024-11-26"))
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (exist != null) {
|
|
|
|
|
+ accountNetflixStateMapper.deleteById(exist.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ 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);
|
|
|
|
|
+
|
|
|
|
|
+ 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));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|