|
|
|
@ -4283,13 +4283,19 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void updateAllPartnerPassword(String clientMoniker, List<String> emails, String accountWhiteList) {
|
|
|
|
|
public void updateAllPartnerPassword(String clientMoniker) {
|
|
|
|
|
JSONObject client = getClientInfoByMoniker(clientMoniker);
|
|
|
|
|
if (client == null) {
|
|
|
|
|
throw new InvalidShortIdException();
|
|
|
|
|
}
|
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
|
String accountWhiteList = sysConfig.getString("reset_password.account_white_list");
|
|
|
|
|
List<JSONObject> partners = clientAccountMapper.partnerAndSubPartnerAccounts(client.getIntValue("client_id"));
|
|
|
|
|
partners = partners.stream().filter(partner -> !Arrays.asList(accountWhiteList.split(",")).contains(partner.getString("username"))).collect(Collectors.toList());
|
|
|
|
|
if (!StringUtils.isEmpty(accountWhiteList)) {
|
|
|
|
|
partners = partners.stream().filter(partner ->
|
|
|
|
|
!Arrays.asList(accountWhiteList.split(",")).contains(partner.getString("username"))
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
partners.forEach(
|
|
|
|
|
partner -> {
|
|
|
|
|
String pwd = RandomStringUtils.random(8, true, true);
|
|
|
|
@ -4304,7 +4310,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
partner.put("password", pwd);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
sendTestMerchantPassword(partners, emails);
|
|
|
|
|
sendTestMerchantPassword(partners);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -4563,52 +4569,44 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void sendTestMerchantPassword(List<JSONObject> accounts, List<String> emails) {
|
|
|
|
|
List<String> devAndBdEmails = managerMapper.listDevAndBdManager();
|
|
|
|
|
for(int i=0;i<devAndBdEmails.size();i++){
|
|
|
|
|
if(StringUtils.isBlank(devAndBdEmails.get(i)))
|
|
|
|
|
devAndBdEmails.remove(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void sendTestMerchantPassword(List<JSONObject> accounts) {
|
|
|
|
|
List<JSONObject> royalPayUsers = managerMapper.listRoyalPayUsers();
|
|
|
|
|
royalPayUsers = royalPayUsers.stream().filter(rpUser -> StringUtils.isNotEmpty(rpUser.getString("email"))).collect(Collectors.toList());
|
|
|
|
|
String needSendEmails = royalPayUsers.stream().filter(user -> StringUtils.isNotEmpty(user.getString("email"))).map(user ->
|
|
|
|
|
user.getString("email")
|
|
|
|
|
).collect(Collectors.joining(","));
|
|
|
|
|
Context ctx = new Context();
|
|
|
|
|
ctx.setVariable("accounts", accounts);
|
|
|
|
|
final String content = thymeleaf.process( "mail/test_merchant_password", ctx);
|
|
|
|
|
final String content = thymeleaf.process("mail/test_merchant_password", ctx);
|
|
|
|
|
new Thread(() -> {
|
|
|
|
|
try {
|
|
|
|
|
mailService.sendEmail("测试商户账户已更新", emails.isEmpty() ? "" : StringUtils.join(emails, ","), devAndBdEmails.isEmpty() ? "" : StringUtils.join(devAndBdEmails, ","), content);
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
logger.error("邮件发送失败", ignored);
|
|
|
|
|
throw new BadRequestException("邮件发送失败");
|
|
|
|
|
mailService.sendEmailWhihBcc("测试商户账户已更新", "info@royalpay.com.au", needSendEmails, content);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BadRequestException("邮件发送失败", e);
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
|
|
|
|
|
StringBuffer accountsStr = new StringBuffer("?");
|
|
|
|
|
|
|
|
|
|
accounts.forEach(e->{
|
|
|
|
|
accountsStr.append("accounts=" + e.getString("username") + ","
|
|
|
|
|
+ e.getString("password") + "," + e.getIntValue("role") + "," + e.getString("client_moniker") + "&");
|
|
|
|
|
accounts.forEach(account -> {
|
|
|
|
|
accountsStr.append("accounts=").append(account.getString("username")).append(",").append(account.getString("password")).append(",").append(account.getIntValue("role")).append(",").append(account.getString("client_moniker")).append("&");
|
|
|
|
|
});
|
|
|
|
|
String account = accountsStr.substring(0, accountsStr.length() - 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> wx_openIds = managerMapper.listDevAndBdOpenId();
|
|
|
|
|
for (String wxopenid : wx_openIds) {
|
|
|
|
|
if (StringUtils.isNotBlank(wxopenid)) {
|
|
|
|
|
try {
|
|
|
|
|
MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi();
|
|
|
|
|
TemplateMessage msg = initSendTestPasswordTemplate(wxopenid, paymentApi.getTemplateId("test-merchant-password"), account);
|
|
|
|
|
paymentApi.sendTemplateMessage(msg);
|
|
|
|
|
} catch (WechatException e) {
|
|
|
|
|
logger.error("Wechat Message Error,密码修改完成" + e.getMessage());
|
|
|
|
|
publisher.publishEvent(new WechatExceptionEvent(this, e, "测试商户密码修改完成"));
|
|
|
|
|
}
|
|
|
|
|
List<String> needNotifyUsers = royalPayUsers.stream().filter(user -> StringUtils.isNotEmpty(user.getString("wx_openid"))).map(user -> user.getString("wx_openid")).collect(Collectors.toList());
|
|
|
|
|
needNotifyUsers.forEach(userOpenId -> {
|
|
|
|
|
try {
|
|
|
|
|
MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi();
|
|
|
|
|
TemplateMessage msg = initSendTestPasswordTemplate(userOpenId, paymentApi.getTemplateId("test-merchant-password"), StringUtils.substring(accountsStr.toString(), 0, accountsStr.length() - 1));
|
|
|
|
|
paymentApi.sendTemplateMessage(msg);
|
|
|
|
|
} catch (WechatException e) {
|
|
|
|
|
logger.error("给{}发送微信消息失败,原因:{}", userOpenId, e.getMessage());
|
|
|
|
|
publisher.publishEvent(new WechatExceptionEvent(this, e, "测试商户密码修改完成"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("给{}发送密码重置消息失败,原因: {}", userOpenId, e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TemplateMessage initSendTestPasswordTemplate(String wxopenid, String templateId,String url) {
|
|
|
|
|
TemplateMessage msg = new TemplateMessage(wxopenid, templateId, "https://mpay.royalpay.com.au/testMerchantPassword" + url);
|
|
|
|
|
msg.put("first", "尊敬的用户,该商户下账号密码已重置。", "#000000");
|
|
|
|
|
private TemplateMessage initSendTestPasswordTemplate(String wxopenid, String templateId, String url) {
|
|
|
|
|
TemplateMessage msg = new TemplateMessage(wxopenid, templateId, PlatformEnvironment.getEnv().concatUrl("testMerchantPassword" + url));
|
|
|
|
|
msg.put("first", "系统测试商户账户已重置", "#000000");
|
|
|
|
|
msg.put("keyword1", "PINE", "#0000ff");
|
|
|
|
|
msg.put("keyword2", "账号密码重置", "#000000");
|
|
|
|
|
msg.put("keyword3", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss,z"), "#000000");
|
|
|
|
|