店铺修改操作密码校验验证码

This commit is contained in:
张松 2025-03-05 15:42:09 +08:00
parent 6de7f4e044
commit fb9346cd5d
3 changed files with 50 additions and 1 deletions

View File

@ -1,16 +1,20 @@
package com.czg.controller.admin;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.shopuser.ShopUserAddDTO;
import com.czg.account.dto.shopuser.ShopUserEditDTO;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
import com.czg.account.dto.shopuser.ShopUserSummaryDTO;
import com.czg.account.entity.ShopUser;
import com.czg.account.entity.ShopUserFlow;
import com.czg.account.service.ShopUserFlowService;
import com.czg.account.service.ShopUserService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
@ -28,6 +32,8 @@ public class ShopUserController {
@Resource
private ShopUserService shopUserService;
@Resource
private ShopUserFlowService shopUserFlowService;
/**
* 获取店铺用户概述信息
@ -41,6 +47,32 @@ public class ShopUserController {
return CzgResult.success(shopUserService.getSummary(StpKit.USER.getShopId(), isVip));
}
/**
* 获取店铺用户充值记录
* @param userId 用户id
* @param bizCode 充值类型 类型
* cashIn 现金充值
* wechatIn 微信小程序充值
* alipayIn 支付宝小程序充值
* awardIn 充值奖励
* rechargeRefund 充值退款
* orderPay 订单消费
* orderRefund 订单退款
* adminIn 管理员充值
* adminOut管理员消费
* @return 充值记录
*/
@SaAdminCheckPermission("shopUser:flow")
@GetMapping("/flow")
public CzgResult<Page<ShopUserFlow>> flow(@RequestParam Integer userId, String bizCode) {
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopUserFlow::getShopId, StpKit.USER.getShopId())
.eq(ShopUserFlow::getUserId, userId);
if (StrUtil.isNotBlank(bizCode)) {
queryWrapper.eq(ShopUserFlow::getBizCode, bizCode);
}
return CzgResult.success(shopUserFlowService.page(PageUtil.buildPage(), queryWrapper));
}
/**
* 获取店铺用户列表
*

View File

@ -13,6 +13,8 @@ public class ShopInfoEditDTO {
@NotNull(message = "id不为空")
private Integer id;
private String code;
/**
* 就餐模式 json形式['dine-in', 'take-out]
*/
@ -81,7 +83,7 @@ public class ShopInfoEditDTO {
/**
* 操作密码
*/
private Integer operationPwd;
private String operationPwd;
/**
* 主店id
*/

View File

@ -3,14 +3,17 @@ package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.czg.account.dto.PageDTO;
import com.czg.account.dto.shopinfo.*;
import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.config.RedisCst;
import com.czg.enums.StatusEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException;
import com.czg.sa.StpKit;
import com.czg.service.RedisService;
import com.czg.service.account.mapper.ShopInfoMapper;
import com.czg.utils.AssertUtil;
import com.czg.utils.GeoUtil;
@ -48,6 +51,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
private ShopUserService shopUserService;
@Resource
private ShopExtendService shopExtendService;
@Resource
private RedisService redisService;
@Override
@Cacheable(key = "#id")
@ -140,6 +145,16 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
if (shopInfoEditDTO.getActivateCode() != null) {
activateShop(shopInfo, shopInfoEditDTO.getActivateCode());
}
if (shopInfoEditDTO.getOperationPwd() != null) {
String key = "%s%s:%s".formatted(RedisCst.SMS_CODE, shopInfo.getPhone(), "editShopInfoOpePwd");
Object val = redisService.get(key);
if (val instanceof String code && !shopInfoEditDTO.getCode().equals(code)) {
throw new ApiNotPrintException("验证码错误");
}
shopInfo.setOperationPwd(SecureUtil.md5(shopInfo.getId() + shopInfoEditDTO.getOperationPwd()));
}
return updateById(shopInfo);
}