|
|
@ -7,11 +7,14 @@ import com.hchbox.entity.master.SellerAccount;
|
|
|
|
import com.hchbox.repository.master.SellerAccountRepository;
|
|
|
|
import com.hchbox.repository.master.SellerAccountRepository;
|
|
|
|
import com.hchbox.service.SellerAccountService;
|
|
|
|
import com.hchbox.service.SellerAccountService;
|
|
|
|
import com.hchbox.service.TaoBaoOrderingService;
|
|
|
|
import com.hchbox.service.TaoBaoOrderingService;
|
|
|
|
|
|
|
|
import com.hchbox.service.TaoBaoRdsPushService;
|
|
|
|
import com.taobao.api.domain.ArticleSub;
|
|
|
|
import com.taobao.api.domain.ArticleSub;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.aspectj.lang.annotation.After;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -26,40 +29,45 @@ import java.util.Optional;
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
public class AccountTask {
|
|
|
|
public class AccountTask {
|
|
|
|
|
|
|
|
|
|
|
|
private final SellerAccountService sellerAccountService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final TaoBaoOrderingService taoBaoOrderingService;
|
|
|
|
|
|
|
|
private final SellerAccountRepository sellerAccountRepository;
|
|
|
|
private final SellerAccountRepository sellerAccountRepository;
|
|
|
|
|
|
|
|
|
|
|
|
// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
|
private final SellerAccountService sellerAccountService;
|
|
|
|
// public void syncAccount() {
|
|
|
|
|
|
|
|
// List<SellerAccount> sellerAccounts = sellerAccountService.queryAccountByParentId();
|
|
|
|
private final TaoBaoRdsPushService taoBaoRdsPushService;
|
|
|
|
// sellerAccounts.forEach(account -> {
|
|
|
|
|
|
|
|
// List<ArticleSub> orderTimeByUserName = taoBaoOrderingService.getOrderTimeByUserName(account.getNickname());
|
|
|
|
|
|
|
|
// Optional<Date> max = orderTimeByUserName.stream().map(ArticleSub::getDeadline).max(Date::compareTo);
|
|
|
|
|
|
|
|
// // TODO 可做判断
|
|
|
|
|
|
|
|
// max.ifPresent(account::setExpirationTime);
|
|
|
|
|
|
|
|
// Boolean result = sellerAccountService.updateAccountByExpirationTime(account);
|
|
|
|
|
|
|
|
// log.info("==================== update account id as {}, result as {} ====================", account.getId(), result);
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 定时检测授权时间
|
|
|
|
* 定时检测授权时间
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
|
|
|
@Scheduled(cron = " 0 1 0 * * ?")
|
|
|
|
public void expiredChildrenAccount() {
|
|
|
|
// @Scheduled(cron = "0 0/1 * * * *")
|
|
|
|
List<SellerAccount> sellerAccounts = sellerAccountRepository.queryChildrenSellerAccounts((long) DefaultNumberConstants.ZERO_NUMBER);
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
if (CollUtil.isNotEmpty(sellerAccounts)) {
|
|
|
|
public void deleteAccountAfterExpirationTime() {
|
|
|
|
for (SellerAccount info : sellerAccounts) {
|
|
|
|
List<SellerAccount> sellerAccounts =
|
|
|
|
Date time = info.getAuthorizeEndTime();
|
|
|
|
sellerAccountRepository.findAllByParentId((long) DefaultNumberConstants.ZERO_NUMBER);
|
|
|
|
int num = DateUtil.compare(DateUtil.date(), time);
|
|
|
|
for (SellerAccount account : sellerAccounts) {
|
|
|
|
if (num > 0) {
|
|
|
|
List<SellerAccount> allByParentId = sellerAccountRepository.findAllByParentId(account.getId());
|
|
|
|
info.setStatus(DefaultNumberConstants.TWO_NUMBER);
|
|
|
|
boolean flag = Boolean.TRUE;
|
|
|
|
long id = sellerAccountRepository.save(info).getId();
|
|
|
|
for (SellerAccount sellerAccount : allByParentId) {
|
|
|
|
log.info("=========update childrenAccount id as {}", id);
|
|
|
|
Date endTime = sellerAccount.getAuthorizeEndTime();
|
|
|
|
|
|
|
|
if (endTime != null) {
|
|
|
|
|
|
|
|
if (endTime.before(DateUtil.date())) {
|
|
|
|
|
|
|
|
sellerAccountRepository.updateSellerStatusById
|
|
|
|
|
|
|
|
(DefaultNumberConstants.TWO_NUMBER, sellerAccount.getId());
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
flag = Boolean.FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
|
|
|
// 删除数据推送
|
|
|
|
|
|
|
|
taoBaoRdsPushService.deletePushUser(account.getNickname());
|
|
|
|
|
|
|
|
// 修改账号状态
|
|
|
|
|
|
|
|
sellerAccountService.updateAccountStatusAndExpiration
|
|
|
|
|
|
|
|
(account.getId(), DefaultNumberConstants.MINUS_ONE_NUMBER, DateUtil.date());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|