|
|
@ -10,6 +10,7 @@ import com.zscat.mallplus.enums.SmsEnum; |
|
|
|
import com.zscat.mallplus.exception.ApiMallPlusException; |
|
|
|
import com.zscat.mallplus.oms.mapper.OmsOrderMapper; |
|
|
|
import com.zscat.mallplus.oms.vo.OrderStstic; |
|
|
|
import com.zscat.mallplus.sys.entity.SysUserVo; |
|
|
|
import com.zscat.mallplus.sys.mapper.SysAreaMapper; |
|
|
|
import com.zscat.mallplus.ums.entity.*; |
|
|
|
import com.zscat.mallplus.ums.mapper.SysAppletSetMapper; |
|
|
@ -110,6 +111,8 @@ public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember |
|
|
|
private JwtTokenUtil jwtTokenUtil; |
|
|
|
@Value("${redis.key.prefix.authCode}") |
|
|
|
private String REDIS_KEY_PREFIX_AUTH_CODE; |
|
|
|
@Value("${redis.key.prefix.loginCode}") |
|
|
|
private String REDIS_KEY_PREFIX_LOGIN_CODE; |
|
|
|
@Value("${authCode.expire.seconds}") |
|
|
|
private Long AUTH_CODE_EXPIRE_SECONDS; |
|
|
|
@Value("${jwt.tokenHead}") |
|
|
@ -448,7 +451,8 @@ public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember |
|
|
|
String redisKey = ""; |
|
|
|
if (SmsEnum.SendEnum.LOGIN.getCode().equals(type)) { |
|
|
|
content = "验证码:" + code + ",用于登录App,有效期5分钟,如非本人操作,请忽略该短信。"; |
|
|
|
redisKey = SmsEnum.SendEnum.LOGIN.getRedisKey(); |
|
|
|
// redisKey = SmsEnum.SendEnum.LOGIN.getRedisKey();
|
|
|
|
redisKey = REDIS_KEY_PREFIX_LOGIN_CODE; |
|
|
|
} |
|
|
|
String result = SmsConfig.SendWaitWorkMsg(phone, code, content); |
|
|
|
if ("1".equals(result)) { |
|
|
@ -457,7 +461,8 @@ public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember |
|
|
|
sms.setCode(sms.getCode()); |
|
|
|
sms.setBizId(result);//返回的code
|
|
|
|
sms.setMessage(resultMsg); |
|
|
|
redisService.set(redisKey + phone, code + date.getTime(), SmsEnum.APP_LOGIN_CODE_TIME_LIMIT); |
|
|
|
redisService.set(redisKey + phone, code + date.getTime()); |
|
|
|
redisService.expire(redisKey + phone, SmsEnum.APP_LOGIN_CODE_TIME_LIMIT); |
|
|
|
log.info("发送短信结果:code:{},message:{}, 1,发送成功"); |
|
|
|
}else{ |
|
|
|
//返回的信息
|
|
|
@ -1207,15 +1212,20 @@ public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberMapper, UmsMember |
|
|
|
String token = null; |
|
|
|
try { |
|
|
|
UserDetails userDetails = userDetailsService.loadUserByUsername(phone); |
|
|
|
|
|
|
|
//验证验证码
|
|
|
|
if (!verifyAuthCode(authCode, phone)) { |
|
|
|
/*if (!verifyAuthCode(authCode, phone)) { |
|
|
|
throw new ApiMallPlusException("验证码错误"); |
|
|
|
}*/ |
|
|
|
String codeFromRedis = redisService.get(REDIS_KEY_PREFIX_LOGIN_CODE+ phone); |
|
|
|
if (StringUtils.isBlank(codeFromRedis)){ |
|
|
|
throw new ApiMallPlusException("短信验证码已失效,请重新发送"); |
|
|
|
} |
|
|
|
if (!authCode.equals(codeFromRedis.substring(0, 4))) { |
|
|
|
throw new ApiMallPlusException("短信验证码错误或已失效,请重新获取"); |
|
|
|
} |
|
|
|
UmsMember member = this.getByUsername(phone); |
|
|
|
if (member == null || member.getId() == null) { |
|
|
|
throw new ApiMallPlusException("用户不存在"); |
|
|
|
|
|
|
|
} |
|
|
|
Authentication authentication = new UsernamePasswordAuthenticationToken( |
|
|
|
userDetails, null, userDetails.getAuthorities()); |
|
|
|