From eccfb59bb0347731afdaf71b3422848649e44b26 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 15 四月 2019 10:44:26 +0800
Subject: [PATCH] 阿里云短信发送添加

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java
index 26a3487..c5838de 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java
@@ -11,10 +11,13 @@
 import com.yeshi.fanli.entity.bus.user.SMSHistory;
 import com.yeshi.fanli.exception.SMSException;
 import com.yeshi.fanli.service.inter.user.SMSService;
+import com.yeshi.fanli.util.AliyunSMSUtil;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TencentSMSUtil;
+
+import net.sf.json.JSONObject;
 
 @Service
 public class SMSServiceImpl implements SMSService {
@@ -30,17 +33,27 @@
 		boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
 		if (limit)
 			throw new SMSException(1001, "璇疯繃60绉掑啀璇�");
-		
+
+		String key = StringUtil.Md5("sms-login-tencent-latest-" + phone);
+
 		String msgCode = StringUtil.getVerifyCode(codeLength);
 		// 楠岃瘉鐮佹ā鏉�
 		String msg = Constant.smsConfig.getSmsLogin().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()).replace("[楠岃瘉鐮乚",
 				msgCode);
 		// 鍙戦�佺煭淇�
-		TencentSMSUtil.sendSingleMsg(phone, msg);
+		// 鍙戦�侀棿闅�2鍒嗛挓鍐呯殑閲囩敤闃块噷浜戠煭淇″彂閫�
+		if (StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
+			TencentSMSUtil.sendSingleMsg(phone, msg);
+			redisManager.cacheCommonString(key, "1", 120);
+		} else {
+			// 鍙戦�侀樋閲屼簯鐭俊
+			JSONObject data = new JSONObject();
+			AliyunSMSUtil.sendSingleMsg(phone, Constant.smsConfig.getAliyunLoginTemplatecode(), data.toString());
+		}
 		// 缂撳瓨
 		redisManager.sendSms(phone, SMSHistory.TYPE_LOGIN);
 		redisManager.saveSMSVCode(phone, SMSHistory.TYPE_LOGIN, msgCode);
-		
+
 		SMSHistory smsHistory = new SMSHistory();
 		smsHistory.setContent(msg);
 		smsHistory.setCreateTime(new Date());
@@ -56,17 +69,17 @@
 		if (limit)
 			throw new SMSException(1001, "璇疯繃60绉掑啀璇�");
 		String msgCode = StringUtil.getVerifyCode(codeLength);
-		
+
 		// 楠岃瘉鐮佹ā鏉�
 		String msg = Constant.smsConfig.getSmsBind().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()).replace("[楠岃瘉鐮乚",
 				msgCode);
 		// 鍙戦�佺煭淇�
 		TencentSMSUtil.sendSingleMsg(phone, msg);
-		
+
 		// 缂撳瓨
 		redisManager.sendSms(phone, SMSHistory.TYPE_BIND);
 		redisManager.saveSMSVCode(phone, SMSHistory.TYPE_BIND, msgCode);
-		
+
 		SMSHistory smsHistory = new SMSHistory();
 		smsHistory.setContent(msg);
 		smsHistory.setCreateTime(new Date());

--
Gitblit v1.8.0