private void SpringSendSMS(SendMailContent content) { try { int time = ConfigManager.getInstance().getInt("sms.Deadtime", 0); // 读配置文件,信息有效时间 // 以小时为单位 Calendar calendar = Calendar.getInstance(); int day = calendar.get(Calendar.HOUR_OF_DAY); calendar.set(Calendar.HOUR_OF_DAY, day + time); // 把当前时间+信息有效时间。 TSMSInfoBO smsInfo = new TSMSInfoBO(); smsInfo.setMobile(content.getToMobile()); smsInfo.setContent(content.getSendSmsText()); smsInfo.setDeadTime(calendar.getTime()); smsInfo.setEid(ConfigManager.getInstance().getString("sms.Eid")); smsInfo.setPassword(ConfigManager.getInstance().getString("sms.Password")); smsInfo.setStatus(0); smsInfo.setUserId(ConfigManager.getInstance().getString("sms.Userid")); smsInfo.setUsrport(ConfigManager.getInstance().getInt("sms.Userport", 0)); // 短信内容的长度限制在255内。如果超过255,就分成多条记录插到数据库dfsdl表中。 int length = content.getSendSmsText().length(); int len = length % 250 == 0 ? length / 250 : length / 250 + 1; for (int i = 0; i < len; i++) { if (i == len - 1) { smsInfo.setContent(content.getSendSmsText().substring(i * 250, length)); } else { smsInfo.setContent(content.getSendSmsText().substring(i * 250, (i + 1) * 250)); } sendInfoDao.insertSMSInfo(smsInfo); } } catch (SQLException e) { e.printStackTrace(); } }
@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); } }