mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-30 03:01:53 +08:00
会员:修改Review的代码
This commit is contained in:
parent
2895ae3ddb
commit
9aee08ee0e
@ -1,8 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.member.enums;
|
package cn.iocoder.yudao.module.member.enums;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.EnumUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员经验 - 业务类型
|
* 会员经验 - 业务类型
|
||||||
*
|
*
|
||||||
@ -15,16 +18,20 @@ public enum MemberExperienceBizTypeEnum {
|
|||||||
/**
|
/**
|
||||||
* 管理员调整、邀请新用户、下单、退单、签到、抽奖
|
* 管理员调整、邀请新用户、下单、退单、签到、抽奖
|
||||||
*/
|
*/
|
||||||
ADMIN(0, "管理员调整","管理员调整获得 {} 经验"),
|
ADMIN(0, "管理员调整", "管理员调整获得 {} 经验"),
|
||||||
INVITE_REGISTER(1, "邀新奖励","邀请好友获得 {} 经验"),
|
INVITE_REGISTER(1, "邀新奖励", "邀请好友获得 {} 经验"),
|
||||||
ORDER(2, "下单奖励", "下单获得 {} 经验"),
|
ORDER(2, "下单奖励", "下单获得 {} 经验"),
|
||||||
REFUND(3, "退单扣除","退单获得 {} 经验"),
|
REFUND(3, "退单扣除", "退单获得 {} 经验"),
|
||||||
SIGN_IN(4, "签到奖励","签到获得 {} 经验"),
|
SIGN_IN(4, "签到奖励", "签到获得 {} 经验"),
|
||||||
LOTTERY(5, "抽奖奖励","抽奖获得 {} 经验"),
|
LOTTERY(5, "抽奖奖励", "抽奖获得 {} 经验"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final int type;
|
private final int type;
|
||||||
private final String title;
|
private final String title;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
|
public static MemberExperienceBizTypeEnum getByType(Integer type) {
|
||||||
|
return EnumUtil.getBy(MemberExperienceBizTypeEnum.class,
|
||||||
|
e -> Objects.equals(type, e.getType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.member.api.level;
|
package cn.iocoder.yudao.module.member.api.level;
|
||||||
|
|
||||||
import cn.hutool.core.util.EnumUtil;
|
|
||||||
import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum;
|
import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.service.level.MemberLevelService;
|
import cn.iocoder.yudao.module.member.service.level.MemberLevelService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE_BIZ_NOT_SUPPORT;
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE_BIZ_NOT_SUPPORT;
|
||||||
@ -26,9 +24,7 @@ public class MemberLevelApiImpl implements MemberLevelApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addExperience(Long userId, Integer experience, Integer bizType, String bizId) {
|
public void addExperience(Long userId, Integer experience, Integer bizType, String bizId) {
|
||||||
// TODO @疯狂:可以在 MemberExperienceBizTypeEnum 增加一个方法,获得哈。
|
MemberExperienceBizTypeEnum bizTypeEnum = MemberExperienceBizTypeEnum.getByType(bizType);
|
||||||
MemberExperienceBizTypeEnum bizTypeEnum = EnumUtil.getBy(MemberExperienceBizTypeEnum.class,
|
|
||||||
e -> Objects.equals(bizType, e.getType()));
|
|
||||||
if (bizTypeEnum == null) {
|
if (bizTypeEnum == null) {
|
||||||
throw exception(EXPERIENCE_BIZ_NOT_SUPPORT);
|
throw exception(EXPERIENCE_BIZ_NOT_SUPPORT);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.member.controller.admin.group.vo.MemberGroupUpdat
|
|||||||
import cn.iocoder.yudao.module.member.convert.group.MemberGroupConvert;
|
import cn.iocoder.yudao.module.member.convert.group.MemberGroupConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.group.MemberGroupDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.group.MemberGroupMapper;
|
import cn.iocoder.yudao.module.member.dal.mysql.group.MemberGroupMapper;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
|||||||
@Resource
|
@Resource
|
||||||
private MemberGroupMapper groupMapper;
|
private MemberGroupMapper groupMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private MemberUserMapper memberUserMapper;
|
private MemberUserService memberUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createGroup(MemberGroupCreateReqVO createReqVO) {
|
public Long createGroup(MemberGroupCreateReqVO createReqVO) {
|
||||||
@ -69,9 +69,8 @@ public class MemberGroupServiceImpl implements MemberGroupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @疯狂:不要直接调用 memberUserMapper,需要对方 service 提供方法
|
|
||||||
void validateGroupHasUser(Long id) {
|
void validateGroupHasUser(Long id) {
|
||||||
Long count = memberUserMapper.selectCountByGroupId(id);
|
Long count = memberUserService.getUserCountByGroupId(id);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
throw exception(GROUP_HAS_USER);
|
throw exception(GROUP_HAS_USER);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
|
|||||||
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelRecordDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper;
|
import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
|
||||||
import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum;
|
import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -49,8 +48,6 @@ public class MemberLevelServiceImpl implements MemberLevelService {
|
|||||||
@Resource
|
@Resource
|
||||||
private MemberExperienceRecordService memberExperienceRecordService;
|
private MemberExperienceRecordService memberExperienceRecordService;
|
||||||
@Resource
|
@Resource
|
||||||
private MemberUserMapper memberUserMapper;
|
|
||||||
@Resource
|
|
||||||
private MemberUserService memberUserService;
|
private MemberUserService memberUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -157,7 +154,7 @@ public class MemberLevelServiceImpl implements MemberLevelService {
|
|||||||
// TODO 有 Service 提供接口哈,不直接调用对方的 memberUserMapper
|
// TODO 有 Service 提供接口哈,不直接调用对方的 memberUserMapper
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateLevelHasUser(Long id) {
|
void validateLevelHasUser(Long id) {
|
||||||
Long count = memberUserMapper.selectCountByLevelId(id);
|
Long count = memberUserService.getUserCountByLevelId(id);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
throw exception(LEVEL_HAS_USER);
|
throw exception(LEVEL_HAS_USER);
|
||||||
}
|
}
|
||||||
@ -239,7 +236,7 @@ public class MemberLevelServiceImpl implements MemberLevelService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemberUserDO user = memberUserMapper.selectById(userId);
|
MemberUserDO user = memberUserService.getUser(userId);
|
||||||
|
|
||||||
int userExperience = NumberUtil.max(user.getExperience() + experience, 0);
|
int userExperience = NumberUtil.max(user.getExperience() + experience, 0);
|
||||||
MemberLevelRecordDO levelRecord = new MemberLevelRecordDO()
|
MemberLevelRecordDO levelRecord = new MemberLevelRecordDO()
|
||||||
|
@ -10,7 +10,7 @@ import cn.iocoder.yudao.module.member.controller.admin.tag.vo.MemberTagUpdateReq
|
|||||||
import cn.iocoder.yudao.module.member.convert.tag.MemberTagConvert;
|
import cn.iocoder.yudao.module.member.convert.tag.MemberTagConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.tag.MemberTagMapper;
|
import cn.iocoder.yudao.module.member.dal.mysql.tag.MemberTagMapper;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public class MemberTagServiceImpl implements MemberTagService {
|
|||||||
@Resource
|
@Resource
|
||||||
private MemberTagMapper tagMapper;
|
private MemberTagMapper tagMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private MemberUserMapper memberUserMapper;
|
private MemberUserService memberUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createTag(MemberTagCreateReqVO createReqVO) {
|
public Long createTag(MemberTagCreateReqVO createReqVO) {
|
||||||
@ -92,7 +92,7 @@ public class MemberTagServiceImpl implements MemberTagService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void validateTagHasUser(Long id) {
|
void validateTagHasUser(Long id) {
|
||||||
Long count = memberUserMapper.selectCountByTagId(id);
|
Long count = memberUserService.getUserCountByTagId(id);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
throw exception(TAG_HAS_USER);
|
throw exception(TAG_HAS_USER);
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import cn.iocoder.yudao.framework.common.validation.Mobile;
|
|||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserResetPasswordReqVO;
|
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserResetPasswordReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdateMobileReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdatePasswordReqVO;
|
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdatePasswordReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdateReqVO;
|
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppMemberUserUpdateMobileReqVO;
|
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -41,7 +41,7 @@ public interface MemberUserService {
|
|||||||
* 基于手机号创建用户。
|
* 基于手机号创建用户。
|
||||||
* 如果用户已经存在,则直接进行返回
|
* 如果用户已经存在,则直接进行返回
|
||||||
*
|
*
|
||||||
* @param mobile 手机号
|
* @param mobile 手机号
|
||||||
* @param registerIp 注册 IP
|
* @param registerIp 注册 IP
|
||||||
* @return 用户对象
|
* @return 用户对象
|
||||||
*/
|
*/
|
||||||
@ -50,7 +50,7 @@ public interface MemberUserService {
|
|||||||
/**
|
/**
|
||||||
* 更新用户的最后登陆信息
|
* 更新用户的最后登陆信息
|
||||||
*
|
*
|
||||||
* @param id 用户编号
|
* @param id 用户编号
|
||||||
* @param loginIp 登陆 IP
|
* @param loginIp 登陆 IP
|
||||||
*/
|
*/
|
||||||
void updateUserLogin(Long id, String loginIp);
|
void updateUserLogin(Long id, String loginIp);
|
||||||
@ -75,7 +75,7 @@ public interface MemberUserService {
|
|||||||
* 【会员】修改基本信息
|
* 【会员】修改基本信息
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param reqVO 基本信息
|
* @param reqVO 基本信息
|
||||||
*/
|
*/
|
||||||
void updateUser(Long userId, AppMemberUserUpdateReqVO reqVO);
|
void updateUser(Long userId, AppMemberUserUpdateReqVO reqVO);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ public interface MemberUserService {
|
|||||||
* 【会员】修改手机
|
* 【会员】修改手机
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param reqVO 请求信息
|
* @param reqVO 请求信息
|
||||||
*/
|
*/
|
||||||
void updateUserMobile(Long userId, AppMemberUserUpdateMobileReqVO reqVO);
|
void updateUserMobile(Long userId, AppMemberUserUpdateMobileReqVO reqVO);
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public interface MemberUserService {
|
|||||||
* 【会员】修改密码
|
* 【会员】修改密码
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param reqVO 请求信息
|
* @param reqVO 请求信息
|
||||||
*/
|
*/
|
||||||
void updateUserPassword(Long userId, AppMemberUserUpdatePasswordReqVO reqVO);
|
void updateUserPassword(Long userId, AppMemberUserUpdatePasswordReqVO reqVO);
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public interface MemberUserService {
|
|||||||
/**
|
/**
|
||||||
* 判断密码是否匹配
|
* 判断密码是否匹配
|
||||||
*
|
*
|
||||||
* @param rawPassword 未加密的密码
|
* @param rawPassword 未加密的密码
|
||||||
* @param encodedPassword 加密后的密码
|
* @param encodedPassword 加密后的密码
|
||||||
* @return 是否匹配
|
* @return 是否匹配
|
||||||
*/
|
*/
|
||||||
@ -135,4 +135,27 @@ public interface MemberUserService {
|
|||||||
*/
|
*/
|
||||||
void updateUserLevel(Long id, Long levelId, Integer experience);
|
void updateUserLevel(Long id, Long levelId, Integer experience);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定用户分组下的用户数量
|
||||||
|
*
|
||||||
|
* @param groupId 用户分组编号
|
||||||
|
* @return 用户数量
|
||||||
|
*/
|
||||||
|
Long getUserCountByGroupId(Long groupId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定用户等级下的用户数量
|
||||||
|
*
|
||||||
|
* @param levelId 用户等级编号
|
||||||
|
* @return 用户数量
|
||||||
|
*/
|
||||||
|
Long getUserCountByLevelId(Long levelId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定会员标签下的用户数量
|
||||||
|
*
|
||||||
|
* @param tagId 用户标签编号
|
||||||
|
* @return 用户数量
|
||||||
|
*/
|
||||||
|
Long getUserCountByTagId(Long tagId);
|
||||||
}
|
}
|
||||||
|
@ -239,4 +239,19 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getUserCountByGroupId(Long groupId) {
|
||||||
|
return memberUserMapper.selectCountByGroupId(groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getUserCountByLevelId(Long levelId) {
|
||||||
|
return memberUserMapper.selectCountByLevelId(levelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getUserCountByTagId(Long tagId) {
|
||||||
|
return memberUserMapper.selectCountByTagId(tagId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user