|
|
package com.yohoufo.order.service.proxy;
|
|
|
|
|
|
import com.yoho.core.rest.client.ServiceCaller;
|
|
|
import com.yoho.service.model.msgcenter.sms.McSmsByMobileBO;
|
|
|
import com.yoho.service.model.sms.response.CommonRspBO;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by chenchao on 2018/10/19.
|
|
|
*/
|
|
|
@Service
|
|
|
public class SendSmsService {
|
|
|
|
|
|
|
|
|
private static Logger log = LoggerFactory.getLogger(SendSmsService.class);
|
|
|
|
|
|
@Autowired
|
|
|
private ServiceCaller serviceCaller;
|
|
|
|
|
|
@Value("${yoho.message.controller.url}")
|
|
|
private String messageUrl;
|
|
|
|
|
|
public void smsSendByMobile(String content, List<String> mobileList) {
|
|
|
log.info("smsSendByMobile start.");
|
|
|
if(StringUtils.isEmpty(content) || CollectionUtils.isEmpty(mobileList)) {
|
|
|
log.warn("smsSendByMobile fail! content is null or mobileList is empty");
|
|
|
return;
|
|
|
}
|
|
|
McSmsByMobileBO[] boArray = new McSmsByMobileBO[mobileList.size()];
|
|
|
for(int i=0; i<mobileList.size(); i++) {
|
|
|
McSmsByMobileBO smsBo = new McSmsByMobileBO();
|
|
|
smsBo.setMobile(mobileList.get(i));
|
|
|
smsBo.setContent(content);
|
|
|
smsBo.setIsNoDisturb(0);//是否免打扰, 1-是 0-否
|
|
|
boArray[i] = smsBo;
|
|
|
}
|
|
|
|
|
|
String url = messageUrl + "/mcSMS/smsSendByMobile";
|
|
|
log.info("sendMessage url is {}", url);
|
|
|
serviceCaller.post("message.sendMessage", url, boArray, CommonRspBO.class, null);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|