From 44087dd5d1c4171efa8a629b9978549373a5f24a Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Wed, 16 May 2018 14:00:52 +0800 Subject: [PATCH] update --- .../manage/system/core/MailGunService.java | 2 ++ .../system/core/impl/MailGunServiceImpl.java | 21 +++++++++++++++++++ .../system/web/MailCallBackController.java | 8 ++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/system/core/MailGunService.java b/src/main/java/au/com/royalpay/payment/manage/system/core/MailGunService.java index d5e6af1a8..8e888c0e8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/core/MailGunService.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/MailGunService.java @@ -13,6 +13,8 @@ public interface MailGunService { void dealNotify(String nofityString) throws Exception; + void dealDroppedNotify(String content) throws Exception; + JSONObject sendMail(SendMail sendMail); JSONObject addClientToMailList(JSONObject client); diff --git a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/MailGunServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/MailGunServiceImpl.java index b6ef1b9f0..f2c35b16c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/MailGunServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/MailGunServiceImpl.java @@ -64,6 +64,25 @@ public class MailGunServiceImpl implements MailGunService { } } + @Override + public void dealDroppedNotify(String content) throws Exception { + String dd = URLDecoder.decode(content, "UTF-8"); + Map mailgunNotify = getQueryMap(dd); + String myData = mailgunNotify.get("my-custom-data"); + String recipient = mailgunNotify.get("recipient"); + if (StringUtils.isNotEmpty(myData) && StringUtils.isNotEmpty(recipient)) { + JSONObject tmpJSONObject = JSONObject.parseObject(myData); + String[] mailAddresses = recipient.split(","); + for (String mailAddress : mailAddresses) { + JSONObject record = new JSONObject(); + record.put("id", tmpJSONObject.getString("id")); + record.put("mail_address", mailAddress); + record.put("status", 2); + mailSendMapper.update(record); + } + } + } + @Override public JSONObject sendMail(SendMail sendMail) { return mailGunClient.sendMail(sendMail); @@ -131,6 +150,8 @@ public class MailGunServiceImpl implements MailGunService { return mailGunClient.sendMail(sendMail); } + + public Map getQueryMap(String query) { String[] params = query.split("&"); Map map = new HashMap<>(); diff --git a/src/main/java/au/com/royalpay/payment/manage/system/web/MailCallBackController.java b/src/main/java/au/com/royalpay/payment/manage/system/web/MailCallBackController.java index 45ea7ac90..cc4f3e55f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/web/MailCallBackController.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/web/MailCallBackController.java @@ -17,8 +17,14 @@ public class MailCallBackController { private MailGunService mailService; @RequestMapping(value = "/callback", method = RequestMethod.POST) - public void contractList(@RequestBody String content) throws Exception { + public void dealSuccessNptify(@RequestBody String content) throws Exception { mailService.dealNotify(content); } + + @RequestMapping(value = "/callback/dropped", method = RequestMethod.POST) + public void contractList(@RequestBody String content) throws Exception { + mailService.dealDroppedNotify(content); + } + } \ No newline at end of file