From 2406574c36a8c4e8e8ffe7c56a34e25dde107a84 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 12 四月 2019 17:08:38 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/SMSServiceImpl.java | 38 +++++++++++++++++++++++++++++++++----- 1 files changed, 33 insertions(+), 5 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 8cd9a9d..26a3487 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 @@ -1,5 +1,6 @@ package com.yeshi.fanli.service.impl.user; +import java.math.BigDecimal; import java.util.Date; import javax.annotation.Resource; @@ -25,12 +26,12 @@ private RedisManager redisManager; @Override - public String sendLoginVCode(String phone) throws SMSException { + public String sendLoginVCode(String phone, int codeLength) throws SMSException { boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_LOGIN); if (limit) throw new SMSException(1001, "璇疯繃60绉掑啀璇�"); - String msgCode = StringUtil.getVerifyCode(6); - System.out.println(msgCode); + + String msgCode = StringUtil.getVerifyCode(codeLength); // 楠岃瘉鐮佹ā鏉� String msg = Constant.smsConfig.getSmsLogin().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()).replace("[楠岃瘉鐮乚", msgCode); @@ -39,6 +40,7 @@ // 缂撳瓨 redisManager.sendSms(phone, SMSHistory.TYPE_LOGIN); redisManager.saveSMSVCode(phone, SMSHistory.TYPE_LOGIN, msgCode); + SMSHistory smsHistory = new SMSHistory(); smsHistory.setContent(msg); smsHistory.setCreateTime(new Date()); @@ -49,18 +51,28 @@ } @Override - public void sendBindVCode(String phone) throws SMSException { + public void sendBindVCode(String phone, int codeLength) throws SMSException { boolean limit = redisManager.isSmsFrequencyLimit(phone, SMSHistory.TYPE_BIND); if (limit) throw new SMSException(1001, "璇疯繃60绉掑啀璇�"); - String msgCode = StringUtil.getRandomCode(6); + 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()); + smsHistory.setPhone(phone); + smsHistory.setType(SMSHistory.TYPE_BIND); + smsHistoryMapper.insertSelective(smsHistory); } @Override @@ -78,4 +90,20 @@ redisManager.saveSMSVCode(phone, SMSHistory.TYPE_EXTRACT, msgCode); } + @Override + public void sendExtractSuccessMsg(String phone, BigDecimal money) throws SMSException { + String msg = Constant.smsConfig.getSmsExtractSuccess().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()) + .replace("[閲戦]", money.toString()); + // 鍙戦�佺煭淇� + TencentSMSUtil.sendSingleMsg(phone, msg); + } + + @Override + public void sendExtractFailMsg(String phone, BigDecimal money) throws SMSException { + String msg = Constant.smsConfig.getSmsExtractFail().replace("[绛惧悕]", Constant.smsConfig.getSmsSign()) + .replace("[閲戦]", money.toString()); + // 鍙戦�佺煭淇� + TencentSMSUtil.sendSingleMsg(phone, msg); + } + } -- Gitblit v1.8.0