Commit a49a0d0e authored by Administrator's avatar Administrator

Merge branch 'staging' into 'master'

Staging

See merge request !77
parents fab91973 80bc9bc1
......@@ -4,6 +4,8 @@ public interface UserShopRepositoryCustom {
boolean deleteByUsernameAndShopId(String username, String shopId);
boolean deleteByShopId(String shopId);
void updateGroupId(String groupId_old, String groupId_new);
boolean deleteByShopIdExceptOwner(String shopId, String owner);
......
......@@ -31,6 +31,18 @@ public class UserShopRepositoryCustomImpl implements UserShopRepositoryCustom {
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
public void updateGroupId(String groupId_old, String groupId_new) {
Document doc = new Document();
......
......@@ -182,11 +182,6 @@ public class IpResourceServiceImpl implements IpResourceService {
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) {
IpChargeRequestDto ipChargeRequestDto = new IpChargeRequestDto();
ipChargeRequestDto.setAmount(request.getAmount());
......
......@@ -99,6 +99,11 @@ public class ShopServiceImpl implements ShopService {
userShop.setGroupId(shopResultDto.getGroup());
}
userShopRepository.save(userShop);
if (StringUtils.isNotBlank(account.getParent())) {
userShop.setUsername(account.getParent());
userShop.setGroupId("-1");
userShopRepository.save(userShop);
}
//可以优化
account.setShopCount(account.getShopCount() + 1);
accountRepository.save(account);
......@@ -155,6 +160,11 @@ public class ShopServiceImpl implements ShopService {
userShop.setGroupId(shopResultDto.getGroup());
}
userShopRepository.save(userShop);
if (StringUtils.isNotBlank(account.getParent())) {
userShop.setUsername(account.getParent());
userShop.setGroupId("-1");
userShopRepository.save(userShop);
}
//可以优化
account.setShopCount(account.getShopCount() + 1);
accountRepository.save(account);
......@@ -215,7 +225,7 @@ public class ShopServiceImpl implements ShopService {
ipResource.setShopId(null);
ipResourceRepository.save(ipResource);
}
boolean result = userShopRepository.deleteByUsernameAndShopId(username, shopId);
boolean result = userShopRepository.deleteByShopId(shopId);
if (result) {
shopRepository.deleteById(shopId);
account.setShopCount(account.getShopCount() - 1);
......@@ -402,6 +412,8 @@ public class ShopServiceImpl implements ShopService {
if (shops == null || shops.getNumberOfElements() < 1)
return new ShopPageResultDto();
List<ShopResultDto> shopResultDtos = new ArrayList<>();
logger.error("shops.size" + shops.getNumberOfElements());
logger.error("shops.content.size " + shops.getContent().size());
shops.getContent().stream().forEach(x -> {
IpResource ipResource = ipResourceRepository.findByShopIdAndIsDeleted(x.getShopId(), false);
if (ipResource == null)
......@@ -450,7 +462,7 @@ public class ShopServiceImpl implements ShopService {
int willexpired = ipResourceRepository.countByStatusAndIdInAndIsDeleted(2, bind, false);
shopSummary.setExpired(expired);
shopSummary.setWillExpire(willexpired);
shopSummary.setTotal(userShopRepository.countByUsername(username));
shopSummary.setTotal(shopIds.size());
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