注释为刚加上的。。请勿见怪。。//该方法为分别给不同的/愿意接受提示邮件的销售/发送属于他的新用户/的邮件
//userIds:所有的新注册的userid
//affirmReseller: 所有愿意接受提示邮件的销售的信息public static void sendAlertNewUserForSale(String abs_app_path, List<Integer> userIds, Map<Integer, ResellerDetail> affirmReseller) throws Exception{
String htmlText = "";
String from = "";
String from_label = "";
String to = "";
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.add(Calendar.DATE, -1);
String subject = "Summary: Users newly registered yesterday (" + Util.formatDate(cal.getTimeInMillis()) + ")";
if(affirmReseller == null && affirmReseller.isEmpty()) return;
//000$$$$$$$¥¥¥¥从此处开始要求重新写代码 只要看try里面的一些逻辑
try{
//每个user都有一个resellerId(相当于销售的ID)
Map<Integer, List<dl.user.User>> users = new HashMap<Integer, List<dl.user.User>>();//key: resellerId, value: user
Set keys = affirmReseller.keySet();
Object[] arraykey = keys.toArray();
for(int i = 0; i < arraykey.length; i++){//有多少个销售就有多少个增加多少个users的键值对..
users.put((Integer)arraykey[i], new ArrayList<dl.user.User>());
}
for(int i = 0; i < userIds.size(); i++){
dl.user.User curUser = Services.userService.getUserById(userIds.get(i));
if(keys.contains(curUser.getResellerId())){//因为需要发送的user所对应的销售可能不想接收提示邮件。。
users.get(curUser.getResellerId()).add(curUser);//把user增加到users..根据不同的reseller...
}
}
for(int i = 0; i < users.size(); i++){
if(users.get(arraykey[i]).size() == 0) //如果该销售名下没有新注册的用户。。continue..
continue;
htmlText += "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"
+"<title>new user</title></head>";
htmlText += "<body>";
htmlText += "<p>please use tel to contact if available</p>";
htmlText += "<table align='center' cellpadding='2px' style='width:100%; font-size: 14px; color: #666666; border: 2px #618B93 solid;border-collapse: collapse;border-spacing: 1px; font-family:Arial, Helvetica, sans-serif;'>";
htmlText += "<tr><th>Login email</th><th>Contact Person</th>"
+ "<th>Tel</th><th>Current list size</th></tr>";
for(int j = 0; j < users.get(arraykey[i]).size(); j++){
dl.user.User curUser = users.get(arraykey[i]).get(j);
htmlText += "<tr align='center'>";
htmlText += "<td>" + curUser.getEmail() + "</td>";
htmlText += "<td>" + curUser.getContactPerson() + "</td>";
htmlText += "<td>" + curUser.getTel() + "</td>";
htmlText += "<td>" + curUser.getListLimit() + "</td>";
htmlText += "</tr>";
}
htmlText += "</table></body></html>";
from = Services.miscService.getMiscStrValue("ALERT_NEW_USER_ADMIN_EMAIL_FROM");
from_label = "";
//to = Services.miscService.getMiscStrValue("ALERT_NEW_USER_ADMIN_EMAIL_TO");
to = affirmReseller.get(arraykey[i]).getReceivingSummaryEmail();
//发送邮件
sendCommonEmail(to, "",from, from_label, subject, htmlText,Services.miscService.getMiscStrValue("EMAIL_RETURN_PATH"));
}
}catch(Exception e){
logger.error(e.getMessage(),e);
throw e;
}
}
//userIds:所有的新注册的userid
//affirmReseller: 所有愿意接受提示邮件的销售的信息public static void sendAlertNewUserForSale(String abs_app_path, List<Integer> userIds, Map<Integer, ResellerDetail> affirmReseller) throws Exception{
String htmlText = "";
String from = "";
String from_label = "";
String to = "";
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.add(Calendar.DATE, -1);
String subject = "Summary: Users newly registered yesterday (" + Util.formatDate(cal.getTimeInMillis()) + ")";
if(affirmReseller == null && affirmReseller.isEmpty()) return;
//000$$$$$$$¥¥¥¥从此处开始要求重新写代码 只要看try里面的一些逻辑
try{
//每个user都有一个resellerId(相当于销售的ID)
Map<Integer, List<dl.user.User>> users = new HashMap<Integer, List<dl.user.User>>();//key: resellerId, value: user
Set keys = affirmReseller.keySet();
Object[] arraykey = keys.toArray();
for(int i = 0; i < arraykey.length; i++){//有多少个销售就有多少个增加多少个users的键值对..
users.put((Integer)arraykey[i], new ArrayList<dl.user.User>());
}
for(int i = 0; i < userIds.size(); i++){
dl.user.User curUser = Services.userService.getUserById(userIds.get(i));
if(keys.contains(curUser.getResellerId())){//因为需要发送的user所对应的销售可能不想接收提示邮件。。
users.get(curUser.getResellerId()).add(curUser);//把user增加到users..根据不同的reseller...
}
}
for(int i = 0; i < users.size(); i++){
if(users.get(arraykey[i]).size() == 0) //如果该销售名下没有新注册的用户。。continue..
continue;
htmlText += "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"
+"<title>new user</title></head>";
htmlText += "<body>";
htmlText += "<p>please use tel to contact if available</p>";
htmlText += "<table align='center' cellpadding='2px' style='width:100%; font-size: 14px; color: #666666; border: 2px #618B93 solid;border-collapse: collapse;border-spacing: 1px; font-family:Arial, Helvetica, sans-serif;'>";
htmlText += "<tr><th>Login email</th><th>Contact Person</th>"
+ "<th>Tel</th><th>Current list size</th></tr>";
for(int j = 0; j < users.get(arraykey[i]).size(); j++){
dl.user.User curUser = users.get(arraykey[i]).get(j);
htmlText += "<tr align='center'>";
htmlText += "<td>" + curUser.getEmail() + "</td>";
htmlText += "<td>" + curUser.getContactPerson() + "</td>";
htmlText += "<td>" + curUser.getTel() + "</td>";
htmlText += "<td>" + curUser.getListLimit() + "</td>";
htmlText += "</tr>";
}
htmlText += "</table></body></html>";
from = Services.miscService.getMiscStrValue("ALERT_NEW_USER_ADMIN_EMAIL_FROM");
from_label = "";
//to = Services.miscService.getMiscStrValue("ALERT_NEW_USER_ADMIN_EMAIL_TO");
to = affirmReseller.get(arraykey[i]).getReceivingSummaryEmail();
//发送邮件
sendCommonEmail(to, "",from, from_label, subject, htmlText,Services.miscService.getMiscStrValue("EMAIL_RETURN_PATH"));
}
}catch(Exception e){
logger.error(e.getMessage(),e);
throw e;
}
}
cal.setTimeInMillis(System.currentTimeMillis());//这行写不写都一样,多余