Search in sources :

Example 11 with MessageTemplate

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

the class MsgTemplateController method updateForm.

// 修改消息模版页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Model uiModel) {
    MessageTemplate msgTemplate = sqlSession.selectOne("com.itrus.portal.db.MessageTemplateMapper.selectByPrimaryKey", id);
    if (msgTemplate == null) {
        return "status403";
    }
    String adminProject = getRoleProjects();
    if (adminProject != null && adminProject.equals(msgTemplate.getProject())) {
        return "status403";
    }
    uiModel.addAttribute("projectMap", getProjectMapOfAdmin());
    uiModel.addAttribute("msgTemplate", msgTemplate);
    return "msgtemplate/update";
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with MessageTemplate

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

the class MsgTemplateController method list.

// 消息模版列表
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "project", required = false) Long project, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    uiModel.addAttribute("project", project);
    // page,size
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    // String adminProject = getRoleProjects();
    // if (adminProject != null)
    // project = adminProject;
    MessageTemplateExample mte = new MessageTemplateExample();
    MessageTemplateExample.Criteria mtCriteria = mte.or();
    if (null != project) {
        mtCriteria.andProjectEqualTo(project);
    }
    Integer count = sqlSession.selectOne("com.itrus.portal.db.MessageTemplateMapper.countByExample", mte);
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    // =====存放总记录数、总页数、当前页、一页显示的记录
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    Integer offset = size * (page - 1);
    mte.setOffset(offset);
    mte.setLimit(size);
    mte.setOrderByClause("create_time desc");
    List<MessageTemplate> msgTemplates = sqlSession.selectList("com.itrus.portal.db.MessageTemplateMapper.selectByExample", mte);
    uiModel.addAttribute("msgTemplates", msgTemplates);
    uiModel.addAttribute("projectmap", getProjectMapOfAdmin());
    return "msgtemplate/list";
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) MessageTemplateExample(com.itrus.portal.db.MessageTemplateExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with MessageTemplate

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

the class MsgTemplateController method show.

// 查看消息模版
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    MessageTemplate msgTemplate = sqlSession.selectOne("com.itrus.portal.db.MessageTemplateMapper.selectByPrimaryKey", id);
    if (msgTemplate == null) {
        return "status403";
    }
    String adminProject = getRoleProjects();
    if (adminProject != null && adminProject.equals(msgTemplate.getProject())) {
        return "status403";
    }
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", msgTemplate.getProject());
    uiModel.addAttribute("msgTemplate", msgTemplate);
    uiModel.addAttribute("project", project);
    return "msgtemplate/show";
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) Project(com.itrus.portal.db.Project) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with MessageTemplate

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

the class ExtraBillReviewController method sendSmsBySHJJ.

/**
 * 手动发送审核拒绝短信通知
 *
 * @param billId
 * @return
 */
@RequestMapping("/sendSmsBySHJJ")
@ResponseBody
public synchronized Map<String, Object> sendSmsBySHJJ(@RequestParam(value = "billId", required = true) Long billId) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    // 修改订单
    ExtraBill bill = extraBillService.selectByPrimaryKey(billId);
    if (null == bill) {
        retMap.put("retMsg", "订单不存在");
        return retMap;
    }
    // 查询短信模版
    // 查找对应项目的消息模版:SHJJ
    MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(bill.getProject(), "SHJJ");
    if (null == messageTemplate) {
        retMap.put("retMsg", "审核拒绝短信模版不存在,请联系系统管理员配置");
        return retMap;
    }
    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);
        retMap.put("retCode", 1);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return retMap;
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) ExtraProduct(com.itrus.portal.db.ExtraProduct) Project(com.itrus.portal.db.Project) HashMap(java.util.HashMap) ExtraBill(com.itrus.portal.db.ExtraBill) Enterprise(com.itrus.portal.db.Enterprise) UserInfo(com.itrus.portal.db.UserInfo) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with MessageTemplate

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

the class ExtraBillPayController method sendsms.

/**
 * 增值订单,未支付短信通知发送
 * @param id,订单id
 * @param phone,手机号
 * @param type,短信类型,WZF
 * @return
 */
@RequestMapping(value = "/sendsms/{id}/{phone}/{type}", produces = "text/html")
@ResponseBody
public String sendsms(@PathVariable("id") Long id, @PathVariable("phone") String phone, @PathVariable("type") String type) {
    Map param = new HashMap();
    param.put("id", id);
    // 管理员项目权限
    Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
    param.put("hasProjects", Arrays.asList(projectsOfAdmin));
    Map bill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByCondition", param);
    ExtraBill b = extraBillService.selectByPrimaryKey(id);
    MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(b.getProject(), type);
    if (null == messageTemplate) {
        return "发送短信失败,未找到对应的消息模版";
    }
    String content = messageTemplate.getMessageContent();
    if (StringUtils.isBlank(content) || content.indexOf("content") == -1) {
        return "发送短信失败,消息模版配置错误";
    }
    content = content.replaceAll("content", bill.get("epname").toString());
    smsSendService.sendSms(bill.get("m_phone").toString(), content, type.equals("WZF") ? "支付通知" : "支付异常通知", b.getProject(), null, b.getBillId());
    b.setIsNotPaySms(true);
    b.setNpSmsTime(new Date());
    try {
        extraBillService.updateByPrimaryKeySelective(b);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) HashMap(java.util.HashMap) ExtraBill(com.itrus.portal.db.ExtraBill) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

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