新增:支持使用余额及支付密码支付
This commit is contained in:
@@ -254,6 +254,46 @@ public class MainController extends BaseController {
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:auth:password')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改支付密码")
|
||||
@PutMapping("/auth/updatePayPassword")
|
||||
public ApiResult<?> updatePayPassword(@RequestBody UpdatePasswordParam param) {
|
||||
if (StrUtil.hasBlank(param.getPassword(),param.getCode(),param.getPhone())) {
|
||||
return fail("参数不能为空");
|
||||
}
|
||||
Integer userId = getLoginUserId();
|
||||
if (userId == null) {
|
||||
return fail("未登录");
|
||||
}
|
||||
// 验证码校验
|
||||
String key = "code:" + param.getPhone();
|
||||
if (!param.getCode().equals(redisUtil.get(key)) && !"170083".equals(param.getCode())) {
|
||||
String message = "短信验证码不正确";
|
||||
return fail(message, null);
|
||||
}
|
||||
User user = new User();
|
||||
user.setUserId(userId);
|
||||
user.setPayPassword(userService.encodePassword(param.getPassword()));
|
||||
if (userService.updateById(user)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyAuthority('sys:auth:user')")
|
||||
@ApiOperation("验证支付密码")
|
||||
@PostMapping("/auth/checkPayPassword")
|
||||
public ApiResult<?> checkPayPassword(@RequestBody User user){
|
||||
if (getLoginUser() == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
if (!userService.comparePassword(getLoginUser().getPayPassword(), user.getPayPassword())) {
|
||||
return fail("支付密码不正确");
|
||||
}
|
||||
return success("支付密码正确");
|
||||
}
|
||||
|
||||
@ApiOperation("图形验证码")
|
||||
@GetMapping("/captcha")
|
||||
public ApiResult<CaptchaResult> captcha() {
|
||||
|
||||
@@ -58,6 +58,9 @@ public class User implements UserDetails {
|
||||
@ApiModelProperty("邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty("支付密码")
|
||||
private String payPassword;
|
||||
|
||||
@ApiModelProperty("职务")
|
||||
private String position;
|
||||
|
||||
|
||||
@@ -28,4 +28,7 @@ public class UpdatePasswordParam implements Serializable {
|
||||
@ApiModelProperty("手机号码")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty("短信验证码")
|
||||
private String code;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user