Authored by michaelcao

修改发送信息接口

... ... @@ -3,6 +3,8 @@
*/
package com.yoho.activity.common.helper;
import java.net.URLEncoder;
import javax.annotation.Resource;
import org.slf4j.Logger;
... ... @@ -10,8 +12,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.yoho.core.common.utils.AES;
import com.yoho.core.common.utils.MD5;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.core.rest.client.hystrix.AsyncFuture;
import com.yoho.error.exception.ServiceException;
... ... @@ -32,17 +32,17 @@ public class SendSMSHelper {
private String sendSMSPassword;
public void sendNoticeSms(String mobile, String content) throws ServiceException {
log.info("sendNoticeSms with mobile={},, content={}", mobile, content);
String url = "http://www.ztsms.cn/sendSms.do?";
try {
String pwd = AES.decrypt("yoho96461qaz2wsx", sendSMSPassword);
url += "username=youhuo&password=" + MD5.md5(pwd) + "&mobile=" + mobile + "&content="+ content +"&productid=333333";
// 调用接口发送短信请求
AsyncFuture<String> response = serviceCaller.get("sms.sendSMS", url, null, String.class, null);
String result = response.get();
log.info("sendNoticeSms result is {}, mobile is {}", result, mobile);
} catch (Exception e) {
log.error("AES.decrypt error with code={}", sendSMSPassword, e);
}
log.info("sendNoticeSms with mobile={},, content={}", mobile, content);
String url = "http://221.179.180.158:9009/HttpQuickProcess_utf-8/submitMessageAll?";
try {
String contentCode = URLEncoder.encode(content, "UTF-8");
url += "OperID=yoho&OperPass=EMKVpwoJ&DesMobile=" + mobile + "&Content=" + contentCode + "&ContentType=8";
// 调用接口发送短信请求
AsyncFuture<String> response = serviceCaller.get("sms.sendSMS", url, null, String.class, null);
String result = response.get();
log.info("sendNoticeSms result is {}, mobile is {}", result, mobile);
} catch (Exception e) {
log.error("AES.decrypt error with code={}", "7jVEde87bLffoTnt6tGxmw==", e);
}
}
}
... ...
... ... @@ -12,7 +12,6 @@ import javax.annotation.Resource;
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;
... ... @@ -20,11 +19,10 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.common.constatns.Constant;
import com.yoho.activity.common.helper.ClientSecretHelper;
import com.yoho.activity.common.helper.SendSMSHelper;
import com.yoho.activity.common.utils.DateUtils;
import com.yoho.activity.common.utils.RandomUtil;
import com.yoho.activity.service.ICocacolaService;
import com.yoho.core.common.utils.AES;
import com.yoho.core.common.utils.MD5;
import com.yoho.core.redis.YHRedisTemplate;
import com.yoho.core.redis.YHValueOperations;
import com.yoho.core.rest.client.ServiceCaller;
... ... @@ -58,6 +56,9 @@ public class CocacolaServiceImpl implements ICocacolaService {
@Resource
private ServiceCaller service;
@Resource
SendSMSHelper sendSMSHelper;
@Resource(name = "yhValueOperations")
private YHValueOperations<String, String> yhValueOperations;
... ... @@ -295,19 +296,8 @@ public class CocacolaServiceImpl implements ICocacolaService {
@Override
public void sendNoticeSms(String mobile, String password) throws ServiceException {
log.info("sendNoticeSms with mobile={}", mobile);
String url = "http://www.ztsms.cn/sendSms.do?";
String content = "【 Yoho!Buy有货】恭喜您获得一张可口可乐优惠券,您的登录账号是 "+ mobile +", 密码是"+ password +";下载Yoho!Buy有货手机端 http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho,更多惊喜等着您!【有货】";
try {
String pwd = AES.decrypt("yoho96461qaz2wsx", this.sendSMSPassword);
url += "username=youhuo&password=" + MD5.md5(pwd) + "&mobile=" + mobile + "&content="+ content +"&productid=333333";
} catch (Exception e) {
log.error("AES.decrypt error with code={}", this.sendSMSPassword, e);
return;
}
// 调用接口发送短信请求
AsyncFuture<String> response = service.get("sms.sendSMS", url, null, String.class, null);
String result = response.get();
log.info("sendNoticeSms result is {}, mobile is {}", result, mobile);
sendSMSHelper.sendNoticeSms(mobile, content);
}
... ...
... ... @@ -20,11 +20,10 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.common.constatns.Constant;
import com.yoho.activity.common.helper.ClientSecretHelper;
import com.yoho.activity.common.helper.SendSMSHelper;
import com.yoho.activity.common.utils.DateUtils;
import com.yoho.activity.common.utils.RandomUtil;
import com.yoho.activity.service.ICouponActivityService;
import com.yoho.core.common.utils.AES;
import com.yoho.core.common.utils.MD5;
import com.yoho.core.redis.YHRedisTemplate;
import com.yoho.core.redis.YHValueOperations;
import com.yoho.core.rest.client.ServiceCaller;
... ... @@ -71,6 +70,9 @@ public class ICouponActivityServiceImpl implements ICouponActivityService {
@Resource
ICouponActivityDAO couponActivityDAO;
@Resource
SendSMSHelper sendSMSHelper;
@Override
public CouponActivityResponseBO getCouponActivityByCode(String activityCode) throws ServiceException {
log.debug("getCouponActivityByCode with activityCode={}", activityCode);
... ... @@ -318,20 +320,8 @@ public class ICouponActivityServiceImpl implements ICouponActivityService {
public void sendNoticeSms(String mobile, String password, CouponActivity activity) throws ServiceException {
log.info("sendNoticeSms with mobile={}", mobile);
String url = "http://www.ztsms.cn/sendSms.do?";
String content = "【 Yoho!Buy有货】恭喜您获得一张"+ activity.getCouponName() +"优惠券,您的登录账号是 "+ mobile +", 密码是"+ password +";下载Yoho!Buy有货手机端 http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho,更多惊喜等着您!【有货】";
try {
String pwd = AES.decrypt("yoho96461qaz2wsx", this.sendSMSPassword);
url += "username=youhuo&password=" + MD5.md5(pwd) + "&mobile=" + mobile + "&content="+ content +"&productid=333333";
} catch (Exception e) {
log.error("AES.decrypt error with code={}", this.sendSMSPassword, e);
return;
}
// 调用接口发送短信请求
AsyncFuture<String> response = service.get("sms.sendSMS", url, null, String.class, null);
String result = response.get();
log.info("sendNoticeSms result={}", result);
log.info("sendNoticeSms result is {}, mobile is {}", result, mobile);
sendSMSHelper.sendNoticeSms(mobile, content);
}
/**
... ...
... ... @@ -22,13 +22,12 @@ import com.yoho.activity.common.bo.TencentMktBO;
import com.yoho.activity.common.constatns.Constant;
import com.yoho.activity.common.convert.TencentMktActivityConvert;
import com.yoho.activity.common.helper.ClientSecretHelper;
import com.yoho.activity.common.helper.SendSMSHelper;
import com.yoho.activity.common.redis.CacheKeyHelper;
import com.yoho.activity.common.utils.DateUtils;
import com.yoho.activity.common.utils.PhoneUtil;
import com.yoho.activity.common.utils.RandomUtil;
import com.yoho.activity.service.ITencentMktService;
import com.yoho.core.common.utils.AES;
import com.yoho.core.common.utils.MD5;
import com.yoho.core.redis.YHRedisTemplate;
import com.yoho.core.redis.YHValueOperations;
import com.yoho.core.rest.client.ServiceCaller;
... ... @@ -71,6 +70,9 @@ public class TencentMktServiceImpl implements ITencentMktService {
@Value("${tencentmkt.shareUrl}")
private String shareUrl;
@Resource
SendSMSHelper sendSMSHelper;
public static final String TENCENT_MKT__ACTIVITY_CACHEKEY = "yh:activity:tencentmkt:";
... ... @@ -342,19 +344,8 @@ public class TencentMktServiceImpl implements ITencentMktService {
@Override
public void sendNoticeSms(String mobile, String password) throws ServiceException {
log.info("sendNoticeSms with mobile={}", mobile);
String url = "http://www.ztsms.cn/sendSms.do?";
String content = "【Yoho!Buy有货】恭喜您获得千元礼包,您的登录账户是"+ mobile +", 密码是"+ password +"(随机6位数字+2位字母);下载Yoho!Buy有货手机端 http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho(最新地址),更多惊喜等着您!【有货】";
try {
String pwd = AES.decrypt("yoho96461qaz2wsx", this.sendSMSPassword);
url += "username=youhuo&password=" + MD5.md5(pwd) + "&mobile=" + mobile + "&content="+ content +"&productid=333333";
} catch (Exception e) {
log.error("AES.decrypt error with code={}", this.sendSMSPassword, e);
return;
}
// 调用接口发送短信请求
AsyncFuture<String> response = service.get("sms.sendSMS", url, null, String.class, null);
String result = response.get();
log.info("sendNoticeSms result is {}, mobile is {}", result, mobile);
sendSMSHelper.sendNoticeSms(mobile, content);
}
... ...