设置用户支付密码

dev
袁野 3 months ago
parent 11e4895431
commit 2a9ce16753
  1. 28
      service/src/main/java/com/hfkj/service/hlt/HuiLianTongUnionCardService.java
  2. 31
      service/src/main/java/com/hfkj/service/user/BsUserPayPasswordService.java
  3. 47
      service/src/main/java/com/hfkj/service/user/impl/BsUserPayPasswordServiceImpl.java
  4. 2
      user/src/main/java/com/user/controller/BsUserController.java
  5. 148
      user/src/main/java/com/user/controller/BsUserPayPasswordController.java

@ -244,6 +244,34 @@ public class HuiLianTongUnionCardService {
return returnObject;
}
/**
* @MethodName portionRefund
* @Description: 部分退款
* @param refundOrderNo
* @param origOrderNo
* @param refundAmount
* @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream
* @Date: 2025/2/27 下午4:19
*/
public static JSONObject portionRefund(String refundOrderNo, String origOrderNo , BigDecimal refundAmount) throws Exception {
Map<String,Object> dataMap = new HashMap<>();
dataMap.put("orderNo", refundOrderNo);
dataMap.put("refundAmount", refundAmount);
dataMap.put("origOrderNo", origOrderNo);
dataMap.put("checkPassword", "N");
log.info("============请求任务Start=============");
log.info("汇联通退款-请求参数: " + JSON.toJSONString(dataMap));
JSONObject returnObject = request("qtk/refundV4", dataMap);
log.info("汇联通退款-响应参数: " + returnObject.toJSONString());
log.info("============请求任务End==============");
return returnObject;
}
/**
* 解析响应的参数
* @param param 参数

@ -0,0 +1,31 @@
package com.hfkj.service.user;
import com.hfkj.entity.BsUserPayPassword;
/**
* 用户支付密码
*/
public interface BsUserPayPasswordService {
/**
* 用户密码编辑
* @param bsUserPayPassword
*/
void editUserPayPwd(BsUserPayPassword bsUserPayPassword);
/**
* 根据用户查询密码
* @param userId
* @return
*/
BsUserPayPassword getDetailByUser(Long userId);
/**
* 查询用户是否设置支付密码
* @param userId
* @return
*/
Boolean isSetPayPwd(Long userId);
}

@ -0,0 +1,47 @@
package com.hfkj.service.user.impl;
import com.hfkj.dao.BsUserPayPasswordMapper;
import com.hfkj.entity.BsUserPayPassword;
import com.hfkj.entity.BsUserPayPasswordExample;
import com.hfkj.service.user.BsUserPayPasswordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service("bsUserPayPasswordService")
public class BsUserPayPasswordServiceImpl implements BsUserPayPasswordService {
@Resource
private BsUserPayPasswordMapper bsUserPayPasswordMapper;
@Override
public void editUserPayPwd(BsUserPayPassword bsUserPayPassword) {
if (bsUserPayPassword.getId() != null) {
bsUserPayPassword.setUpdateTime(new Date());
bsUserPayPasswordMapper.updateByPrimaryKey(bsUserPayPassword);
} else {
bsUserPayPassword.setCreateTime(new Date());
bsUserPayPassword.setUpdateTime(new Date());
bsUserPayPasswordMapper.insert(bsUserPayPassword);
}
}
@Override
public BsUserPayPassword getDetailByUser(Long userId) {
BsUserPayPasswordExample example = new BsUserPayPasswordExample();
example.createCriteria().andUserIdEqualTo(userId);
List<BsUserPayPassword> list = bsUserPayPasswordMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public Boolean isSetPayPwd(Long userId) {
BsUserPayPassword data = getDetailByUser(userId);
return data != null;
}
}

@ -227,7 +227,7 @@ public class BsUserController {
try {
Map<String, Object> other = new HashMap<>();
return ResponseMsgUtil.success(userService.login(UserLoginPlatform.H5, UserLoginType.SMS, "13985476824", "123456", other));
return ResponseMsgUtil.success(userService.login(UserLoginPlatform.H5, UserLoginType.SMS, "18090580471", "123456", other));
} catch (Exception e) {
log.error("LoginController --> phone() error!", e);

@ -0,0 +1,148 @@
package com.user.controller;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.AESEncodeUtil;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.RedisUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsUser;
import com.hfkj.entity.BsUserPayPassword;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.user.BsUserPayPasswordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
@Controller
@RequestMapping(value="/userPayPwd")
@Api(value="客户端")
public class BsUserPayPasswordController {
Logger log = LoggerFactory.getLogger(BsUserPayPasswordController.class);
@Resource
private BsUserPayPasswordService userPayPasswordService;
@Resource
private UserCenter userCenter;
@Resource
private RedisUtil redisUtil;
@RequestMapping(value = "/setUserPayPwd", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "设置用户支付密码")
public ResponseData setUserPayPwd(@RequestBody JSONObject body) {
try {
// 用户
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
BsUser bsUser = userSession.getUser();
if (StringUtils.isBlank(body.getString("password"))
|| body.getString("password").length() != 6){
log.error("HighUserController --> setUserPayPwd() error!", "请设置6位支付密码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置6位支付密码");
}
// 查询用户密码
BsUserPayPassword userPayPassword = userPayPasswordService.getDetailByUser(bsUser.getId());
if (userPayPassword != null) {
log.error("HighUserController --> setUserPayPwd() error!", "您已设置了支付密码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "您已设置了支付密码!");
}
userPayPassword = new BsUserPayPassword();
userPayPassword.setUserId(bsUser.getId());
userPayPassword.setPassword(AESEncodeUtil.aesEncrypt(body.getString("password")));
userPayPasswordService.editUserPayPwd(userPayPassword);
// 定义个人所有数据
return ResponseMsgUtil.success("设置成功");
} catch (Exception e) {
log.error("HighUserController --> setUserPayPwd() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/updateUserPayPwd", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改用户支付密码")
public ResponseData updateUserPayPwd(@RequestBody JSONObject body) {
try {
// 用户
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
BsUser bsUser = userSession.getUser();
if ( StringUtils.isBlank(body.getString("newPassword")) || StringUtils.isBlank(body.getString("code"))) {
log.error("HighUserController --> setUserPayPwd() error!", "");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
if (bsUser.getPhone() == null) {
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "请先绑定手机号");
}
// 查询用户密码
BsUserPayPassword userPayPassword = userPayPasswordService.getDetailByUser(bsUser.getId());
if (userPayPassword == null) {
log.error("HighUserController --> setUserPayPwd() error!", "修改失败,未设置支付密码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "修改失败,未设置支付密码");
}
if (StringUtils.isBlank(body.getString("smsCode"))) {
log.error("LoginController --> phone() error!", "请输入短信验证码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码");
}
// 手机号的验证码
Object phoneCodeObject = redisUtil.get("SMS_CODE:" + bsUser.getPhone());
if (phoneCodeObject == null) {
log.error("LoginController --> phone() error!", "短信验证码错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误");
}
if (!body.getString("smsCode").equals(phoneCodeObject.toString())) {
log.error("LoginController --> phone() error!", "短信验证码错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误");
}
redisUtil.del("SMS_CODE:" + bsUser.getPhone());
userPayPassword.setPassword(AESEncodeUtil.aesEncrypt(body.getString("newPassword")));
userPayPasswordService.editUserPayPwd(userPayPassword);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighUserController --> updateUserPayPwd() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/isSetPayPwd", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "用户是否设置支付密码")
public ResponseData isSetPayPwd() {
try {
// 用户
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
BsUser bsUser = userSession.getUser();
return ResponseMsgUtil.success(userPayPasswordService.isSetPayPwd(bsUser.getId()));
} catch (Exception e) {
log.error("HighUserController --> setUserPayPwd() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}
Loading…
Cancel
Save