Commit 933d81b6 authored by renjie's avatar renjie

店铺bug

parent fab91973
...@@ -4,6 +4,8 @@ public interface UserShopRepositoryCustom { ...@@ -4,6 +4,8 @@ public interface UserShopRepositoryCustom {
boolean deleteByUsernameAndShopId(String username, String shopId); boolean deleteByUsernameAndShopId(String username, String shopId);
boolean deleteByShopId(String shopId);
void updateGroupId(String groupId_old, String groupId_new); void updateGroupId(String groupId_old, String groupId_new);
boolean deleteByShopIdExceptOwner(String shopId, String owner); boolean deleteByShopIdExceptOwner(String shopId, String owner);
......
...@@ -31,6 +31,18 @@ public class UserShopRepositoryCustomImpl implements UserShopRepositoryCustom { ...@@ -31,6 +31,18 @@ public class UserShopRepositoryCustomImpl implements UserShopRepositoryCustom {
return true; return true;
} }
@Override
public boolean deleteByShopId(String shopId) {
Document doc = new Document();
BasicQuery basicQuery = new BasicQuery(doc);
basicQuery.addCriteria(where("shopId").is(shopId));
DeleteResult operation = mongoTemplate.remove(basicQuery, UserShop.class);
if (operation.getDeletedCount() < 1)
return false;
else
return true;
}
@Override @Override
public void updateGroupId(String groupId_old, String groupId_new) { public void updateGroupId(String groupId_old, String groupId_new) {
Document doc = new Document(); Document doc = new Document();
......
...@@ -182,11 +182,6 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -182,11 +182,6 @@ public class IpResourceServiceImpl implements IpResourceService {
return retStr; return retStr;
} }
public static void main(String[] args) {
String password = genRandom(3, 12);
System.out.println(password);
}
private IpChargeRequestDto buildIpChargeRequestDto(IpResourceRequestDto request, int chargeType, int payMethod) { private IpChargeRequestDto buildIpChargeRequestDto(IpResourceRequestDto request, int chargeType, int payMethod) {
IpChargeRequestDto ipChargeRequestDto = new IpChargeRequestDto(); IpChargeRequestDto ipChargeRequestDto = new IpChargeRequestDto();
ipChargeRequestDto.setAmount(request.getAmount()); ipChargeRequestDto.setAmount(request.getAmount());
......
...@@ -99,6 +99,11 @@ public class ShopServiceImpl implements ShopService { ...@@ -99,6 +99,11 @@ public class ShopServiceImpl implements ShopService {
userShop.setGroupId(shopResultDto.getGroup()); userShop.setGroupId(shopResultDto.getGroup());
} }
userShopRepository.save(userShop); userShopRepository.save(userShop);
if (StringUtils.isNotBlank(account.getParent())) {
userShop.setUsername(account.getParent());
userShop.setGroupId("-1");
userShopRepository.save(userShop);
}
//可以优化 //可以优化
account.setShopCount(account.getShopCount() + 1); account.setShopCount(account.getShopCount() + 1);
accountRepository.save(account); accountRepository.save(account);
...@@ -155,6 +160,11 @@ public class ShopServiceImpl implements ShopService { ...@@ -155,6 +160,11 @@ public class ShopServiceImpl implements ShopService {
userShop.setGroupId(shopResultDto.getGroup()); userShop.setGroupId(shopResultDto.getGroup());
} }
userShopRepository.save(userShop); userShopRepository.save(userShop);
if (StringUtils.isNotBlank(account.getParent())) {
userShop.setUsername(account.getParent());
userShop.setGroupId("-1");
userShopRepository.save(userShop);
}
//可以优化 //可以优化
account.setShopCount(account.getShopCount() + 1); account.setShopCount(account.getShopCount() + 1);
accountRepository.save(account); accountRepository.save(account);
...@@ -215,7 +225,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -215,7 +225,7 @@ public class ShopServiceImpl implements ShopService {
ipResource.setShopId(null); ipResource.setShopId(null);
ipResourceRepository.save(ipResource); ipResourceRepository.save(ipResource);
} }
boolean result = userShopRepository.deleteByUsernameAndShopId(username, shopId); boolean result = userShopRepository.deleteByShopId(shopId);
if (result) { if (result) {
shopRepository.deleteById(shopId); shopRepository.deleteById(shopId);
account.setShopCount(account.getShopCount() - 1); account.setShopCount(account.getShopCount() - 1);
...@@ -402,6 +412,8 @@ public class ShopServiceImpl implements ShopService { ...@@ -402,6 +412,8 @@ public class ShopServiceImpl implements ShopService {
if (shops == null || shops.getNumberOfElements() < 1) if (shops == null || shops.getNumberOfElements() < 1)
return new ShopPageResultDto(); return new ShopPageResultDto();
List<ShopResultDto> shopResultDtos = new ArrayList<>(); List<ShopResultDto> shopResultDtos = new ArrayList<>();
logger.error("shops.size" + shops.getNumberOfElements());
logger.error("shops.content.size " + shops.getContent().size());
shops.getContent().stream().forEach(x -> { shops.getContent().stream().forEach(x -> {
IpResource ipResource = ipResourceRepository.findByShopIdAndIsDeleted(x.getShopId(), false); IpResource ipResource = ipResourceRepository.findByShopIdAndIsDeleted(x.getShopId(), false);
if (ipResource == null) if (ipResource == null)
...@@ -450,7 +462,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -450,7 +462,7 @@ public class ShopServiceImpl implements ShopService {
int willexpired = ipResourceRepository.countByStatusAndIdInAndIsDeleted(2, bind, false); int willexpired = ipResourceRepository.countByStatusAndIdInAndIsDeleted(2, bind, false);
shopSummary.setExpired(expired); shopSummary.setExpired(expired);
shopSummary.setWillExpire(willexpired); shopSummary.setWillExpire(willexpired);
shopSummary.setTotal(userShopRepository.countByUsername(username)); shopSummary.setTotal(shopIds.size());
return shopSummary; return shopSummary;
} }
......
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