|
|
@ -10,6 +10,7 @@ import org.jeecg.api.untils.HttpConf; |
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
import org.jeecg.common.constant.CommonConstant; |
|
|
|
import org.jeecg.common.exception.JeecgBootException; |
|
|
|
import org.jeecg.common.sms.config.SmsConfig; |
|
|
|
import org.jeecg.common.sms.entity.SmsResponse; |
|
|
|
import org.jeecg.common.sms.service.SmsService; |
|
|
|
import org.jeecg.common.system.util.JwtUtil; |
|
|
@ -19,6 +20,7 @@ import org.jeecg.modules.commonConfig.entity.CommonConfig; |
|
|
|
import org.jeecg.modules.commonConfig.service.ICommonConfigService; |
|
|
|
import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; |
|
|
|
import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -59,6 +61,10 @@ public class AppletLoginServiceImpl implements AppletLoginService { |
|
|
|
//配置信息 |
|
|
|
@Resource |
|
|
|
private ICommonConfigService commonConfigService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SmsConfig smsConfig; |
|
|
|
|
|
|
|
|
|
|
|
// 验证码相关常量 |
|
|
|
private static final String SMS_CODE_PREFIX = "SMS_CODE:"; |
|
|
@ -241,24 +247,28 @@ public class AppletLoginServiceImpl implements AppletLoginService { |
|
|
|
return Result.error("验证码不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
// String cacheKey = SMS_CODE_PREFIX + phone; |
|
|
|
// String cachedCode = (String) redisUtil.get(cacheKey); |
|
|
|
// |
|
|
|
// if (StringUtils.isBlank(cachedCode)) { |
|
|
|
// return Result.error("验证码已过期,请重新获取"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// if (!code.equals(cachedCode)) { |
|
|
|
// return Result.error("验证码错误"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// // 验证码正确,删除缓存中的验证码 |
|
|
|
// redisUtil.del(cacheKey); |
|
|
|
|
|
|
|
HanHaiMember member = memberService.lambdaQuery().eq(HanHaiMember::getPhone, phone).one(); |
|
|
|
if("Y".equals(register) && member == null){ |
|
|
|
String cacheKey = SMS_CODE_PREFIX + phone; |
|
|
|
String cachedCode = (String) redisUtil.get(cacheKey); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(cachedCode)) { |
|
|
|
return Result.error("验证码已过期,请重新获取"); |
|
|
|
} |
|
|
|
|
|
|
|
}else if (member == null) {// 判断用户是否存在 |
|
|
|
if (!code.equals(cachedCode)) { |
|
|
|
return Result.error("验证码错误"); |
|
|
|
} |
|
|
|
|
|
|
|
// 验证码正确,删除缓存中的验证码 |
|
|
|
redisUtil.del(cacheKey); |
|
|
|
|
|
|
|
List<HanHaiMember> list = memberService.lambdaQuery() |
|
|
|
.eq(HanHaiMember::getPhone, phone).list(); |
|
|
|
HanHaiMember member = list.size() > 0 ? list.get(0) : null; |
|
|
|
// if("Y".equals(register) && member == null){ |
|
|
|
// // TODO 进行注册 |
|
|
|
// |
|
|
|
// }else |
|
|
|
if (member == null) {// 判断用户是否存在 |
|
|
|
throw new JeecgBootException("电话号码不存在:"+phone); |
|
|
|
} |
|
|
|
// 生成token返回给小程序端 |
|
|
@ -292,7 +302,8 @@ public class AppletLoginServiceImpl implements AppletLoginService { |
|
|
|
String verifyCode = generateVerifyCode(); |
|
|
|
|
|
|
|
// 构建短信内容 |
|
|
|
String content = String.format("您的验证码是:%s,%d分钟内有效,请勿泄露给他人。", |
|
|
|
String content = String.format("%s您的验证码是:%s,%d分钟内有效,请勿泄露给他人。", |
|
|
|
smsConfig.getCompanyName(), |
|
|
|
verifyCode, SMS_CODE_EXPIRE_TIME / 60); |
|
|
|
|
|
|
|
// 发送短信 |
|
|
|