Commit 839a7bc1f2e9fbf8a1e1be7ab90c0efc9eb25f14

Authored by 王言钊
1 parent ada6fd6f

新增直播申请短信通知功能

src/main/java/com/cnlive/shenhe/job/LiveApplyJob.java
@@ -51,6 +51,9 @@ public class LiveApplyJob { @@ -51,6 +51,9 @@ public class LiveApplyJob {
51 @Value("${email_send_URL}") 51 @Value("${email_send_URL}")
52 private String email_send_URL; 52 private String email_send_URL;
53 53
  54 + @Value("${mobile_send_URL}")
  55 + private String mobile_send_URL;
  56 +
54 @Autowired 57 @Autowired
55 SitesService sitesService; 58 SitesService sitesService;
56 @Autowired 59 @Autowired
@@ -118,15 +121,16 @@ public class LiveApplyJob { @@ -118,15 +121,16 @@ public class LiveApplyJob {
118 String emailAddr = shyEmail.getEmail(); 121 String emailAddr = shyEmail.getEmail();
119 String title = liveApply.getSpid_desc() + "新直播开播申请"; 122 String title = liveApply.getSpid_desc() + "新直播开播申请";
120 String templateId = "4017"; 123 String templateId = "4017";
121 - Map<String, String> params = new HashMap<>();  
122 - params.put("appId", appId);  
123 - params.put("emailAddr", emailAddr);  
124 - params.put("title", title);  
125 - params.put("content", content);  
126 - params.put("templateId", templateId);  
127 - params.put("sign", OpenUtil.sign(params, appKey)); 124 + Map<String, String> emailparams = new HashMap<>();
  125 + emailparams.put("appId", appId);
  126 + emailparams.put("emailAddr", emailAddr);
  127 + emailparams.put("title", title);
  128 + emailparams.put("content", content);
  129 + emailparams.put("templateId", templateId);
  130 + emailparams.put("sign", OpenUtil.sign(emailparams, appKey));
128 HttpUtil httpUtil = HttpUtil.init(); 131 HttpUtil httpUtil = HttpUtil.init();
129 - httpUtil.setParamMap(params); 132 + httpUtil.setParamMap(emailparams);
  133 + int i = 0;
130 try { 134 try {
131 Map<String, String> post = httpUtil.post(url); 135 Map<String, String> post = httpUtil.post(url);
132 logger.info("当前发送邮件用户为:" + emailAddr + ",发送邮件的直播申请审核云id为:" + liveApply.getId() + "结果为:" + post.get("result")); 136 logger.info("当前发送邮件用户为:" + emailAddr + ",发送邮件的直播申请审核云id为:" + liveApply.getId() + "结果为:" + post.get("result"));
@@ -134,12 +138,14 @@ public class LiveApplyJob { @@ -134,12 +138,14 @@ public class LiveApplyJob {
134 if (result == null) { 138 if (result == null) {
135 noticeState = CommonConst.NOTICE_FAIL; 139 noticeState = CommonConst.NOTICE_FAIL;
136 noticeMsg = noticeMsg + "\n" + dateTime + " 邮件服务器调用失败,result为空"; 140 noticeMsg = noticeMsg + "\n" + dateTime + " 邮件服务器调用失败,result为空";
  141 + i++;
137 break; 142 break;
138 } 143 }
139 Integer code = result.getInteger("errorCode"); 144 Integer code = result.getInteger("errorCode");
140 if (code != 0) { 145 if (code != 0) {
141 noticeState = CommonConst.NOTICE_FAIL; 146 noticeState = CommonConst.NOTICE_FAIL;
142 noticeMsg = noticeMsg + "\n" + dateTime + " 邮件服务器调用失败,result返回消息为:" + result.getString("errorMessage"); 147 noticeMsg = noticeMsg + "\n" + dateTime + " 邮件服务器调用失败,result返回消息为:" + result.getString("errorMessage");
  148 + i++;
143 break; 149 break;
144 } else { 150 } else {
145 noticeState = CommonConst.NOTICE_SUCCESS; 151 noticeState = CommonConst.NOTICE_SUCCESS;
@@ -149,8 +155,25 @@ public class LiveApplyJob { @@ -149,8 +155,25 @@ public class LiveApplyJob {
149 logger.info("异常结果为:{}", e.getMessage()); 155 logger.info("异常结果为:{}", e.getMessage());
150 noticeState = CommonConst.NOTICE_FAIL; 156 noticeState = CommonConst.NOTICE_FAIL;
151 noticeMsg = noticeMsg + "\n" + dateTime + " 邮件服务器调用失败,服务器报错了"; 157 noticeMsg = noticeMsg + "\n" + dateTime + " 邮件服务器调用失败,服务器报错了";
  158 + i++;
152 break; 159 break;
153 } 160 }
  161 + String taskId = "003_01";
  162 + String signatureId = "0";
  163 + Map<String, String> mobileparams = new HashMap<>(16);
  164 + mobileparams.put("appId", appId);
  165 + mobileparams.put("mobile", liveApply.getMobile());
  166 + mobileparams.put("title", title);
  167 + mobileparams.put("content", content);
  168 + mobileparams.put("taskId", taskId);
  169 + mobileparams.put("signatureId", signatureId);
  170 + httpUtil.setParamMap(mobileparams);
  171 + if (i >10) {
  172 + Map<String, String> post = httpUtil.post(mobile_send_URL);
  173 + logger.info("当前发送短信用户为:" + liveApply.getMobile() + ",发送短信的直播申请审核云id为:" + liveApply.getId() + "结果为:" + post.get("result"));
  174 + noticeState = CommonConst.NOTICE_SUCCESS;
  175 + noticeMsg = noticeMsg + "\n" + dateTime + "短信手机号" + liveApply.getMobile() + "(" + liveApply.getSender() + ")发送成功";
  176 + }
154 } 177 }
155 liveApply.setEmail_notice_state(noticeState); 178 liveApply.setEmail_notice_state(noticeState);
156 liveApply.setEmail_notice_msg(noticeMsg); 179 liveApply.setEmail_notice_msg(noticeMsg);
src/main/resources/application-dev.properties
@@ -97,6 +97,7 @@ live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe @@ -97,6 +97,7 @@ live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe
97 email_app_id=769_jetja50p18 97 email_app_id=769_jetja50p18
98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba 98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
99 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action 99 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action
  100 +mobile_send_URL=http://sms.cnlive.com/CnliveM3/msg/sendSms.action
100 101
101 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D 102 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D
102 qn_bucket=cnlivetest 103 qn_bucket=cnlivetest
src/main/resources/application-prod.properties
@@ -91,6 +91,7 @@ live_url=http://bc.cnlive.com/bokong/activity/activityShenHe @@ -91,6 +91,7 @@ live_url=http://bc.cnlive.com/bokong/activity/activityShenHe
91 email_app_id=769_jetja50p18 91 email_app_id=769_jetja50p18
92 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba 92 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
93 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action 93 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action
  94 +mobile_send_URL=http://sms.cnlive.com/CnliveM3/msg/sendSms.action
94 95
95 96
96 qn_bucket=mam-sxzg-82 97 qn_bucket=mam-sxzg-82
src/main/resources/application-test.properties
@@ -97,6 +97,7 @@ live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe @@ -97,6 +97,7 @@ live_url=http://test.bc.cnlive.com/bokong/activity/activityShenHe
97 email_app_id=769_jetja50p18 97 email_app_id=769_jetja50p18
98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba 98 email_app_key=ad101b9152817a79b5c33c3617b96ff91385096ff3b4ba
99 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action 99 email_send_URL=http://sms.cnlive.com/CnliveM3/email/sendMoreVarEmail.action
  100 +mobile_send_URL=http://sms.cnlive.com/CnliveM3/msg/sendSms.action
100 101
101 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D 102 #\u62BD\u5E27\u5B58\u653Ebucket\u548C\u57DF\u540D
102 qn_bucket=cnlivetest 103 qn_bucket=cnlivetest