mailgun list add & remove

master
wangning 7 years ago
parent e22617082e
commit 57ee6e86bb

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

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