mailgun list add & remove

master
wangning 7 years ago
parent e22617082e
commit 57ee6e86bb

@ -598,6 +598,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
@Override
@Transactional
public void updateClientRegisterInfo(JSONObject manager, String clientMoniker, ClientRegisterInfo info) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
Assert.notNull(client);
@ -629,21 +630,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
clientMapper.update(updateInfo);
if (!client.getString("contact_email").equals(updateInfo.getString("contact_email"))) {
List<String> exceptClientIds = new ArrayList<>();
exceptClientIds.add(String.valueOf(clientId));
JSONObject sameMailClients = getByEmail(client.getString("contact_email"),1,1,exceptClientIds);
if(sameMailClients.getJSONArray("data").size()<1) {
mailGunService.updateClientOfMailList(updateInfo, client);
}else {
client.put("contact_email",updateInfo.getString("contact_email"));
mailGunService.addClientToMailList(client);
}
}
saveOrUpdateMailList(updateInfo, client);
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override
@Transactional
public void updateClientRegisterInfoV2(JSONObject manager, String clientMoniker, JSONObject info) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
Assert.notNull(client);
@ -675,18 +667,22 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
}
clientMapper.update(info);
if (!client.getString("contact_email").equals(info.getString("contact_email"))) {
saveOrUpdateMailList(info, client);
clientInfoCacheSupport.clearClientCache(clientId);
}
private void saveOrUpdateMailList(JSONObject newClient, JSONObject oldClient) {
if (!oldClient.getString("contact_email").equals(newClient.getString("contact_email"))) {
List<String> exceptClientIds = new ArrayList<>();
exceptClientIds.add(String.valueOf(clientId));
JSONObject sameMailClients = getByEmail(client.getString("contact_email"),1,1,exceptClientIds);
exceptClientIds.add(newClient.getString("client_id"));
JSONObject sameMailClients = getByEmail(oldClient.getString("contact_email"),1,1,exceptClientIds);
if(sameMailClients.getJSONArray("data").size()<1) {
mailGunService.updateClientOfMailList(info, client);
mailGunService.updateClientOfMailList(newClient, oldClient);
}else {
client.put("contact_email",info.getString("contact_email"));
mailGunService.addClientToMailList(client);
oldClient.put("contact_email",newClient.getString("contact_email"));
mailGunService.addClientToMailList(oldClient);
}
}
clientInfoCacheSupport.clearClientCache(clientId);
}
@Override

@ -313,6 +313,13 @@
<select id="simpleQuery" resultType="com.alibaba.fastjson.JSONObject">
select * from sys_clients
where is_valid = 1
<if test="except_client_ids!=null">
and client_id not in (
<foreach collection="except_client_ids" item="item" separator=",">
#{item}
</foreach>
)
</if>
<if test="source!=null">
and source = #{source}
</if>
@ -322,13 +329,5 @@
<if test="contact_email!=null">
and contact_email = #{contact_email}
</if>
<if test="except_client_ids!=null">
and client_id not in (
<foreach collection="except_client_ids" item="item" separator=",">
#{item}
</foreach>
)
</if>
</select>
</mapper>
Loading…
Cancel
Save