use of com.itrus.portal.db.CourierInfo 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;
}
Aggregations