Commit 9deeeb23 authored by Administrator's avatar Administrator

Merge branch 'fix-hotbugs' into 'master'

注册bug修复以及店铺列表部分业务修改

See merge request !189
parents 43139220 38acd057
...@@ -17,7 +17,7 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc ...@@ -17,7 +17,7 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
Account findByEmail(String email); Account findByEmail(String email);
Account findByPhoneNumber(String phone); Account findOneByPhoneNumber(String phone);
Account findByPhoneNumberAndParentIsNull(String phone); Account findByPhoneNumberAndParentIsNull(String phone);
......
...@@ -426,8 +426,8 @@ public class AccountServiceImpl implements AccountService { ...@@ -426,8 +426,8 @@ public class AccountServiceImpl implements AccountService {
public Account createWithSms(User user) { public Account createWithSms(User user) {
// 1. 校验注册用户是否已存在 // 1. 校验注册用户是否已存在
Account existing1 = accountRepository.findByName(user.getUsername()).orElse(null); Account existing1 = accountRepository.findByName(user.getUsername()).orElse(null);
Account existing2 = accountRepository.findByPhoneNumber(user.getUsername()); Account existing2 = accountRepository.findOneByPhoneNumber(user.getUsername());
Account existing3 = accountRepository.findByPhoneNumber(user.getPhone()); Account existing3 = accountRepository.findOneByPhoneNumber(user.getPhone());
Account existing4 = accountRepository.findByName(user.getPhone()).orElse(null); Account existing4 = accountRepository.findByName(user.getPhone()).orElse(null);
if (existing1 != null || existing2 != null || existing3 != null || existing4 != null) { if (existing1 != null || existing2 != null || existing3 != null || existing4 != null) {
throw new ClientRequestException(AccountErrorCode.NAMEEXIST, "account already exists: " + user.getUsername()); throw new ClientRequestException(AccountErrorCode.NAMEEXIST, "account already exists: " + user.getUsername());
...@@ -492,7 +492,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -492,7 +492,7 @@ public class AccountServiceImpl implements AccountService {
if (existing != null) { if (existing != null) {
throw new ClientRequestException(AccountErrorCode.NAMEEXIST, "account already exists: " + user.getUsername()); throw new ClientRequestException(AccountErrorCode.NAMEEXIST, "account already exists: " + user.getUsername());
} }
existing = accountRepository.findByPhoneNumber(user.getUsername()); existing = accountRepository.findOneByPhoneNumber(user.getUsername());
if (existing != null) { if (existing != null) {
throw new ClientRequestException(AccountErrorCode.NAMEEXIST, "account already exists: " + user.getUsername()); throw new ClientRequestException(AccountErrorCode.NAMEEXIST, "account already exists: " + user.getUsername());
} }
...@@ -617,12 +617,12 @@ public class AccountServiceImpl implements AccountService { ...@@ -617,12 +617,12 @@ public class AccountServiceImpl implements AccountService {
} }
if (!StringUtils.isEmpty(user.getPhoneNumber())) { if (!StringUtils.isEmpty(user.getPhoneNumber())) {
existing = accountRepository.findByPhoneNumber(user.getPhoneNumber()); existing = accountRepository.findOneByPhoneNumber(user.getPhoneNumber());
if (existing != null) if (existing != null)
throw new ClientRequestException(AccountErrorCode.PHONEEXIST, "phone number already exists: " + user.getEmail()); throw new ClientRequestException(AccountErrorCode.PHONEEXIST, "phone number already exists: " + user.getEmail());
} }
existing = accountRepository.findByPhoneNumber(user.getName()); existing = accountRepository.findOneByPhoneNumber(user.getName());
if (existing != null) { if (existing != null) {
throw new ClientRequestException(AccountErrorCode.PHONEEXIST, "phone number already exists: " + user.getEmail()); throw new ClientRequestException(AccountErrorCode.PHONEEXIST, "phone number already exists: " + user.getEmail());
} }
...@@ -918,7 +918,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -918,7 +918,7 @@ public class AccountServiceImpl implements AccountService {
@Override @Override
public AccountDto getAccountByCellphone(String cellphone) { public AccountDto getAccountByCellphone(String cellphone) {
Account account = accountRepository.findByPhoneNumber(cellphone); Account account = accountRepository.findOneByPhoneNumber(cellphone);
if (account == null) { if (account == null) {
return null; return null;
} }
......
...@@ -169,7 +169,7 @@ public class ShopController { ...@@ -169,7 +169,7 @@ public class ShopController {
} catch (ClientRequestException e) { } catch (ClientRequestException e) {
dealClientRequestException(resultDto, e); dealClientRequestException(resultDto, e);
} }
logger.info("getshoplist totalTime:{}, {}", principal.getName(), System.currentTimeMillis() - start); logger.info("getshoplist totalTime:{}, {},{}", principal.getName(), System.currentTimeMillis() - start, Thread.currentThread().getName());
return resultDto; return resultDto;
} }
...@@ -180,6 +180,7 @@ public class ShopController { ...@@ -180,6 +180,7 @@ public class ShopController {
@RequestMapping(value = "/penghai/list", method = RequestMethod.POST) @RequestMapping(value = "/penghai/list", method = RequestMethod.POST)
public ResultDto getPenghaiShopList(Principal principal, @RequestBody ShopRequestDto shopRequestDto) { public ResultDto getPenghaiShopList(Principal principal, @RequestBody ShopRequestDto shopRequestDto) {
logger.info("shop list params {}", JSONObject.toJSONString(shopRequestDto)); logger.info("shop list params {}", JSONObject.toJSONString(shopRequestDto));
long start = System.currentTimeMillis();
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
try { try {
...@@ -190,6 +191,7 @@ public class ShopController { ...@@ -190,6 +191,7 @@ public class ShopController {
} catch (ClientRequestException e) { } catch (ClientRequestException e) {
dealClientRequestException(resultDto, e); dealClientRequestException(resultDto, e);
} }
logger.info("getshoplist totalTime:{},{}, {},{}", "penghai", principal.getName(), System.currentTimeMillis() - start, Thread.currentThread().getName());
return resultDto; return resultDto;
} }
......
...@@ -481,6 +481,10 @@ public class ShopServiceImpl implements ShopService { ...@@ -481,6 +481,10 @@ public class ShopServiceImpl implements ShopService {
ShopPageResultDto<ShopResultDto> shopPageResultDto = new ShopPageResultDto<>(); ShopPageResultDto<ShopResultDto> shopPageResultDto = new ShopPageResultDto<>();
if (shops != null && shops.getNumberOfElements() >= 1) { if (shops != null && shops.getNumberOfElements() >= 1) {
List<ShopResultDto> shopResultDtos = new ArrayList<>(); List<ShopResultDto> shopResultDtos = new ArrayList<>();
SpecialLine specialLine = specialLineRepository.findAll().get(0);
List<IpResource> pageIpResourceListToSave = new ArrayList<>();
shops.getContent().stream().forEach( shops.getContent().stream().forEach(
// 设置ip资源状态 并 封装 shopResultDto信息 // 设置ip资源状态 并 封装 shopResultDto信息
x -> { x -> {
...@@ -492,34 +496,32 @@ public class ShopServiceImpl implements ShopService { ...@@ -492,34 +496,32 @@ public class ShopServiceImpl implements ShopService {
if (ipResource.getValidTime() <= Instant.now().plusSeconds(60 * 60 * 24 * 7).toEpochMilli() && ipResource.getValidTime() > Instant.now().toEpochMilli()) { if (ipResource.getValidTime() <= Instant.now().plusSeconds(60 * 60 * 24 * 7).toEpochMilli() && ipResource.getValidTime() > Instant.now().toEpochMilli()) {
if (ipResource.getStatus() != 5 && ipResource.getStatus() != 3 && ipResource.getStatus() != 6) { if (ipResource.getStatus() != 5 && ipResource.getStatus() != 3 && ipResource.getStatus() != 6) {
ipResource.setStatus(2); ipResource.setStatus(2);
ipResourceRepository.save(ipResource); //ipResourceRepository.save(ipResource);
pageIpResourceListToSave.add(ipResource);
} }
// 2. ip资源在七天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源 // 2. ip资源在七天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源
} else if (ipResource.getValidTime() <= Instant.now().minusSeconds(60 * 60 * 24 * 7).toEpochMilli() && ipResource.getStatus() != 3 && ipResource.getStatus() != 6) { } else if (ipResource.getValidTime() <= Instant.now().minusSeconds(60 * 60 * 24 * 7).toEpochMilli() && ipResource.getStatus() != 3 && ipResource.getStatus() != 6) {
IpResourceRequestDto ipResourceRequestDto1 = new IpResourceRequestDto();
if (ipResource.getIpType() == IpType.VENDOR) { if (ipResource.getIpType() == IpType.VENDOR) {
IpResourceRequestDto ipResourceRequestDto1 = new IpResourceRequestDto();
ipResourceRequestDto1.setAddr(Arrays.asList(ipResource.getAddr())); ipResourceRequestDto1.setAddr(Arrays.asList(ipResource.getAddr()));
try {
ipResourceService.deleteExpiredIp(username, ipResourceRequestDto1);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
} else { } else {
IpResourceRequestDto ipResourceRequestDto1 = new IpResourceRequestDto();
ipResourceRequestDto1.setIpId(Arrays.asList(ipResource.getId())); ipResourceRequestDto1.setIpId(Arrays.asList(ipResource.getId()));
try {
ipResourceService.deleteExpiredIp(username, ipResourceRequestDto1);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
} }
try {
ipResourceService.deleteExpiredIp(username, ipResourceRequestDto1);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return; return;
// 3. ip资源到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则设置 ip 资源的状态为 1(已过期) // 3. ip资源到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则设置 ip 资源的状态为 1(已过期)
} else if (ipResource.getValidTime() <= Instant.now().toEpochMilli() && ipResource.getStatus() != 3 && ipResource.getStatus() != 6) { } else if (ipResource.getValidTime() <= Instant.now().toEpochMilli() && ipResource.getStatus() != 3 && ipResource.getStatus() != 6) {
ipResource.setStatus(1); ipResource.setStatus(1);
ipResourceRepository.save(ipResource); //ipResourceRepository.save(ipResource);
pageIpResourceListToSave.add(ipResource);
// 4. 其他,将ip资源状态设置为 未使用 // 4. 其他,将ip资源状态设置为 未使用
} else { } else {
...@@ -528,16 +530,19 @@ public class ShopServiceImpl implements ShopService { ...@@ -528,16 +530,19 @@ public class ShopServiceImpl implements ShopService {
} else if (ipResource.getIpType().equals(IpType.LOCAL) && (ipResource.getStatus() == 1 || ipResource.getStatus() == 2) && ipResource.getAddr().equals("本地Ip未使用")) { } else if (ipResource.getIpType().equals(IpType.LOCAL) && (ipResource.getStatus() == 1 || ipResource.getStatus() == 2) && ipResource.getAddr().equals("本地Ip未使用")) {
ipResource.setStatus(4); ipResource.setStatus(4);
} }
ipResourceRepository.save(ipResource); // ipResourceRepository.save(ipResource);
pageIpResourceListToSave.add(ipResource);
} }
} }
ShopResultDto shopResultDto = getShopResultDto(username, x, ipResource); //ShopResultDto shopResultDto = getShopResultDto(username, x, ipResource, specialLine);
ShopResultDto shopResultDto = getShopResultDto(groupId, x, ipResource, specialLine);
shopResultDtos.add(shopResultDto); shopResultDtos.add(shopResultDto);
logger.info("getshoplist step-6.x:{},{}", username, System.currentTimeMillis() - start1); logger.info("getshoplist step-6.x:{},{},{}", username, System.currentTimeMillis() - start1, Thread.currentThread().getName());
} }
); );
ipResourceRepository.saveAll(pageIpResourceListToSave);
Page<ShopResultDto> shopDtoPage = new PageImpl<>(shopResultDtos, pageable, shopIds.size()); Page<ShopResultDto> shopDtoPage = new PageImpl<>(shopResultDtos, pageable, shopIds.size());
shopPageResultDto.setShopList(shopDtoPage.getContent()); shopPageResultDto.setShopList(shopDtoPage.getContent());
...@@ -765,18 +770,31 @@ public class ShopServiceImpl implements ShopService { ...@@ -765,18 +770,31 @@ public class ShopServiceImpl implements ShopService {
return shops; return shops;
} }
private ShopResultDto getShopResultDto(String username, Shop x, IpResource ipResource) { /*private ShopResultDto getShopResultDto(String username, Shop x, IpResource ipResource, SpecialLine specialLine) {
if (ipResource == null) { if (ipResource == null) {
ipResource = new IpResource(); ipResource = new IpResource();
} }
String group1 = userShopRepository.findByUsernameAndShopId(username, x.getShopId()).getGroupId(); String group1 = userShopRepository.findByUsernameAndShopId(username, x.getShopId()).getGroupId();
ShopResultDto shopResultDto = null; ShopResultDto shopResultDto = null;
if (ipResource.isSpecialLine()) { if (ipResource.isSpecialLine()) {
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));
} }
return shopResultDto; return shopResultDto;
}*/
private ShopResultDto getShopResultDto(String groupId, Shop x, IpResource ipResource, SpecialLine specialLine) {
if (ipResource == null) {
ipResource = new IpResource();
}
ShopResultDto shopResultDto = null;
if (ipResource.isSpecialLine()) {
shopResultDto = ShopResultDto.of(x, groupId, new IpResourceDto(ipResource, null, false, specialLine));
} else {
shopResultDto = ShopResultDto.of(x, groupId, new IpResourceDto(ipResource, null, false));
}
return shopResultDto;
} }
} }
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