|
@@ -93,53 +93,56 @@ public class BaseServiceImpl implements BaseService {
|
|
|
*
|
|
|
* @param mobile 手机号
|
|
|
* @param activateCodeType 1:找回密码,2:手机号注册机构,3:供应商注册
|
|
|
+ * @param platformType 0:www,1:crm/h5,2:小程序
|
|
|
+ * @param isCheckCaptcha 是否检查图片验证码,0:检查,1:不检查
|
|
|
* @param imgCode 图片验证码
|
|
|
* @param token 图片验证码token
|
|
|
- * @param platformType 0:www,1:crm/h5,2:小程序
|
|
|
*/
|
|
|
@Override
|
|
|
- public ResponseJson getSmsCode(String mobile, String activateCodeType, String imgCode, String token, Integer platformType) {
|
|
|
- Boolean checkFlag = checkCaptchaImage(token, imgCode, platformType);
|
|
|
- if (!checkFlag) {
|
|
|
- return ResponseJson.error("图片验证码错误");
|
|
|
- } else {
|
|
|
- // 验证手机号
|
|
|
- ResponseJson mobileModel = ValidateUtil.validateMobile(mobile);
|
|
|
- if (mobileModel.getCode() == -1) {
|
|
|
- return mobileModel;
|
|
|
+ public ResponseJson getSmsCode(String mobile, Integer activateCodeType, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
|
|
|
+ if (null != isCheckCaptcha && isCheckCaptcha == 1){
|
|
|
+ Boolean checkFlag = checkCaptchaImage(token, imgCode, platformType);
|
|
|
+ if (!checkFlag) {
|
|
|
+ return ResponseJson.error("图片验证码错误");
|
|
|
}
|
|
|
- boolean sendFlag = false;
|
|
|
- // 生成六位验证码
|
|
|
- String randomCode = CodeUtil.generateCodeInt(6);
|
|
|
- // 根据手机号查询用户Id
|
|
|
- Integer userId = baseMapper.getUserIdByMobile(mobile);
|
|
|
- if ("1".equals(activateCodeType)) {
|
|
|
- if (null == userId || userId < 1) {
|
|
|
- return ResponseJson.error("该手机号尚未注册");
|
|
|
- }
|
|
|
- // 找回密码
|
|
|
- sendFlag = AliyunSmsUtil.sendSms(mobile, 1, "{code:" + randomCode + "}");
|
|
|
- } else {
|
|
|
- if (null != userId && userId > 0) {
|
|
|
- return ResponseJson.error("该手机号已被使用");
|
|
|
- }
|
|
|
- if ("2".equals(activateCodeType)) {
|
|
|
- // 机构用户(自主)注册
|
|
|
- sendFlag = AliyunSmsUtil.sendSms(mobile, 8, "{code:"+ randomCode +"}");
|
|
|
- } else if ("3".equals(activateCodeType)) {
|
|
|
- // 供应商(自主)注册
|
|
|
- sendFlag = AliyunSmsUtil.sendSms(mobile, 9, "{code:"+ randomCode +"}");
|
|
|
- } else {
|
|
|
- return ResponseJson.error("参数错误:activateCodeType");
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 验证手机号
|
|
|
+ ResponseJson mobileModel = ValidateUtil.validateMobile(mobile);
|
|
|
+ if (mobileModel.getCode() == -1) {
|
|
|
+ return mobileModel;
|
|
|
+ }
|
|
|
+ boolean sendFlag = false;
|
|
|
+ // 生成六位验证码
|
|
|
+ String randomCode = CodeUtil.generateCodeInt(6);
|
|
|
+ // 根据手机号查询用户Id
|
|
|
+ Integer userId = baseMapper.getUserIdByMobile(mobile);
|
|
|
+ if (1 == activateCodeType) {
|
|
|
+ if (null == userId || userId < 1) {
|
|
|
+ return ResponseJson.error("该手机号尚未注册");
|
|
|
+ }
|
|
|
+ // 找回密码
|
|
|
+ sendFlag = AliyunSmsUtil.sendSms(mobile, 1, "{code:" + randomCode + "}");
|
|
|
+ } else {
|
|
|
+ if (null != userId && userId > 0) {
|
|
|
+ return ResponseJson.error("该手机号已被使用");
|
|
|
}
|
|
|
- if (sendFlag) {
|
|
|
- redisService.set("code:"+mobile, randomCode, 1800L);
|
|
|
- log.info("发送到:" + mobile + "的短信验证码为: " + randomCode);
|
|
|
+ if (2 == activateCodeType) {
|
|
|
+ // 机构用户(自主)注册
|
|
|
+ sendFlag = AliyunSmsUtil.sendSms(mobile, 8, "{code:"+ randomCode +"}");
|
|
|
+ } else if (3 == activateCodeType) {
|
|
|
+ // 供应商(自主)注册
|
|
|
+ sendFlag = AliyunSmsUtil.sendSms(mobile, 9, "{code:"+ randomCode +"}");
|
|
|
} else {
|
|
|
- return ResponseJson.error("验证码发送失败!请稍后重试");
|
|
|
+ return ResponseJson.error("参数错误:activateCodeType");
|
|
|
}
|
|
|
}
|
|
|
+ if (sendFlag) {
|
|
|
+ redisService.set("code:"+mobile, randomCode, 1800L);
|
|
|
+ String codeType = activateCodeType == 1 ? "找回密码" : (activateCodeType == 2 ? "注册机构" : "注册供应商");
|
|
|
+ log.info(codeType + ",发送到:" + mobile + "的短信验证码为: " + randomCode);
|
|
|
+ } else {
|
|
|
+ return ResponseJson.error("验证码发送失败!请稍后重试");
|
|
|
+ }
|
|
|
return ResponseJson.success("发送验证码成功");
|
|
|
}
|
|
|
}
|