modify mail send

master
wangning 6 years ago
parent 7e21301e7d
commit a46cfe5444

@ -69,6 +69,7 @@ import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.system.core.ClientContractService;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
@ -83,6 +84,7 @@ import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.exceptions.event.WechatExceptionEvent;
import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.mail.SendMail;
import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig;
import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
@ -145,8 +147,10 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
@ -260,6 +264,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private ClientInfoCacheSupport clientInfoCacheSupport;
@Resource
private MongoTemplate mongoTemplate;
@Resource
private MailGunService mailGunService;
private static final String SOURCE_AGREE_FILE = "source_agree_file";
private static final String CLIENT_BANK_FILE = "client_bank_file";
@ -790,7 +796,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (StringUtils.isEmpty(mailTo)) {
throw new EmailException("Client Contact Email is invalid");
}
final List<String> emails = new ArrayList<>();
final Set<String> emails = new HashSet<>();
for (JSONObject bd : bds) {
String email = bd.getString("email");
if (StringUtils.isNotEmpty(email)) {
@ -801,9 +807,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void run() {
try {
String emailId = mailService.sendEmail("Your RoyalPay Cross-border Payment has been set up", mailTo,
emails.isEmpty() ? "" : StringUtils.join(emails, ","), content);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, emailId));
SendMail sendMail = new SendMail();
Set<String> to = new HashSet<>();
to.add(mailTo);
sendMail.setMailTos(to);
sendMail.setMailCcs(emails);
sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up");
sendMail.setContent(content);
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);
@ -837,7 +849,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
List<JSONObject> bds = clientBDMapper.listClientBDInfoAvailable(client.getIntValue("client_id"), new Date());
final List<String> emails = new ArrayList<>();
final Set<String> emails = new HashSet<>();
for (JSONObject bd : bds) {
String email = bd.getString("email");
if (StringUtils.isNotEmpty(email)) {
@ -848,9 +860,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void run() {
try {
String emailId = mailService.sendEmail("Your Partner Account Has Been Authenticated Successfully", mailTo,
emails.isEmpty() ? "" : StringUtils.join(emails, ","), content);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, emailId));
SendMail sendMail = new SendMail();
Set<String> to = new HashSet<>();
to.add(mailTo);
sendMail.setMailTos(to);
sendMail.setMailCcs(emails);
sendMail.setTitle("Your Partner Account Has Been Authenticated Successfully");
sendMail.setContent(content);
JSONObject mailResult = mailGunService.sendMail(sendMail);
clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, mailResult.getString("mail_id")));
} catch (Exception e) {
throw new EmailException("Email Sending Failed", e);
}

@ -15,7 +15,7 @@ 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.MailService;
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;
@ -63,7 +63,7 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
@Resource
private ClientMapper clientMapper;
@Resource
private MailService mailService;
private MailGunService mailService;
@Resource
private PermissionManager permissionManager;
@Resource

@ -5,7 +5,7 @@ import au.com.royalpay.payment.tools.mail.SendMail;
import com.alibaba.fastjson.JSONObject;
public interface MailService {
public interface MailGunService {
void dealNotify(String nofityString) throws Exception;

@ -1,7 +1,7 @@
package au.com.royalpay.payment.manage.system.core.impl;
import au.com.royalpay.payment.manage.mappers.system.MailSendMapper;
import au.com.royalpay.payment.manage.system.core.MailService;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.tools.mail.MailGunClient;
import au.com.royalpay.payment.tools.mail.SendMail;
@ -19,7 +19,7 @@ import java.util.Map;
import javax.annotation.Resource;
@Service
public class MailServiceImpl implements MailService {
public class MailGunServiceImpl implements MailGunService {
Logger logger = LoggerFactory.getLogger(getClass());
@Resource

@ -1,6 +1,6 @@
package au.com.royalpay.payment.manage.system.web;
import au.com.royalpay.payment.manage.system.core.MailService;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -14,7 +14,7 @@ import javax.annotation.Resource;
public class MailCallBackController {
@Resource
private MailService mailService;
private MailGunService mailService;
@RequestMapping(value = "/callback", method = RequestMethod.POST)
public void contractList(@RequestBody String content) throws Exception {

@ -100,3 +100,5 @@ app.ofei.md5-key=Khjx6wejblaJzmG0JBWFlPFKAUxhFIXQ
app.ofei.pwd=aomi@8888
app.ofei.sp-code=A1407200
mail.mailgun.api_key=api:key-96fa3b5866ace125b8ec5a9d27e19353
mail.mailgun.domain=dev.showcodes.com

@ -34,7 +34,7 @@ import cn.yixblog.platform.http.HttpRequestResult;
* Created by wangning on 05/01/2018.
*/
@SpringBootTest
@ActiveProfiles({ "proxy", "alipay", "wechat", "jd", "bestpay" })
@ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" })
@RunWith(SpringRunner.class)
public class CustomerImpressionImplTest {
@Resource
@ -49,6 +49,7 @@ public class CustomerImpressionImplTest {
@Resource
private MailGunClient mailGunClient;
// @Test
// public void redisQueue() {
// BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
@ -96,13 +97,9 @@ public class CustomerImpressionImplTest {
@Test
public void sendSimpleMessage() throws Exception {
String url = "https://api.mailgun.net/v3/dev.showcodes.com/messages";
String url = "https://api.mailgun.net/v3/dev.showcodes.com/messages?from=postmaster@dev.showcodes.com&to=164851225@qq.com,1029811920@qq.com&subject=啊是记录&text=暗杀苏&v:my-custom-data={\"key\":\"value\"}";
String asd = "王宁测试标题";
HttpRequestGenerator generator = new HttpRequestGenerator(url, RequestMethod.POST).addHeader("Authorization", getHeader());
generator.initFileEntity().attachExternalParam("from", "postmaster@dev.showcodes.com").attachExternalParam("to", "info@dev.showcodes.com")
.attachExternalParam("v:my-custom-data","{\"key\":\"value\"}")
.attachExternalParam("subject", "阿克江啊啊艾克安居客逻辑").attachExternalParam("subscribed", "false")
.attachExternalParam("text", "扯大额卡加二胺二胺傲娇了阿姐拿进来")
.attachExternalParam("html", "<html><p>啊看见的那会计师你打卡机难爱的那是的拉屎加上就开始啦看见了</p ></html>").attachExternalParam("o:tag", "test1");
HttpRequestResult res = null;
try {
@ -163,6 +160,21 @@ public class CustomerImpressionImplTest {
sendMail.setMailCcs(mailCCs);
Set<String> mailtos = new HashSet<>();
mailtos.add("1029811920@qq.com");
mailtos.add("164851225@qq.com");
mailtos.add("1@qq.com");
mailtos.add("5@qq.com");
mailtos.add("6@qq.com");
mailtos.add("12@qq.com");
mailtos.add("13@qq.com");
mailtos.add("14@qq.com");
mailtos.add("15@qq.com");
mailtos.add("16@qq.com");
mailtos.add("17@qq.com");
mailtos.add("18@qq.com");
mailtos.add("19@qq.com");
mailtos.add("2@qq.com");
mailtos.add("4@qq.com");
mailtos.add("3@qq.com");
sendMail.setMailTos(mailtos);
sendMail.setTitle("Final Test");

@ -1,6 +1,6 @@
package au.com.royalpay.payment.manage.system.core.impl;
import au.com.royalpay.payment.manage.system.core.MailService;
import au.com.royalpay.payment.manage.system.core.MailGunService;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -13,10 +13,10 @@ import javax.annotation.Resource;
@SpringBootTest
@ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" })
@RunWith(SpringRunner.class)
public class MailServiceImplTest {
public class MailGunServiceImplTest {
@Resource
MailService mailService;
MailGunService mailService;
@Test
public void dealNotify() {
String dd= "timestamp=1526298391&token=b7ad8dc0905c46b1c4853200941d30417b4d3f3695815dc729&signature=a3507be4d7ad2b48c4b57202eabd6f63b75abfacd974a9bc7773dc968a12c34e&X-Mailgun-Sid=WyJlMjYwYSIsICI0NjQ1NjMxMThAcXEuY29tIiwgIjQzODY0NiJd&domain=dev.showcodes.com&X-Mailgun-Tag=test1&event=delivered&event-timestamp=1526298391.16&message-headers=[[\"X-Mailgun-Sending-Ip\", \"184.173.153.207\"], [\"X-Mailgun-Sid\", \"WyJlMjYwYSIsICI0NjQ1NjMxMThAcXEuY29tIiwgIjQzODY0NiJd\"], [\"List-Unsubscribe\", \"<mailto:u+mq6timzygy2dmjtjhuzdamjyga2tcnbrge2dmmrzfyys4msdivdecmkegi3uenbwgu4ugnbfgqygizlwfzzwq33xmnxwizltfzrw63jgna6tgmbummzdqnjzga2tkylggfqwkzjqhbrwiyzumzqtkztgg44donrgnu6tknjugqytomjgoi6tinrugu3dgmjrhastimdroexgg33nezwxslldovzxi33nfvsgc5dbhustoqrfgizgwzlzeuzdejjtiestemtwmfwhkzjfgizckn2e@dev.showcodes.com>\"], [\"Received\", \"by luna.mailgun.net with SMTP X-Mailgun-List-Id=5544171, 8794346058393; Mon, 14 May 2018 11:46:29 +0000\"], [\"X-Mailgun-List-Id\", \"5544171\"], [\"X-Mailgun-List-Address\", \"info@dev.showcodes.com\"], [\"List-Id\", \"<info.dev.showcodes.com>\"], [\"Received\", \"by luna.mailgun.net with HTTP; Mon, 14 May 2018 11:46:27 +0000\"], [\"Date\", \"Mon, 14 May 2018 11:46:27 +0000\"], [\"Sender\", \"postmaster@dev.showcodes.com\"], [\"X-Mailgun-Variables\", \"{\\\"my-custom-data\\\": \\\"{\\\\\\\"key\\\\\\\":\\\\\\\"value\\\\\\\"}\\\"}\"], [\"X-Mailgun-Tag\", \"test1\"], [\"From\", \"postmaster@dev.showcodes.com\"], [\"Subject\", \"Testqweasdzxc1\"], [\"Mime-Version\", \"1.0\"], [\"Content-Type\", [\"multipart/alternative\", {\"boundary\": \"12109fc0295a479385fcbed01f501455\"}]], [\"Message-Id\", \"<20180514114629.1.2CEFA1D27B4659C4@dev.showcodes.com>\"], [\"To\", \"yz <464563118@qq.com>\"]]&Message-Id=<20180514114629.1.2CEFA1D27B4659C4@dev.showcodes.com>&recipient=464563118@qq.com&my-custom-data={\"id\":\"123\"}&body-plain=";
Loading…
Cancel
Save