|
|
|
@ -28,10 +28,9 @@ import org.springframework.util.Assert;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
@ -146,6 +145,7 @@ public class NoticeManageImpl implements NoticeManage {
|
|
|
|
|
}
|
|
|
|
|
if (!notice.getBoolean("merchants_type")){
|
|
|
|
|
StringBuilder sendClients = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
List<JSONObject> clients = clientMapper.listValidClient();
|
|
|
|
|
clients.forEach(c -> {
|
|
|
|
|
if (c.getInteger("parent_client_id")==null || c.getInteger("parent_client_id")!=9){
|
|
|
|
@ -155,40 +155,45 @@ public class NoticeManageImpl implements NoticeManage {
|
|
|
|
|
});
|
|
|
|
|
if (sendClients.length()>0){
|
|
|
|
|
notice.put("send_clients",sendClients.substring(0,sendClients.length()-1));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
notice.put("send_clients",info.getSend_clients());
|
|
|
|
|
}
|
|
|
|
|
noticeManageMapper.updateNotice(notice);
|
|
|
|
|
|
|
|
|
|
if (info.getStatus() != null && info.getSend_clients() != null) {
|
|
|
|
|
if (info.getStatus().equals("1") && noticeInfo.getString("status").equals("0") && !info.getSend_clients().isEmpty()) {
|
|
|
|
|
|
|
|
|
|
String client_monikers []=info.getSend_clients().split(",");
|
|
|
|
|
Set<String> mailto = new HashSet<>();
|
|
|
|
|
if(notice.getBoolean("merchants_type")){
|
|
|
|
|
List<JSONObject> mailto = new ArrayList<>();
|
|
|
|
|
ArrayList<String> mailboxs = new ArrayList<>();
|
|
|
|
|
for (String clientMoniker : client_monikers) {
|
|
|
|
|
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
|
|
|
|
|
JSONObject c = new JSONObject();
|
|
|
|
|
c.put("create_time", date);
|
|
|
|
|
c.put("notice_id", noticeId);
|
|
|
|
|
c.put("client_id", client.getIntValue("client_id"));
|
|
|
|
|
noticePartnerMapper.save(c);
|
|
|
|
|
String contact_email = client.getString("contact_email");
|
|
|
|
|
if (contact_email!=null){
|
|
|
|
|
mailto.add(contact_email);
|
|
|
|
|
if (contact_email!=null && !mailboxs.contains(contact_email)){
|
|
|
|
|
c.put("mailto",contact_email);
|
|
|
|
|
mailto.add(c);
|
|
|
|
|
mailboxs.add(contact_email);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
mailto.add(mailListDefault);
|
|
|
|
|
}
|
|
|
|
|
if(info.isIs_tomail()){
|
|
|
|
|
//同时发送给股东
|
|
|
|
|
if (info.isIs_tomail_cc_stockholder()){
|
|
|
|
|
String stockholder_mails_mailto [] = stockholder_mails.trim().split(",");
|
|
|
|
|
for (String stockholder_mailto:stockholder_mails_mailto){
|
|
|
|
|
mailto.add(stockholder_mailto);
|
|
|
|
|
JSONObject stockholder = new JSONObject();
|
|
|
|
|
stockholder.put("mailto",stockholder_mailto);
|
|
|
|
|
stockholder.put("client_id",0);
|
|
|
|
|
mailto.add(stockholder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
logger.info(noticeId+"|"+info.getTitle()+"|"+mailto);
|
|
|
|
|
JSONObject mailResult = mailGunService.sendEmail(noticeId,info.getTitle(),mailto,info.getContent());
|
|
|
|
|
notice.put("mail_id",mailResult.getString("mail_id"));
|
|
|
|
|
|
|
|
|
|
String mail_id = mailService.sendEmail(noticeId,info.getTitle(),mailto,info.getContent());
|
|
|
|
|
notice.put("mail_id",mail_id);
|
|
|
|
|
noticeManageMapper.updateNotice(notice);
|
|
|
|
|
} catch (URISyntaxException | IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -201,8 +206,82 @@ public class NoticeManageImpl implements NoticeManage {
|
|
|
|
|
retailAppService.sendNoticeMessage(info,client_monikers);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// public void updateNotice(JSONObject manager, String noticeId, NoticeInfo info) throws Exception {
|
|
|
|
|
// JSONObject noticeInfo = noticeManageMapper.getNoticeDetailById(noticeId);
|
|
|
|
|
// Assert.notNull(noticeInfo);
|
|
|
|
|
// Date date = new Date();
|
|
|
|
|
// JSONObject notice = info.toJson();
|
|
|
|
|
// notice.put("notice_id", noticeId);
|
|
|
|
|
// if (info.getStatus().equals("1")) {
|
|
|
|
|
// notice.put("send_time", date);
|
|
|
|
|
// notice.put("send_id", manager.getString("manager_id"));
|
|
|
|
|
// notice.put("send_name", manager.getString("display_name"));
|
|
|
|
|
// }
|
|
|
|
|
// if (!notice.getBoolean("merchants_type")){
|
|
|
|
|
// StringBuilder sendClients = new StringBuilder();
|
|
|
|
|
//
|
|
|
|
|
// List<JSONObject> clients = clientMapper.listValidClient();
|
|
|
|
|
// clients.forEach(c -> {
|
|
|
|
|
// if (c.getInteger("parent_client_id")==null || c.getInteger("parent_client_id")!=9){
|
|
|
|
|
// String p = c.getString("client_moniker")+",";
|
|
|
|
|
// sendClients.append(p);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (sendClients.length()>0){
|
|
|
|
|
// notice.put("send_clients",sendClients.substring(0,sendClients.length()-1));
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// noticeManageMapper.updateNotice(notice);
|
|
|
|
|
// if (info.getStatus() != null && info.getSend_clients() != null) {
|
|
|
|
|
// if (info.getStatus().equals("1") && noticeInfo.getString("status").equals("0") && !info.getSend_clients().isEmpty()) {
|
|
|
|
|
// String client_monikers []=info.getSend_clients().split(",");
|
|
|
|
|
// List<JSONObject> mailto = new ArrayList<>();
|
|
|
|
|
// ArrayList<String> mailboxs = new ArrayList<>();
|
|
|
|
|
// for (String clientMoniker : client_monikers) {
|
|
|
|
|
// JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
|
|
|
|
|
// client.put("create_time", date);
|
|
|
|
|
// client.put("notice_id", noticeId);
|
|
|
|
|
// noticePartnerMapper.save(client);
|
|
|
|
|
// String contact_email = client.getString("contact_email");
|
|
|
|
|
// if (contact_email!=null && !mailboxs.contains(contact_email)){
|
|
|
|
|
// client.put("mailto",contact_email);
|
|
|
|
|
// mailto.add(client);
|
|
|
|
|
// mailboxs.add(contact_email);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if(info.isIs_tomail()){
|
|
|
|
|
// //同时发送给股东
|
|
|
|
|
// if (info.isIs_tomail_cc_stockholder()){
|
|
|
|
|
// String stockholder_mails_mailto [] = stockholder_mails.trim().split(",");
|
|
|
|
|
// for (String stockholder_mailto:stockholder_mails_mailto){
|
|
|
|
|
// JSONObject stockholder = new JSONObject();
|
|
|
|
|
// stockholder.put("mailto",stockholder_mailto);
|
|
|
|
|
// stockholder.put("client_id",0);
|
|
|
|
|
// mailto.add(stockholder);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// try {
|
|
|
|
|
// String mail_id = mailService.sendEmail(noticeId,info.getTitle(),mailto,info.getContent());
|
|
|
|
|
// notice.put("mail_id",mail_id);
|
|
|
|
|
// noticeManageMapper.updateNotice(notice);
|
|
|
|
|
// } catch (URISyntaxException | IOException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// logger.error("sending email failed:", e.getMessage(), e);
|
|
|
|
|
// throw new Exception(e.getMessage());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (info.isIs_to_app()){
|
|
|
|
|
// info.setNotice_id(noticeId);
|
|
|
|
|
// retailAppService.sendNoticeMessage(info,client_monikers);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|