Search in sources :

Example 1 with MessageTemplate

use of com.itrus.portal.db.MessageTemplate in project portal by ixinportal.

the class MsgTemplateController method update.

// 处理修改消息模版
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@Valid MessageTemplate msgTemplate, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("projectmap", getProjectMapOfAdmin());
        uiModel.addAttribute("msgTemplate", msgTemplate);
        return "msgtemplate/update";
    }
    MessageTemplate msgTemplate0 = sqlSession.selectOne("com.itrus.portal.db.MessageTemplateMapper.selectByPrimaryKey", msgTemplate.getId());
    msgTemplate.setCreateTime(msgTemplate0.getCreateTime());
    // 一个项目下只能创建一个模版类型的消息模版
    MessageTemplateExample mte = new MessageTemplateExample();
    MessageTemplateExample.Criteria mtCriteria = mte.or();
    mtCriteria.andProjectEqualTo(msgTemplate.getProject());
    mtCriteria.andMessageTypeEqualTo(msgTemplate.getMessageType());
    Integer count = sqlSession.selectOne("com.itrus.portal.db.MessageTemplateMapper.countByExample", mte);
    if ((msgTemplate0.getProject() == msgTemplate.getProject()) && count >= 2) {
        uiModel.addAttribute("projectMap", getProjectMapOfAdmin());
        uiModel.addAttribute("msgTemplate", msgTemplate);
        uiModel.addAttribute("message", "该项目下已经存在同样类型的模版消息");
        return "msgtemplate/update";
    }
    if ((msgTemplate0.getProject() != msgTemplate.getProject()) && count != 0) {
        uiModel.addAttribute("projectMap", getProjectMapOfAdmin());
        uiModel.addAttribute("msgTemplate", msgTemplate);
        uiModel.addAttribute("message", "该项目下已经存在同样类型的模版消息");
        return "msgtemplate/update";
    }
    // String adminProject = getRoleProjects();
    // if (adminProject != null
    // && (!adminProject.equals(msgTemplate0.getProject()) || !adminProject
    // .equals(msgTemplate.getProject()))) {
    // return "status403";
    // }
    sqlSession.update("com.itrus.portal.db.MessageTemplateMapper.updateByPrimaryKey", msgTemplate);
    String oper = "修改消息模版";
    String info = "消息模板内容: " + msgTemplate.getMessageContent();
    LogUtil.adminlog(sqlSession, oper, info);
    return "redirect:/msgtemplate/" + msgTemplate.getId();
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) MessageTemplateExample(com.itrus.portal.db.MessageTemplateExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with MessageTemplate

use of com.itrus.portal.db.MessageTemplate in project portal by ixinportal.

the class MsgTemplateController method delete.

// 删除消息模版
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
    MessageTemplate msgTemplate = sqlSession.selectOne("com.itrus.portal.db.MessageTemplateMapper.selectByPrimaryKey", id);
    if (msgTemplate == null) {
        uiModel.addAttribute("message", "未找到要删除消息");
    } else {
        String adminProject = getRoleProjects();
        if (adminProject != null && adminProject.equals(msgTemplate.getProject())) {
            return "status403";
        }
        try {
            sqlSession.delete("com.itrus.portal.db.MessageTemplateMapper.deleteByPrimaryKey", id);
            String oper = "删除消息模板";
            String info = "消息内容: " + msgTemplate.getMessageContent();
            LogUtil.adminlog(sqlSession, oper, info);
        } catch (Exception e) {
            uiModel.addAttribute("message", "要删除消息模板存在关联,无法删除");
        }
    }
    return "redirect:/msgtemplate";
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with MessageTemplate

use of com.itrus.portal.db.MessageTemplate in project portal by ixinportal.

the class ReviewServiceImpl method sendSmsBySHJJ.

// 拒绝后台的订单,发送短信通知
/**
 * 发送审核拒绝短信通知(模版类型:SHJJ)
 *
 * @param billId
 * @return
 */
public boolean sendSmsBySHJJ(Long billId) {
    if (null == billId) {
        return false;
    }
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    if (null == bill) {
        return false;
    }
    // 查询短信模版
    // 查找对应项目的消息模版:SHJJ
    MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(bill.getProject(), "SHJJ");
    if (null == messageTemplate) {
        logger.error("发送短信失败,未找到对应的鉴证审核消息模版");
        return false;
    }
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    String content = messageTemplate.getMessageContent();
    // 替换特定内容:企业名称:enterpriseName,产品名称:productName,项目名称:projectName,拒绝原因:reason
    if (content.contains("enterpriseName")) {
        content = content.replaceAll("enterpriseName", enterprise.getEnterpriseName());
    }
    if (content.contains("productName")) {
        content = content.replaceAll("productName", product.getName());
    }
    if (content.contains("projectName")) {
        content = content.replaceAll("projectName", project.getName());
    }
    if (content.contains("reason")) {
        content = content.replaceAll("reason", bill.getCancelReason());
    }
    // 发送短信
    try {
        if (smsSendService.sendRefuseReview(userInfo.getmPhone(), content, "SHJJ", project.getId(), userInfo.getUniqueId(), bill.getBillId())) {
            // 发送成功
            return true;
        } else {
            return false;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) Project(com.itrus.portal.db.Project) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) ParseException(java.text.ParseException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Example 4 with MessageTemplate

use of com.itrus.portal.db.MessageTemplate in project portal by ixinportal.

the class NotPayExtraBillSmsTask method run.

@Override
public void run() {
    Map<String, Object> param = new HashMap<String, Object>();
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.HOUR_OF_DAY, -3);
    Date queryDate = calendar.getTime();
    param.put("queryDate2", queryDate);
    param.put("payStatus", 1);
    param.put("isNotPaySms", 0);
    param.put("limit", 20);
    List<Map<String, Object>> billexall = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectByCondition", param);
    ExtraBill b;
    MessageTemplate messageTemplate;
    for (Map<String, Object> bill : billexall) {
        b = extraBillService.selectByPrimaryKey(Long.parseLong(bill.get("id").toString()));
        messageTemplate = messageTemplateService.getMsgTemp(b.getProject(), "WZF");
        if (null == messageTemplate) {
            continue;
        }
        String content = messageTemplate.getMessageContent();
        if (StringUtils.isBlank(content) || content.indexOf("content") == -1) {
            continue;
        }
        content = content.replaceAll("content", bill.get("epname").toString());
        boolean sendFlag = smsSendService.sendSms(bill.get("m_phone").toString(), content, "支付通知", b.getProject(), null, b.getBillId());
        if (sendFlag) {
            b.setIsNotPaySms(true);
            b.setNpSmsTime(new Date());
            try {
                extraBillService.updateByPrimaryKeySelective(b);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) HashMap(java.util.HashMap) Calendar(java.util.Calendar) ExtraBill(com.itrus.portal.db.ExtraBill) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date)

Example 5 with MessageTemplate

use of com.itrus.portal.db.MessageTemplate in project portal by ixinportal.

the class SHJJExtraBillSmsTask method run.

@Override
public void run() {
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("reviewStatus", 3);
    param.put("isRefuseSms", 0);
    param.put("limit", 20);
    List<Map<String, Object>> billexall = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectByCondition", param);
    ExtraBill bill;
    MessageTemplate messageTemplate;
    for (Map<String, Object> billMap : billexall) {
        bill = extraBillService.selectByPrimaryKey(Long.parseLong(billMap.get("id").toString()));
        // 查询短信模版
        // 查找对应项目的消息模版:SHJJ
        messageTemplate = messageTemplateService.getMsgTemp(bill.getProject(), "SHJJ");
        if (null == messageTemplate) {
            continue;
        }
        Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
        ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
        Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
        UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
        String content = messageTemplate.getMessageContent();
        // 替换特定内容:企业名称:enterpriseName,产品名称:productName,项目名称:projectName,拒绝原因:reason
        if (content.contains("enterpriseName")) {
            content = content.replaceAll("enterpriseName", enterprise.getEnterpriseName());
        }
        if (content.contains("productName")) {
            content = content.replaceAll("productName", product.getAppName());
        }
        if (content.contains("projectName")) {
            content = content.replaceAll("projectName", project.getName());
        }
        if (content.contains("reason")) {
            content = content.replaceAll("reason", bill.getRefuseReason());
        }
        // 发送短信
        try {
            smsSendService.sendRefuseReview(userInfo.getmPhone(), content, "SHJJ", project.getId(), userInfo.getUniqueId(), bill.getBillId());
        } catch (Exception e) {
            e.printStackTrace();
        }
        bill.setIsRefuseSms(true);
        bill.setSendTime(new Date());
        try {
            extraBillService.updateByPrimaryKey(bill);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Also used : HashMap(java.util.HashMap) ExtraBill(com.itrus.portal.db.ExtraBill) UserInfo(com.itrus.portal.db.UserInfo) Date(java.util.Date) MessageTemplate(com.itrus.portal.db.MessageTemplate) ExtraProduct(com.itrus.portal.db.ExtraProduct) Project(com.itrus.portal.db.Project) Enterprise(com.itrus.portal.db.Enterprise) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

MessageTemplate (com.itrus.portal.db.MessageTemplate)18 Date (java.util.Date)10 HashMap (java.util.HashMap)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)6 Calendar (java.util.Calendar)5 DynamicCode (com.itrus.portal.db.DynamicCode)4 DynamicCodeExample (com.itrus.portal.db.DynamicCodeExample)4 ExtraBill (com.itrus.portal.db.ExtraBill)4 Project (com.itrus.portal.db.Project)4 Map (java.util.Map)4 Bill (com.itrus.portal.db.Bill)3 Enterprise (com.itrus.portal.db.Enterprise)3 MessageTemplateExample (com.itrus.portal.db.MessageTemplateExample)3 UserInfo (com.itrus.portal.db.UserInfo)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 ExtraProduct (com.itrus.portal.db.ExtraProduct)2 Courier (com.itrus.portal.db.Courier)1 CourierExample (com.itrus.portal.db.CourierExample)1 CourierInfo (com.itrus.portal.db.CourierInfo)1