|
|
@@ -54,21 +54,6 @@ public class WxUserGrantController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private WxMsgValidationcodeService wxMsgValidationcodeService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private boolean isFmOpen; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CUserServiceFactory cuserFactory; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MallCooUserInfoService mallCooUserInfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCUserCarService wxCUserCarService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxScoreRulesService wxScoreRulesService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxLevelConfigService wxLevelConfigService; |
|
|
|
|
|
|
@@ -162,7 +147,7 @@ public class WxUserGrantController extends BaseController { |
|
|
|
return new ResultData(ErrorCode.USER_IS_EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
String encryptPassword = PasswordHelper.encryptPassword(phone, password); |
|
|
|
String encryptPassword = new PasswordHelper().encryptPassword(phone, password); |
|
|
|
|
|
|
|
if(!encryptPassword.equals(basicInfo.getPassword())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "手机号或密码错误"); |
|
|
@@ -181,6 +166,48 @@ public class WxUserGrantController extends BaseController { |
|
|
|
@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true)}) |
|
|
|
public ResultData sendLoginPhoneCode(String phone) { |
|
|
|
logger.debug("[" + getIpAddr() + "] WxUserGrantController::sendlogincode"); |
|
|
|
if(StringUtils.isBlank(phone)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "请输入手机号"); |
|
|
|
} |
|
|
|
|
|
|
|
WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); |
|
|
|
wxMsgValidationcode.setPhone(phone); |
|
|
|
wxMsgValidationcode.setType(EnumMsgModel.VALIDATION_CODE.getCode()); |
|
|
|
return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 需要效验用户及图片验证码 |
|
|
|
* @param phone |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@AuthIgnore |
|
|
|
@ApiOperation("发送修改密码验证码") |
|
|
|
@GetMapping("sendPhoneCode") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true)}) |
|
|
|
public ResultData sendPhoneCode(String phone,String code) { |
|
|
|
String ipAddr = getIpAddr(); |
|
|
|
logger.debug("[" + ipAddr + "] WxUserGrantController::sendPhoneCode"); |
|
|
|
if(StringUtils.isBlank(phone)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "请输入手机号"); |
|
|
|
} |
|
|
|
if(StringUtils.isBlank(code)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "请输入验证码"); |
|
|
|
} |
|
|
|
|
|
|
|
String key = Constant.captchaPrev + ":" + ipAddr; |
|
|
|
String code1 = RedisCacheUtils.getCacheString(redisTemplate, key); |
|
|
|
if(StringUtils.isBlank(code1)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); |
|
|
|
} |
|
|
|
if(!code1.equals(code)){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); |
|
|
|
} |
|
|
|
WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); |
|
|
|
if(basicInfo == null){ |
|
|
|
return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"该手机号未注册"); |
|
|
|
} |
|
|
|
|
|
|
|
WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); |
|
|
|
wxMsgValidationcode.setPhone(phone); |
|
|
@@ -215,7 +242,7 @@ public class WxUserGrantController extends BaseController { |
|
|
|
if(isValidCode) { |
|
|
|
WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); |
|
|
|
if(basicInfo == null){ |
|
|
|
basicInfo = wxCUserBasicInfoService.registerByPhone(getTenantInfo(),phone,null,null,null,null); |
|
|
|
basicInfo = wxCUserBasicInfoService.register(getTenantInfo(),phone,null); |
|
|
|
} |
|
|
|
wxCUserBasicInfoService.handleLoginUser(basicInfo); |
|
|
|
Map resultMap = new HashMap(); |
|
|
@@ -227,6 +254,47 @@ public class WxUserGrantController extends BaseController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@AuthIgnore |
|
|
|
@ApiOperation(value = "手机号注册", notes = "{\"phone\",\"string\",\"code\",\"string\"}") |
|
|
|
@PostMapping("/doRegisterByPhone") |
|
|
|
public ResultData doRegisterByPhone(@RequestBody Map<String, String> params, HttpServletResponse response) { |
|
|
|
String ipaddress = getIpAddr(); |
|
|
|
logger.debug("[" + ipaddress + "] WxUserGrantController::doRegisterByPhone"); |
|
|
|
// String phone,String code,String pwd |
|
|
|
String phone = params.get("phone"); |
|
|
|
String password = params.get("password"); |
|
|
|
String code = params.get("code"); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(phone)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "手机号不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(password)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); |
|
|
|
} |
|
|
|
// if (StringUtils.isBlank(code)) { |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "验证码不能为空"); |
|
|
|
// } |
|
|
|
WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); |
|
|
|
if(basicInfo != null){ |
|
|
|
return new ResultData(ErrorCode.USER_PHONE_IS_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// check 验证码正确 |
|
|
|
// boolean isValidCode = false; |
|
|
|
// try { |
|
|
|
// isValidCode = wxMsgValidationcodeService.checkCodeValid(phone,code); |
|
|
|
// } catch (Exception e) { |
|
|
|
// return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
// } |
|
|
|
// if(isValidCode) { |
|
|
|
basicInfo = wxCUserBasicInfoService.register(getTenantInfo(),phone,password); |
|
|
|
return new ResultData(); |
|
|
|
// } else { |
|
|
|
// return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND); |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
@AuthIgnore |
|
|
|
@ApiOperation(value = "手机验证码修改密码", notes = "{\"phone\",\"string\",\"code\",\"string\"}") |
|
|
|
@PostMapping("/updPass") |
|
|
@@ -247,6 +315,10 @@ public class WxUserGrantController extends BaseController { |
|
|
|
if (StringUtils.isBlank(pwd)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); |
|
|
|
} |
|
|
|
WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); |
|
|
|
if(basicInfo == null){ |
|
|
|
return new ResultData(ErrorCode.USER_PHONE_IS_NOT_FOUND.getCode(), "手机号还未注册"); |
|
|
|
} |
|
|
|
|
|
|
|
// check 验证码正确 |
|
|
|
boolean isValidCode = false; |
|
|
@@ -256,11 +328,7 @@ public class WxUserGrantController extends BaseController { |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
if(isValidCode) { |
|
|
|
WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); |
|
|
|
if(basicInfo == null){ |
|
|
|
basicInfo = wxCUserBasicInfoService.registerByPhone(getTenantInfo(),phone,null,null,null,null); |
|
|
|
} |
|
|
|
String encryptPassword = PasswordHelper.encryptPassword(phone, pwd); |
|
|
|
String encryptPassword = new PasswordHelper().encryptPassword(phone, pwd); |
|
|
|
WxCUserBasicInfo basicInfoUpd = new WxCUserBasicInfo(); |
|
|
|
basicInfoUpd.setId(basicInfo.getId()); |
|
|
|
basicInfoUpd.setPassword(encryptPassword); |
|
|
|