|
|
|
@ -22,6 +22,7 @@ import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper
|
|
|
|
|
import au.com.royalpay.payment.manage.appclient.beans.AppClientBean;
|
|
|
|
|
import au.com.royalpay.payment.manage.appclient.beans.AppMerchantBean;
|
|
|
|
|
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
|
|
|
|
|
import au.com.royalpay.payment.manage.dev.bean.TestMerchantAccountInfo;
|
|
|
|
|
import au.com.royalpay.payment.manage.device.core.DeviceManager;
|
|
|
|
|
import au.com.royalpay.payment.manage.management.sysconfig.core.impls.PermissionPartnerManagerImpl;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper;
|
|
|
|
@ -94,6 +95,7 @@ import org.springframework.cache.annotation.Cacheable;
|
|
|
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
|
import org.springframework.context.ApplicationEventPublisherAware;
|
|
|
|
|
import org.springframework.context.MessageSource;
|
|
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -280,6 +282,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
private CommonSubMerchantIdMapper commonSubMerchantIdMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private Locker locker;
|
|
|
|
|
@Resource
|
|
|
|
|
private MongoTemplate mongoTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@ -5093,30 +5097,28 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
|
|
|
|
|
private void sendTestMerchantPassword(List<JSONObject> accounts) {
|
|
|
|
|
List<JSONObject> royalPayUsers = managerMapper.listRoyalPayUsers();
|
|
|
|
|
royalPayUsers = royalPayUsers.stream().filter(rpUser -> StringUtils.isNotEmpty(rpUser.getString("email"))).collect(Collectors.toList());
|
|
|
|
|
List<String> needNotifyUsers = royalPayUsers.stream().filter(user -> StringUtils.isNotEmpty(user.getString("wx_openid"))).map(user -> user.getString("wx_openid")).collect(Collectors.toList());
|
|
|
|
|
List<JSONObject> sendAccounts = new ArrayList<>();
|
|
|
|
|
needNotifyUsers.forEach(userOpenId -> {
|
|
|
|
|
try {
|
|
|
|
|
accounts.forEach(account -> {
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
|
params.put("client_moniker", account.getString("client_moniker"));
|
|
|
|
|
params.put("role", account.getIntValue("role"));
|
|
|
|
|
params.put("username", account.getString("username"));
|
|
|
|
|
params.put("password", account.getString("password"));
|
|
|
|
|
sendAccounts.add(params);
|
|
|
|
|
TestMerchantAccountInfo accountInfo = new TestMerchantAccountInfo();
|
|
|
|
|
accountInfo.setId(account.getString("username"));
|
|
|
|
|
accountInfo.setClientMoniker(account.getString("client_moniker"));
|
|
|
|
|
accountInfo.setRole(account.getIntValue("role"));
|
|
|
|
|
accountInfo.setUsername(account.getString("username"));
|
|
|
|
|
accountInfo.setPassword(account.getString("password"));
|
|
|
|
|
mongoTemplate.save(accountInfo);
|
|
|
|
|
});
|
|
|
|
|
String signStr = "?sign=" + AESencrypt(sendAccounts.toString(), userOpenId);
|
|
|
|
|
needNotifyUsers.forEach(userOpenId -> {
|
|
|
|
|
try {
|
|
|
|
|
MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi();
|
|
|
|
|
TemplateMessage msg = initSendTestPasswordTemplate(userOpenId, paymentApi.getTemplateId("test-merchant-password"), signStr.replace("+", "%2B"));
|
|
|
|
|
TemplateMessage msg = initSendTestPasswordTemplate(userOpenId, paymentApi.getTemplateId("test-merchant-password"));
|
|
|
|
|
paymentApi.sendTemplateMessage(msg);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("给{}发送微信消息失败,原因:{}", userOpenId, e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
private TemplateMessage initSendTestPasswordTemplate(String wxopenid, String templateId, String url) {
|
|
|
|
|
TemplateMessage msg = new TemplateMessage(wxopenid, templateId, PlatformEnvironment.getEnv().concatUrl("testMerchantPassword" + url));
|
|
|
|
|
private TemplateMessage initSendTestPasswordTemplate(String wxopenid, String templateId) {
|
|
|
|
|
TemplateMessage msg = new TemplateMessage(wxopenid, templateId, PlatformEnvironment.getEnv().concatUrl("testMerchantPassword"));
|
|
|
|
|
msg.put("first", "系统测试商户账户已重置", "#000000");
|
|
|
|
|
msg.put("keyword1", "PINE", "#0000ff");
|
|
|
|
|
msg.put("keyword2", "账号密码重置", "#000000");
|
|
|
|
@ -5130,27 +5132,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
return api.registerShortUrl(longUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String AESencrypt(String content, String password) {
|
|
|
|
|
try {
|
|
|
|
|
KeyGenerator kgen = KeyGenerator.getInstance("AES");
|
|
|
|
|
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
|
|
|
|
random.setSeed(password.getBytes());
|
|
|
|
|
kgen.init(128, random);
|
|
|
|
|
SecretKey secretKey = kgen.generateKey();
|
|
|
|
|
byte[] enCodeFormat = secretKey.getEncoded();
|
|
|
|
|
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");
|
|
|
|
|
Cipher cipher = Cipher.getInstance("AES");
|
|
|
|
|
byte[] byteContent = content.getBytes(StandardCharsets.UTF_8);
|
|
|
|
|
cipher.init(Cipher.ENCRYPT_MODE, key);
|
|
|
|
|
byte[] result = cipher.doFinal(byteContent);
|
|
|
|
|
return Base64.encodeBase64String(result);
|
|
|
|
|
} catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject getRsaKey() {
|
|
|
|
|
JSONObject key = new JSONObject();
|
|
|
|
|
KeyPair keyPairGen = RSACrypt.generateKeyPairs();
|
|
|
|
|