|
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.security.SecureRandom;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -204,7 +205,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
return ResponseJson.error("验证码已发送,请勿重复操作");
|
|
|
}*/
|
|
|
// 重复发送,删除前一个验证码
|
|
|
- redisService.remove("code:"+ mobile);
|
|
|
+ redisService.remove("code:" + mobile);
|
|
|
Integer dbUserId = null;
|
|
|
// 根据手机号查询用户Id
|
|
|
String content = "";
|
|
@@ -217,14 +218,14 @@ public class BaseServiceImpl implements BaseService {
|
|
|
// 您正在操作登录采美商城,验证码:{s6},请在5分钟内完成验证。如非本人操作,请忽略本短信。
|
|
|
content = "您正在操作登录采美商城,验证码:" + randomCode + ",请在5分钟内完成验证。如非本人操作,请忽略本短信。";
|
|
|
codeTypeTxt = "登录采美商城";
|
|
|
- } else if (9 == activateCodeType){
|
|
|
+ } else if (9 == activateCodeType) {
|
|
|
// 联合丽格登录发送短信
|
|
|
- dbUserId = baseMapper.getUserIdByOrganize(4,mobile);
|
|
|
+ dbUserId = baseMapper.getUserIdByOrganize(4, mobile);
|
|
|
if (dbUserId == null) {
|
|
|
return ResponseJson.error("该手机号暂未注册");
|
|
|
}
|
|
|
UserLoginVo userLoginVo = baseMapper.getUserIdByOrganizeStatus(4, mobile);
|
|
|
- if ( null != userLoginVo.getClubStatus()) {
|
|
|
+ if (null != userLoginVo.getClubStatus()) {
|
|
|
if (1 == userLoginVo.getClubStatus()) {
|
|
|
return ResponseJson.error(-1, "账号待审核,请耐心等待审核结果", null);
|
|
|
}
|
|
@@ -241,14 +242,14 @@ public class BaseServiceImpl implements BaseService {
|
|
|
} else {
|
|
|
return ResponseJson.error("参数错误:activateCodeType");
|
|
|
}
|
|
|
- boolean smsFlag = isBeta || remoteCallService.remoteSendSms(0,1,mobile,content);
|
|
|
+ boolean smsFlag = isBeta || remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
if (!smsFlag) {
|
|
|
// 短信发送失败重试一次
|
|
|
- smsFlag = remoteCallService.remoteSendSms(0,1,mobile,content);
|
|
|
+ smsFlag = remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
}
|
|
|
if (smsFlag) {
|
|
|
- redisService.set("code:"+ mobile, randomCode,300L);
|
|
|
- log.info(codeTypeTxt + "登录短信,发送到"+ mobile + "的验证码为:"+ randomCode);
|
|
|
+ redisService.set("code:" + mobile, randomCode, 300L);
|
|
|
+ log.info(codeTypeTxt + "登录短信,发送到" + mobile + "的验证码为:" + randomCode);
|
|
|
return ResponseJson.success("发送验证码成功");
|
|
|
} else {
|
|
|
log.info(codeTypeTxt + ",验证码发送失败!");
|
|
@@ -256,39 +257,39 @@ public class BaseServiceImpl implements BaseService {
|
|
|
}
|
|
|
} else if (8 == activateCodeType) {
|
|
|
// 联合丽格注册发送短信
|
|
|
- Integer dbUserId = baseMapper.getUserIdByOrganize(4,mobile);
|
|
|
+ Integer dbUserId = baseMapper.getUserIdByOrganize(4, mobile);
|
|
|
if (dbUserId != null) {
|
|
|
return ResponseJson.error("该手机号已注册");
|
|
|
}
|
|
|
// 您的验证码为:{s6},5分钟内有效,请勿泄漏他人。
|
|
|
String content = "【丽格集采联盟】您的验证码为:" + randomCode + ",5分钟内有效,请勿泄漏他人。";
|
|
|
- sendFlag = isBeta || remoteCallService.remoteSendSms(0,1,mobile,content);
|
|
|
+ sendFlag = isBeta || remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
if (!sendFlag) {
|
|
|
// 短信发送失败重试一次
|
|
|
- sendFlag = remoteCallService.remoteSendSms(0,1,mobile,content);
|
|
|
+ sendFlag = remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
}
|
|
|
codeTypeTxt = "联合丽格注册";
|
|
|
- } else if (10 == activateCodeType){
|
|
|
+ } else if (10 == activateCodeType) {
|
|
|
// 联合丽格找回密码发送短信
|
|
|
- Integer dbUserId = baseMapper.getUserIdByOrganize(4,mobile);
|
|
|
+ Integer dbUserId = baseMapper.getUserIdByOrganize(4, mobile);
|
|
|
if (dbUserId == null) {
|
|
|
return ResponseJson.error("该手机号暂未注册");
|
|
|
}
|
|
|
// 您正在修改密码,验证码为:{s6},5分钟内有效,请勿泄漏他人。
|
|
|
String content = "【丽格集采联盟】您正在修改密码,验证码为:" + randomCode + ",5分钟内有效,请勿泄漏他人。";
|
|
|
- sendFlag = isBeta || remoteCallService.remoteSendSms(0,1,mobile,content);
|
|
|
+ sendFlag = isBeta || remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
if (!sendFlag) {
|
|
|
// 短信发送失败重试一次
|
|
|
- sendFlag = remoteCallService.remoteSendSms(0,1,mobile,content);
|
|
|
+ sendFlag = remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
}
|
|
|
codeTypeTxt = "联合丽格找回密码";
|
|
|
- } else if (11 == activateCodeType){
|
|
|
- // 联合丽格
|
|
|
- // 您正在更改手机号,验证码为:{s6},5分钟内有效,请勿泄漏他人。
|
|
|
- String content = "【丽格集采联盟】您正在更改手机号,验证码为:" + randomCode + ",5分钟内有效,请勿泄漏他人。";
|
|
|
+ } else if (11 == activateCodeType) {
|
|
|
+ // 联合丽格
|
|
|
+ // 您正在更改手机号,验证码为:{s6},5分钟内有效,请勿泄漏他人。
|
|
|
+ String content = "【丽格集采联盟】您正在更改手机号,验证码为:" + randomCode + ",5分钟内有效,请勿泄漏他人。";
|
|
|
|
|
|
- sendFlag = isBeta || remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
- codeTypeTxt = "更换联系人(旧手机号验证码)";
|
|
|
+ sendFlag = isBeta || remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
+ codeTypeTxt = "更换联系人(旧手机号验证码)";
|
|
|
} else if (12 == activateCodeType) {
|
|
|
// 联合丽格
|
|
|
if (null != userId && userId > 0) {
|
|
@@ -329,10 +330,10 @@ public class BaseServiceImpl implements BaseService {
|
|
|
if (6 == activateCodeType) {
|
|
|
//二手验证码10分钟有效期
|
|
|
redisService.set("code:" + mobile, randomCode, 600L);
|
|
|
- } else if (8 == activateCodeType || 10 == activateCodeType || 11 == activateCodeType||14 == activateCodeType||15 == activateCodeType) {
|
|
|
+ } else if (8 == activateCodeType || 10 == activateCodeType || 11 == activateCodeType || 14 == activateCodeType || 15 == activateCodeType) {
|
|
|
// 联合丽格验证码5分钟有效期
|
|
|
redisService.set("code:" + mobile, randomCode, 300L);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
redisService.set("code:" + mobile, randomCode, 1800L);
|
|
|
}
|
|
|
log.info(codeTypeTxt + ",发送到:" + mobile + "的短信验证码为: " + randomCode);
|
|
@@ -528,19 +529,19 @@ public class BaseServiceImpl implements BaseService {
|
|
|
// 生成6位数验证码
|
|
|
String randomCode = CodeUtil.generateCodeInt(6);
|
|
|
// 开发、测试环境下短信验证码固定为666666
|
|
|
- boolean isCode = "dev".equals(profile)||"beta".equals(profile);
|
|
|
+ boolean isCode = "dev".equals(profile) || "beta".equals(profile);
|
|
|
if (isCode) {
|
|
|
randomCode = "666666";
|
|
|
}
|
|
|
// 您正在操作绑定运营人员,验证码:{s6},请在5分钟内完成验证。如非本人操作,请忽略本短信。
|
|
|
- String content = "您正在操作绑定运营人员,验证码:"+ randomCode+",请在5分钟内完成验证。如非本人操作,请忽略本短信。";
|
|
|
- boolean smsFlag = isCode || remoteCallService.remoteSendSms(0,1,mobile,content);
|
|
|
+ String content = "您正在操作绑定运营人员,验证码:" + randomCode + ",请在5分钟内完成验证。如非本人操作,请忽略本短信。";
|
|
|
+ boolean smsFlag = isCode || remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
if (!smsFlag) {
|
|
|
- smsFlag = remoteCallService.remoteSendSms(0,1,mobile,content);
|
|
|
+ smsFlag = remoteCallService.remoteSendSms(0, 1, mobile, content);
|
|
|
}
|
|
|
if (smsFlag) {
|
|
|
- redisService.set("code:"+mobile,randomCode,300L);
|
|
|
- log.info("绑定运营人员,发送到:"+mobile+"验证码为:"+randomCode);
|
|
|
+ redisService.set("code:" + mobile, randomCode, 300L);
|
|
|
+ log.info("绑定运营人员,发送到:" + mobile + "验证码为:" + randomCode);
|
|
|
return ResponseJson.success("发送验证码成功");
|
|
|
} else {
|
|
|
return ResponseJson.error("发送验证码失败,请稍后再试");
|
|
@@ -614,7 +615,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
String dbPassword = Md5Util.md5(passWord);
|
|
|
baseMapper.updatePasswordByUserId(dbPassword, dbUserId);
|
|
|
//重新设置密码后将登录失败表中近30分钟记录置为删除
|
|
|
- redisService.remove("login-"+dbUserId);
|
|
|
+ redisService.remove("login-" + dbUserId);
|
|
|
return ResponseJson.success("密码修改成功", "");
|
|
|
}
|
|
|
|
|
@@ -672,7 +673,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
String dbPassword = Md5Util.md5(passWord);
|
|
|
baseMapper.updatePasswordByUserId(dbPassword, dbUserId);
|
|
|
//重新设置密码后将登录失败表中近30分钟记录置为删除
|
|
|
- redisService.remove("login-"+dbUserId);
|
|
|
+ redisService.remove("login-" + dbUserId);
|
|
|
return ResponseJson.success("密码修改成功", "");
|
|
|
}
|
|
|
|
|
@@ -820,7 +821,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
|
|
|
@Override
|
|
|
public String getByMobile(Integer userIdentity, Integer userId) {
|
|
|
- return baseMapper.getByMobile(userIdentity,userId);
|
|
|
+ return baseMapper.getByMobile(userIdentity, userId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -842,6 +843,32 @@ public class BaseServiceImpl implements BaseService {
|
|
|
public CmUser findUserByMobile(String mobile, Integer oldUserId, Integer userIdentity) {
|
|
|
return baseMapper.findUserByMobile(mobile, oldUserId, userIdentity);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson creatTicket() {
|
|
|
+ for (int i = 0; i < 400; i++) {
|
|
|
+ String s = generateSecureRandomString(12);
|
|
|
+ Integer id = baseMapper.findTicket(s);
|
|
|
+ if (null == id) {
|
|
|
+ baseMapper.insertTicket(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseJson.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String generateSecureRandomString(int length) {
|
|
|
+ String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ SecureRandom random = new SecureRandom();
|
|
|
+ for (int i = 0; i < length; i++) {
|
|
|
+ int index = random.nextInt(chars.length());
|
|
|
+ sb.append(chars.charAt(index));
|
|
|
+ }
|
|
|
+
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public int getUserType(String userId) {
|
|
|
return baseMapper.getUserType(userId);
|