// to fix bug 2495 private String getTable(TSendInfoBO tSendInfoBO) { StringBuilder s1 = new StringBuilder(100); try { // bug 0003895 0003898 0003046 List<TInstanceInfoBO> list = orderDao.findService2InstanceByOrderId(tSendInfoBO.getOrderId(), tSendInfoBO.getType()); s1.append("<table id=\"mytable\" cellspacing=\"0\"><caption> </caption>"); if (list.size() != 0) { // bug 0003884 s1.append("<tr>"); s1.append("<th scope=\"col\">服 务</th>"); s1.append("<th scope=\"col\">资 源</th>"); s1.append("<th scope=\"col\">类 型</th>"); s1.append("</tr>"); } // fix bug 0002495 for (TInstanceInfoBO info : list) { s1.append("<tr>"); s1.append("<td class=\"row\">" + info.getServiceName() + "</td>"); s1.append("<td class=\"row\">" + info.getInstanceName() + "</td>"); s1.append("<td class=\"row\">" + info.getTemplateName() + "</td>"); s1.append("</tr>"); } s1.append("</table>"); } catch (SQLException e) { e.printStackTrace(); } return s1.toString(); }
// to fix bug 2495 private String setMailMessage(TSendInfoBO tSendInfoBO) throws SQLException { StringBuilder sb = new StringBuilder(500); try { TUserBO auditor = orderDao.getAuditorByOrderId(tSendInfoBO.getOrderId()); TOrderBO order = orderDao.searchOrderById(tSendInfoBO.getOrderId()); // fix bug 2495 sb.append( "<br />" + order.getCreateUserName() + " 您好,您的订单" + getAuditStr(tSendInfoBO) + ",具体订单信息如下:"); // fix bug 2495 sb.append("<br />订单号为:" + tSendInfoBO.getOrderId() + ""); sb.append("<br />包含以下服务内容:<br />" + getTable(tSendInfoBO)); sb.append("<br />订单类型:" + getOrderType(tSendInfoBO) + ""); sb.append("<br />当前审批人为:" + auditor.getName() + ""); sb.append("<br />操作时间:" + auditor.getCreateDt().toString().replace(".0", "") + ""); if (tSendInfoBO.getState() == 1) { // 审核拒绝 sb.append("<br />审批不通过原因:" + tSendInfoBO.getApproveReason() + ""); sb.append("<br />您可以重新选择其他服务进行申请,如有问题请登录自服务门户查询,谢谢您选择我们的云平台"); } if (tSendInfoBO.getState() == 2) { // 审核通过 // to fix bug:2853 String desc = ""; if (tSendInfoBO.getType() == 1) { // 新申请 desc = "已经审核通过,敬请耐心等待服务开通使用,如有问题请登录自服务门户查询,谢谢您选择我们的云平台。"; } else if (tSendInfoBO.getType() == 2) { // 修改 desc = "修改审核已通过,请等待开通使用,谢谢。"; } else if (tSendInfoBO.getType() == 3) { // 退订 desc = "退订审核已通过,服务即将关闭,谢谢。"; } sb.append("<br />" + desc); } } catch (Exception e) { e.printStackTrace(); } return sb.toString(); }
@Override public void FSendMail() throws MailException, SQLException { log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); log.info("infoDao-----------=" + sendInfoDao); List<TSendInfoBO> lists = sendInfoDao.findAllPedding(); if (lists.size() > 0) { SendMailContent content; for (TSendInfoBO tSendInfoBO : lists) { content = new SendMailContent(); content.setToMail(tSendInfoBO.getReceiveAddress()); content.setFromMail(ConfigManager.getInstance().getString("mail.from")); if (tSendInfoBO.getState() == 1) { content.setSubject("审核不通过"); // 邮件内容 to fix bug 2495 content.setSendText(setMailMessage(tSendInfoBO)); // content.setSendText("您好,您的订单《" + // tSendInfoBO.getOrderCode() + "》没有通过审核,不通过理由《" + // tSendInfoBO.getApproveReason() + "》。"); if (ConfigManager.getInstance().containsKey("sms.audit.order.no.text")) { content.setSendSmsText( String.format( ConfigManager.getInstance().getString("sms.audit.order.no.text"), tSendInfoBO.getOrderCode(), tSendInfoBO.getApproveReason())); } } else if (tSendInfoBO.getState() == 2) { // bugid = 0001707 // 查询结果集中添加 o.TYPE 字段 : // 订单类型;1:新申请;2:修改申请;3:删除申请 int type = tSendInfoBO.getType(); String desc = ""; if (type == 1) { desc = "已经审核通过,请等待开通使用,谢谢。"; if (ConfigManager.getInstance().containsKey("sms.audit.order.pass.text1")) { content.setSendSmsText( String.format( ConfigManager.getInstance().getString("sms.audit.order.pass.text1"), tSendInfoBO.getOrderCode())); } } else if (type == 3) { // to fix bug 2160 desc = "退订审核已通过,服务已关闭,谢谢。"; if (ConfigManager.getInstance().containsKey("sms.audit.order.pass.text3")) { content.setSendSmsText( String.format( ConfigManager.getInstance().getString("sms.audit.order.pass.text3"), tSendInfoBO.getOrderCode())); } } else if (type == 2) { desc = "修改审核已通过,请等待开通使用,谢谢。"; if (ConfigManager.getInstance().containsKey("sms.audit.order.pass.text2")) { content.setSendSmsText( String.format( ConfigManager.getInstance().getString("sms.audit.order.pass.text2"), tSendInfoBO.getOrderCode())); } } content.setSubject("审核通过"); // 邮件内容 to fix bug 2495 content.setSendText(setMailMessage(tSendInfoBO)); // content.setSendText("您好,您的订单《" + // tSendInfoBO.getOrderCode() + "》" + desc); } else { continue; } TUserBO user = userDao.findUserByOrderId(tSendInfoBO.getOrderId()); if (user == null) { continue; } content.setToMobile(user.getMobile()); if (StringUtils.isNotEmpty(content.getSendText())) { this.sendMail(content); } else { return; } } sendInfoDao.updateSendInfo(lists); } }