Search in sources :

Example 1 with Courier

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

the class PsCourierController method sendMoreSmsFhtz.

/**
 * 发送属于快递配送的短信
 */
private Map<String, Object> sendMoreSmsFhtz(Long pcId) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    try {
        CourierInfo ci = sqlSession.selectOne("com.itrus.portal.db.CourierInfoMapper.selectByPrimaryKey", pcId);
        if (null == ci) {
            retMap.put("retMsg", "发送短信失败,未找到对应的快递配送记录");
            return retMap;
        }
        Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", ci.getBill());
        CourierExample courierex = new CourierExample();
        Map<Long, Courier> couriermap = sqlSession.selectMap("com.itrus.portal.db.CourierMapper.selectByExample", courierex, "id");
        // 查找对应项目的消息模版:FHTZ
        MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(bill.getProject(), "FHTZ");
        if (null == messageTemplate) {
            retMap.put("retMsg", "发送短信失败,未找到对应的快递配送消息模版");
            return retMap;
        }
        String content = messageTemplate.getMessageContent();
        if (StringUtils.isBlank(content) || content.indexOf("cItems") == -1 || content.indexOf("cId") == -1 || content.indexOf("cName") == -1) {
            retMap.put("retMsg", "发送短信失败,快递配送消息模版配置错误");
            return retMap;
        }
        String str = null;
        if (ci.getCourierItems() == 1) {
            str = "电子钥匙";
        }
        if (ci.getCourierItems() == 2) {
            str = "发票";
        }
        if (ci.getCourierItems() == 3) {
            str = "电子钥匙和发票";
        }
        content = content.replaceAll("cItems", str);
        content = content.replaceAll("cId", ci.getCourierId());
        content = content.replaceAll("cName", couriermap.get(ci.getCourier()).getCompanyName());
        Delivery delivery = sqlSession.selectOne("com.itrus.portal.db.DeliveryMapper.selectByPrimaryKey", bill.getDelivery());
        if (smsSendService.sendSms(delivery.getRvPhone(), content, "发货通知", bill.getProject(), bill.getUniqueId(), bill.getBillId())) {
            ci.setMessageSms(1);
            sqlSession.update("com.itrus.portal.db.CourierInfoMapper.updateByPrimaryKeySelective", ci);
            retMap.put("retCode", 1);
            retMap.put("retMsg", "发送短信成功");
        }
    } catch (Exception e) {
        e.printStackTrace();
        retMap.put("retMsg", "发送短信失败,errmsg:" + e.getMessage());
        return retMap;
    }
    return retMap;
}
Also used : HashMap(java.util.HashMap) CourierInfo(com.itrus.portal.db.CourierInfo) MessageTemplate(com.itrus.portal.db.MessageTemplate) Bill(com.itrus.portal.db.Bill) CourierExample(com.itrus.portal.db.CourierExample) Delivery(com.itrus.portal.db.Delivery) Courier(com.itrus.portal.db.Courier)

Example 2 with Courier

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

the class CourierController method delete.

// 删除
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
    Courier courier = sqlSession.selectOne("com.itrus.portal.db.CourierMapper.selectByPrimaryKey", id);
    if (courier == null) {
        // uiModel.addAttribute("message", "未找到要删除快递");
        return "未找到要删除配送服务";
    } else {
        try {
            sqlSession.delete("com.itrus.portal.db.CourierMapper.deleteByPrimaryKey", id);
            String oper = "删除配送服务";
            String info = "配送服务名称: " + courier.getCourierName();
            LogUtil.adminlog(sqlSession, oper, info);
        } catch (Exception e) {
            // + "】存在关联,无法删除");
            return "要删除配送服务【" + courier.getCourierName() + "】存在关联,无法删除";
        }
    }
    return null;
}
Also used : Courier(com.itrus.portal.db.Courier) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with Courier

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

the class CourierController method update.

// 修改处理
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@Valid Courier courier, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("courier", courier);
        return "courier/update";
    }
    Courier courier0 = sqlSession.selectOne("com.itrus.portal.db.CourierMapper.selectByPrimaryKey", courier.getId());
    courier.setCreator(courier0.getCreator());
    courier.setCreateTime(courier0.getCreateTime());
    courier.setModifyTime(new Date());
    courier.setModifier(getAdmin().getId());
    sqlSession.update("com.itrus.portal.db.CourierMapper.updateByPrimaryKey", courier);
    String oper = "修改配送服务";
    String info = "配送服务名称: " + courier.getCourierName();
    LogUtil.adminlog(sqlSession, oper, info);
    return "redirect:/courier/" + courier.getId();
}
Also used : Courier(com.itrus.portal.db.Courier) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Courier

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

the class CourierController method updateForm.

// 返回修改页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Model uiModel) {
    Courier courier = sqlSession.selectOne("com.itrus.portal.db.CourierMapper.selectByPrimaryKey", id);
    uiModel.addAttribute("courier", courier);
    return "courier/update";
}
Also used : Courier(com.itrus.portal.db.Courier) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with Courier

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

the class CourierController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    Courier courier = sqlSession.selectOne("com.itrus.portal.db.CourierMapper.selectByPrimaryKey", id);
    uiModel.addAttribute("courier", courier);
    return "courier/show";
}
Also used : Courier(com.itrus.portal.db.Courier) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Courier (com.itrus.portal.db.Courier)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 CourierExample (com.itrus.portal.db.CourierExample)2 HashMap (java.util.HashMap)2 Bill (com.itrus.portal.db.Bill)1 CourierInfo (com.itrus.portal.db.CourierInfo)1 Delivery (com.itrus.portal.db.Delivery)1 MessageTemplate (com.itrus.portal.db.MessageTemplate)1 Date (java.util.Date)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1