master
wangning 7 years ago
commit adbfe6ca31

@ -107,6 +107,7 @@ import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
@ -144,6 +145,7 @@ import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
@ -578,6 +580,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientApplyMapper.updatePartnerApplication(apply); clientApplyMapper.updatePartnerApplication(apply);
} }
} }
try {
JSONObject res = addClientToMailList(partner);
}catch (Exception e){
logger.error("邮件列表添加成员失败",e);
}
return partner; return partner;
} }
@ -3335,4 +3342,71 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
return logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id")); return logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"));
} }
public JSONObject addClientToMailList(JSONObject client){
String createUrl = "https://api.mailgun.net/v3/lists/1551130722@sandbox08f2aafe29184b08b38322106c8bd4f5.mailgun.org/members";
JSONObject vars = new JSONObject();
vars.put("client_moniker",client.getString("client_moniker"));
vars.put("short_name",client.getString("short_name"));
vars.put("bd_user_name",client.getString("bd_user_name"));
vars.put("company_phone",client.getString("company_phone"));
vars.put("description",client.getString("description"));
HttpRequestGenerator generator = new HttpRequestGenerator(createUrl, RequestMethod.POST)
.addHeader("Authorization",getHeader())
.addQueryString("subscribed","true")
.addQueryString("address",client.getString("contact_email"))
.addQueryString("name",client.getString("company_name"))
.addQueryString("description","merchant")
.addQueryString("vars",vars.toJSONString());
HttpRequestResult res = null;
try {
res = generator.execute();
} catch (URISyntaxException e) {
e.printStackTrace();
}
try {
return res.getResponseContentJSONObj();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public JSONObject updateClientOfMailList(JSONObject newClient,JSONObject oldClient){
String createUrl = "https://api.mailgun.net/v3/lists/1551130722@sandbox08f2aafe29184b08b38322106c8bd4f5.mailgun.org/members/"+oldClient.getString("contact_email");
JSONObject vars = new JSONObject();
vars.put("client_moniker",newClient.getString("client_moniker"));
vars.put("short_name",newClient.getString("short_name"));
vars.put("bd_user_name",newClient.getString("bd_user_name"));
vars.put("company_phone",newClient.getString("company_phone"));
vars.put("description",newClient.getString("description"));
HttpRequestGenerator generator = new HttpRequestGenerator(createUrl, RequestMethod.PUT).addHeader("Authorization",getHeader())
.addQueryString("address",newClient.getString("contact_email"))
.addQueryString("name",newClient.getString("company_name"))
.addQueryString("vars",vars.toJSONString());
HttpRequestResult res = null;
try {
res = generator.execute();
} catch (URISyntaxException e) {
e.printStackTrace();
}
try {
return res.getResponseContentJSONObj();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
private String getHeader() {
String auth = "api:key-17c2d9f2b569cfc0983320cfb22d3fdc";
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("UTF-8")));
String authHeader = "Basic " + new String(encodedAuth);
return authHeader;
}
} }

Loading…
Cancel
Save