master
wangning 7 years ago
parent 2b2b5563d4
commit 44087dd5d1

@ -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);

@ -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<String, String> 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<String, String> getQueryMap(String query) {
String[] params = query.split("&");
Map<String, String> map = new HashMap<>();

@ -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);
}
}
Loading…
Cancel
Save