rollback mailgun

master
wangning 7 years ago
parent 57ee6e86bb
commit ab42149104

@ -68,7 +68,7 @@ public interface ClientManager {
void checkAndSendInitEmail(JSONObject manager, String clientMoniker);
void sendInitEmail(JSONObject account,JSONObject client, String username, String pwd);
// void sendInitEmail(JSONObject account,JSONObject client, String username, String pwd);
void markApproveEmailSendStatus(String clientMoniker, JSONObject manager);

@ -756,7 +756,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client.getIntValue("source") == 4) {
List<JSONObject> accounts = clientAccountMapper.listAdminAccounts(client.getIntValue("client_id"));
JSONObject account = accounts.get(0);
sendInitEmail(manager, client, account.getString("username"), "*****");
sendInitEmail(client, account.getString("username"), "*****");
// sendInitEmail(manager, client, account.getString("username"), "*****");
saveClientAuditProcess(client.getIntValue("client_id"), open_status, 5, "合规通过", manager);
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager,clientMoniker,"skip_clearing",false));
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager,clientMoniker,"common_sub_merchant_id",false));
@ -812,7 +813,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
username += "1";
}
}
sendInitEmail(manager, client, username, pwd);
sendInitEmail(client, username, pwd);
// sendInitEmail(manager, client, username, pwd);
}
@Override
@ -836,7 +838,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
List<JSONObject> accounts = clientAccountMapper.listAdminAccounts(clientId);
if (client.getIntValue("source") == 4) {
JSONObject account = accounts.get(0);
sendInitEmail(manager, client, account.getString("username"), "*****");
// sendInitEmail(manager, client, account.getString("username"), "*****");
sendInitEmail(client, account.getString("username"), "*****");
} else {
if (accounts.size() == 0) {
initAdminUserAndSendEmail(manager, clientMoniker, client);
@ -844,13 +847,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
JSONObject account = accounts.get(0);
String pwd = RandomStringUtils.random(8, true, true);
resetAccountPwd(manager, clientMoniker, account.getString("account_id"), pwd);
sendInitEmail(manager, client, account.getString("username"), pwd);
// sendInitEmail(manager, client, account.getString("username"), pwd);
sendInitEmail(client, account.getString("username"), pwd);
}
}
}
@Override
public void sendInitEmail(JSONObject account, final JSONObject client, String username, String pwd) {
public void sendInitEmail(final JSONObject client, String username, String pwd) {
logger.debug("sending email after comply");
JSONObject model = new JSONObject();
model.put("username", username);
@ -867,7 +870,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
ctx.setVariable("client_moniker", client.getString("client_moniker"));
ctx.setVariable("contact_person", client.getString("contact_person"));
ctx.setVariable("credential_code", client.getString("credential_code"));
ctx.setVariable("short_name", client.getString("short_name"));
final String content = thymeleaf.process("mail/new_client_notice", ctx);
// final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/new_client_notice.vm",
// "utf-8", model);
@ -875,7 +877,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (StringUtils.isEmpty(mailTo)) {
throw new EmailException("Client Contact Email is invalid");
}
final Set<String> emails = new HashSet<>();
final List<String> emails = new ArrayList<>();
for (JSONObject bd : bds) {
String email = bd.getString("email");
if (StringUtils.isNotEmpty(email)) {
@ -886,24 +888,81 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void run() {
try {
SendMail sendMail = new SendMail();
Set<String> to = new HashSet<>();
to.add(mailTo);
sendMail.setFrom("info@mail.royalpay.com.au");
sendMail.setMailTos(to);
sendMail.setMailCcs(emails);
sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up");
sendMail.setContent(content);
sendMail.setTags(tags);
JSONObject mailResult = mailGunService.sendMail(sendMail);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, mailResult.getString("mail_id")));
String emailId = mailService.sendEmail("Your RoyalPay Cross-border Payment has been set up", mailTo,
emails.isEmpty() ? "" : StringUtils.join(emails, ","), content);
JSONObject clientUpdate = new JSONObject();
clientUpdate.put("client_id", client.getIntValue("client_id"));
clientUpdate.put("approve_email_send", 3);
clientUpdate.put("approve_email_id", emailId);
clientMapper.update(clientUpdate);
} catch (Exception e) {
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 0, null));
JSONObject clientUpdate = new JSONObject();
clientUpdate.put("client_id", client.getIntValue("client_id"));
clientUpdate.put("approve_email_send", 0);
clientUpdate.put("approve_email_id", null);
clientMapper.update(clientUpdate);
throw new EmailException("Email Sending Failed", e);
}
}
}.start();
}
/**
* public void sendInitEmail(JSONObject account, final JSONObject client, String username, String pwd) {
logger.debug("sending email after comply");
JSONObject model = new JSONObject();
model.put("username", username);
model.put("password", pwd);
model.put("client_moniker", client.getString("client_moniker"));
model.put("contact_person", client.getString("contact_person"));
model.put("credential_code", client.getString("credential_code"));
List<JSONObject> bds = clientBDMapper.listClientBDInfoAvailable(client.getIntValue("client_id"), new Date());
// todo Velocity
Context ctx = new Context();
ctx.setVariable("bds", bds);
ctx.setVariable("password", pwd);
ctx.setVariable("username", username);
ctx.setVariable("client_moniker", client.getString("client_moniker"));
ctx.setVariable("contact_person", client.getString("contact_person"));
ctx.setVariable("credential_code", client.getString("credential_code"));
ctx.setVariable("short_name", client.getString("short_name"));
final String content = thymeleaf.process("mail/new_client_notice", ctx);
// final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/new_client_notice.vm",
// "utf-8", model);
final String mailTo = client.getString("contact_email");
if (StringUtils.isEmpty(mailTo)) {
throw new EmailException("Client Contact Email is invalid");
}
final Set<String> emails = new HashSet<>();
for (JSONObject bd : bds) {
String email = bd.getString("email");
if (StringUtils.isNotEmpty(email)) {
emails.add(email);
}
}
new Thread() {
@Override
public void run() {
try {
SendMail sendMail = new SendMail();
Set<String> to = new HashSet<>();
to.add(mailTo);
sendMail.setFrom("info@mail.royalpay.com.au");
sendMail.setMailTos(to);
sendMail.setMailCcs(emails);
sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up");
sendMail.setContent(content);
sendMail.setTags(tags);
JSONObject mailResult = mailGunService.sendMail(sendMail);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, mailResult.getString("mail_id")));
} catch (Exception e) {
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 0, null));
throw new EmailException("Email Sending Failed", e);
}
}
}.start();
}
*/
public void sendAuthInitEmail(JSONObject account, final JSONObject client) {
logger.debug("sending email after comply about a new partner opening by quick access");

@ -28,10 +28,9 @@ import org.springframework.util.Assert;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
@ -146,6 +145,7 @@ public class NoticeManageImpl implements NoticeManage {
}
if (!notice.getBoolean("merchants_type")){
StringBuilder sendClients = new StringBuilder();
List<JSONObject> clients = clientMapper.listValidClient();
clients.forEach(c -> {
if (c.getInteger("parent_client_id")==null || c.getInteger("parent_client_id")!=9){
@ -155,40 +155,45 @@ public class NoticeManageImpl implements NoticeManage {
});
if (sendClients.length()>0){
notice.put("send_clients",sendClients.substring(0,sendClients.length()-1));
}
}else {
notice.put("send_clients",info.getSend_clients());
}
noticeManageMapper.updateNotice(notice);
if (info.getStatus() != null && info.getSend_clients() != null) {
if (info.getStatus().equals("1") && noticeInfo.getString("status").equals("0") && !info.getSend_clients().isEmpty()) {
String client_monikers []=info.getSend_clients().split(",");
Set<String> mailto = new HashSet<>();
if(notice.getBoolean("merchants_type")){
for (String clientMoniker : client_monikers) {
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
String contact_email = client.getString("contact_email");
if (contact_email!=null){
mailto.add(contact_email);
}
List<JSONObject> mailto = new ArrayList<>();
ArrayList<String> mailboxs = new ArrayList<>();
for (String clientMoniker : client_monikers) {
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
JSONObject c = new JSONObject();
c.put("create_time", date);
c.put("notice_id", noticeId);
c.put("client_id", client.getIntValue("client_id"));
noticePartnerMapper.save(c);
String contact_email = client.getString("contact_email");
if (contact_email!=null && !mailboxs.contains(contact_email)){
c.put("mailto",contact_email);
mailto.add(c);
mailboxs.add(contact_email);
}
}else {
mailto.add(mailListDefault);
}
if(info.isIs_tomail()){
//同时发送给股东
if (info.isIs_tomail_cc_stockholder()){
String stockholder_mails_mailto [] = stockholder_mails.trim().split(",");
for (String stockholder_mailto:stockholder_mails_mailto){
mailto.add(stockholder_mailto);
JSONObject stockholder = new JSONObject();
stockholder.put("mailto",stockholder_mailto);
stockholder.put("client_id",0);
mailto.add(stockholder);
}
}
try {
logger.info(noticeId+"|"+info.getTitle()+"|"+mailto);
JSONObject mailResult = mailGunService.sendEmail(noticeId,info.getTitle(),mailto,info.getContent());
notice.put("mail_id",mailResult.getString("mail_id"));
String mail_id = mailService.sendEmail(noticeId,info.getTitle(),mailto,info.getContent());
notice.put("mail_id",mail_id);
noticeManageMapper.updateNotice(notice);
} catch (URISyntaxException | IOException e) {
e.printStackTrace();
@ -201,8 +206,82 @@ public class NoticeManageImpl implements NoticeManage {
retailAppService.sendNoticeMessage(info,client_monikers);
}
}
}
}
// public void updateNotice(JSONObject manager, String noticeId, NoticeInfo info) throws Exception {
// JSONObject noticeInfo = noticeManageMapper.getNoticeDetailById(noticeId);
// Assert.notNull(noticeInfo);
// Date date = new Date();
// JSONObject notice = info.toJson();
// notice.put("notice_id", noticeId);
// if (info.getStatus().equals("1")) {
// notice.put("send_time", date);
// notice.put("send_id", manager.getString("manager_id"));
// notice.put("send_name", manager.getString("display_name"));
// }
// if (!notice.getBoolean("merchants_type")){
// StringBuilder sendClients = new StringBuilder();
//
// List<JSONObject> clients = clientMapper.listValidClient();
// clients.forEach(c -> {
// if (c.getInteger("parent_client_id")==null || c.getInteger("parent_client_id")!=9){
// String p = c.getString("client_moniker")+",";
// sendClients.append(p);
// }
// });
// if (sendClients.length()>0){
// notice.put("send_clients",sendClients.substring(0,sendClients.length()-1));
//
// }
// }
// noticeManageMapper.updateNotice(notice);
// if (info.getStatus() != null && info.getSend_clients() != null) {
// if (info.getStatus().equals("1") && noticeInfo.getString("status").equals("0") && !info.getSend_clients().isEmpty()) {
// String client_monikers []=info.getSend_clients().split(",");
// List<JSONObject> mailto = new ArrayList<>();
// ArrayList<String> mailboxs = new ArrayList<>();
// for (String clientMoniker : client_monikers) {
// JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
// client.put("create_time", date);
// client.put("notice_id", noticeId);
// noticePartnerMapper.save(client);
// String contact_email = client.getString("contact_email");
// if (contact_email!=null && !mailboxs.contains(contact_email)){
// client.put("mailto",contact_email);
// mailto.add(client);
// mailboxs.add(contact_email);
// }
// }
// if(info.isIs_tomail()){
// //同时发送给股东
// if (info.isIs_tomail_cc_stockholder()){
// String stockholder_mails_mailto [] = stockholder_mails.trim().split(",");
// for (String stockholder_mailto:stockholder_mails_mailto){
// JSONObject stockholder = new JSONObject();
// stockholder.put("mailto",stockholder_mailto);
// stockholder.put("client_id",0);
// mailto.add(stockholder);
// }
// }
// try {
// String mail_id = mailService.sendEmail(noticeId,info.getTitle(),mailto,info.getContent());
// notice.put("mail_id",mail_id);
// noticeManageMapper.updateNotice(notice);
// } catch (URISyntaxException | IOException e) {
// e.printStackTrace();
// logger.error("sending email failed:", e.getMessage(), e);
// throw new Exception(e.getMessage());
// }
// }
// if (info.isIs_to_app()){
// info.setNotice_id(noticeId);
// retailAppService.sendNoticeMessage(info,client_monikers);
// }
// }
//
// }
// }

@ -9,19 +9,18 @@ import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientConfigService;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.manage.signin.events.ClientLoginEvent;
import au.com.royalpay.payment.manage.signin.events.ManagerLoginEvent;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.env.RequestEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.mail.SendMail;
import au.com.royalpay.payment.tools.utils.PasswordUtils;
import com.alibaba.fastjson.JSONObject;
@ -40,10 +39,8 @@ import org.thymeleaf.spring4.SpringTemplateEngine;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
@ -64,7 +61,7 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
@Resource
private ClientMapper clientMapper;
@Resource
private MailGunService mailService;
private MailService mailService;
@Resource
private PermissionManager permissionManager;
@Resource
@ -310,28 +307,24 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
String codeKey = signInStatusManager.addChangepasswordVerifyCode(client_moniker);
String url = PlatformEnvironment.getEnv().concatUrl("/global/userstatus/partner_changepassword_page/" + codeKey);
// JSONObject map = new JSONObject();
// map.put("url", url);
// map.put("accounts", accounts);
// map.put("client_moniker", client_moniker);
// todo velocityEngine
// JSONObject map = new JSONObject();
// map.put("url", url);
// map.put("accounts", accounts);
// map.put("client_moniker", client_moniker);
//todo velocityEngine
Context ctx = new Context();
ctx.setVariable("url", url);
ctx.setVariable("accounts", accounts);
ctx.setVariable("client_moniker", client_moniker);
final String content = thymeleaf.process("mail/reset_password", ctx);
// final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/reset_password.vm",
// "utf-8", map);
SendMail sendMail = new SendMail();
Set<String> to = new HashSet<>();
to.add(contact_email);
sendMail.setMailTos(to);
sendMail.setFrom("info@mail.royalpay.com.au");
sendMail.setTitle("Reset Password");
sendMail.setContent(content);
sendMail.setTags(tags);
mailService.sendMail(sendMail);
final String content = thymeleaf.process( "mail/reset_password", ctx);
//final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/reset_password.vm", "utf-8", map);
new Thread(() -> {
try {
mailService.sendEmail("Reset Password", contact_email, "", content);
} catch (Exception ignored) {
}
}).start();
return contact_email;
@ -342,6 +335,50 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
throw new Exception("Not found the corresponding partner code,Please contact customer service");
}
}
// public String ForgetPassword(String client_moniker) throws Exception {
// JSONObject client = clientMapper.findClientByMoniker(client_moniker);
// if (client != null) {
// final String contact_email = client.getString("contact_email");
// if (contact_email == null) {
// throw new Exception("Email Address of this partner is null,Please contact customer service");
// }
// List<JSONObject> accounts = clientAccountMapper.listAdminAccounts(client.getIntValue("client_id"));
// if (accounts != null && accounts.size() > 0) {
//
// String codeKey = signInStatusManager.addChangepasswordVerifyCode(client_moniker);
// String url = PlatformEnvironment.getEnv().concatUrl("/global/userstatus/partner_changepassword_page/" + codeKey);
// // JSONObject map = new JSONObject();
// // map.put("url", url);
// // map.put("accounts", accounts);
// // map.put("client_moniker", client_moniker);
// // todo velocityEngine
// Context ctx = new Context();
// ctx.setVariable("url", url);
// ctx.setVariable("accounts", accounts);
// ctx.setVariable("client_moniker", client_moniker);
// final String content = thymeleaf.process("mail/reset_password", ctx);
// // final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/reset_password.vm",
// // "utf-8", map);
//
// SendMail sendMail = new SendMail();
// Set<String> to = new HashSet<>();
// to.add(contact_email);
// sendMail.setMailTos(to);
// sendMail.setFrom("info@mail.royalpay.com.au");
// sendMail.setTitle("Reset Password");
// sendMail.setContent(content);
// sendMail.setTags(tags);
// mailService.sendMail(sendMail);
//
// return contact_email;
//
// } else {
// throw new Exception("The partner has no Administrator account ,Please contact customer service");
// }
// } else {
// throw new Exception("Not found the corresponding partner code,Please contact customer service");
// }
// }
public static JSONObject clientInfoWithNoSecretInfo(JSONObject client) {
JSONObject simpleClient = new JSONObject();

Loading…
Cancel
Save