md
This commit is contained in:
parent
ace0ed0a12
commit
f6831aa6d1
@ -43,6 +43,7 @@ package com.xdadan.erp.emis.service;
|
|||||||
import com.xdadan.erp.emis.service.IEmisWaybillService;
|
import com.xdadan.erp.emis.service.IEmisWaybillService;
|
||||||
import com.xdadan.erp.emis.service.sms.AliyunSMSService;
|
import com.xdadan.erp.emis.service.sms.AliyunSMSService;
|
||||||
import com.xdadan.erp.emis.service.sms.CMCCSMSService;
|
import com.xdadan.erp.emis.service.sms.CMCCSMSService;
|
||||||
|
import com.xdadan.erp.emis.service.sms.Sms253Service;
|
||||||
import com.xdadan.erp.emis.utils.HTTPHelperV3;
|
import com.xdadan.erp.emis.utils.HTTPHelperV3;
|
||||||
import com.xdadan.erp.emis.utils.Kd100Helper;
|
import com.xdadan.erp.emis.utils.Kd100Helper;
|
||||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||||
@ -150,7 +151,10 @@ public class EmisBaseService {
|
|||||||
private AliyunSMSService aliyunSMSService;
|
private AliyunSMSService aliyunSMSService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CMCCSMSService cmccSMSService;
|
private Sms253Service sms253Service;
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private CMCCSMSService cmccSMSService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmisSiteSettleRecordMapper emisSiteSettleRecordMapper;
|
private EmisSiteSettleRecordMapper emisSiteSettleRecordMapper;
|
||||||
@ -1440,52 +1444,58 @@ public class EmisBaseService {
|
|||||||
// 发件短信
|
// 发件短信
|
||||||
if ("1".equals(dt.getSmsType())) {
|
if ("1".equals(dt.getSmsType())) {
|
||||||
|
|
||||||
EmisWaybill waybill = getWaybillByBillCode(dt.getBillCode());
|
// EmisWaybill waybill = getWaybillByBillCode(dt.getBillCode());
|
||||||
// "尊敬的客户:您寄往${Nationalcity}的包裹已寄出,运单号${name}。如有疑问,详询服务热线4000257080,感谢您使用探路速运!";
|
// "尊敬的客户:您寄往${Nationalcity}的包裹已寄出,运单号${name}。如有疑问,详询服务热线4000257080,感谢您使用探路速运!";
|
||||||
String nationalcity=waybill.getReceiveCountryName()+""+waybill.getReceiveProvinceName();
|
// String nationalcity=waybill.getReceiveCountryName()+""+waybill.getReceiveProvinceName();
|
||||||
JSONObject jObjParam = new JSONObject();
|
// JSONObject jObjParam = new JSONObject();
|
||||||
jObjParam.put("Nationalcity",nationalcity);
|
// jObjParam.put("Nationalcity",nationalcity);
|
||||||
jObjParam.put("name",dt.getBillCode());
|
// jObjParam.put("name",dt.getBillCode());
|
||||||
|
// aliyunSMSService.sendMessage("探路速运", dt.getPhone(),"SMS_465316363", jObjParam.toJSONString());
|
||||||
aliyunSMSService.sendMessage("探路速运", dt.getPhone(),"SMS_465316363", jObjParam.toJSONString());
|
|
||||||
|
|
||||||
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
||||||
|
|
||||||
|
String content="【探路速运】"+dt.getContent();
|
||||||
|
sms253Service.sendMessage( dt.getPhone(),content);
|
||||||
|
|
||||||
}
|
}
|
||||||
// 签收短信
|
// 签收短信
|
||||||
else if ("2".equals(dt.getSmsType())) {
|
else if ("2".equals(dt.getSmsType())) {
|
||||||
|
|
||||||
EmisWaybill waybill = getWaybillByBillCode(dt.getBillCode());
|
// EmisWaybill waybill = getWaybillByBillCode(dt.getBillCode());
|
||||||
// 尊敬的客户:您寄往${Nationalcity}的快递${name}已被签收,感谢您使用探路速运。
|
//// 尊敬的客户:您寄往${Nationalcity}的快递${name}已被签收,感谢您使用探路速运。
|
||||||
String nationalcity=waybill.getReceiveCountryName()+""+waybill.getReceiveProvinceName();
|
// String nationalcity=waybill.getReceiveCountryName()+""+waybill.getReceiveProvinceName();
|
||||||
JSONObject jObjParam = new JSONObject();
|
// JSONObject jObjParam = new JSONObject();
|
||||||
jObjParam.put("Nationalcity",nationalcity);
|
// jObjParam.put("Nationalcity",nationalcity);
|
||||||
jObjParam.put("name",dt.getBillCode());
|
// jObjParam.put("name",dt.getBillCode());
|
||||||
|
// aliyunSMSService.sendMessage("探路速运", dt.getPhone(), "SMS_465341331", jObjParam.toJSONString());
|
||||||
aliyunSMSService.sendMessage("探路速运", dt.getPhone(), "SMS_465341331", jObjParam.toJSONString());
|
|
||||||
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
||||||
|
|
||||||
|
String content="【探路速运】"+dt.getContent();
|
||||||
|
sms253Service.sendMessage( dt.getPhone(),content);
|
||||||
|
|
||||||
}
|
}
|
||||||
// 问题件
|
// 问题件
|
||||||
else if ("3".equals(dt.getSmsType())) {
|
else if ("3".equals(dt.getSmsType())) {
|
||||||
|
|
||||||
EmisWaybill waybill = getWaybillByBillCode(dt.getBillCode());
|
// EmisWaybill waybill = getWaybillByBillCode(dt.getBillCode());
|
||||||
|
|
||||||
// "尊敬的用户:您的运单${name}从${Sendingcountry}寄往${Receivingcountry}因${Problemtype}的问题导致货物时效延误预计送达时间${time},详询400-025-7080感谢您对探路速运的支持!";
|
// "尊敬的用户:您的运单${name}从${Sendingcountry}寄往${Receivingcountry}因${Problemtype}的问题导致货物时效延误预计送达时间${time},详询400-025-7080感谢您对探路速运的支持!";
|
||||||
|
|
||||||
EmisProblemType emisProblemType=getEmisProblemTypeByType(waybill.getProblemType());
|
// EmisProblemType emisProblemType=getEmisProblemTypeByType(waybill.getProblemType());
|
||||||
|
//
|
||||||
|
// String sendingcountry=waybill.getSendCountryName();
|
||||||
|
// String receivingcountry=waybill.getReceiveCountryName();
|
||||||
|
// JSONObject jObjParam = new JSONObject();
|
||||||
|
// jObjParam.put("Sendingcountry",sendingcountry);
|
||||||
|
// jObjParam.put("Receivingcountry",receivingcountry);
|
||||||
|
// jObjParam.put("name",waybill.getBillCode());
|
||||||
|
// jObjParam.put("Problemtype",emisProblemType.getTypeName());
|
||||||
|
// jObjParam.put("time",DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,waybill.getEstimateDate()));
|
||||||
|
|
||||||
String sendingcountry=waybill.getSendCountryName();
|
// aliyunSMSService.sendMessage("探路速运", dt.getPhone(),"SMS_465386407", jObjParam.toJSONString());
|
||||||
String receivingcountry=waybill.getReceiveCountryName();
|
|
||||||
JSONObject jObjParam = new JSONObject();
|
|
||||||
jObjParam.put("Sendingcountry",sendingcountry);
|
|
||||||
jObjParam.put("Receivingcountry",receivingcountry);
|
|
||||||
jObjParam.put("name",waybill.getBillCode());
|
|
||||||
jObjParam.put("Problemtype",emisProblemType.getTypeName());
|
|
||||||
jObjParam.put("time",DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,waybill.getEstimateDate()));
|
|
||||||
|
|
||||||
aliyunSMSService.sendMessage("探路速运", dt.getPhone(),"SMS_465386407", jObjParam.toJSONString());
|
|
||||||
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
||||||
|
|
||||||
|
String content="【探路速运】"+dt.getContent();
|
||||||
|
sms253Service.sendMessage( dt.getPhone(),content);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
continue;
|
continue;
|
||||||
@ -1499,7 +1509,8 @@ public class EmisBaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dt.setFee("0");
|
dt.setFee("0");
|
||||||
dt.setSmsChannel("aliyun");
|
// dt.setSmsChannel("aliyun");
|
||||||
|
dt.setSmsChannel("sms253");
|
||||||
dt.setTaskDate(new Date());
|
dt.setTaskDate(new Date());
|
||||||
emisSmsSendRecordMapper.updateEmisSmsSendRecord(dt);
|
emisSmsSendRecordMapper.updateEmisSmsSendRecord(dt);
|
||||||
log.error("===>End 发送短信");
|
log.error("===>End 发送短信");
|
||||||
|
|||||||
@ -1,13 +1,7 @@
|
|||||||
package com.xdadan.erp.emis.service.sms;
|
package com.xdadan.erp.emis.service.sms;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
|
||||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
|
||||||
import com.xdadan.erp.system.service.ISysConfigService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,109 +11,109 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service("CMCCSMSService")
|
@Service("CMCCSMSService")
|
||||||
public class CMCCSMSService {
|
public class CMCCSMSService {
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ISysConfigService configService;
|
// private ISysConfigService configService;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 发送短信
|
// * 发送短信
|
||||||
*/
|
// */
|
||||||
public int sendMessage(String seqNo,String phone,String content) throws EmisBizError {
|
// public int sendMessage(String seqNo,String phone,String content) throws EmisBizError {
|
||||||
String jsonParamStr=configService.selectConfigByKey("sys.cmcc.sms");
|
// String jsonParamStr=configService.selectConfigByKey("sys.cmcc.sms");
|
||||||
JSONObject jObjAliyunParam=JSONObject.parseObject(jsonParamStr);
|
// JSONObject jObjAliyunParam=JSONObject.parseObject(jsonParamStr);
|
||||||
String url=jObjAliyunParam.getString("url");
|
// String url=jObjAliyunParam.getString("url");
|
||||||
String userAccount=jObjAliyunParam.getString("userAccount");
|
// String userAccount=jObjAliyunParam.getString("userAccount");
|
||||||
String password=jObjAliyunParam.getString("password");
|
// String password=jObjAliyunParam.getString("password");
|
||||||
String ecname=jObjAliyunParam.getString("ecname");
|
// String ecname=jObjAliyunParam.getString("ecname");
|
||||||
String signCode=jObjAliyunParam.getString("signCode");
|
// String signCode=jObjAliyunParam.getString("signCode");
|
||||||
|
//
|
||||||
/*
|
// /*
|
||||||
SDK java http://112.35.4.197:15000
|
// SDK java http://112.35.4.197:15000
|
||||||
单位名称:接口联调账号
|
// 单位名称:接口联调账号
|
||||||
用户名 :JStlz
|
// 用户名 :JStlz
|
||||||
密 码 :Passwd@#123
|
// 密 码 :Passwd@#123
|
||||||
签名编码:bM16CfN2B
|
// 签名编码:bM16CfN2B
|
||||||
服务代码:10657204006
|
// 服务代码:10657204006
|
||||||
黑名单 普通短信 有发送能力
|
// 黑名单 普通短信 有发送能力
|
||||||
时效:1个月 10条/天
|
// 时效:1个月 10条/天
|
||||||
{
|
// {
|
||||||
"url":"http://112.35.4.197:15000",
|
// "url":"http://112.35.4.197:15000",
|
||||||
"userAccount":"JStlz",
|
// "userAccount":"JStlz",
|
||||||
"password":"Passwd@#123",
|
// "password":"Passwd@#123",
|
||||||
"ecname":"接口联调账号",
|
// "ecname":"接口联调账号",
|
||||||
"ecname":"接口联调账号",
|
// "ecname":"接口联调账号",
|
||||||
"signCode":"bM16CfN2B",
|
// "signCode":"bM16CfN2B",
|
||||||
"serviceCode":"10657204006",
|
// "serviceCode":"10657204006",
|
||||||
"desc":"黑名单 普通短信 有发送能力",
|
// "desc":"黑名单 普通短信 有发送能力",
|
||||||
"timeDesc":"1个月 10条/天"
|
// "timeDesc":"1个月 10条/天"
|
||||||
}
|
// }
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
return innerSendNormal(seqNo,
|
// return innerSendNormal(seqNo,
|
||||||
url,userAccount,password,ecname,signCode,
|
// url,userAccount,password,ecname,signCode,
|
||||||
phone,content);
|
// phone,content);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static int innerSendNormal(
|
// public static int innerSendNormal(
|
||||||
String seqNo,
|
// String seqNo,
|
||||||
String url,String userAccount,String password,
|
// String url,String userAccount,String password,
|
||||||
String ecname,String signCode,String phone,String content
|
// String ecname,String signCode,String phone,String content
|
||||||
) throws EmisBizError {
|
// ) throws EmisBizError {
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
// Client client = Client.getInstance( );
|
//// Client client = Client.getInstance( );
|
||||||
// // 登录地址需另外提供
|
//// // 登录地址需另外提供
|
||||||
// boolean isLoggedin = client.login( url, userAccount, password, ecname );
|
//// boolean isLoggedin = client.login( url, userAccount, password, ecname );
|
||||||
// if( !isLoggedin ) {
|
//// if( !isLoggedin ) {
|
||||||
// log.error("移动短信渠道登录失败");
|
//// log.error("移动短信渠道登录失败");
|
||||||
// throw new EmisBizError(EmisBizErrorType.FAIL,"移动短信渠道登录失败");
|
//// throw new EmisBizError(EmisBizErrorType.FAIL,"移动短信渠道登录失败");
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// // 普通短信
|
||||||
|
//// int rst = client.sendDSMS( new String[]{phone}, content, seqNo, 1, signCode, null, true );
|
||||||
|
// int rst=1;
|
||||||
|
//// // 获取状态报告——开始
|
||||||
|
//// List<StatusReportModel> statusReportlist = client.getReport( );
|
||||||
|
//// log.error( "===>移动短信渠道发送状态==>:" + JSON.toJSONString( statusReportlist ) );
|
||||||
|
//// // 获取状态报告——结束
|
||||||
|
//
|
||||||
|
////
|
||||||
|
// if(rst==1) {
|
||||||
|
// return 1;
|
||||||
|
//// if ("OK".equals(response.getBody().getCode())) {
|
||||||
|
//// } else {
|
||||||
|
//// throw new EmisBizError(EmisBizErrorType.FAIL,response.getBody().getMessage());
|
||||||
|
//// }
|
||||||
|
// }else{
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道发送错误");
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // 普通短信
|
// }catch (Exception e) {
|
||||||
// int rst = client.sendDSMS( new String[]{phone}, content, seqNo, 1, signCode, null, true );
|
// e.printStackTrace();
|
||||||
int rst=1;
|
// throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道异常");
|
||||||
// // 获取状态报告——开始
|
// }
|
||||||
// List<StatusReportModel> statusReportlist = client.getReport( );
|
// }
|
||||||
// log.error( "===>移动短信渠道发送状态==>:" + JSON.toJSONString( statusReportlist ) );
|
|
||||||
// // 获取状态报告——结束
|
|
||||||
|
|
||||||
//
|
//
|
||||||
if(rst==1) {
|
//
|
||||||
return 1;
|
// public static void main(String[] args) {
|
||||||
// if ("OK".equals(response.getBody().getCode())) {
|
//
|
||||||
// } else {
|
// String url="http://112.35.4.197:15000";
|
||||||
// throw new EmisBizError(EmisBizErrorType.FAIL,response.getBody().getMessage());
|
// String userAccount="JStlz";
|
||||||
// }
|
// String password="Passwd@#123";
|
||||||
}else{
|
// String ecname="接口联调账号";
|
||||||
throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道发送错误");
|
// String phoneNumbers="13815412745";
|
||||||
}
|
// String signCode="bM16CfN2B";
|
||||||
|
//
|
||||||
}catch (Exception e) {
|
// String content="尊敬的客户:您寄往越南的包裹已寄出,运单号T123。如有疑问,详询服务热线4000257080,感谢您使用探路速运!";
|
||||||
e.printStackTrace();
|
//
|
||||||
throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道异常");
|
// try {
|
||||||
}
|
//
|
||||||
}
|
// int ret = innerSendNormal("1",
|
||||||
|
// url,userAccount,password,ecname,signCode,
|
||||||
|
// phoneNumbers,content);
|
||||||
public static void main(String[] args) {
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
String url="http://112.35.4.197:15000";
|
// }
|
||||||
String userAccount="JStlz";
|
// }
|
||||||
String password="Passwd@#123";
|
|
||||||
String ecname="接口联调账号";
|
|
||||||
String phoneNumbers="13815412745";
|
|
||||||
String signCode="bM16CfN2B";
|
|
||||||
|
|
||||||
String content="尊敬的客户:您寄往越南的包裹已寄出,运单号T123。如有疑问,详询服务热线4000257080,感谢您使用探路速运!";
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
int ret = innerSendNormal("1",
|
|
||||||
url,userAccount,password,ecname,signCode,
|
|
||||||
phoneNumbers,content);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,13 +6,17 @@ import com.aliyun.dysmsapi20170525.Client;
|
|||||||
import com.aliyun.tea.TeaModel;
|
import com.aliyun.tea.TeaModel;
|
||||||
import com.aliyun.teautil.Common;
|
import com.aliyun.teautil.Common;
|
||||||
import com.aliyun.teautil.models.RuntimeOptions;
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
|
import com.xdadan.erp.common.utils.DateUtils;
|
||||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||||
|
import com.xdadan.erp.emis.utils.HTTPHelperV3;
|
||||||
import com.xdadan.erp.system.service.ISysConfigService;
|
import com.xdadan.erp.system.service.ISysConfigService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service("Sms253Service")
|
@Service("Sms253Service")
|
||||||
public class Sms253Service {
|
public class Sms253Service {
|
||||||
@ -22,60 +26,73 @@ public class Sms253Service {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送短信
|
* 发送短信
|
||||||
* @param signName 签名
|
|
||||||
* @param templateCode 模板
|
|
||||||
* @param phone 手机号
|
* @param phone 手机号
|
||||||
* @param tplParam 参数
|
* @param content 发送内容
|
||||||
*/
|
*/
|
||||||
public int sendMessage(String signName,String phone, String templateCode,String tplParam) throws EmisBizError {
|
public int sendMessage(String phone, String content) throws EmisBizError {
|
||||||
|
|
||||||
String jsonParamStr=configService.selectConfigByKey("sys.sms253.sms");
|
String jsonParamStr=configService.selectConfigByKey("sys.sms253.sms");
|
||||||
JSONObject jObjAliyunParam=JSONObject.parseObject(jsonParamStr);
|
JSONObject jObjAliyunParam=JSONObject.parseObject(jsonParamStr);
|
||||||
String accessKeyId=jObjAliyunParam.getString("accessKeyId");
|
String account=jObjAliyunParam.getString("account");
|
||||||
String accessKeySecret=jObjAliyunParam.getString("accessKeySecret");
|
String passwd=jObjAliyunParam.getString("passwd");
|
||||||
|
|
||||||
return innerSendMessage(accessKeyId,accessKeySecret,signName,templateCode,phone,tplParam);
|
|
||||||
|
|
||||||
|
return innerSendMessage(account,passwd,phone,content);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static int innerSendMessage(String account,String password, String phone, String msg) throws EmisBizError {
|
||||||
* 使用AK&SK初始化账号Client
|
|
||||||
* @param accessKeyId
|
|
||||||
* @param accessKeySecret
|
|
||||||
* @return Client
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
|
||||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
|
||||||
.setAccessKeyId(accessKeyId)
|
|
||||||
.setAccessKeySecret(accessKeySecret);
|
|
||||||
// 访问的域名
|
|
||||||
config.endpoint = "dysmsapi.aliyuncs.com";
|
|
||||||
return new Client(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int innerSendMessage(String accessKeyId,String accessKeySecret,String signName,String templateCode, String phone, String tplParam) throws EmisBizError {
|
|
||||||
try {
|
try {
|
||||||
Client client = createClient(accessKeyId, accessKeySecret);
|
|
||||||
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest();
|
|
||||||
sendSmsRequest.setPhoneNumbers(phone);
|
|
||||||
sendSmsRequest.setSignName(signName);
|
|
||||||
sendSmsRequest.setTemplateCode(templateCode);
|
|
||||||
// sendSmsRequest.setTemplateParam("{\"code\":\""+param+"\"}");
|
|
||||||
sendSmsRequest.setTemplateParam(tplParam);
|
|
||||||
RuntimeOptions runtime = new RuntimeOptions();
|
|
||||||
com.aliyun.dysmsapi20170525.models.SendSmsResponse response = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
|
||||||
String jsonStr= Common.toJSONString(TeaModel.buildMap(response));
|
|
||||||
|
|
||||||
if(response.getStatusCode()==200) {
|
String url="http://smssh1.253.com/msg/v1/send/json";
|
||||||
if ("OK".equals(response.getBody().getCode())) {
|
JSONObject jObjSms = new JSONObject();
|
||||||
return 1;
|
jObjSms.put("account",account);
|
||||||
} else {
|
jObjSms.put("password",password);
|
||||||
throw new EmisBizError(EmisBizErrorType.FAIL,response.getBody().getMessage());
|
jObjSms.put("phone",phone);
|
||||||
|
// DateUtils.dateTimeNow()
|
||||||
|
jObjSms.put("sendtime", "");
|
||||||
|
jObjSms.put("msg",msg);
|
||||||
|
jObjSms.put("report","true");
|
||||||
|
jObjSms.put("extend","1");
|
||||||
|
jObjSms.put("uid","1");
|
||||||
|
|
||||||
|
log.debug("===>SMS253==>发送短信数据:{}",jObjSms.toJSONString());
|
||||||
|
String retStr=HTTPHelperV3.postJson(url,null,jObjSms.toJSONString());
|
||||||
|
log.debug("===>SMS253==>返回短信发送结果:{}",retStr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
{"account":"N6000001",
|
||||||
|
"password":"123456",
|
||||||
|
"msg":"【签名】您的验证码是:123456",
|
||||||
|
"phone":"15800000000",
|
||||||
|
"sendtime":"201704101400",
|
||||||
|
"report":"true",
|
||||||
|
"extend":"555",
|
||||||
|
"uid":"321abc",
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"failNum":"0",
|
||||||
|
"time":"20170410103836",
|
||||||
|
"successNum":"1",
|
||||||
|
"msgId":"17041010383624511",
|
||||||
|
"errorMsg":"",
|
||||||
|
"code":"0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
JSONObject jRst=JSONObject.parseObject(retStr);
|
||||||
|
String code=jRst.getString("code");
|
||||||
|
String errorMsg=jRst.getString("errorMsg");
|
||||||
|
|
||||||
|
if("0".equals(code)) {
|
||||||
|
return 1;
|
||||||
}else{
|
}else{
|
||||||
throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道发送错误");
|
throw new EmisBizError(EmisBizErrorType.FAIL,errorMsg);
|
||||||
}
|
}
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -86,14 +103,15 @@ public class Sms253Service {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
String accessKeyId="LTAI5tA1yz1QK6BVhzg3ne5D";
|
// API账号:N588993_N5355809
|
||||||
String accessKeySecret="bFbFle1hFsy1zeyTeN79FXopPx9yRS";
|
// API密码:LF2vA700801dca
|
||||||
String signName="跨境助手";
|
|
||||||
String templateCode="SMS_179215861";
|
String accessKeyId="N588993_N5355809";
|
||||||
|
String accessKeySecret="LF2vA700801dca";
|
||||||
String phoneNumbers="13764645922";
|
String phoneNumbers="13764645922";
|
||||||
String param="1234";
|
String msg="【探路速运】尊敬的客户:您寄往${Nationalcity}的包裹已寄出,运单号${name}。如有疑问,详询服务热线4000257080,感谢您使用探路速运!\n";
|
||||||
try {
|
try {
|
||||||
int ret = innerSendMessage(accessKeyId,accessKeySecret,signName,templateCode,phoneNumbers,param);
|
int ret = innerSendMessage(accessKeyId,accessKeySecret,phoneNumbers,msg);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user