Commit 752513f1 authored by Administrator's avatar Administrator

Merge branch 'staging' into 'master'

提供前端查询ip

See merge request !173
parents 24f3c4b8 9d3a5426
......@@ -511,9 +511,13 @@ public class AdministratorServiceImpl implements AdministratorService {
@Override
public PromotionInfoDto countPromotionInfos(String username, String promotionCode, String beginDate, String endDate) {
// 1. 根据传入的 username 或者 推荐码 获取用户信息
long start = System.currentTimeMillis();
Account account = getAccount(username, promotionCode);
log.info("===>countPromotionInfos step-1 consume time {}", System.currentTimeMillis() - start);
// 2. 获取 该推荐码下所有的用户
start = System.currentTimeMillis();
List<Account> accounts = accountRepository.findAllByPromotionCodeAndParentIsNull(account.getPromotion().getCode());
log.info("===>countPromotionInfos step-2 consume time {}", System.currentTimeMillis() - start);
// promotion 用来存储所有用户的消费信息
PromotionInfoDto promotionInfoDto = new PromotionInfoDto();
......@@ -527,12 +531,15 @@ public class AdministratorServiceImpl implements AdministratorService {
Date beginTime = formatter.parse(beginDate);
Date endTime = formatter.parse(endDate);
start = System.currentTimeMillis();
if (accounts != null && accounts.size() > 0) {
// 邀请的一级用户数
promotionInfoDto.setFirstLevelInvitedUsers(accounts.size());
int i = 3, j = 0;
accounts.forEach(x -> {
long start2 = System.currentTimeMillis();
int[] arr1 = getCommissionAndIps(beginTime, endTime, x);
log.info("===>countPromotionInfos step-3-{} consume time {}", accounts.indexOf(x) + 1, (System.currentTimeMillis() - start2));
promotionInfoDto.setFirstLevelCommission(promotionInfoDto.getFirstLevelCommission() + arr1[0]);
promotionInfoDto.setFirstLevelIps(promotionInfoDto.getFirstLevelIps() + arr1[1]);
......@@ -543,7 +550,9 @@ public class AdministratorServiceImpl implements AdministratorService {
if (secondPromotes != null && secondPromotes.size() > 0) {
for (Account secondPromote : secondPromotes) {
// 将下级账户及下级账户的子账户中未过期的ip统计到 ipCount中
long start3 = System.currentTimeMillis();
int[] arr2 = getCommissionAndIps(beginTime, endTime, secondPromote);
log.info("===>countPromotionInfos step-3-{}-{} consume time {}", accounts.indexOf(x) + 1, secondPromotes.indexOf(secondPromote) + 1, (System.currentTimeMillis() - start3));
promotionInfoDto.setSecondLevelCommission(promotionInfoDto.getSecondLevelCommission() + arr2[0]);
promotionInfoDto.setSecondLevelIps(promotionInfoDto.getSecondLevelIps() + arr2[1]);
}
......@@ -551,7 +560,7 @@ public class AdministratorServiceImpl implements AdministratorService {
}
});
}
log.info("===>countPromotionInfos step-4 consume time {}", System.currentTimeMillis() - start);
// 设置总ip
promotionInfoDto.setAllLevelIps(promotionInfoDto.getFirstLevelIps() + promotionInfoDto.getSecondLevelIps());
// 设置应当提现的礼物金额
......
......@@ -3,10 +3,7 @@ package com.edgec.browserbackend.browser.controller;
import com.edgec.browserbackend.browser.domain.UserCode;
import com.edgec.browserbackend.browser.service.TempService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* 一些临时执行的代码可以放在这里,方便删除
......@@ -26,4 +23,9 @@ public class TempController {
tempService.save(userCode);
}
@GetMapping("/{ip}")
public String getPaasword(@PathVariable("ip") String ip) {
return tempService.getPaasword(ip);
}
}
......@@ -67,4 +67,6 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
long countAllByOwnerInAndIsDeletedAndValidTimeGreaterThan(List<String> username, boolean isDeleted, long time);
long countAllByOwner(String username);
IpResource findFirstByAddrOrderByPurchasedTimeDesc(String addr);
}
......@@ -41,4 +41,16 @@ public class TempServiceImpl implements TempService {
ipResourceRepository.save(ipResource);
log.info("ip地址为:" + addr + "专线状态更改为:" + flag);
}
@Override
public String getPaasword(String ip) {
IpResource ipResource = ipResourceRepository.findFirstByAddrOrderByPurchasedTimeDesc(ip);
String password;
if ("mainland".equals(ipResource.getRegion())) {
password = ipResource.getPassword();
} else {
password = ipResource.getProxyPassword();
}
return password;
}
}
......@@ -9,4 +9,6 @@ public interface TempService {
void save(UserCode userCode);
void saveIpResource(String addr, String flag);
String getPaasword(String ip);
}
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