|
|
|
@ -4,6 +4,8 @@ import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
|
import au.com.royalpay.payment.manage.notice.beans.NoticeBean;
|
|
|
|
|
import au.com.royalpay.payment.manage.notice.core.MailService;
|
|
|
|
|
import au.com.royalpay.payment.tools.codec.AESCrypt;
|
|
|
|
|
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
@ -18,6 +20,8 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.net.util.Base64;
|
|
|
|
|
import org.jsoup.Jsoup;
|
|
|
|
|
import org.jsoup.nodes.Document;
|
|
|
|
|
import org.jsoup.nodes.Element;
|
|
|
|
@ -26,10 +30,13 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.security.Key;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -53,7 +60,11 @@ public class MailServiceImp implements MailService {
|
|
|
|
|
@Resource
|
|
|
|
|
private MailUnsubMapper mailUnsubMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private SysConfigManager sysConfigManager;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientManager clientManager;
|
|
|
|
|
@Value("${app.settle.aes-key}")
|
|
|
|
|
private String settleAESKey;
|
|
|
|
|
|
|
|
|
|
/* @Override
|
|
|
|
|
public void sendEmail(NoticeBean noticeBean) {
|
|
|
|
@ -120,10 +131,6 @@ public class MailServiceImp implements MailService {
|
|
|
|
|
String postUrl = mailHost + "/mail?" + generateMailSignParam();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HttpRequestResult result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).execute();
|
|
|
|
|
if (result.isSuccess()) {
|
|
|
|
|
String mail_id = result.getResponseContentJSONObj().getString("mail_id");
|
|
|
|
@ -234,8 +241,13 @@ public class MailServiceImp implements MailService {
|
|
|
|
|
mailClients.add(mailClient);
|
|
|
|
|
noticeBean.setMailClients(mailClients);
|
|
|
|
|
noticeBean.setContent(content);
|
|
|
|
|
noticeBean.setSenderAddress("settlement@royalpay.com.au");
|
|
|
|
|
noticeBean.setPassword("MMKdMn7dJj49jp");
|
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
|
noticeBean.setSenderAddress(sysConfig.getString("settle.email.address"));
|
|
|
|
|
String mailPwdEncrypted = sysConfig.getString("settle.email.password");
|
|
|
|
|
Assert.isTrue(StringUtils.isNotEmpty(mailPwdEncrypted), "Settlement mail pwd not configured");
|
|
|
|
|
Key aesKey = AESCrypt.fromKeyString(Base64.decodeBase64(settleAESKey));
|
|
|
|
|
String mailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(mailPwdEncrypted), aesKey), StandardCharsets.UTF_8);
|
|
|
|
|
noticeBean.setPassword(mailPwd);
|
|
|
|
|
noticeBean.setAttachFiles(attachFiles);
|
|
|
|
|
String postUrl = mailHost + "/mail/single?" + generateMailSignParam();
|
|
|
|
|
HttpRequestResult result = null;
|
|
|
|
|