Commit 873f0c8d authored by renjie's avatar renjie

Merge branch 'dev-zrj' into 'staging'

Dev zrj

See merge request !128
parents b365f7b6 3d35f69e
......@@ -382,7 +382,7 @@ public class AdministratorServiceImpl implements AdministratorService {
public IpCountQueryResultDto queyrIpCount(String username) {
IpCountQueryResultDto ipCountQueryResultDto = new IpCountQueryResultDto();
if (StringUtils.isBlank(username)) {
long ipcount_using = ipResourceRepository.countAllByIsDeleted(false);
long ipcount_using = ipResourceRepository.countAllByIsDeletedAndValidTimeGreaterThan(false, Instant.now().toEpochMilli());
long ipcount_all = ipResourceRepository.count();
ipCountQueryResultDto.setIpCount_using(ipcount_using);
ipCountQueryResultDto.setIpCount_all(ipcount_all);
......@@ -394,7 +394,7 @@ public class AdministratorServiceImpl implements AdministratorService {
ipCountQueryResultDto.setIpCount_using(ipCountRecord.getIp_using());
}
} else {
long ipcount_using = ipResourceRepository.countAllByOwnerAndIsDeleted(username, false);
long ipcount_using = ipResourceRepository.countAllByOwnerAndIsDeletedAndValidTimeGreaterThan(username, false, Instant.now().toEpochMilli());
long ipcount_all = ipResourceRepository.countAllByOwner(username);
ipCountQueryResultDto.setIpCount_using(ipcount_using);
ipCountQueryResultDto.setIpCount_all(ipcount_all);
......@@ -453,12 +453,12 @@ public class AdministratorServiceImpl implements AdministratorService {
promotion.setTotalCommission(promotion.getTotalCommission() + (int)totalCommission);
promotion.setCommission(promotion.getCommission() + x.getPromotion().getCommission());
double secondCommission = 0;
ipCount.addAndGet(ipResourceRepository.countAllByOwnerAndIsDeleted(x.getName(), false));
ipCount.addAndGet(ipResourceRepository.countAllByOwnerAndIsDeletedAndValidTimeGreaterThan(x.getName(), false, Instant.now().toEpochMilli()));
if (finalAccount.getPromotion().isSale() && x.getParent() == null) {
List<Account> secondPromotes = accountRepository.findByPromotionCodeAndParentIsNull(x.getPromotion().getCode());
if (secondPromotes != null && secondPromotes.size() > 0) {
for (Account secondPromote : secondPromotes) {
ipCount.addAndGet(ipResourceRepository.countAllByOwnerAndIsDeleted(secondPromote.getName(), false));
ipCount.addAndGet(ipResourceRepository.countAllByOwnerAndIsDeletedAndValidTimeGreaterThan(secondPromote.getName(), false, Instant.now().toEpochMilli()));
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByAdministratorAndPayMethodInAndTimestampBetween(secondPromote.getName(), Arrays.asList(1,2,3), dateTime1.getTime(), dateTime2.getTime());
if (userPrePaidBillings1 != null && userPrePaidBillings1.size() > 0)
secondCommission += userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
......
......@@ -44,8 +44,8 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
int countByStatusAndIdInAndIsDeleted(int status, List<String> ipIds, boolean isDeleted);
long countAllByIsDeleted(boolean isDeleted);
long countAllByIsDeletedAndValidTimeGreaterThan(boolean isDeleted, long time);
long countAllByOwnerAndIsDeleted(String username, boolean isDeleted);
long countAllByOwnerAndIsDeletedAndValidTimeGreaterThan(String username, boolean isDeleted, long time);
long countAllByOwner(String username);
}
......@@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
......@@ -238,7 +239,11 @@ public class BrowserTask {
if (ipResourceRepository.healthLock(ipResource)) {
try {
QueryIpUrlList queryIpUrlList = queryIpUrlListRepository.findAll().get(0);
if (ipResource.isSpecialLine()) {
if (ipResource.getValidTime() <= Instant.now().toEpochMilli() && ipResource.getStatus() != 3 && ipResource.getStatus() != 6) {
ipResource.setStatus(1);
ipResourceRepository.save(ipResource);
}
else if (ipResource.isSpecialLine()) {
Trans trans = new Trans(ipResource.getProxyUsername(), ipResource.getProxyPassword());
String sp_result = trans.get(queryIpUrlList.getUrl());
int failTime = 0;
......@@ -296,7 +301,7 @@ public class BrowserTask {
IpCountRecord ipCountRecord = new IpCountRecord();
ipCountRecord.setUsername(x.getName());
ipCountRecord.setTimestamp(Instant.now().toEpochMilli());
long ipcount_using = ipResourceRepository.countAllByOwnerAndIsDeleted(x.getName(), false);
long ipcount_using = ipResourceRepository.countAllByOwnerAndIsDeletedAndValidTimeGreaterThan(x.getName(), false, Instant.now().toEpochMilli());
long ipcount_all = ipResourceRepository.countAllByOwner(x.getName());
ipCountRecord.setIp_all(ipcount_all);
ipCountRecord.setIp_using(ipcount_using);
......@@ -305,7 +310,7 @@ public class BrowserTask {
IpCountRecord ipCountRecord = new IpCountRecord();
ipCountRecord.setUsername("all");
ipCountRecord.setTimestamp(Instant.now().toEpochMilli());
long ipcount_using = ipResourceRepository.countAllByIsDeleted(false);
long ipcount_using = ipResourceRepository.countAllByIsDeletedAndValidTimeGreaterThan(false, Instant.now().toEpochMilli());
long ipcount_all = ipResourceRepository.count();
ipCountRecord.setIp_using(ipcount_using);
ipCountRecord.setIp_all(ipcount_all);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment