feat:管理端活动信息收集管理和家长参与代理商活动管理

This commit is contained in:
嘉多宝宝 2026-01-08 14:38:44 +08:00
parent c596fb3db8
commit 7792e17438
5 changed files with 89 additions and 28 deletions

View File

@ -17,6 +17,10 @@ public class AgentEmployeeSaveReq {
@NotNull(message = "员工名称不能为空")
private String employeeName;
@Schema(description = "员工密码")
@NotNull(message = "员工密码不能为空")
private String password;
@Schema(description = "员工职位")
private String position;

View File

@ -31,7 +31,7 @@ public class AdminParentAgentActivityService {
LambdaQueryWrapper<MpParentAgentActivityRelationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Objects.nonNull(query.getActivityId()), MpParentAgentActivityRelationEntity::getActivityId, query.getActivityId())
.eq(Objects.nonNull(query.getAgentId()), MpParentAgentActivityRelationEntity::getAgentId, query.getAgentId())
.eq(Objects.nonNull(query.getAgentId()), MpParentAgentActivityRelationEntity::getParentId, query.getAgentId())
.eq(Objects.nonNull(query.getParentId()), MpParentAgentActivityRelationEntity::getParentId, query.getParentId())
.like(Objects.nonNull(query.getActivityName()) && !query.getActivityName().isEmpty(), MpParentAgentActivityRelationEntity::getActivityName, query.getActivityName())
.like(Objects.nonNull(query.getAgentName()) && !query.getAgentName().isEmpty(), MpParentAgentActivityRelationEntity::getAgentName, query.getAgentName())
.eq(Objects.nonNull(query.getStatus()), MpParentAgentActivityRelationEntity::getStatus, query.getStatus())

View File

@ -6,16 +6,18 @@ import com.seer.teach.common.PageListBean;
import com.seer.teach.common.enums.ResultCodeEnum;
import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.common.utils.PageConverterUtils;
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
import com.seer.teach.mp.admin.service.IAdminAgentEmployeeRelationService;
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationQueryReq;
import com.seer.teach.mp.admin.controller.req.AgentEmployeeRelationReq;
import com.seer.teach.mp.admin.controller.req.AgentEmployeeSaveReq;
import com.seer.teach.mp.admin.controller.resp.AgentEmployeeRelationResp;
import com.seer.teach.mp.admin.convert.AdminAgentEmployeeRelationConvert;
import com.seer.teach.mp.admin.service.IAdminAgentEmployeeRelationService;
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
import com.seer.teach.mp.entity.MpAgentEntity;
import com.seer.teach.mp.service.IMpAgentEmployeeRelationService;
import com.seer.teach.mp.service.IMpAgentService;
import com.seer.teach.user.api.UserInfoServiceApi;
import com.seer.teach.user.api.dto.UserInfoDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -38,6 +40,8 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
private final IMpAgentService mpAgentService;
private final UserInfoServiceApi userInfoServiceApi;
@Override
public PageListBean<AgentEmployeeRelationResp> pageList(AgentEmployeeRelationQueryReq query) {
Page<MpAgentEmployeeRelationEntity> pageParm = new Page<>(query.getPageNo(), query.getPageSize());
@ -70,15 +74,29 @@ public class AdminAgentEmployeeRelationServiceImpl implements IAdminAgentEmploye
public List<AgentEmployeeRelationResp> getEmployeeRelationsByAgentId(Integer agentId) {
var relations = agentEmployeeRelationService.getEmployeeRelationsByAgentId(agentId);
return relations.stream()
.map(AdminAgentEmployeeRelationConvert.INSTANCE::convertToResp)
.toList();
.map(AdminAgentEmployeeRelationConvert.INSTANCE::convertToResp)
.toList();
}
@Override
public boolean save(AgentEmployeeSaveReq request) {
AssertUtils.isNull(request.getAgentName(), ResultCodeEnum.AGENT_EMPLOYEE_ALREADY_EXISTS);
MpAgentEmployeeRelationEntity relation = AdminAgentEmployeeRelationConvert.INSTANCE.convert(request);
MpAgentEmployeeRelationEntity one = agentEmployeeRelationService.lambdaQuery()
.eq(MpAgentEmployeeRelationEntity::getEmployeeName, request.getEmployeeName()).one();
AssertUtils.isNull(one, ResultCodeEnum.AGENT_EMPLOYEE_ALREADY_EXISTS);
UserInfoDTO userInfoDTO = new UserInfoDTO();
userInfoDTO.setUserName(request.getEmployeeName());
userInfoDTO.setPassword(request.getPassword());
userInfoServiceApi.saveAgentInfo(userInfoDTO);
Integer employeeUserId = userInfoServiceApi.getUserIdByUserName(request.getEmployeeName());
Integer agentId = mpAgentService.lambdaQuery().eq(MpAgentEntity::getAgentName, request.getAgentName()).one().getId();
MpAgentEmployeeRelationEntity entity = new MpAgentEmployeeRelationEntity();
entity.setAgentId(agentId);
entity.setEmployeeUserId(employeeUserId);
entity.setEmployeeName(request.getEmployeeName());
entity.setAgentName(request.getAgentName());
entity.setPosition(request.getPosition());
entity.setStatus(request.getStatus());
agentEmployeeRelationService.save(entity);
return true;
}
}

View File

@ -170,4 +170,10 @@ public interface UserInfoServiceApi {
@GetMapping("/checkUserInfo")
Integer checkUserInfo(@RequestParam("userId") Integer userId);
@GetMapping("/getUserIdByUserName")
Integer getUserIdByUserName(@RequestParam("userName") String userName);
@PostMapping("/save-agentInfo")
boolean saveAgentInfo(@RequestBody UserInfoDTO userInfoDTO);
}

View File

@ -61,6 +61,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
/**
* 根据用户ID获取用户信息
*
* @param id 用户ID
* @return 用户信息DTO对象
*/
@ -72,7 +73,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
log.info("userEntity:{}", userEntity);
UserExtendEntity userExtendEntity = userExtendService.getUserExtendByUserId(id);
log.info("userExtendEntity:{}", userExtendEntity);
return UserInfoConvert.INSTANCE.convertOne(userEntity,userExtendEntity);
return UserInfoConvert.INSTANCE.convertOne(userEntity, userExtendEntity);
}
@Override
@ -93,20 +94,21 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
}
@Override
public List<UserAuthDTO> getUserAuthListByUserIdsAndAppId(UserAuthQueryDTO userAuthQueryDTO){
public List<UserAuthDTO> getUserAuthListByUserIdsAndAppId(UserAuthQueryDTO userAuthQueryDTO) {
List<UserAuthEntity> userAuthList = userAuthService.getUserAuthListByUserIdsAndAppId(userAuthQueryDTO.getUserIds(), userAuthQueryDTO.getAppId());
return UserInfoConvert.INSTANCE.convertUserAuthList(userAuthList);
}
/**
* 根据OpenId获取用户信息
*
* @param openId 微信OpenId
* @return 用户信息DTO对象
*/
@Override
public UserInfoDTO getByOpenId(String openId) {
UserAuthEntity userAuthEntity = userAuthService.getOneByOpenId(openId);
if(Objects.isNull(userAuthEntity)){
if (Objects.isNull(userAuthEntity)) {
return null;
}
UserEntity userEntity = userService.getById(userAuthEntity.getUserId());
@ -115,13 +117,14 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
/**
* 获取用户权限信息
*
* @param userId 用户ID
* @return 用户权限DTO对象
*/
@Override
public UserPermissionDTO getUserPermission(Integer userId) {
UserEntity userEntity = userService.getById(userId);
if(Objects.isNull(userEntity)){
if (Objects.isNull(userEntity)) {
return new UserPermissionDTO();
}
List<AuthorityEntity> permissions = authorityService.getPermissionsByUserId(userId);
@ -130,7 +133,8 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
/**
* 为用户添加经验值
* @param userId 用户ID
*
* @param userId 用户ID
* @param experienceValue 要添加的经验值
*/
@Override
@ -140,11 +144,12 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
UserExtendEntity userExtend = userExtendService.extraPoints(userId, experienceValue);
Integer parentId = userInfoServiceApi.getParentIdByChildrenId(children.getId());
UserCoinAccountRespDTO userCoinAccount = coinAccountServiceApi.getUserCoinAccount(parentId);
pushUpdateChildrenInfoMessage(children,userExtend,device,userId,userCoinAccount);
pushUpdateChildrenInfoMessage(children, userExtend, device, userId, userCoinAccount);
}
/**
* 获取孩子信息
*
* @param userId 孩子用户ID
* @return 孩子信息DTO对象
*/
@ -168,6 +173,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
/**
* 获取孩子年级ID
*
* @param userId 孩子用户ID
* @return 年级ID
*/
@ -179,24 +185,25 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
/**
* 保存用户信息
*
* @param userInfoDTO 用户信息DTO对象
* @return 用户ID如果用户已存在则返回已存在的用户ID
*/
@Override
public Integer save(UserInfoDTO userInfoDTO) {
// 根据UnionId判断用户是否已存在
if(StringUtils.hasText(userInfoDTO.getUnionId())){
if (StringUtils.hasText(userInfoDTO.getUnionId())) {
UserAuthEntity userAuthEntity = userAuthService.getOneByUnionId(userInfoDTO.getUnionId());
if(Objects.nonNull(userAuthEntity)){
if (Objects.nonNull(userAuthEntity)) {
log.info("用户已存在,请勿重复添加");
return userAuthEntity.getId();
}
return save0(userInfoDTO);
}
// 根据OpenId判断用户是否已存在
if(StringUtils.hasText(userInfoDTO.getOpenId())){
if (StringUtils.hasText(userInfoDTO.getOpenId())) {
UserAuthEntity one = userAuthService.getOneByOpenId(userInfoDTO.getOpenId());
if(Objects.nonNull(one)){
if (Objects.nonNull(one)) {
log.info("用户已存在,请勿重复添加");
return one.getId();
}
@ -220,7 +227,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
@Override
public List<UserInfoDTO> listByMobile(String mobile) {
List<UserEntity> userList = userService.list(new LambdaQueryWrapper<UserEntity>()
.like(UserEntity::getMobile, mobile));
.like(UserEntity::getMobile, mobile));
return UserInfoConvert.INSTANCE.convertList(userList);
}
@ -233,6 +240,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
/**
* 根据用户ID列表获取用户信息
*
* @param userIds
* @return
*/
@ -244,6 +252,7 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
/**
* 根据用户ID获取用户信息
*
* @param userId
* @return
*/
@ -265,40 +274,64 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
@Override
public Integer checkUserInfo(Integer userId) {
UserExtendEntity byUserId = userExtendService.getByUserId(userId);
if (Objects.isNull(byUserId)){
if (Objects.isNull(byUserId)) {
return IsInfoEnum.NO_INFO.getCode();
}
return IsInfoEnum.HAS_INFO.getCode();
}
@Override
public Integer getUserIdByUserName(String userName) {
UserEntity userEntity = userService.getOne(new LambdaQueryWrapper<UserEntity>()
.eq(UserEntity::getUserName, userName));
if (Objects.nonNull(userEntity)) {
return userEntity.getId();
}
return null;
}
@Override
public boolean saveAgentInfo(UserInfoDTO userInfoDTO) {
UserEntity one = userService.getOne(new LambdaQueryWrapper<UserEntity>()
.eq(UserEntity::getUserName, userInfoDTO.getUserName()));
AssertUtils.isNull(one, ResultCodeEnum.USERNAME_IS_EXIST);
UserEntity user = new UserEntity();
user.setUserName(userInfoDTO.getUserName());
String password = CommonUtils.encryptPassword(userInfoDTO.getPassword());
user.setPassword(password);
return userService.save(user);
}
/**
* 推送更新孩子信息的MQ消息
* @param children 孩子用户实体对象
*
* @param children 孩子用户实体对象
* @param userExtendEntity 用户扩展信息实体对象
* @param device 设备信息
* @param userId 用户ID
* @param device 设备信息
* @param userId 用户ID
*/
public void pushUpdateChildrenInfoMessage(UserEntity children,UserExtendEntity userExtendEntity, String device, Integer userId,UserCoinAccountRespDTO userCoinAccount) {
public void pushUpdateChildrenInfoMessage(UserEntity children, UserExtendEntity userExtendEntity, String device, Integer userId, UserCoinAccountRespDTO userCoinAccount) {
// 获取年级和等级信息
GradeEntity grade = gradeService.getById(userExtendEntity.getGradeId());
LevelEntity level = levelService.getById(userExtendEntity.getLevelId());
MqUserInfoDTO userInfoDTO = UserInfoConvert.INSTANCE.toMqUserInfoDTO(children, userExtendEntity,grade,level,device);
MqUserInfoDTO userInfoDTO = UserInfoConvert.INSTANCE.toMqUserInfoDTO(children, userExtendEntity, grade, level, device);
userInfoDTO.setExperience(CommonUtils.calculatePercentage(userExtendEntity.getExperience(), level.getPoint()));
userInfoDTO.setCoinNumber(userCoinAccount.getAvailableBalance().intValue());
String userJson = JSONUtil.toJsonStr(userInfoDTO);
String topic = ImMqTopicEnum.USER_INFO.getTopic();
String tag = UserInfoTopiTagEnum.UPDATE_CHILDREN_INFO.getTag();
log.info("发送更新孩子[{}]MQ消息开始 Device: [{}],Topic:{}, Tag:{}",userId,device,topic,tag);
mqProducer.sendMsg(topic, tag,device, userJson);
log.info("发送更新孩子[{}]MQ消息成功 Device: [{}]",userId,device);
log.info("发送更新孩子[{}]MQ消息开始 Device: [{}],Topic:{}, Tag:{}", userId, device, topic, tag);
mqProducer.sendMsg(topic, tag, device, userJson);
log.info("发送更新孩子[{}]MQ消息成功 Device: [{}]", userId, device);
}
/**
* 实际保存用户信息的私有方法
*
* @param userInfoDTO 用户信息DTO对象
* @return 保存后的用户ID
*/
private int save0(UserInfoDTO userInfoDTO){
private int save0(UserInfoDTO userInfoDTO) {
UserEntity UserEntity = UserInfoConvert.INSTANCE.convertOne(userInfoDTO);
boolean saveOrUpdate = userService.saveOrUpdate(UserEntity);
log.info("保存用户信息:{}", saveOrUpdate);