操作密码

This commit is contained in:
wangw 2025-03-19 14:43:04 +08:00
parent dd945d7d0b
commit 5cb5e4f439
7 changed files with 40 additions and 8 deletions

View File

@ -75,7 +75,7 @@ public class SysController {
@SaAdminCheckRole("admin") @SaAdminCheckRole("admin")
@PutMapping("/pwd") @PutMapping("/pwd")
public CzgResult<Boolean> editPwd(@RequestBody @Validated SysUserEditPwdDTO sysUserEditPwdDTO) { public CzgResult<Boolean> editPwd(@RequestBody @Validated SysUserEditPwdDTO sysUserEditPwdDTO) {
return CzgResult.success(sysUserService.editPwd(StpKit.USER.getLoginIdAsLong(), sysUserEditPwdDTO)); return CzgResult.success(sysUserService.editPwd(sysUserEditPwdDTO));
} }
/** /**

View File

@ -15,13 +15,12 @@ public class SysUserEditPwdDTO {
/** /**
* ID * ID
*/ */
@NotNull(message = "ID不能为空")
private Long id; private Long id;
/** /**
* 原密码 * 原密码
*/ */
@NotBlank(message = "原密码不为空") // @NotBlank(message = "原密码不为空")
private String originalPassword; private String originalPassword;
/** /**

View File

@ -37,6 +37,6 @@ public interface SysUserService extends IService<SysUser> {
SysUserDetailVO detail(Integer id); SysUserDetailVO detail(Integer id);
Boolean editPwd(long sysUserId, SysUserEditPwdDTO sysUserEditPwdDTO); Boolean editPwd(SysUserEditPwdDTO sysUserEditPwdDTO);
} }

View File

@ -51,6 +51,8 @@ public class OrderInfoRefundDTO implements Serializable {
private String refundReason; private String refundReason;
private String pwd;
/** /**
* 退单明细 * 退单明细
* id: orderDetailId * id: orderDetailId

View File

@ -41,7 +41,7 @@ import static com.mybatisflex.core.query.QueryMethods.column;
* @since 2025-02-08 * @since 2025-02-08
*/ */
@Service @Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService { public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
@Resource @Resource
private SysRoleMapper sysRoleMapper; private SysRoleMapper sysRoleMapper;
@ -206,9 +206,24 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
} }
@Override @Override
public Boolean editPwd(long sysUserId, SysUserEditPwdDTO sysUserEditPwdDTO) { public Boolean editPwd(SysUserEditPwdDTO sysUserEditPwdDTO) {
SysUser sysUser = getById(sysUserId); SysUser sysUser;
if (!sysUserEditPwdDTO.getPassword().equals(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getOriginalPassword()))) { if (sysUserEditPwdDTO.getId() == null) {
sysUserEditPwdDTO.setId(StpKit.USER.getLoginIdAsLong());
sysUser = getById(sysUserEditPwdDTO.getId());
} else {
sysUser = getById(sysUserEditPwdDTO.getId());
if (sysUser.getAccount().contains("@")) {
if (!sysUser.getAccount().split("@")[0].equals(StpKit.USER.getShopId().toString())) {
throw new CzgException("修改失败");
}
} else {
throw new CzgException("修改失败");
}
}
if (StrUtil.isNotBlank(sysUserEditPwdDTO.getOriginalPassword()) &&
!sysUserEditPwdDTO.getPassword().equals(SecureUtil.md5(sysUser.getId() + sysUserEditPwdDTO.getOriginalPassword()))) {
throw new ApiNotPrintException("原密码不正确"); throw new ApiNotPrintException("原密码不正确");
} }

View File

@ -45,4 +45,5 @@ public class VipRefundDTO implements Serializable {
private String platformType; private String platformType;
private String pwd;
} }

View File

@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.exceptions.ValidateException; import cn.hutool.core.exceptions.ValidateException;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO; import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
@ -466,6 +467,13 @@ public class PayServiceImpl implements PayService {
@Override @Override
public CzgResult<Object> refundVip(VipRefundDTO refPayParam) { public CzgResult<Object> refundVip(VipRefundDTO refPayParam) {
ShopInfo shopInfo = shopInfoService.getById(refPayParam.getShopId());
if (shopInfo.getIsReturnPwd().equals(1)) {
AssertUtil.isBlank(shopInfo.getOperationPwd(), "请设置操作密码后使用");
if (!SecureUtil.md5(refPayParam.getPwd()).equals(shopInfo.getOperationPwd())) {
throw new CzgException("操作密码错误");
}
}
ShopUser shopUser = shopUserService.getShopUserInfo(refPayParam.getShopId(), refPayParam.getUserId()); ShopUser shopUser = shopUserService.getShopUserInfo(refPayParam.getShopId(), refPayParam.getUserId());
ShopUserFlow inFlow = userFlowService.getById(refPayParam.getFlowId()); ShopUserFlow inFlow = userFlowService.getById(refPayParam.getFlowId());
AssertUtil.isNull(inFlow, "充值记录不存在"); AssertUtil.isNull(inFlow, "充值记录不存在");
@ -549,6 +557,13 @@ public class PayServiceImpl implements PayService {
@Transactional @Transactional
public CzgResult<Object> refundOrderBefore(OrderInfoRefundDTO param) { public CzgResult<Object> refundOrderBefore(OrderInfoRefundDTO param) {
OrderInfo orderInfo = orderInfoService.getById(param.getOrderId()); OrderInfo orderInfo = orderInfoService.getById(param.getOrderId());
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
if (shopInfo.getIsReturnPwd().equals(1)) {
AssertUtil.isBlank(shopInfo.getOperationPwd(), "请设置操作密码后使用");
if (!SecureUtil.md5(param.getPwd()).equals(shopInfo.getOperationPwd())) {
throw new CzgException("操作密码错误");
}
}
Map<String, BigDecimal> returnProMap = new HashMap<>(); Map<String, BigDecimal> returnProMap = new HashMap<>();
boolean isPay = true; boolean isPay = true;
String refPayOrderNo = "REFO" + IdUtil.getSnowflakeNextId(); String refPayOrderNo = "REFO" + IdUtil.getSnowflakeNextId();