|
|
@@ -207,6 +207,55 @@ public class SendMessageContorller {
|
|
|
Util.json(response, json.toString());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 接口发送短信
|
|
|
+ * @param phones 手机号码
|
|
|
+ * @param Contents 发送内容
|
|
|
+ * @param md5 加密
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @WithoutUserLogin
|
|
|
+ @RoleLimit(pid = Const.SYSTEM_ROLE_LIMIT_PID, mid = Const.SYSTEM_ROLE_LIMIT_MID)
|
|
|
+ @Transactional(value = "txManager")
|
|
|
+ @RequestMapping(value = "sendSmsBySignId")
|
|
|
+ public void sendSms(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ try {
|
|
|
+ request.setCharacterEncoding("utf-8");
|
|
|
+ String smsUserPhoens = request.getParameter("phones");
|
|
|
+ String content = request.getParameter("contents");
|
|
|
+ String signId = request.getParameter("signId");
|
|
|
+ String res = SmsUtil.sendNewSmsPostBySignId(smsUserPhoens, content, signId);
|
|
|
+ Map mapObj = JSON.parseObject(res, Map.class);
|
|
|
+ String msgNo = mapObj.get("msg_no").toString();
|
|
|
+ Integer code = Integer.valueOf(mapObj.get("code").toString());
|
|
|
+ //将短信记录保存进数据库
|
|
|
+ SmsRecord smsRecord = new SmsRecord();
|
|
|
+ smsRecord.setContent(content);
|
|
|
+ smsRecord.setCreateDate(new Date());
|
|
|
+ smsRecord.setPhoens(smsUserPhoens);
|
|
|
+ smsRecord.setMsgid(msgNo);
|
|
|
+ smsRecordService.insertSelective(smsRecord);
|
|
|
+ if (code == 0) {// 提交供应商成功,查询发送是否成功
|
|
|
+ SmsSendState sss = new SmsSendState();
|
|
|
+ sss.setMsgid(msgNo);
|
|
|
+ sss.setCreateDate(new Date());
|
|
|
+ sss.setContents(res);
|
|
|
+ smsSendStateService.insertSelective(sss);
|
|
|
+ json.element("status", "0");
|
|
|
+ json.element("message", "发送成功");
|
|
|
+ } else {
|
|
|
+ json.element("status", "3");
|
|
|
+ json.element("message", "校验失败");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ json.element("status", SmsConst.ERROR);
|
|
|
+ json.element("message", "发送异常");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ Util.json(response, json.toString());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加用户
|
|
|
*/
|