|
|
1
|
+package com.yohoufo.order.service.proxy;
|
|
|
2
|
+
|
|
|
3
|
+import com.yoho.core.rest.client.ServiceCaller;
|
|
|
4
|
+import com.yoho.service.model.msgcenter.sms.McSmsByMobileBO;
|
|
|
5
|
+import com.yoho.service.model.sms.response.CommonRspBO;
|
|
|
6
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
7
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
8
|
+import org.slf4j.Logger;
|
|
|
9
|
+import org.slf4j.LoggerFactory;
|
|
|
10
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
11
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
12
|
+import org.springframework.stereotype.Service;
|
|
|
13
|
+
|
|
|
14
|
+import java.util.List;
|
|
|
15
|
+
|
|
|
16
|
+/**
|
|
|
17
|
+ * Created by chenchao on 2018/10/19.
|
|
|
18
|
+ */
|
|
|
19
|
+@Service
|
|
|
20
|
+public class SendSmsService {
|
|
|
21
|
+
|
|
|
22
|
+
|
|
|
23
|
+ private static Logger log = LoggerFactory.getLogger(SendSmsService.class);
|
|
|
24
|
+
|
|
|
25
|
+ @Autowired
|
|
|
26
|
+ private ServiceCaller serviceCaller;
|
|
|
27
|
+
|
|
|
28
|
+ @Value("${yoho.message.controller.url}")
|
|
|
29
|
+ private String messageUrl;
|
|
|
30
|
+
|
|
|
31
|
+ public void smsSendByMobile(String content, List<String> mobileList) {
|
|
|
32
|
+ log.info("smsSendByMobile start.");
|
|
|
33
|
+ if(StringUtils.isEmpty(content) || CollectionUtils.isEmpty(mobileList)) {
|
|
|
34
|
+ log.warn("smsSendByMobile fail! content is null or mobileList is empty");
|
|
|
35
|
+ return;
|
|
|
36
|
+ }
|
|
|
37
|
+ McSmsByMobileBO[] boArray = new McSmsByMobileBO[mobileList.size()];
|
|
|
38
|
+ for(int i=0; i<mobileList.size(); i++) {
|
|
|
39
|
+ McSmsByMobileBO smsBo = new McSmsByMobileBO();
|
|
|
40
|
+ smsBo.setMobile(mobileList.get(i));
|
|
|
41
|
+ smsBo.setContent(content);
|
|
|
42
|
+ smsBo.setIsNoDisturb(0);//是否免打扰, 1-是 0-否
|
|
|
43
|
+ boArray[i] = smsBo;
|
|
|
44
|
+ }
|
|
|
45
|
+
|
|
|
46
|
+ String url = messageUrl + "/mcSMS/smsSendByMobile";
|
|
|
47
|
+ log.info("sendMessage url is {}", url);
|
|
|
48
|
+ serviceCaller.post("message.sendMessage", url, boArray, CommonRspBO.class, null);
|
|
|
49
|
+ }
|
|
|
50
|
+
|
|
|
51
|
+} |