增加代理商,活动,代理商员工关,代理商活动参与者相关功能

This commit is contained in:
Wang 2025-12-30 17:59:48 +08:00
parent 8db570e1ad
commit 42bd6576eb
30 changed files with 545 additions and 99 deletions

View File

@ -327,8 +327,9 @@ public enum ResultCodeEnum {
INVALID_ACTIVITY(13003, "活动不存在或已失效"), INVALID_ACTIVITY(13003, "活动不存在或已失效"),
INVALID_AGENT(13004, "代理商不存在或已失效"), INVALID_AGENT(13004, "代理商不存在或已失效"),
AGENT_STATUS_INVALID(13005, "代理商状态无效"), AGENT_STATUS_INVALID(13005, "代理商状态无效"),
AGENT_NON_PARTICIPANT_ACTIVE(130061, "代理商没有参与该活动"), AGENT_EMPLOYEE_ALREADY_EXISTS(130051, "代理商员工已存在"),
AGENT_CONTACT_INFO_INVALID(13006, "联系信息无效"), AGENT_CONTACT_INFO_INVALID(13006, "联系信息无效"),
AGENT_NON_PARTICIPANT_ACTIVE(130061, "代理商没有参与该活动"),
ACTIVITY_NOT_FOUND(13007, "活动不存在"), ACTIVITY_NOT_FOUND(13007, "活动不存在"),
ACTIVITY_ALREADY_EXISTS(13008, "活动已存在"), ACTIVITY_ALREADY_EXISTS(13008, "活动已存在"),
ACTIVITY_NOT_ACTIVE(13009, "活动未开始或已结束"), ACTIVITY_NOT_ACTIVE(13009, "活动未开始或已结束"),

View File

@ -32,10 +32,4 @@ public class MpAgentActivityParticipantEntity extends BaseEntity {
*/ */
@TableField("agent_id") @TableField("agent_id")
private Integer agentId; private Integer agentId;
/**
* 家长ID对应user表的ID
*/
@TableField("parent_id")
private Integer parentId;
} }

View File

@ -29,6 +29,23 @@
<groupId>org.springdoc</groupId> <groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -8,12 +8,15 @@ import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation; import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.common.annotation.LogPrint; import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq; import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
import com.seer.teach.mp.app.controller.resp.AppAgentActivityResp; import com.seer.teach.mp.app.controller.resp.AppActivityResp;
import com.seer.teach.mp.app.service.IAppAgentActivityService; import com.seer.teach.mp.app.service.IAppActivityService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* <p> * <p>
@ -23,29 +26,29 @@ import org.springframework.web.bind.annotation.*;
* @author Lingma * @author Lingma
* @since 2025-12-29 * @since 2025-12-29
*/ */
@Tag(name = "APP - 代理商活动") @Tag(name = "APP - 活动列表")
@RestController @RestController
@RequestMapping("/app/agent/activity") @RequestMapping("/app/activity")
@LogPrint @LogPrint
@EncryptionAnnotation @EncryptionAnnotation
@DecryptionAnnotation @DecryptionAnnotation
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppAgentActivityController { public class AppAgentActivityController {
private final IAppAgentActivityService agentActivityService; private final IAppActivityService agentActivityService;
@Operation(summary = "代理商活动列表") @Operation(summary = "活动列表")
@GetMapping("/page-list") @GetMapping("/page-list")
@SaCheckPermission("mp:app:agent:activity:list") @SaCheckPermission("mp:app:agent:activity:list")
public ResultBean<PageListBean<AppAgentActivityResp>> pageList(AppAgentActivityQueryReq query) { public ResultBean<PageListBean<AppActivityResp>> pageList(AppAgentActivityQueryReq query) {
Integer agentId = StpUtil.getLoginIdAsInt(); Integer userId = StpUtil.getLoginIdAsInt();
return ResultBean.success(agentActivityService.pageList(query,agentId)); return ResultBean.success(agentActivityService.pageList(query,userId));
} }
@Operation(summary = "查看活动详情") @Operation(summary = "查看活动详情")
@GetMapping("/{id}") @GetMapping("/{id}")
@SaCheckPermission("mp:app:agent:activity:detail") @SaCheckPermission("mp:app:agent:activity:detail")
public ResultBean<AppAgentActivityResp> getDetail(@PathVariable Integer id) { public ResultBean<AppActivityResp> getDetail(@PathVariable Integer id) {
return ResultBean.success(agentActivityService.getById(id)); return ResultBean.success(agentActivityService.getById(id));
} }
} }

View File

@ -0,0 +1,49 @@
package com.seer.teach.mp.app.controller;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 代理商活动参与家长信息App控制器
* </p>
*
* @author Lingma
* @since 2025-12-30
*/
@Tag(name = "APP - 代理商活动参与家长信息")
@RestController
@RequestMapping("/app/agent/activity/parent-info")
@LogPrint
@EncryptionAnnotation
@DecryptionAnnotation
@RequiredArgsConstructor
public class AppAgentActivityParentInfoController {
private final IAppAgentActivityParentInfoService agentActivityParentInfoService;
@Operation(summary = "获取参加指定活动的家长列表")
@GetMapping("/getActivityParents")
@SaCheckLogin
public ResultBean<List<AgentActivityParentInfoResp>> getActivityParents(
@RequestParam("activityId") Integer activityId,
@RequestParam("agentId") Integer agentId) {
Integer userId = StpUtil.getLoginIdAsInt();
return ResultBean.success(agentActivityParentInfoService.getParentsByActivityAndAgent(activityId, agentId,userId));
}
}

View File

@ -7,11 +7,14 @@ import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation; import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.common.annotation.LogPrint; import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp; import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
import com.seer.teach.user.api.dto.UserInfoDTO; import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -32,14 +35,13 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppAgentActivityParticipantController { public class AppAgentActivityParticipantController {
private final com.seer.teach.mp.app.service.IAppAgentActivityParticipantService agentActivityParticipantService; private final IAppAgentActivityParticipantService agentActivityParticipantService;
@Operation(summary = "获取代理商参加的活动列表")
@Operation(summary = "获取代理商参与的活动中的家长列表") @GetMapping()
@GetMapping("/parents-by-agent")
@SaCheckPermission("mp:app:agent:participant:parents") @SaCheckPermission("mp:app:agent:participant:parents")
public ResultBean<List<AgentActivityParticipantResp>> getParentsByAgentAndActivity( public ResultBean<List<AgentActivityParticipantResp>> getParentsByAgentAndActivity(@RequestParam("agentId") Integer agentId) {
@RequestParam("activityId") Integer activityId,@RequestParam("agentId") Integer agentId) { Integer userId = StpUtil.getLoginIdAsInt();
return ResultBean.success(agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId)); return ResultBean.success(agentActivityParticipantService.getParticipantsByActivityAndAgent(agentId,userId));
} }
} }

View File

@ -0,0 +1,44 @@
package com.seer.teach.mp.app.controller;
import cn.dev33.satoken.stp.StpUtil;
import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.mp.app.controller.resp.AppMpAgentResp;
import com.seer.teach.mp.app.service.IAppActivityService;
import com.seer.teach.mp.app.service.IAppAgentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 代理商App控制器
* </p>
*
* @author Lingma
* @since 2025-12-29
*/
@Tag(name = "APP - 代理商管理接口")
@RestController
@RequestMapping("/app/agent")
@LogPrint
@EncryptionAnnotation
@DecryptionAnnotation
@RequiredArgsConstructor
public class AppAgentController {
private final IAppActivityService agentActivityService;
private final IAppAgentService appAgentService;
@Operation(summary = "获取代理商详情")
@GetMapping("/detail")
public ResultBean<AppMpAgentResp> getAgent() {
Integer userId = StpUtil.getLoginIdAsInt();
return ResultBean.success(appAgentService.getAgentRespByUserId(userId));
}
}

View File

@ -3,9 +3,9 @@ package com.seer.teach.mp.app.controller;
import cn.dev33.satoken.annotation.SaCheckLogin; import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import com.seer.teach.common.ResultBean; import com.seer.teach.common.ResultBean;
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp; import com.seer.teach.mp.app.controller.resp.AppMpSignUpActivityResp;
import com.seer.teach.mp.app.service.AppParentAgentActivityService; import com.seer.teach.mp.app.service.AppParentAgentActivityService;
import com.seer.teach.mp.app.controller.req.AppMpSignUpActivityReq;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**

View File

@ -17,17 +17,20 @@ public class AppMpSignUpActivityReq {
@Schema(description = "代理商ID") @Schema(description = "代理商ID")
private Integer agentId; private Integer agentId;
@Schema(description = "手机号码")
private String mobile;
@Schema(description = "孩子姓名") @Schema(description = "孩子姓名")
private String childName; private String childName;
@Schema(description = "孩子性别") @Schema(description = "孩子性别")
private String childGender; private Integer childGender;
@Schema(description = "孩子出生日期") @Schema(description = "孩子出生日期")
private LocalDate childBirthDate; private LocalDate childBirthDate;
@Schema(description = "年级") @Schema(description = "年级")
private String grade; private Integer grade;
@Schema(description = "学校") @Schema(description = "学校")
private String school; private String school;

View File

@ -0,0 +1,59 @@
package com.seer.teach.mp.app.controller.resp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
import java.util.List;
@Schema(name = "AgentActivityParentInfoResp", description = "代理商活动参与家长信息Resp")
@Data
public class AgentActivityParentInfoResp {
@Schema(description = "信息收集记录ID")
private Integer id;
@Schema(description = "关联的家长参与代理商活动关系ID")
private Integer relationId;
@Schema(description = "活动ID")
private Integer activityId;
@Schema(description = "代理商ID")
private Integer agentId;
@Schema(description = "家长ID")
private Integer parentId;
@Schema(description = "孩子姓名")
private String childName;
@Schema(description = "孩子性别(M-男,F-女)")
private String childGender;
@Schema(description = "出生年月")
private LocalDate childBirthDate;
@Schema(description = "年级")
private String grade;
@Schema(description = "学校")
private String school;
@Schema(description = "地区")
private String region;
@Schema(description = "家长身份(爸爸,妈妈)")
private String parentIdentity;
@Schema(description = "学习情况(优、良、中、差)")
private String learningSituation;
@Schema(description = "优势学科ID列表")
private List<Integer> strongSubjectIds;
@Schema(description = "劣势学科ID列表")
private List<Integer> weakSubjectIds;
}

View File

@ -15,9 +15,7 @@ public class AgentActivityParticipantResp {
@Schema(description = "代理商ID") @Schema(description = "代理商ID")
private Integer agentId; private Integer agentId;
@Schema(description = "家长ID") private String activityName;
private Integer parentId;
@Schema(description = "家长手机号")
private String parentMobile;
} }

View File

@ -5,9 +5,9 @@ import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Schema(name = "AppAgentActivityResp", description = "代理商活动响应参数") @Schema(name = "AppActivityResp", description = "活动响应参数")
@Data @Data
public class AppAgentActivityResp { public class AppActivityResp {
private Integer id; private Integer id;

View File

@ -0,0 +1,30 @@
package com.seer.teach.mp.app.controller.resp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "App端代理商响应对象")
public class AppMpAgentResp {
@Schema(description = "代理商ID")
private Integer agentId;
@Schema(description = "代理商名称")
private String agentName;
@Schema(description = "代理商编码")
private String agentCode;
@Schema(description = "代理商等级")
private String agentLevel;
@Schema(description = "联系人姓名")
private String contactName;
@Schema(description = "联系电话")
private String contactPhone;
@Schema(description = "代理商地址")
private String address;
}

View File

@ -1,7 +1,7 @@
package com.seer.teach.mp.app.convert; package com.seer.teach.mp.app.convert;
import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq; import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
import com.seer.teach.mp.app.controller.resp.AppAgentActivityResp; import com.seer.teach.mp.app.controller.resp.AppActivityResp;
import com.seer.teach.mp.entity.MpActivityEntity; import com.seer.teach.mp.entity.MpActivityEntity;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
@ -18,7 +18,7 @@ public interface AppAgentActivityConvert {
@Mapping(target = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss") @Mapping(target = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
@Mapping(target = "updateTime", dateFormat = "yyyy-MM-dd HH:mm:ss") @Mapping(target = "updateTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
AppAgentActivityResp convertToResp(MpActivityEntity entity); AppActivityResp convertToResp(MpActivityEntity entity);
List<AppAgentActivityResp> convertToRespList(List<MpActivityEntity> mpAgentActivityEntities); List<AppActivityResp> convertToRespList(List<MpActivityEntity> mpAgentActivityEntities);
} }

View File

@ -0,0 +1,19 @@
package com.seer.teach.mp.app.convert;
import com.seer.teach.mp.app.controller.resp.AppMpAgentResp;
import com.seer.teach.mp.entity.MpAgentEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
/**
* 代理商实体转换器
*/
@Mapper
public interface AppAgentConvert {
AppAgentConvert INSTANCE = Mappers.getMapper(AppAgentConvert.class);
@Mapping(source = "id", target = "agentId")
AppMpAgentResp entityToResp(MpAgentEntity entity);
}

View File

@ -13,6 +13,5 @@ public interface AppMpActivityInfoCollectionConvert {
AppMpSignUpActivityResp convert2Resp(MpActivityInfoCollectionEntity entity); AppMpSignUpActivityResp convert2Resp(MpActivityInfoCollectionEntity entity);
MpActivityInfoCollectionEntity convert2Entity(AppMpSignUpActivityReq request); MpActivityInfoCollectionEntity convert2Entity(AppMpSignUpActivityReq request);
} }

View File

@ -1,7 +1,7 @@
package com.seer.teach.mp.app.service; package com.seer.teach.mp.app.service;
import com.seer.teach.common.PageListBean; import com.seer.teach.common.PageListBean;
import com.seer.teach.mp.app.controller.resp.AppAgentActivityResp; import com.seer.teach.mp.app.controller.resp.AppActivityResp;
import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq; import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
/** /**
@ -12,7 +12,7 @@ import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
* @author Lingma * @author Lingma
* @since 2025-12-30 * @since 2025-12-30
*/ */
public interface IAppAgentActivityService { public interface IAppActivityService {
/** /**
* 分页查询代理商活动列表 * 分页查询代理商活动列表
@ -21,7 +21,7 @@ public interface IAppAgentActivityService {
* @param agentId 代理商ID * @param agentId 代理商ID
* @return 代理商活动分页列表 * @return 代理商活动分页列表
*/ */
PageListBean<AppAgentActivityResp> pageList(AppAgentActivityQueryReq query,Integer agentId); PageListBean<AppActivityResp> pageList(AppAgentActivityQueryReq query, Integer agentId);
/** /**
* 根据ID获取活动详情 * 根据ID获取活动详情
@ -29,5 +29,5 @@ public interface IAppAgentActivityService {
* @param id 活动ID * @param id 活动ID
* @return 活动详情 * @return 活动详情
*/ */
AppAgentActivityResp getById(Integer id); AppActivityResp getById(Integer id);
} }

View File

@ -0,0 +1,26 @@
package com.seer.teach.mp.app.service;
import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
import java.util.List;
/**
* <p>
* 代理商活动参与家长信息服务类
* </p>
*
* @author Lingma
* @since 2025-12-30
*/
public interface IAppAgentActivityParentInfoService {
/**
* 根据活动ID获取参与的家长信息列表
*
* @param activityId 活动ID
* @param agentId 代理商ID
* @param userId 用户ID
* @return 参与活动的家长信息列表
*/
List<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer activityId, Integer agentId,Integer userId);
}

View File

@ -17,10 +17,10 @@ public interface IAppAgentActivityParticipantService {
/** /**
* 根据活动ID和代理商ID获取参与记录 * 根据活动ID和代理商ID获取参与记录
* *
* @param activityId 活动ID * @param agentId 代理商ID
* @param agentId 代理商ID * @param userId 用户Id
* @return 参与记录列表 * @return 参与记录列表
*/ */
List<AgentActivityParticipantResp> getParticipantsByActivityAndAgent(Integer activityId, Integer agentId); List<AgentActivityParticipantResp> getParticipantsByActivityAndAgent(Integer agentId,Integer userId);
} }

View File

@ -0,0 +1,25 @@
package com.seer.teach.mp.app.service;
import com.seer.teach.mp.app.controller.resp.AppMpAgentResp;
/**
* App端代理商服务接口
*/
public interface IAppAgentService {
/**
* 根据用户ID获取代理商响应对象
*
* @param userId 用户ID
* @return 代理商响应对象
*/
AppMpAgentResp getAgentRespByUserId(Integer userId);
/**
* 根据用户ID获取代理商ID
*
* @param userId 用户ID
* @return 代理商ID
*/
Integer getAgentIdByUserId(Integer userId);
}

View File

@ -7,9 +7,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seer.teach.common.PageListBean; import com.seer.teach.common.PageListBean;
import com.seer.teach.common.utils.PageConverterUtils; import com.seer.teach.common.utils.PageConverterUtils;
import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq; import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
import com.seer.teach.mp.app.controller.resp.AppAgentActivityResp; import com.seer.teach.mp.app.controller.resp.AppActivityResp;
import com.seer.teach.mp.app.convert.AppAgentActivityConvert; import com.seer.teach.mp.app.convert.AppAgentActivityConvert;
import com.seer.teach.mp.app.service.IAppAgentActivityService; import com.seer.teach.mp.app.service.IAppActivityService;
import com.seer.teach.mp.entity.MpActivityEntity; import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.service.IMpActivityService; import com.seer.teach.mp.service.IMpActivityService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -30,12 +30,12 @@ import java.util.Objects;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppAgentActivityServiceImpl implements IAppAgentActivityService { public class AppActivityServiceImpl implements IAppActivityService {
private final IMpActivityService activityService; private final IMpActivityService activityService;
@Override @Override
public PageListBean<AppAgentActivityResp> pageList(AppAgentActivityQueryReq query,Integer agentId) { public PageListBean<AppActivityResp> pageList(AppAgentActivityQueryReq query, Integer agentId) {
log.info("查询参数:{}", query); log.info("查询参数:{}", query);
IPage<MpActivityEntity> page = new Page<>(query.getPageNo(), query.getPageSize()); IPage<MpActivityEntity> page = new Page<>(query.getPageNo(), query.getPageSize());
var pageResult = activityService.page(page, new LambdaQueryWrapper<>(MpActivityEntity.class) var pageResult = activityService.page(page, new LambdaQueryWrapper<>(MpActivityEntity.class)
@ -49,7 +49,7 @@ public class AppAgentActivityServiceImpl implements IAppAgentActivityService {
} }
@Override @Override
public AppAgentActivityResp getById(Integer id) { public AppActivityResp getById(Integer id) {
MpActivityEntity entity = activityService.getById(id); MpActivityEntity entity = activityService.getById(id);
return AppAgentActivityConvert.INSTANCE.convertToResp(entity); return AppAgentActivityConvert.INSTANCE.convertToResp(entity);
} }

View File

@ -0,0 +1,77 @@
package com.seer.teach.mp.app.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.seer.teach.common.enums.ResultCodeEnum;
import com.seer.teach.common.exception.CommonException;
import com.seer.teach.mp.app.controller.resp.AgentActivityParentInfoResp;
import com.seer.teach.mp.app.service.IAppAgentActivityParentInfoService;
import com.seer.teach.mp.app.service.IAppAgentService;
import com.seer.teach.mp.entity.MpActivityInfoCollectionEntity;
import com.seer.teach.mp.service.IMpActivityInfoCollectionService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <p>
* 代理商活动参与家长信息服务实现类
* </p>
*
* @author Lingma
* @since 2025-12-30
*/
@Slf4j
@Service
@AllArgsConstructor
public class AppAgentActivityParentInfoServiceImpl implements IAppAgentActivityParentInfoService {
private final IMpActivityInfoCollectionService activityInfoCollectionService;
private final IAppAgentService appAgentService;
@Override
public List<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer activityId, Integer agentId,Integer userId) {
var userAgentId = appAgentService.getAgentIdByUserId(userId);
if (Objects.isNull(userAgentId)) {
return List.of();
}
log.info("userAgentId:{}", userAgentId);
if(userAgentId.intValue() != agentId){
throw new CommonException(ResultCodeEnum.RELATION_NOT_FOUND);
}
LambdaQueryWrapper<MpActivityInfoCollectionEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(MpActivityInfoCollectionEntity::getActivityId, activityId)
.eq(MpActivityInfoCollectionEntity::getAgentId, agentId);
// 查询所有符合条件的记录
List<MpActivityInfoCollectionEntity> entities = activityInfoCollectionService.list(queryWrapper);
// 转换为响应对象列表
return entities.stream()
.map(this::convertToResp)
.collect(Collectors.toList());
}
private AgentActivityParentInfoResp convertToResp(MpActivityInfoCollectionEntity entity) {
AgentActivityParentInfoResp resp = new AgentActivityParentInfoResp();
resp.setId(entity.getId());
resp.setRelationId(entity.getRelationId());
resp.setActivityId(entity.getActivityId());
resp.setAgentId(entity.getAgentId());
resp.setParentId(entity.getParentId());
resp.setChildName(entity.getChildName());
resp.setChildGender(entity.getChildGender());
resp.setChildBirthDate(entity.getChildBirthDate());
resp.setGrade(entity.getGrade());
resp.setSchool(entity.getSchool());
resp.setRegion(entity.getRegion());
resp.setParentIdentity(entity.getParentIdentity());
resp.setLearningSituation(entity.getLearningSituation());
resp.setStrongSubjectIds(entity.getStrongSubjectIds());
resp.setWeakSubjectIds(entity.getWeakSubjectIds());
return resp;
}
}

View File

@ -1,13 +1,18 @@
package com.seer.teach.mp.app.service.impl; package com.seer.teach.mp.app.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.seer.teach.common.enums.ResultCodeEnum;
import com.seer.teach.common.exception.CommonException;
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp; import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService; import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService;
import com.seer.teach.mp.app.service.IAppAgentService;
import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService; import com.seer.teach.mp.service.IMpAgentActivityParticipantService;
import com.seer.teach.user.api.UserInfoServiceApi; import com.seer.teach.user.api.UserInfoServiceApi;
import com.seer.teach.user.api.dto.UserInfoDTO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -24,6 +29,7 @@ import java.util.stream.Collectors;
* @author Lingma * @author Lingma
* @since 2025-12-30 * @since 2025-12-30
*/ */
@Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivityParticipantService { public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivityParticipantService {
@ -32,36 +38,45 @@ public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivity
private final UserInfoServiceApi userInfoServiceApi; private final UserInfoServiceApi userInfoServiceApi;
private final IAppAgentService appAgentService;
private final IMpActivityService mpActivityService;
@Override @Override
public List<AgentActivityParticipantResp> getParticipantsByActivityAndAgent(Integer activityId, Integer agentId) { public List<AgentActivityParticipantResp> getParticipantsByActivityAndAgent(Integer agentId, Integer userId) {
var participants = agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId); var userAgentId = appAgentService.getAgentIdByUserId(userId);
if (Objects.isNull(userAgentId)) {
return List.of();
}
log.info("userAgentId:{}", userAgentId);
if(userAgentId.intValue() != agentId){
throw new CommonException(ResultCodeEnum.RELATION_NOT_FOUND);
}
var participants = agentActivityParticipantService.getListByAgentId(agentId);
if (CollectionUtil.isEmpty(participants)) { if (CollectionUtil.isEmpty(participants)) {
return List.of(); return List.of();
} }
// 提取家长ID Set<Integer> activityIds = participants.stream().map(MpAgentActivityParticipantEntity::getActivityId).collect(Collectors.toSet());
Set<Integer> parentIds = participants.stream().map(MpAgentActivityParticipantEntity::getParentId).collect(Collectors.toSet());
List<UserInfoDTO> parentInfos = userInfoServiceApi.getListByUserIds(parentIds); List<MpActivityEntity> parentInfos = mpActivityService.listByIds(activityIds);
var parentInfoMap = parentInfos.stream().collect(Collectors.toMap(UserInfoDTO::getId, parentInfo -> parentInfo)); var activityInfoMap = parentInfos.stream().collect(Collectors.toMap(MpActivityEntity::getId, activity -> activity));
return participants.stream() return participants.stream()
.map(entity -> convertToDto(entity, parentInfoMap)) .map(entity -> convertToDto(entity, activityInfoMap))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private AgentActivityParticipantResp convertToDto(MpAgentActivityParticipantEntity entity, Map<Integer, MpActivityEntity> activityInfoMap) {
private AgentActivityParticipantResp convertToDto(MpAgentActivityParticipantEntity entity, Map<Integer,UserInfoDTO> parentInfoMap) {
AgentActivityParticipantResp resp = new AgentActivityParticipantResp(); AgentActivityParticipantResp resp = new AgentActivityParticipantResp();
resp.setId(entity.getId()); resp.setId(entity.getId());
resp.setActivityId(entity.getActivityId()); resp.setActivityId(entity.getActivityId());
resp.setAgentId(entity.getAgentId()); resp.setAgentId(entity.getAgentId());
resp.setParentId(entity.getParentId()); MpActivityEntity activity = activityInfoMap.get(entity.getActivityId());
UserInfoDTO userInfoDTO = parentInfoMap.get(entity.getParentId()); if(Objects.nonNull(activity)){
if(Objects.nonNull(userInfoDTO)){ resp.setActivityName(activity.getActivityName());
resp.setParentMobile(userInfoDTO.getMobile());
} }
return resp; return resp;
} }

View File

@ -0,0 +1,44 @@
package com.seer.teach.mp.app.service.impl;
import com.seer.teach.mp.app.controller.resp.AppMpAgentResp;
import com.seer.teach.mp.app.service.IAppAgentService;
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 lombok.RequiredArgsConstructor;
import com.seer.teach.mp.app.convert.AppAgentConvert;
import org.springframework.stereotype.Service;
/**
* App端代理商服务实现类
*/
@Service
@RequiredArgsConstructor
public class AppAgentServiceImpl implements IAppAgentService {
private final IMpAgentService mpAgentService;
private final IMpAgentEmployeeRelationService mpAgentEmployeeRelationService;
@Override
public AppMpAgentResp getAgentRespByUserId(Integer userId) {
MpAgentEmployeeRelationEntity mpAgentEmployeeRelationEntity = mpAgentEmployeeRelationService.getOneByUserId(userId);
if (mpAgentEmployeeRelationEntity == null) {
return null;
}
MpAgentEntity agentEntity = mpAgentService.getAgentById(mpAgentEmployeeRelationEntity.getAgentId());
if (agentEntity == null) {
return null;
}
return AppAgentConvert.INSTANCE.entityToResp(agentEntity);
}
@Override
public Integer getAgentIdByUserId(Integer userId) {
MpAgentEmployeeRelationEntity mpAgentEmployeeRelationEntity = mpAgentEmployeeRelationService.getOneByUserId(userId);
if (mpAgentEmployeeRelationEntity == null) {
return null;
}
return mpAgentEmployeeRelationEntity.getAgentId();
}
}

View File

@ -3,6 +3,8 @@ package com.seer.teach.mp.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import java.util.List;
/** /**
* <p> * <p>
* 代理商活动参与记录表 服务类 * 代理商活动参与记录表 服务类
@ -21,4 +23,12 @@ public interface IMpAgentActivityParticipantService extends IService<MpAgentActi
* @return 参与记录列表 * @return 参与记录列表
*/ */
MpAgentActivityParticipantEntity getParticipantsByActivityAndAgent(Integer activityId, Integer agentId); MpAgentActivityParticipantEntity getParticipantsByActivityAndAgent(Integer activityId, Integer agentId);
/**
* 根据代理商ID获取所有参与活动记录
*
* @param agentId 代理商ID
* @return 参与记录列表
*/
List<MpAgentActivityParticipantEntity> getListByAgentId(Integer agentId);
} }

View File

@ -55,4 +55,12 @@ public interface IMpAgentEmployeeRelationService extends IService<MpAgentEmploye
* @return 是否为员工 * @return 是否为员工
*/ */
boolean isEmployeeOfAgent(Integer agentId, Integer employeeUserId); boolean isEmployeeOfAgent(Integer agentId, Integer employeeUserId);
/**
* 根据用户ID获取代理商员工关联
*
* @param userId 用户ID
* @return 代理商员工关联
*/
MpAgentEmployeeRelationEntity getOneByUserId(Integer userId);
} }

View File

@ -12,5 +12,27 @@ import java.util.Map;
*/ */
public interface IMpAgentService extends IService<MpAgentEntity> { public interface IMpAgentService extends IService<MpAgentEntity> {
/**
* 根据ID获取代理商信息
*
* @param id 代理商ID
* @return 代理商实体
*/
MpAgentEntity getAgentById(Integer id);
/**
* 保存代理商
*
* @param agentEntity 代理商实体
* @return 是否成功
*/
Boolean saveAgent(MpAgentEntity agentEntity);
/**
* 更新代理商
*
* @param agentEntity 代理商实体
* @return 是否成功
*/
Boolean updateAgent(MpAgentEntity agentEntity);
} }

View File

@ -1,13 +1,8 @@
package com.seer.teach.mp.service.impl; package com.seer.teach.mp.service.impl;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.exception.AgentActivityErrorCodeEnum;
import com.seer.teach.mp.mapper.MpAgentActivityParticipantMapper; import com.seer.teach.mp.mapper.MpAgentActivityParticipantMapper;
import com.seer.teach.mp.service.IMpAgentActivityLogService; import com.seer.teach.mp.service.IMpAgentActivityLogService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService; import com.seer.teach.mp.service.IMpAgentActivityParticipantService;
@ -15,7 +10,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@ -42,4 +36,10 @@ public class MpAgentActivityParticipantServiceImpl extends ServiceImpl<MpAgentAc
return super.getOne(queryWrapper); return super.getOne(queryWrapper);
} }
@Override
public List<MpAgentActivityParticipantEntity> getListByAgentId(Integer agentId) {
return super.list(new LambdaQueryWrapper<MpAgentActivityParticipantEntity>()
.eq(MpAgentActivityParticipantEntity::getAgentId, agentId));
}
} }

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seer.teach.common.enums.ResultCodeEnum;
import com.seer.teach.common.exception.CommonException;
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity; import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
import com.seer.teach.mp.mapper.MpAgentEmployeeRelationMapper; import com.seer.teach.mp.mapper.MpAgentEmployeeRelationMapper;
import com.seer.teach.mp.service.IMpAgentEmployeeRelationService; import com.seer.teach.mp.service.IMpAgentEmployeeRelationService;
@ -50,29 +52,20 @@ public class MpAgentEmployeeRelationServiceImpl extends ServiceImpl<MpAgentEmplo
@Override @Override
public boolean saveOrUpdateRelation(MpAgentEmployeeRelationEntity entity) { public boolean saveOrUpdateRelation(MpAgentEmployeeRelationEntity entity) {
// 验证数据
validateRelation(entity);
if (entity.getId() == null) { if (entity.getId() == null) {
// 检查是否已存在相同的关联关系 LambdaQueryWrapper<MpAgentEmployeeRelationEntity> checkWrapper =
LambdaQueryWrapper<MpAgentEmployeeRelationEntity> checkWrapper =
new LambdaQueryWrapper<MpAgentEmployeeRelationEntity>() new LambdaQueryWrapper<MpAgentEmployeeRelationEntity>()
.eq(MpAgentEmployeeRelationEntity::getAgentId, entity.getAgentId()) .eq(MpAgentEmployeeRelationEntity::getAgentId, entity.getAgentId())
.eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, entity.getEmployeeUserId()); .eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, entity.getEmployeeUserId());
long count = this.count(checkWrapper); long count = super.count(checkWrapper);
if (count > 0) { if (count > 0) {
throw new com.seer.teach.mp.exception.AgentActivityException( throw new CommonException(ResultCodeEnum.AGENT_EMPLOYEE_ALREADY_EXISTS);
com.seer.teach.mp.exception.AgentActivityErrorCodeEnum.PARTICIPATION_FAILED,
"员工已关联到代理商"
);
} }
// 新增时设置创建时间
entity.setCreateTime(LocalDateTime.now()); entity.setCreateTime(LocalDateTime.now());
} }
entity.setUpdateTime(LocalDateTime.now()); entity.setUpdateTime(LocalDateTime.now());
return this.saveOrUpdate(entity); return super.saveOrUpdate(entity);
} }
@Override @Override
@ -87,7 +80,7 @@ public class MpAgentEmployeeRelationServiceImpl extends ServiceImpl<MpAgentEmplo
.eq(MpAgentEmployeeRelationEntity::getAgentId, agentId) .eq(MpAgentEmployeeRelationEntity::getAgentId, agentId)
.orderByDesc(MpAgentEmployeeRelationEntity::getCreateTime); .orderByDesc(MpAgentEmployeeRelationEntity::getCreateTime);
return this.list(queryWrapper); return super.list(queryWrapper);
} }
@Override @Override
@ -98,16 +91,11 @@ public class MpAgentEmployeeRelationServiceImpl extends ServiceImpl<MpAgentEmplo
.eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, employeeUserId) .eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, employeeUserId)
.eq(MpAgentEmployeeRelationEntity::getStatus, 1); // 只检查启用状态的关联 .eq(MpAgentEmployeeRelationEntity::getStatus, 1); // 只检查启用状态的关联
return this.count(queryWrapper) > 0; return super.count(queryWrapper) > 0;
} }
/** @Override
* 验证关联数据 public MpAgentEmployeeRelationEntity getOneByUserId(Integer userId) {
*/ return super.getOne(new LambdaQueryWrapper<>(MpAgentEmployeeRelationEntity.class).eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, userId));
private void validateRelation(MpAgentEmployeeRelationEntity entity) {
com.seer.teach.common.utils.AssertUtils.notNull(entity.getAgentId(),
com.seer.teach.mp.exception.AgentActivityErrorCodeEnum.INVALID_AGENT, "代理商ID不能为空");
com.seer.teach.common.utils.AssertUtils.notNull(entity.getEmployeeUserId(),
com.seer.teach.mp.exception.AgentActivityErrorCodeEnum.PARENT_NOT_FOUND, "员工用户ID不能为空");
} }
} }

View File

@ -12,4 +12,18 @@ import org.springframework.stereotype.Service;
@Service @Service
public class MpAgentServiceImpl extends ServiceImpl<MpAgentMapper, MpAgentEntity> implements IMpAgentService { public class MpAgentServiceImpl extends ServiceImpl<MpAgentMapper, MpAgentEntity> implements IMpAgentService {
@Override
public MpAgentEntity getAgentById(Integer id) {
return this.getById(id);
}
@Override
public Boolean saveAgent(MpAgentEntity agentEntity) {
return this.save(agentEntity);
}
@Override
public Boolean updateAgent(MpAgentEntity agentEntity) {
return this.updateById(agentEntity);
}
} }