Commit b4ef7b38 authored by hezhen's avatar hezhen

123

parent da48fdd6
...@@ -161,13 +161,13 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -161,13 +161,13 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
example.createCriteria().andEqualTo("tickerNo",TickerNo).andEqualTo("isDel",0); example.createCriteria().andEqualTo("tickerNo",TickerNo).andEqualTo("isDel",0);
List<UserCoupon> list=selectByExample(example); List<UserCoupon> list=selectByExample(example);
if(list.size()==0){ if(list.size()==0){
log.error(userId+"----没有可用优惠卷--TickerNo==="+TickerNo); log.error(userId+"----没有可用优惠卷--tickerNo==="+TickerNo);
return couponAmout; return couponAmout;
} }
UserCoupon userCoupon=list.get(0); UserCoupon userCoupon=list.get(0);
if(userCoupon!=null&&userCoupon.getIsUse()==1){ if(userCoupon!=null&&userCoupon.getIsUse()==1){
log.error(userId+"----该优惠卷已使用--TickerNo=="+TickerNo); log.error(userId+"----该优惠卷已使用--tickerNo=="+TickerNo);
return couponAmout; return couponAmout;
} }
if (type==1){ if (type==1){
...@@ -209,7 +209,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -209,7 +209,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
return; return;
} }
Example example=new Example(UserCoupon.class); Example example=new Example(UserCoupon.class);
example.createCriteria().andEqualTo("TickerNo",TickerNo).andEqualTo("isDel",0); example.createCriteria().andEqualTo("tickerNo",TickerNo).andEqualTo("isDel",0);
List<UserCoupon> list=selectByExample(example); List<UserCoupon> list=selectByExample(example);
if(list.size()==0){ if(list.size()==0){
log.error(TickerNo+"----优惠卷不存在"); log.error(TickerNo+"----优惠卷不存在");
......
...@@ -15,6 +15,8 @@ import com.aliyuncs.profile.IClientProfile; ...@@ -15,6 +15,8 @@ import com.aliyuncs.profile.IClientProfile;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import com.github.wxiaoqi.security.common.util.RandomUtil; import com.github.wxiaoqi.security.common.util.RandomUtil;
...@@ -155,6 +157,62 @@ public class SmsService { ...@@ -155,6 +157,62 @@ public class SmsService {
return false; return false;
} }
public boolean sendTemplate(String PhoneNumbers,String params,String templateCode) throws ClientException {
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
//组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
//必填:待发送手机号
request.setPhoneNumbers(PhoneNumbers);
//必填:短信签名-可在短信控制台中找到
request.setSignName(SignName);
//必填:短信模板-可在短信控制台中找到
request.setTemplateCode(templateCode);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
request.setTemplateParam(params);//\"name\":\"Tom\",
//选填-上行短信扩展码(无特殊需求用户请忽略此字段)
//request.setSmsUpExtendCode("90997");
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
//request.setOutId("yourOutId");
//hint 此处可能会抛出异常,注意catch
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
log.info("短信接口返回的数据----------------mobile======"+PhoneNumbers+"----templateParam===="+params);
log.info("Code=" + sendSmsResponse.getCode());
log.info("Message=" + sendSmsResponse.getMessage());
log.info("RequestId=" + sendSmsResponse.getRequestId());
log.info("BizId=" + sendSmsResponse.getBizId());
if(sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {
//请求成功
return true;
}
return false;
}
public String getString(Map<String,Object> params){
if(params!=null){
StringBuilder sb = new StringBuilder("{");
for (Object o : params.keySet()) {
sb.append("\"" + o + "\"" +":"+"\"" + params.get(o) + "\"" +",");
}
sb.replace(sb.length() - 1, sb.length(), "}");
return sb.toString();
}
return null;
}
/* public static QuerySendDetailsResponse querySendDetails(String bizId) throws ClientException { /* public static QuerySendDetailsResponse querySendDetails(String bizId) throws ClientException {
...@@ -188,14 +246,19 @@ public class SmsService { ...@@ -188,14 +246,19 @@ public class SmsService {
} }
*/ */
public static void main(String[] args) throws ClientException, InterruptedException { public static void main(String[] args) throws ClientException, InterruptedException {
SmsService SmsService=new SmsService(); SmsService smsService=new SmsService();
//发短信 //发短信
String response = SmsService.sendSms("15521075918","123456"); Map<String,Object> params=new HashMap<>();
params.put("name","何振");
params.put("code","123456");
params.put("time",5);
params.put("other","何振2");
smsService.sendTemplate("13612688539","123","SMS_171112286");
/*System.out.println("短信接口返回的数据----------------"); /*System.out.println("短信接口返回的数据----------------");
System.out.println("Code=" + response.getCode()); System.out.println("Code=" + response.getCode());
System.out.println("Message=" + response.getMessage()); System.out.println("Message=" + response.getMessage());
System.out.println("RequestId=" + response.getRequestId()); System.out.println("RequestId=" + response.getRequestId());
System.out.println("BizId=" + response.getBizId());*/ System.out.println("BizId=" + response.getBizId());*//*
Thread.sleep(3000L); Thread.sleep(3000L);
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment