Commit 9a6088da authored by jim's avatar jim

ip

parent 97cad9d7
...@@ -206,7 +206,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -206,7 +206,7 @@ public class IpResourceServiceImpl implements IpResourceService {
String price = vendorPrices.stream() String price = vendorPrices.stream()
.filter(x -> Vendor.valueOf(ipResourceRequestDto.getVendor()).getValue().equals(x.substring(0, x.indexOf("-")))) .filter(x -> Vendor.valueOf(ipResourceRequestDto.getVendor()).getValue().equals(x.substring(0, x.indexOf("-"))))
.map(x -> x.substring(x.lastIndexOf("-") + 1)).collect(Collectors.joining()); .map(x -> x.substring(x.lastIndexOf("-") + 1)).collect(Collectors.joining());
newprice = ipResourceRequestDto.getUnit().equals("week") ? (Integer.valueOf(price)/3) : Integer.valueOf(price); newprice = ipResourceRequestDto.getUnit().equals("week") ? (Integer.valueOf(price) / 3) : Integer.valueOf(price);
} }
IpChargeResultDto ipChargeResultDto = accountService.preChargeByMoney(username, newprice * ipResourceRequestDto.getAmount() * ipResourceRequestDto.getPeriod()); IpChargeResultDto ipChargeResultDto = accountService.preChargeByMoney(username, newprice * ipResourceRequestDto.getAmount() * ipResourceRequestDto.getPeriod());
...@@ -290,7 +290,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -290,7 +290,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResource.setProxyUsername(ipResource.getAddr()); ipResource.setProxyUsername(ipResource.getAddr());
ipResource.setProxyPassword(genRandom(3, 12)); ipResource.setProxyPassword(genRandom(3, 12));
ipResource.setSpecialLine(true); ipResource.setSpecialLine(true);
ipResource.setHealthLockTimestamp(Instant.now().minusSeconds(60*20).toEpochMilli()); ipResource.setHealthLockTimestamp(Instant.now().minusSeconds(60 * 20).toEpochMilli());
} }
ipResource.setRegionCn(ipResourceRequestDto.getRegionCn()); ipResource.setRegionCn(ipResourceRequestDto.getRegionCn());
ipResource.setProtocol(protocol); ipResource.setProtocol(protocol);
...@@ -322,7 +322,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -322,7 +322,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override @Override
public IpOperationResultDto renewIp(String username, IpResourceRequestDto ipResourceRequestDto) { public IpOperationResultDto renewIp(String username, IpResourceRequestDto ipResourceRequestDto) {
String URL = (profiles.equals("dev") || profiles.equals("staging"))? TESTURL : CLOUDAMURL; String URL = (profiles.equals("dev") || profiles.equals("staging")) ? TESTURL : CLOUDAMURL;
Account account = accountRepository.findByName(username); Account account = accountRepository.findByName(username);
if (account == null) if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
...@@ -343,12 +343,13 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -343,12 +343,13 @@ public class IpResourceServiceImpl implements IpResourceService {
else else
prices = priceList.get("自有"); prices = priceList.get("自有");
} }
for(String vendorprice:prices) { for (String vendorprice : prices) {
if (ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-")))) if (ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-"))))
totalprice.updateAndGet(v -> new Double( v + Double.valueOf(vendorprice.substring(vendorprice.lastIndexOf("-") + 1)))); totalprice.updateAndGet(v -> new Double(v + Double.valueOf(vendorprice.substring(vendorprice.lastIndexOf("-") + 1))));
} }); }
});
double newprice = ipResourceRequestDto.getUnit().equals("week") ? (int) (totalprice.get()/3) : totalprice.get().intValue(); double newprice = ipResourceRequestDto.getUnit().equals("week") ? (int) (totalprice.get() / 3) : totalprice.get().intValue();
IpChargeResultDto ipChargeResultDto = accountService.preChargeByMoney(username, newprice * ipResourceRequestDto.getPeriod() * ipResourceRequestDto.getAmount()); IpChargeResultDto ipChargeResultDto = accountService.preChargeByMoney(username, newprice * ipResourceRequestDto.getPeriod() * ipResourceRequestDto.getAmount());
if (!ipChargeResultDto.isSuccess()) { if (!ipChargeResultDto.isSuccess()) {
throw new ClientRequestException(AccountErrorCode.NOTENOUGHBALANCE); throw new ClientRequestException(AccountErrorCode.NOTENOUGHBALANCE);
...@@ -386,7 +387,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -386,7 +387,7 @@ public class IpResourceServiceImpl implements IpResourceService {
.filter(vendorprice -> ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-")))) .filter(vendorprice -> ipResource.getVendor().getValue().equals(vendorprice.substring(0, vendorprice.indexOf("-"))))
.map(vendorprice -> vendorprice.substring(vendorprice.lastIndexOf("-") + 1)).collect(Collectors.joining()); .map(vendorprice -> vendorprice.substring(vendorprice.lastIndexOf("-") + 1)).collect(Collectors.joining());
double newprice1 = ipResourceRequestDto.getUnit().equals("week") ? (Integer.valueOf(price)/3) : Integer.valueOf(price); double newprice1 = ipResourceRequestDto.getUnit().equals("week") ? (Integer.valueOf(price) / 3) : Integer.valueOf(price);
IpChargeRequestDto ipChargeRequestDto = buildIpChargeRequestDto(ipResourceRequestDto, 2, ipResourceRequestDto.getPayMethod()); IpChargeRequestDto ipChargeRequestDto = buildIpChargeRequestDto(ipResourceRequestDto, 2, ipResourceRequestDto.getPayMethod());
accountService.chargeByMoney(username, newprice1 * ipResourceRequestDto.getPeriod() * ipResourceRequestDto.getAmount(), ipChargeRequestDto); accountService.chargeByMoney(username, newprice1 * ipResourceRequestDto.getPeriod() * ipResourceRequestDto.getAmount(), ipChargeRequestDto);
...@@ -440,7 +441,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -440,7 +441,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override @Override
public IpOperationResultDto deleteIp(String username, IpResourceRequestDto ipResourceRequestDto) { public IpOperationResultDto deleteIp(String username, IpResourceRequestDto ipResourceRequestDto) {
String URL = (profiles.equals("dev") || profiles.equals("staging"))? TESTURL : CLOUDAMURL; String URL = (profiles.equals("dev") || profiles.equals("staging")) ? TESTURL : CLOUDAMURL;
Account account = accountRepository.findByName(username); Account account = accountRepository.findByName(username);
if (account == null) if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
...@@ -591,10 +592,17 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -591,10 +592,17 @@ public class IpResourceServiceImpl implements IpResourceService {
break; break;
case 4: case 4:
if (!isParent) if (!isParent)
notUsed = ipResourceRepository.findByOwnerAndStatusIsNotInAndIsDeletedAndBind(username, Arrays.asList(3, 5, 6),false, false); notUsed = ipResourceRepository.findByOwnerAndStatusIsNotInAndIsDeletedAndBind(username, Arrays.asList(3, 5, 6), false, false);
else else
notUsed = ipResourceRepository.findByOwnerInAndStatusIsNotInAndIsDeletedAndBind(children, Arrays.asList(3, 5, 6), false, false); notUsed = ipResourceRepository.findByOwnerInAndStatusIsNotInAndIsDeletedAndBind(children, Arrays.asList(3, 5, 6), false, false);
break; break;
case 5:
ipResources = ipResourceRepository.findShopIdInList(shopIds, false);
if (!isParent)
notUsed = ipResourceRepository.findByOwnerAndStatusIsNotInAndIsDeletedAndBind(username, Arrays.asList(0, 2, 4, 8), false, false);
else
notUsed = ipResourceRepository.findByOwnerInAndStatusIsNotInAndIsDeletedAndBind(children, Arrays.asList(0, 2, 4, 8), false, false);
break;
} }
if (notUsed != null) if (notUsed != null)
ipResources.addAll(notUsed); ipResources.addAll(notUsed);
...@@ -603,11 +611,9 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -603,11 +611,9 @@ public class IpResourceServiceImpl implements IpResourceService {
Page<IpResource> ipResources1 = null; Page<IpResource> ipResources1 = null;
if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getRegion())) { if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getRegion())) {
ipResources1 = ipResourceRepository.findByIsDeletedAndIdInAndRegionCnLikeOrderByPurchasedTimeDesc(false, allIpIds, ipFilterDto.getRegion(), pageable); ipResources1 = ipResourceRepository.findByIsDeletedAndIdInAndRegionCnLikeOrderByPurchasedTimeDesc(false, allIpIds, ipFilterDto.getRegion(), pageable);
} } else if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getAddr())) {
else if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getAddr())) {
ipResources1 = ipResourceRepository.findByIsDeletedAndIdInAndAddrLikeOrderByPurchasedTimeDesc(false, allIpIds, ipFilterDto.getAddr(), pageable); ipResources1 = ipResourceRepository.findByIsDeletedAndIdInAndAddrLikeOrderByPurchasedTimeDesc(false, allIpIds, ipFilterDto.getAddr(), pageable);
} } else if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getVendor())) {
else if (ipFilterDto != null && StringUtils.isNotBlank(ipFilterDto.getVendor())) {
ipResources1 = ipResourceRepository.findByIsDeletedAndIdInAndVendorCnLikeOrderByPurchasedTimeDesc(false, allIpIds, ipFilterDto.getVendor(), pageable); ipResources1 = ipResourceRepository.findByIsDeletedAndIdInAndVendorCnLikeOrderByPurchasedTimeDesc(false, allIpIds, ipFilterDto.getVendor(), pageable);
} else { } else {
ipResources1 = ipResourceRepository.findByIdInAndIsDeletedOrderByPurchasedTimeDesc(allIpIds, false, pageable); ipResources1 = ipResourceRepository.findByIdInAndIsDeletedOrderByPurchasedTimeDesc(allIpIds, false, pageable);
...@@ -628,13 +634,11 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -628,13 +634,11 @@ public class IpResourceServiceImpl implements IpResourceService {
if (StringUtils.isNotBlank(x.getAddr())) { if (StringUtils.isNotBlank(x.getAddr())) {
if (x.getLockTimestamp() >= Instant.now().minusSeconds(120).toEpochMilli() && x.getIpType() == IpType.VENDOR && (x.getStatus() == 0 || x.getStatus() == 2)) { if (x.getLockTimestamp() >= Instant.now().minusSeconds(120).toEpochMilli() && x.getIpType() == IpType.VENDOR && (x.getStatus() == 0 || x.getStatus() == 2)) {
x.setStatus(3); x.setStatus(3);
} } else if (x.getValidTime() <= Instant.now().plusSeconds(60 * 60 * 24 * 7).toEpochMilli() && x.getValidTime() > Instant.now().toEpochMilli()) {
else if (x.getValidTime() <= Instant.now().plusSeconds(60*60*24*7).toEpochMilli() && x.getValidTime() >Instant.now().toEpochMilli()) {
if (x.getStatus() != 5 && x.getStatus() != 3 && x.getStatus() != 6) { if (x.getStatus() != 5 && x.getStatus() != 3 && x.getStatus() != 6) {
ipResourceRepository.updateStatus(x.getId(), 2); ipResourceRepository.updateStatus(x.getId(), 2);
} }
} } else if (x.getValidTime() <= Instant.now().minusSeconds(60 * 60 * 24 * 7).toEpochMilli() && x.getStatus() != 3 && x.getStatus() != 6) {
else if (x.getValidTime() <= Instant.now().minusSeconds(60*60*24*7).toEpochMilli() && x.getStatus() != 3 && x.getStatus() != 6) {
if (x.getIpType() == IpType.VENDOR) { if (x.getIpType() == IpType.VENDOR) {
IpResourceRequestDto ipResourceRequestDto = new IpResourceRequestDto(); IpResourceRequestDto ipResourceRequestDto = new IpResourceRequestDto();
ipResourceRequestDto.setAddr(Arrays.asList(x.getAddr())); ipResourceRequestDto.setAddr(Arrays.asList(x.getAddr()));
...@@ -645,19 +649,17 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -645,19 +649,17 @@ public class IpResourceServiceImpl implements IpResourceService {
deleteIp(username, ipResourceRequestDto); deleteIp(username, ipResourceRequestDto);
} }
return; return;
} } else if (x.getValidTime() <= Instant.now().toEpochMilli() && x.getStatus() != 3 && x.getStatus() != 6) {
else if (x.getValidTime() <= Instant.now().toEpochMilli() && x.getStatus() != 3 && x.getStatus() != 6) {
ipResourceRepository.updateStatus(x.getId(), 1); ipResourceRepository.updateStatus(x.getId(), 1);
} } else {
else {
if ((x.getStatus() == 0 || x.getStatus() == 1 || x.getStatus() == 2) && !x.getVendor().equals(Vendor.local)) { if ((x.getStatus() == 0 || x.getStatus() == 1 || x.getStatus() == 2) && !x.getVendor().equals(Vendor.local)) {
ipResourceRepository.updateStatus(x.getId(), 0); ipResourceRepository.updateStatus(x.getId(), 0);
} else if (x.getIpType().equals(IpType.LOCAL) && (x.getStatus() == 1 || x.getStatus() == 2) && x.getAddr().equals("本地Ip未使用") ) { } else if (x.getIpType().equals(IpType.LOCAL) && (x.getStatus() == 1 || x.getStatus() == 2) && x.getAddr().equals("本地Ip未使用")) {
ipResourceRepository.updateStatus(x.getId(), 4); ipResourceRepository.updateStatus(x.getId(), 4);
} }
} }
} }
if (x.getStatus() == 6 || (x.isSpecialLine() && x.getPurchasedTime() > (Instant.now().toEpochMilli() - 12*60*1000))) if (x.getStatus() == 6 || (x.isSpecialLine() && x.getPurchasedTime() > (Instant.now().toEpochMilli() - 12 * 60 * 1000)))
x.setStatus(3); x.setStatus(3);
if (x.getStatus() == 3) { if (x.getStatus() == 3) {
x.setAddr(""); x.setAddr("");
...@@ -717,7 +719,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -717,7 +719,7 @@ public class IpResourceServiceImpl implements IpResourceService {
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
IpSummary ipSummary = new IpSummary(); IpSummary ipSummary = new IpSummary();
List<String> shopIds = userShopRepository.findByUsername(username).stream().map(x -> x.getShopId()).collect(Collectors.toList()); List<String> shopIds = userShopRepository.findByUsername(username).stream().map(x -> x.getShopId()).collect(Collectors.toList());
List<String> used = ipResourceRepository.findShopIdInList(shopIds,false).stream().map(x -> x.getId()).collect(Collectors.toList()); List<String> used = ipResourceRepository.findShopIdInList(shopIds, false).stream().map(x -> x.getId()).collect(Collectors.toList());
List<String> unbind = ipResourceRepository.findByOwnerAndIsDeletedAndBind(username, false, false).stream().map(x -> x.getId()).collect(Collectors.toList()); List<String> unbind = ipResourceRepository.findByOwnerAndIsDeletedAndBind(username, false, false).stream().map(x -> x.getId()).collect(Collectors.toList());
ipSummary.setUnbind(unbind.size()); ipSummary.setUnbind(unbind.size());
unbind.addAll(used); unbind.addAll(used);
...@@ -822,7 +824,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -822,7 +824,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override @Override
public void releaseDeletedIp() { public void releaseDeletedIp() {
String URL = (profiles.equals("dev") || profiles.equals("staging"))? TESTURL : CLOUDAMURL; String URL = (profiles.equals("dev") || profiles.equals("staging")) ? TESTURL : CLOUDAMURL;
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = buildGetHeader(); HttpHeaders headers = buildGetHeader();
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
......
...@@ -106,7 +106,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -106,7 +106,7 @@ public class ShopServiceImpl implements ShopService {
//可以优化 //可以优化
account.setShopCount(account.getShopCount() + 1); account.setShopCount(account.getShopCount() + 1);
accountRepository.save(account); accountRepository.save(account);
}catch (Exception e) { } catch (Exception e) {
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
return id; return id;
...@@ -170,7 +170,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -170,7 +170,7 @@ public class ShopServiceImpl implements ShopService {
account.setShopCount(account.getShopCount() + 1); account.setShopCount(account.getShopCount() + 1);
accountRepository.save(account); accountRepository.save(account);
ids.add(id); ids.add(id);
}catch (Exception e) { } catch (Exception e) {
logger.error("fail to add shops", e.getMessage()); logger.error("fail to add shops", e.getMessage());
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
...@@ -197,7 +197,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -197,7 +197,7 @@ public class ShopServiceImpl implements ShopService {
try { try {
shop_old = shop_old.of(shopResultDto); shop_old = shop_old.of(shopResultDto);
shopRepository.save(shop_old); shopRepository.save(shop_old);
}catch (Exception e) { } catch (Exception e) {
logger.error("fail to update", e.getMessage()); logger.error("fail to update", e.getMessage());
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE); throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
} }
...@@ -277,8 +277,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -277,8 +277,7 @@ public class ShopServiceImpl implements ShopService {
if (accounts == null || accounts.size() != users.size()) if (accounts == null || accounts.size() != users.size())
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
for (Account ac : accounts) { for (Account ac : accounts) {
if (ac.getParent() == null || !ac.getParent().equals(username)) if (ac.getParent() == null || !ac.getParent().equals(username)) {
{
throw new ClientRequestException(AccountErrorCode.NOPERMISSION); throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
} }
} }
...@@ -336,8 +335,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -336,8 +335,7 @@ public class ShopServiceImpl implements ShopService {
if (ipResource.isSpecialLine()) { if (ipResource.isSpecialLine()) {
SpecialLine specialLine = specialLineRepository.findAll().get(0); SpecialLine specialLine = specialLineRepository.findAll().get(0);
shopResultDto = ShopResultDto.of(shop, group, new IpResourceDto(ipResource, null, false, specialLine)); shopResultDto = ShopResultDto.of(shop, group, new IpResourceDto(ipResource, null, false, specialLine));
} } else
else
shopResultDto = ShopResultDto.of(shop, group, new IpResourceDto(ipResource, null, false)); shopResultDto = ShopResultDto.of(shop, group, new IpResourceDto(ipResource, null, false));
return shopResultDto; return shopResultDto;
} }
...@@ -369,11 +367,10 @@ public class ShopServiceImpl implements ShopService { ...@@ -369,11 +367,10 @@ public class ShopServiceImpl implements ShopService {
.map(x -> x.getShopId()).collect(Collectors.toList()); .map(x -> x.getShopId()).collect(Collectors.toList());
shopIds = ipResourceRepository.findShopIdInList(allIds, false) shopIds = ipResourceRepository.findShopIdInList(allIds, false)
.stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList()); .stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
} } else {
else {
List<String> allIds = userShopRepository.findByUsername(username).stream() List<String> allIds = userShopRepository.findByUsername(username).stream()
.map(x -> x.getShopId()).collect(Collectors.toList()); .map(x -> x.getShopId()).collect(Collectors.toList());
for (String id:allIds) { for (String id : allIds) {
IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false); IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false);
if (ipResource == null) { if (ipResource == null) {
shopIds.add(id); shopIds.add(id);
...@@ -389,11 +386,10 @@ public class ShopServiceImpl implements ShopService { ...@@ -389,11 +386,10 @@ public class ShopServiceImpl implements ShopService {
map(x -> x.getShopId()).collect(Collectors.toList()); map(x -> x.getShopId()).collect(Collectors.toList());
shopIds = ipResourceRepository.findShopIdInList(allIds, false) shopIds = ipResourceRepository.findShopIdInList(allIds, false)
.stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList()); .stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
} } else {
else {
List<String> allIds = userShopRepository.findByUsernameAndGroupId(username, groupId).stream() List<String> allIds = userShopRepository.findByUsernameAndGroupId(username, groupId).stream()
.map(x -> x.getShopId()).collect(Collectors.toList()); .map(x -> x.getShopId()).collect(Collectors.toList());
for (String id:allIds) { for (String id : allIds) {
IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false); IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false);
if (ipResource == null) if (ipResource == null)
shopIds.add(id); shopIds.add(id);
...@@ -405,8 +401,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -405,8 +401,7 @@ public class ShopServiceImpl implements ShopService {
List<String> filter = ipResourceRepository.findShopIdInListAndRegionLike(shopIds, false, shopFilterDto.getIpRegion()) List<String> filter = ipResourceRepository.findShopIdInListAndRegionLike(shopIds, false, shopFilterDto.getIpRegion())
.stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList()); .stream().flatMap((x -> x.getShopIds().stream())).collect(Collectors.toList());
shops = shopRepository.findByShopIdInOrderByCreateTimeDesc(filter, pageable); shops = shopRepository.findByShopIdInOrderByCreateTimeDesc(filter, pageable);
} } else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopAccount()))
else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopAccount()))
shops = shopRepository.findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getShopAccount(), pageable); shops = shopRepository.findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getShopAccount(), pageable);
else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopName())) else if (shopFilterDto != null && StringUtils.isNotBlank(shopFilterDto.getShopName()))
shops = shopRepository.findByShopIdInAndShopNameLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getShopName(), pageable); shops = shopRepository.findByShopIdInAndShopNameLikeOrderByCreateTimeDesc(shopIds, shopFilterDto.getShopName(), pageable);
...@@ -464,8 +459,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -464,8 +459,7 @@ public class ShopServiceImpl implements ShopService {
if (ipResource.isSpecialLine()) { if (ipResource.isSpecialLine()) {
SpecialLine specialLine = specialLineRepository.findAll().get(0); SpecialLine specialLine = specialLineRepository.findAll().get(0);
shopResultDto = ShopResultDto.of(x, group1, new IpResourceDto(ipResource, null, false, specialLine)); shopResultDto = ShopResultDto.of(x, group1, new IpResourceDto(ipResource, null, false, specialLine));
} } else
else
shopResultDto = ShopResultDto.of(x, group1, new IpResourceDto(ipResource, null, false)); shopResultDto = ShopResultDto.of(x, group1, new IpResourceDto(ipResource, null, false));
shopResultDtos.add(shopResultDto); shopResultDtos.add(shopResultDto);
}); });
...@@ -489,7 +483,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -489,7 +483,7 @@ public class ShopServiceImpl implements ShopService {
List<String> allShopIds = userShopRepository.findByUsername(username).stream().map(x -> x.getShopId()).collect(Collectors.toList()); List<String> allShopIds = userShopRepository.findByUsername(username).stream().map(x -> x.getShopId()).collect(Collectors.toList());
List<String> unbind = new ArrayList<>(); List<String> unbind = new ArrayList<>();
if (allShopIds != null && allShopIds.size() > 0) { if (allShopIds != null && allShopIds.size() > 0) {
for (String id:allShopIds) { for (String id : allShopIds) {
IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false); IpResource ipResource = ipResourceRepository.findFirstByShopIdsIsAndIsDeleted(id, false);
if (ipResource == null) { if (ipResource == null) {
unbind.add(id); unbind.add(id);
...@@ -529,7 +523,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -529,7 +523,7 @@ public class ShopServiceImpl implements ShopService {
if (shopIds != null && shopIds.size() > 0) { if (shopIds != null && shopIds.size() > 0) {
String maxShopId = null; String maxShopId = null;
int max = 0; int max = 0;
for (String shopId:shopIds) { for (String shopId : shopIds) {
int userCount = userShopRepository.countByShopId(shopId); int userCount = userShopRepository.countByShopId(shopId);
if (userCount > max) { if (userCount > max) {
max = userCount; max = userCount;
......
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