Commit 5e9a7946 authored by renjie's avatar renjie

分配店铺bug

parent f22e948f
...@@ -124,6 +124,9 @@ public class AccountServiceImpl implements AccountService { ...@@ -124,6 +124,9 @@ public class AccountServiceImpl implements AccountService {
@Autowired @Autowired
private QueryIpUrlListRepository queryIpUrlListRepository; private QueryIpUrlListRepository queryIpUrlListRepository;
@Autowired
private PaymentService paymentService;
@Override @Override
public List<UserBillList> getUserBills0(String name) { public List<UserBillList> getUserBills0(String name) {
...@@ -465,8 +468,9 @@ public class AccountServiceImpl implements AccountService { ...@@ -465,8 +468,9 @@ public class AccountServiceImpl implements AccountService {
account.setEmail(user.getEmail()); account.setEmail(user.getEmail());
account.setPhoneNumber(user.getUsername()); account.setPhoneNumber(user.getUsername());
account.setPermission(15); account.setPermission(15);
if (user.getPromotionCode() != null) if (user.getPromotionCode() != null) {
account.setPromotionCode(user.getPromotionCode()); account.setPromotionCode(user.getPromotionCode());
}
Account inviter = repository.findByPromotion(user.getPromotionCode()); Account inviter = repository.findByPromotion(user.getPromotionCode());
if (inviter != null) { if (inviter != null) {
...@@ -498,6 +502,10 @@ public class AccountServiceImpl implements AccountService { ...@@ -498,6 +502,10 @@ public class AccountServiceImpl implements AccountService {
userAuthService.create(new com.edgec.browserbackend.auth.domain.User(user)); userAuthService.create(new com.edgec.browserbackend.auth.domain.User(user));
repository.save(account); repository.save(account);
if (inviter != null) {
paymentService.bankTransferInsertion(account.getName(), 12);
}
log.info("new account has been created: " + account.getName()); log.info("new account has been created: " + account.getName());
notifyCustomerRegister(account); notifyCustomerRegister(account);
......
...@@ -213,4 +213,21 @@ public class ShopController { ...@@ -213,4 +213,21 @@ public class ShopController {
} }
return resultDto; return resultDto;
} }
@RequestMapping(value = "/batch/subusers", method = RequestMethod.POST)
public ResultDto getBatchShopSubUsers(Principal principal, @RequestBody ShopRequestDto shopRequestDto) {
ResultDto resultDto = new ResultDto();
try {
List<String> subUsers = shopService.getBatchShopUsers(principal.getName(), shopRequestDto.getShopIds());
resultDto.setData(subUsers);
resultDto.setStatus(0);
}catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
statusInfo.put("message", e.getMessage());
resultDto.setStatusInfo(statusInfo);
}
return resultDto;
}
} }
...@@ -12,4 +12,6 @@ public interface UserShopRepository extends MongoRepository<UserShop, String>, U ...@@ -12,4 +12,6 @@ public interface UserShopRepository extends MongoRepository<UserShop, String>, U
List<UserShop> findByUsernameAndGroupId(String username, String groupId); List<UserShop> findByUsernameAndGroupId(String username, String groupId);
List<UserShop> findByUsernameAndShopIdIn(String username, List<String> shopIds); List<UserShop> findByUsernameAndShopIdIn(String username, List<String> shopIds);
int countByUsername(String username); int countByUsername(String username);
int countByShopId(String shopId);
int countByUsernameAndShopIdIn(String username, List<String> shopIds);
} }
...@@ -24,6 +24,7 @@ import org.springframework.data.domain.Page; ...@@ -24,6 +24,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -267,7 +268,6 @@ public class ShopServiceImpl implements ShopService { ...@@ -267,7 +268,6 @@ public class ShopServiceImpl implements ShopService {
{ {
throw new ClientRequestException(AccountErrorCode.NOPERMISSION); throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
} }
} }
shops.stream().forEach(shop -> { shops.stream().forEach(shop -> {
try { try {
...@@ -410,7 +410,39 @@ public class ShopServiceImpl implements ShopService { ...@@ -410,7 +410,39 @@ public class ShopServiceImpl implements ShopService {
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST); throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
if (account.getParent() != null) if (account.getParent() != null)
throw new ClientRequestException(AccountErrorCode.NOPERMISSION); throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
List<String> shopUsers = userShopRepository.findByShopId(shopId).stream().map(x -> x.getUsername()).filter(x -> x==username).collect(Collectors.toList()); List<String> shopUsers = userShopRepository.findByShopId(shopId).stream().map(x -> x.getUsername()).filter(x -> !x.equals(username)).collect(Collectors.toList());
return shopUsers;
}
@Override
public List<String> getBatchShopUsers(String username, List<String> shopIds) {
Account account = accountRepository.findByName(username);
if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
if (account.getParent() != null)
throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
List<String> shopUsers = new ArrayList<>();
if (shopIds != null && shopIds.size() > 0) {
String maxShopId = null;
int max = 0;
for (String shopId:shopIds) {
int userCount = userShopRepository.countByShopId(shopId);
if (userCount > max) {
max = userCount;
maxShopId = shopId;
}
}
if (maxShopId == null)
return new ArrayList<>();
List<String> users = userShopRepository.findByShopId(maxShopId).stream().map(x -> x.getUsername()).filter(x -> !x.equals(username)).collect(Collectors.toList());
for (String user : users) {
int shopCount = userShopRepository.countByUsernameAndShopIdIn(user, shopIds);
if (shopCount < shopIds.size())
continue;
else
shopUsers.add(user);
}
}
return shopUsers; return shopUsers;
} }
} }
...@@ -30,4 +30,6 @@ public interface ShopService { ...@@ -30,4 +30,6 @@ public interface ShopService {
ShopSummary getShopSummary(String username); ShopSummary getShopSummary(String username);
List<String> getShopUsers(String username, String shopId); List<String> getShopUsers(String username, String shopId);
List<String> getBatchShopUsers(String username, List<String> shopIds);
} }
package com.edgec.browserbackend.common.utils;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.util.StringUtils;
import javax.crypto.*;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.Base64;
public class EncodeUtil {
public void decodeBase64() {
System.out.println(Base64.getDecoder().decode("G65nlqVr9c7ZBUN/uEG136nZ/a1lneIHbQ3sY8Cj5SA="));
}
public void encodeBase64() throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, UnsupportedEncodingException, InvalidKeySpecException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
byte[] byteContent = new byte[0];
byteContent = "b3LcaXzXzf4Z6GzB6q2KyMP5RC1pF6".getBytes("utf-8");
byte[] salt = new byte[]{
0x47, 0x8, 0x0e, 0x0b, 0x02, 0x0f, 0x0b, 0x0c,
0x01, 0x03, 0x12, 0x07, 0x0c, 0x02, 0x07, 0x09,
0x0a, 0x0a, 0x01, 0x07, 0x0b, 0x07, 0x09, 0x0d};
SecretKeyFactory factory = null;
factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
char[] passphrase = (StringUtils.isEmpty(System.getenv("INTELLIGROUP_PHRASE")) ?
"ACtrecje!@9cs93cdeMMdkc" : System.getenv("INTELLIGROUP_PHRASE")).toCharArray();
KeySpec spec = new PBEKeySpec(passphrase, salt, 65536, 256);
SecretKey tmp = null;
tmp = factory.generateSecret(spec);
SecretKeySpec secret = new SecretKeySpec(tmp.getEncoded(), "AES");
Security.addProvider(new BouncyCastleProvider());
Cipher encryptor = null;
encryptor = Cipher.getInstance("AES/ECB/PKCS7Padding", "BC");
encryptor.init(Cipher.ENCRYPT_MODE, secret);
byte[] cryptograph = new byte[0];
cryptograph = encryptor.doFinal(byteContent);
String encryptedKeyId = Base64.getEncoder().encodeToString(cryptograph);
System.out.println(encryptedKeyId);
}
}
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