dev-chenjiajian #1
@ -1,7 +1,6 @@
|
||||
package com.seer.teach.mp.admin.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.ResultBean;
|
||||
import com.seer.teach.common.annotation.LogPrint;
|
||||
@ -9,26 +8,30 @@ import com.seer.teach.mp.admin.controller.req.MpActivityQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpActivityReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminActivityResp;
|
||||
import com.seer.teach.mp.admin.service.IAdminActivityService;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
import com.seer.teach.mp.service.IMpAgentService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@LogPrint
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@Tag(name = "管理端 - 活动")
|
||||
@RequestMapping("/mp/agent/activity")
|
||||
@RequestMapping("/mp/activity")
|
||||
public class AdminActivityController {
|
||||
|
||||
private final IAdminActivityService agentActivityService;
|
||||
|
||||
private final IMpAgentService mpAgentService;
|
||||
|
||||
@Operation(summary = "活动列表")
|
||||
@PostMapping("/page-list")
|
||||
@SaCheckPermission("mp:admin:agent:activity:list")
|
||||
@ -46,25 +49,22 @@ public class AdminActivityController {
|
||||
@Operation(summary = "删除活动")
|
||||
@DeleteMapping("/{id}")
|
||||
@SaCheckPermission("mp:admin:agent:activity:delete")
|
||||
public ResultBean<Boolean> delete(@PathVariable Integer id) {
|
||||
public ResultBean<Boolean> delete(@PathVariable("id") Integer id) {
|
||||
return ResultBean.success(agentActivityService.deleteActivity(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "详情")
|
||||
@GetMapping("/{id}")
|
||||
@SaCheckPermission("mp:admin:agent:activity:get")
|
||||
public ResultBean<AdminActivityResp> get(@PathVariable Integer id) {
|
||||
public ResultBean<AdminActivityResp> get(@PathVariable("id") Integer id) {
|
||||
AdminActivityResp result = agentActivityService.getById(id);
|
||||
return ResultBean.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取活动二维码")
|
||||
@GetMapping("/{activityId}/qrcode")
|
||||
@SaCheckPermission("mp:admin:agent:activity:qrcode")
|
||||
public ResultBean<String> getQrCode(@PathVariable("activityId") Integer activityId, @RequestParam("appId") String appId) {
|
||||
Integer userId = StpUtil.getLoginIdAsInt();
|
||||
MpAgentEntity one = mpAgentService.lambdaQuery().eq(MpAgentEntity::getContactUserId, userId).one();
|
||||
Integer agentId = one.getId();
|
||||
return ResultBean.success(agentActivityService.getQrCode(agentId, activityId, appId));
|
||||
@Operation(summary = "查询代理商没有参与的活动列表")
|
||||
@GetMapping("/agent/{agentId}")
|
||||
@SaCheckPermission("mp:admin:agent:activity:list")
|
||||
public ResultBean<List<AdminActivityResp>> getAgentActivities(@PathVariable("agentId") Integer agentId) {
|
||||
return ResultBean.success(agentActivityService.getAgentActivities(agentId));
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,14 @@
|
||||
package com.seer.teach.mp.admin.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.ResultBean;
|
||||
import com.seer.teach.common.annotation.LogPrint;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminAgentActivityParticipantResp;
|
||||
import com.seer.teach.mp.admin.service.IAdminAgentActivityParticipantService;
|
||||
import com.seer.teach.mp.admin.service.IAdminAgentActivityRelationService;
|
||||
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
|
||||
import com.seer.teach.mp.service.IMpActivityService;
|
||||
import com.seer.teach.mp.service.IMpAgentService;
|
||||
@ -15,7 +16,15 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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;
|
||||
|
||||
@ -24,9 +33,9 @@ import java.util.List;
|
||||
@RestController
|
||||
@Tag(name = "管理端 - 代理商活动参与记录")
|
||||
@RequestMapping("/mp/agent/activity/participant")
|
||||
public class AdminAgentActivityParticipantController {
|
||||
public class AdminAgentActivityRelationController {
|
||||
|
||||
private final IAdminAgentActivityParticipantService adminAgentActivityParticipantService;
|
||||
private final IAdminAgentActivityRelationService adminAgentActivityParticipantService;
|
||||
|
||||
private final IMpAgentService mpAgentService;
|
||||
|
||||
@ -67,16 +76,12 @@ public class AdminAgentActivityParticipantController {
|
||||
return ResultBean.success(adminAgentActivityParticipantService.deleteById(ids));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "查询代理商名称")
|
||||
@GetMapping("/agent-name")
|
||||
public ResultBean<List<String>> getAgentName() {
|
||||
return ResultBean.success(mpAgentService.getAgentName());
|
||||
@Operation(summary = "获取活动二维码")
|
||||
@GetMapping("/{activityId}/{agentId}/qrcode")
|
||||
@SaCheckPermission("mp:admin:agent:activity:qrcode")
|
||||
public ResultBean<String> getQrCode(@PathVariable("activityId") Integer activityId,@PathVariable("agentId") Integer agentId, @RequestParam("appId") String appId) {
|
||||
Integer userId = StpUtil.getLoginIdAsInt();
|
||||
return ResultBean.success(adminAgentActivityParticipantService.getQrCode(agentId, activityId, appId,userId));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询活动名称")
|
||||
@GetMapping("/activity-name")
|
||||
public ResultBean<List<String>> getActivityName() {
|
||||
return ResultBean.success(mpActivityService.getActivityName());
|
||||
}
|
||||
}
|
||||
@ -27,4 +27,7 @@ public class AgentActivityParticipantQueryReq {
|
||||
|
||||
@Schema(description = "代理商名称")
|
||||
private String agentName;
|
||||
|
||||
@Schema(description = "代理商ID")
|
||||
private Integer agentId;
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.seer.teach.mp.admin.controller.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ -12,7 +13,15 @@ public class AgentActivityParticipantReq {
|
||||
@NotBlank(message = "代理商名称不能为空")
|
||||
private String agentName;
|
||||
|
||||
@Schema(description = "代理商ID")
|
||||
@NotNull(message = "代理商ID不能为空")
|
||||
private Integer agentId;
|
||||
|
||||
@Schema(description = "活动名称")
|
||||
@NotBlank(message = "活动名称不能为空")
|
||||
private String activityName;
|
||||
|
||||
@Schema(description = "活动ID")
|
||||
@NotNull(message = "活动ID不能为空")
|
||||
private Integer activityId;
|
||||
}
|
||||
|
||||
@ -17,6 +17,11 @@ public interface AdminAgentActivityParticipantConvert {
|
||||
|
||||
List<AdminAgentActivityParticipantResp> convertToRespList(List<MpAgentActivityParticipantEntity> entity);
|
||||
|
||||
|
||||
/**
|
||||
* 转换为实体
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
MpAgentActivityParticipantEntity convertToEntity(AgentActivityParticipantReq entity);
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ import com.seer.teach.mp.admin.controller.req.MpActivityQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpActivityReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminActivityResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 管理端代理商活动服务类
|
||||
@ -48,11 +50,10 @@ public interface IAdminActivityService {
|
||||
AdminActivityResp getById(Integer id);
|
||||
|
||||
/**
|
||||
* 获取活动二维码
|
||||
* 根据代理商ID获取其参与的活动列表
|
||||
*
|
||||
* @param agentId 代理商ID
|
||||
* @param activityId 活动ID
|
||||
* @param appId 微信公众号ID
|
||||
* @return 活动二维码
|
||||
* @return 活动列表
|
||||
*/
|
||||
String getQrCode(Integer agentId, Integer activityId, String appId);
|
||||
List<AdminActivityResp> getAgentActivities(Integer agentId);
|
||||
}
|
||||
@ -16,7 +16,7 @@ import java.util.List;
|
||||
* @author
|
||||
* @since 2025-12-30
|
||||
*/
|
||||
public interface IAdminAgentActivityParticipantService {
|
||||
public interface IAdminAgentActivityRelationService {
|
||||
|
||||
/**
|
||||
* 分页查询代理商活动参与记录列表(管理端)
|
||||
@ -57,4 +57,15 @@ public interface IAdminAgentActivityParticipantService {
|
||||
* @return 操作是否成功
|
||||
*/
|
||||
Boolean deleteById(List<Integer> ids);
|
||||
|
||||
/**
|
||||
* 获取活动二维码
|
||||
*
|
||||
* @param agentId 代理商ID
|
||||
* @param activityId 活动ID
|
||||
* @param appId 微信公众号appId
|
||||
* @param userId 用户ID
|
||||
* @return 二维码地址
|
||||
*/
|
||||
String getQrCode(Integer agentId, Integer activityId, String appId, Integer userId);
|
||||
}
|
||||
@ -3,26 +3,23 @@ package com.seer.teach.mp.admin.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||
import com.seer.teach.common.exception.CommonException;
|
||||
import com.seer.teach.common.utils.AssertUtils;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentGenerateQrCodeReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpActivityQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.MpActivityReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminActivityResp;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminAgentQrCodeResp;
|
||||
import com.seer.teach.mp.admin.convert.AdminActivityConvert;
|
||||
import com.seer.teach.mp.admin.service.AdminOfficialQrCodeService;
|
||||
import com.seer.teach.mp.admin.service.IAdminActivityService;
|
||||
import com.seer.teach.mp.entity.MpActivityEntity;
|
||||
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
|
||||
import com.seer.teach.mp.service.IMpActivityService;
|
||||
import com.seer.teach.mp.service.IMpAgentActivityParticipantService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -33,6 +30,7 @@ import java.util.Objects;
|
||||
* @author Lingma
|
||||
* @since 2025-12-30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdminActivityServiceImpl implements IAdminActivityService {
|
||||
@ -41,8 +39,6 @@ public class AdminActivityServiceImpl implements IAdminActivityService {
|
||||
|
||||
private final IMpAgentActivityParticipantService agentActivityParticipantService;
|
||||
|
||||
private final AdminOfficialQrCodeService officialQrCodeService;
|
||||
|
||||
@Override
|
||||
public PageListBean<AdminActivityResp> pageList(MpActivityQueryReq query) {
|
||||
Page<MpActivityEntity> page = new Page<>(query.getPageNo(), query.getPageSize());
|
||||
@ -70,25 +66,25 @@ public class AdminActivityServiceImpl implements IAdminActivityService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQrCode(Integer agentId, Integer activityId, String appId) {
|
||||
MpActivityEntity activity = agentActivityService.getById(activityId);
|
||||
AssertUtils.notNull(activity, ResultCodeEnum.INVALID_ACTIVITY);
|
||||
|
||||
if (activity.getStatus() != 1) {
|
||||
throw new CommonException(ResultCodeEnum.INVALID_ACTIVITY);
|
||||
public List<AdminActivityResp> getAgentActivities(Integer agentId) {
|
||||
List<MpActivityEntity> result = new ArrayList<>();
|
||||
// 先查询代理商参与的所有活动ID
|
||||
var participants = agentActivityParticipantService.getListByAgentId(agentId);
|
||||
if (participants.isEmpty()) {
|
||||
log.info("没有代理商参与活动");
|
||||
result.addAll(agentActivityService.list());
|
||||
}else{
|
||||
var activityIds = participants.stream()
|
||||
.map(MpAgentActivityParticipantEntity::getActivityId)
|
||||
.distinct()
|
||||
.toList();
|
||||
// 查询这些活动的详细信息
|
||||
var wrapper = new LambdaQueryWrapper<MpActivityEntity>()
|
||||
.notIn(MpActivityEntity::getId, activityIds)
|
||||
.orderByDesc(MpActivityEntity::getCreateTime);
|
||||
List<MpActivityEntity> activitys = agentActivityService.list(wrapper);
|
||||
result.addAll(activitys);
|
||||
}
|
||||
MpAgentActivityParticipantEntity relation = agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId);
|
||||
AssertUtils.notNull(relation, ResultCodeEnum.INVALID_ACTIVITY);
|
||||
if (StringUtils.isNotBlank(relation.getQrCodeUrl())) {
|
||||
return relation.getQrCodeUrl();
|
||||
}
|
||||
AgentGenerateQrCodeReq req = new AgentGenerateQrCodeReq();
|
||||
req.setSceneStr("agentId=" + agentId + "&activityId=" + activityId);
|
||||
req.setAppId(appId);
|
||||
req.setType(2);
|
||||
AdminAgentQrCodeResp QrCodeResp = officialQrCodeService.generateQrCode(req);
|
||||
relation.setQrCodeUrl(QrCodeResp.getQrCodeUrl());
|
||||
agentActivityParticipantService.updateById(relation);
|
||||
return QrCodeResp.getQrCodeUrl();
|
||||
return AdminActivityConvert.INSTANCE.convertToRespList(result);
|
||||
}
|
||||
}
|
||||
@ -3,12 +3,18 @@ package com.seer.teach.mp.admin.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||
import com.seer.teach.common.exception.CommonException;
|
||||
import com.seer.teach.common.utils.AssertUtils;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantQueryReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentActivityParticipantReq;
|
||||
import com.seer.teach.mp.admin.controller.req.AgentGenerateQrCodeReq;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminAgentActivityParticipantResp;
|
||||
import com.seer.teach.mp.admin.controller.resp.AdminAgentQrCodeResp;
|
||||
import com.seer.teach.mp.admin.convert.AdminAgentActivityParticipantConvert;
|
||||
import com.seer.teach.mp.admin.service.IAdminAgentActivityParticipantService;
|
||||
import com.seer.teach.mp.admin.service.AdminOfficialQrCodeService;
|
||||
import com.seer.teach.mp.admin.service.IAdminAgentActivityRelationService;
|
||||
import com.seer.teach.mp.entity.MpActivityEntity;
|
||||
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
@ -16,6 +22,7 @@ import com.seer.teach.mp.service.IMpActivityService;
|
||||
import com.seer.teach.mp.service.IMpAgentActivityParticipantService;
|
||||
import com.seer.teach.mp.service.IMpAgentService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -30,7 +37,7 @@ import java.util.List;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdminAgentActivityParticipantServiceImpl implements IAdminAgentActivityParticipantService {
|
||||
public class AdminAgentActivityRelationServiceImpl implements IAdminAgentActivityRelationService {
|
||||
|
||||
private final IMpAgentActivityParticipantService mpAgentActivityParticipantService;
|
||||
|
||||
@ -38,6 +45,8 @@ public class AdminAgentActivityParticipantServiceImpl implements IAdminAgentActi
|
||||
|
||||
private final IMpActivityService mpActivityService;
|
||||
|
||||
private final AdminOfficialQrCodeService officialQrCodeService;
|
||||
|
||||
@Override
|
||||
public PageListBean<AdminAgentActivityParticipantResp> pageList(AgentActivityParticipantQueryReq query) {
|
||||
Page<MpAgentActivityParticipantEntity> page = new Page<>(query.getPageNum(), query.getPageSize());
|
||||
@ -51,27 +60,26 @@ public class AdminAgentActivityParticipantServiceImpl implements IAdminAgentActi
|
||||
if (query.getAgentName() != null) {
|
||||
wrapper.like(MpAgentActivityParticipantEntity::getAgentName, query.getAgentName());
|
||||
}
|
||||
if (query.getAgentId() != null) {
|
||||
wrapper.eq(MpAgentActivityParticipantEntity::getAgentId, query.getAgentId());
|
||||
}
|
||||
Page<MpAgentActivityParticipantEntity> result = mpAgentActivityParticipantService.page(page, wrapper);
|
||||
return PageConverterUtils.convertPageListBean(result, AdminAgentActivityParticipantConvert.INSTANCE::convertToRespList);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean saveParticipant(AgentActivityParticipantReq entity) {
|
||||
public boolean saveParticipant(AgentActivityParticipantReq req) {
|
||||
// 检查是否已存在相同的活动、代理商和家长记录
|
||||
LambdaQueryWrapper<MpAgentActivityParticipantEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MpAgentActivityParticipantEntity::getActivityName, entity.getActivityName())
|
||||
.eq(MpAgentActivityParticipantEntity::getAgentName, entity.getAgentName());
|
||||
wrapper.eq(MpAgentActivityParticipantEntity::getActivityId, req.getActivityId())
|
||||
.eq(MpAgentActivityParticipantEntity::getAgentId, req.getAgentId());
|
||||
|
||||
long count = mpAgentActivityParticipantService.count(wrapper);
|
||||
if (count > 0) {
|
||||
throw new RuntimeException("该代理商活动参与记录已存在");
|
||||
}
|
||||
Integer agentId = mpAgentService.lambdaQuery().eq(MpAgentEntity::getAgentName, entity.getAgentName()).one().getId();
|
||||
Integer activityId = mpActivityService.lambdaQuery().eq(MpActivityEntity::getActivityName, entity.getActivityName()).one().getId();
|
||||
MpAgentActivityParticipantEntity result = AdminAgentActivityParticipantConvert.INSTANCE.convertToEntity(entity);
|
||||
result.setActivityId(activityId);
|
||||
result.setAgentId(agentId);
|
||||
MpAgentActivityParticipantEntity result = AdminAgentActivityParticipantConvert.INSTANCE.convertToEntity(req);
|
||||
return mpAgentActivityParticipantService.save(result);
|
||||
}
|
||||
|
||||
@ -108,4 +116,27 @@ public class AdminAgentActivityParticipantServiceImpl implements IAdminAgentActi
|
||||
return mpAgentActivityParticipantService.removeByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQrCode(Integer agentId, Integer activityId, String appId, Integer userId) {
|
||||
MpActivityEntity activity = mpActivityService.getById(activityId);
|
||||
AssertUtils.notNull(activity, ResultCodeEnum.INVALID_ACTIVITY);
|
||||
|
||||
if (activity.getStatus() != 1) {
|
||||
throw new CommonException(ResultCodeEnum.INVALID_ACTIVITY);
|
||||
}
|
||||
MpAgentActivityParticipantEntity relation = mpAgentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId);
|
||||
AssertUtils.notNull(relation, ResultCodeEnum.INVALID_ACTIVITY);
|
||||
if (StringUtils.isNotBlank(relation.getQrCodeUrl())) {
|
||||
return relation.getQrCodeUrl();
|
||||
}
|
||||
AgentGenerateQrCodeReq req = new AgentGenerateQrCodeReq();
|
||||
req.setSceneStr("agentId=" + agentId + "&activityId=" + activityId);
|
||||
req.setAppId(appId);
|
||||
req.setType(2);
|
||||
AdminAgentQrCodeResp QrCodeResp = officialQrCodeService.generateQrCode(req);
|
||||
relation.setQrCodeUrl(QrCodeResp.getQrCodeUrl());
|
||||
mpAgentActivityParticipantService.updateById(relation);
|
||||
return QrCodeResp.getQrCodeUrl();
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,7 +7,7 @@ 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.req.AppAgentActivityQueryReq;
|
||||
import com.seer.teach.mp.app.controller.req.AppActivityQueryReq;
|
||||
import com.seer.teach.mp.app.controller.resp.AppActivityResp;
|
||||
import com.seer.teach.mp.app.service.IAppActivityService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -41,7 +41,7 @@ public class AppMpActivityController {
|
||||
@Operation(summary = "活动列表")
|
||||
@GetMapping("/page-list")
|
||||
@SaCheckPermission("mp:app:agent:activity:list")
|
||||
public ResultBean<PageListBean<AppActivityResp>> pageList(AppAgentActivityQueryReq query) {
|
||||
public ResultBean<PageListBean<AppActivityResp>> pageList(AppActivityQueryReq query) {
|
||||
Integer userId = StpUtil.getLoginIdAsInt();
|
||||
return ResultBean.success(agentActivityService.pageList(query,userId));
|
||||
}
|
||||
@ -53,11 +53,4 @@ public class AppMpActivityController {
|
||||
return ResultBean.success(agentActivityService.getById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "活动二维码")
|
||||
@GetMapping("/{agentId}/{activityId}/qrcode")
|
||||
@SaCheckPermission("mp:app:agent:activity:qrcode")
|
||||
public ResultBean<String> getQrCode(@PathVariable("agentId") Integer agentId, @PathVariable("activityId") Integer activityId, @RequestParam("appId") String appId) {
|
||||
Integer userId = StpUtil.getLoginIdAsInt();
|
||||
return ResultBean.success(agentActivityService.getQrCode(userId,agentId,activityId,appId));
|
||||
}
|
||||
}
|
||||
@ -4,9 +4,9 @@ import com.seer.teach.common.request.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(name = "AppAgentActivityQueryReq", description = "代理商活动查询请求参数")
|
||||
@Schema(name = "AppActivityQueryReq", description = "代理商活动查询请求参数")
|
||||
@Data
|
||||
public class AppAgentActivityQueryReq extends PageRequest {
|
||||
public class AppActivityQueryReq extends PageRequest {
|
||||
|
||||
@Schema(description = "活动名称")
|
||||
private String activityName;
|
||||
@ -30,4 +30,8 @@ public class AppMpAgentResp {
|
||||
|
||||
@Schema(description = "是否是代理商联系人")
|
||||
private Boolean isContactPerson;
|
||||
|
||||
@Schema(description = "是否有多个代理商")
|
||||
private Boolean hasMultipleAgents;
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
package com.seer.teach.mp.app.convert;
|
||||
|
||||
import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
|
||||
import com.seer.teach.mp.app.controller.req.AppActivityQueryReq;
|
||||
import com.seer.teach.mp.app.controller.resp.AppActivityResp;
|
||||
import com.seer.teach.mp.entity.MpActivityEntity;
|
||||
import org.mapstruct.Mapper;
|
||||
@ -14,7 +14,7 @@ public interface AppAgentActivityConvert {
|
||||
|
||||
AppAgentActivityConvert INSTANCE = Mappers.getMapper(AppAgentActivityConvert.class);
|
||||
|
||||
MpActivityEntity convert(AppAgentActivityQueryReq req);
|
||||
MpActivityEntity convert(AppActivityQueryReq req);
|
||||
|
||||
@Mapping(target = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@Mapping(target = "updateTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.seer.teach.mp.app.service;
|
||||
|
||||
import com.seer.teach.common.PageListBean;
|
||||
import com.seer.teach.mp.app.controller.req.AppActivityQueryReq;
|
||||
import com.seer.teach.mp.app.controller.resp.AppActivityResp;
|
||||
import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -21,7 +21,7 @@ public interface IAppActivityService {
|
||||
* @param agentId 代理商ID
|
||||
* @return 代理商活动分页列表
|
||||
*/
|
||||
PageListBean<AppActivityResp> pageList(AppAgentActivityQueryReq query, Integer agentId);
|
||||
PageListBean<AppActivityResp> pageList(AppActivityQueryReq query, Integer agentId);
|
||||
|
||||
/**
|
||||
* 根据ID获取活动详情
|
||||
@ -31,13 +31,4 @@ public interface IAppActivityService {
|
||||
*/
|
||||
AppActivityResp getById(Integer id);
|
||||
|
||||
/**
|
||||
* 获取活动二维码
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param agentId 代理商ID
|
||||
* @param activityId 活动ID
|
||||
* @return 活动二维码
|
||||
*/
|
||||
String getQrCode(Integer userId,Integer agentId,Integer activityId,String appId);
|
||||
}
|
||||
@ -2,6 +2,8 @@ package com.seer.teach.mp.app.service;
|
||||
|
||||
import com.seer.teach.mp.app.controller.resp.AppMpAgentResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* App端代理商服务接口
|
||||
*/
|
||||
@ -21,5 +23,5 @@ public interface IAppAgentService {
|
||||
* @param userId 用户ID
|
||||
* @return 代理商ID
|
||||
*/
|
||||
Integer getAgentIdByUserId(Integer userId);
|
||||
List<Integer> getAgentIdListByUserId(Integer userId);
|
||||
}
|
||||
@ -9,7 +9,7 @@ import com.seer.teach.common.enums.ResultCodeEnum;
|
||||
import com.seer.teach.common.exception.CommonException;
|
||||
import com.seer.teach.common.utils.AssertUtils;
|
||||
import com.seer.teach.common.utils.PageConverterUtils;
|
||||
import com.seer.teach.mp.app.controller.req.AppAgentActivityQueryReq;
|
||||
import com.seer.teach.mp.app.controller.req.AppActivityQueryReq;
|
||||
import com.seer.teach.mp.app.controller.req.MpGenerateQrCodeReq;
|
||||
import com.seer.teach.mp.app.controller.resp.AppActivityResp;
|
||||
import com.seer.teach.mp.app.controller.resp.MpQrCodeResp;
|
||||
@ -20,7 +20,6 @@ import com.seer.teach.mp.entity.MpActivityEntity;
|
||||
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.IMpAgentService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -48,7 +47,7 @@ public class AppActivityServiceImpl implements IAppActivityService {
|
||||
private final IMpAgentActivityParticipantService agentActivityParticipantService;
|
||||
|
||||
@Override
|
||||
public PageListBean<AppActivityResp> pageList(AppAgentActivityQueryReq query, Integer agentId) {
|
||||
public PageListBean<AppActivityResp> pageList(AppActivityQueryReq query, Integer agentId) {
|
||||
log.info("查询参数:{}", query);
|
||||
IPage<MpActivityEntity> page = new Page<>(query.getPageNo(), query.getPageSize());
|
||||
var pageResult = activityService.page(page, new LambdaQueryWrapper<>(MpActivityEntity.class)
|
||||
@ -66,27 +65,4 @@ public class AppActivityServiceImpl implements IAppActivityService {
|
||||
MpActivityEntity entity = activityService.getById(id);
|
||||
return AppAgentActivityConvert.INSTANCE.convertToResp(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQrCode(Integer userId,Integer agentId,Integer activityId,String appId) {
|
||||
MpActivityEntity activity = activityService.getById(activityId);
|
||||
AssertUtils.notNull(activity, ResultCodeEnum.INVALID_ACTIVITY);
|
||||
|
||||
if(activity.getStatus() != 1){
|
||||
throw new CommonException(ResultCodeEnum.INVALID_ACTIVITY);
|
||||
}
|
||||
MpAgentActivityParticipantEntity relation = agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId);
|
||||
AssertUtils.notNull(relation, ResultCodeEnum.INVALID_ACTIVITY);
|
||||
if(StringUtils.isNotBlank(relation.getQrCodeUrl())){
|
||||
return relation.getQrCodeUrl();
|
||||
}
|
||||
MpGenerateQrCodeReq req = new MpGenerateQrCodeReq();
|
||||
req.setSceneStr("agentId=" + agentId + "&activityId=" + activityId);
|
||||
req.setAppId(appId);
|
||||
req.setType(2);
|
||||
MpQrCodeResp mpQrCodeResp = officialQrCodeService.generateQrCode(req);
|
||||
relation.setQrCodeUrl(mpQrCodeResp.getQrCodeUrl());
|
||||
agentActivityParticipantService.updateById(relation);
|
||||
return mpQrCodeResp.getQrCodeUrl();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.seer.teach.mp.app.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.seer.teach.common.PageListBean;
|
||||
@ -17,7 +18,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -38,12 +38,11 @@ public class AppAgentActivityParentInfoServiceImpl implements IAppAgentActivityP
|
||||
|
||||
@Override
|
||||
public List<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer activityId, Integer agentId,Integer userId) {
|
||||
var userAgentId = appAgentService.getAgentIdByUserId(userId);
|
||||
if (Objects.isNull(userAgentId)) {
|
||||
var userAgentIds = appAgentService.getAgentIdListByUserId(userId);
|
||||
if (CollectionUtil.isEmpty(userAgentIds)) {
|
||||
return List.of();
|
||||
}
|
||||
log.info("getParentsByActivityAndAgent userAgentId:{}", userAgentId);
|
||||
if(userAgentId.intValue() != agentId){
|
||||
if(!userAgentIds.contains(agentId)){
|
||||
throw new CommonException(ResultCodeEnum.RELATION_NOT_FOUND);
|
||||
}
|
||||
LambdaQueryWrapper<MpActivityInfoCollectionEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@ -61,12 +60,11 @@ public class AppAgentActivityParentInfoServiceImpl implements IAppAgentActivityP
|
||||
|
||||
@Override
|
||||
public PageListBean<AgentActivityParentInfoResp> getParentsByActivityAndAgent(Integer userId,AgentActivityParentQueryReq queryReq) {
|
||||
var userAgentId = appAgentService.getAgentIdByUserId(userId);
|
||||
if (Objects.isNull(userAgentId)) {
|
||||
var userAgentIds = appAgentService.getAgentIdListByUserId(userId);
|
||||
if (CollectionUtil.isEmpty(userAgentIds)) {
|
||||
return new PageListBean<>();
|
||||
}
|
||||
log.info("userAgentId:{}", userAgentId);
|
||||
if(userAgentId.intValue() != queryReq.getAgentId()){
|
||||
if(!userAgentIds.contains(queryReq.getAgentId())){
|
||||
throw new CommonException(ResultCodeEnum.RELATION_NOT_FOUND);
|
||||
}
|
||||
// 创建分页对象
|
||||
@ -75,7 +73,7 @@ public class AppAgentActivityParentInfoServiceImpl implements IAppAgentActivityP
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<MpActivityInfoCollectionEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MpActivityInfoCollectionEntity::getActivityId, queryReq.getActivityId())
|
||||
.eq(MpActivityInfoCollectionEntity::getAgentId, userAgentId);
|
||||
.eq(MpActivityInfoCollectionEntity::getAgentId, queryReq.getAgentId());
|
||||
|
||||
// 执行分页查询
|
||||
Page<MpActivityInfoCollectionEntity> pageResult = activityInfoCollectionService.page(page, queryWrapper);
|
||||
|
||||
@ -56,12 +56,11 @@ public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivity
|
||||
|
||||
@Override
|
||||
public List<AgentActivityParticipantResp> getParticipantsByActivityAndAgent(Integer agentId, Integer userId) {
|
||||
var userAgentId = appAgentService.getAgentIdByUserId(userId);
|
||||
if (Objects.isNull(userAgentId)) {
|
||||
var userAgentIds = appAgentService.getAgentIdListByUserId(userId);
|
||||
if (CollectionUtil.isEmpty(userAgentIds)) {
|
||||
return List.of();
|
||||
}
|
||||
log.info("userAgentId:{}", userAgentId);
|
||||
if(userAgentId.intValue() != agentId){
|
||||
if(!userAgentIds.contains(agentId) ){
|
||||
throw new CommonException(ResultCodeEnum.RELATION_NOT_FOUND);
|
||||
}
|
||||
var participants = agentActivityParticipantService.getListByAgentId(agentId);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.seer.teach.mp.app.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.seer.teach.common.enums.ResultCodeEnum;
|
||||
import com.seer.teach.common.utils.AssertUtils;
|
||||
import com.seer.teach.mp.app.controller.resp.AppMpAgentResp;
|
||||
@ -10,9 +11,14 @@ 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 lombok.val;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* App端代理商服务实现类
|
||||
@ -26,25 +32,38 @@ public class AppAgentServiceImpl implements IAppAgentService {
|
||||
|
||||
@Override
|
||||
public AppMpAgentResp getAgentRespByUserId(Integer userId) {
|
||||
MpAgentEntity one = mpAgentService.lambdaQuery().eq(MpAgentEntity::getContactUserId, userId).one();
|
||||
AssertUtils.notNull(one, ResultCodeEnum.AGENT_NOT_FOUND);
|
||||
Integer agentId = one.getId();
|
||||
MpAgentEntity agentEntity = mpAgentService.getAgentById(agentId);
|
||||
if (Objects.isNull(agentEntity)) {
|
||||
return null;
|
||||
List<MpAgentEntity> agents = mpAgentService.getListByUserId(userId);
|
||||
AssertUtils.notEmpty(agents, ResultCodeEnum.AGENT_NOT_FOUND);
|
||||
|
||||
MpAgentEntity agentEntity = null;
|
||||
boolean hasContactPerson = false;
|
||||
for (MpAgentEntity agent : agents) {
|
||||
if (Objects.nonNull(agent.getContactUserId()) && agent.getContactUserId().equals(userId)) {
|
||||
agentEntity = agent;
|
||||
hasContactPerson = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 如果没找到对应的联系人,则取第一个代理商
|
||||
if (agentEntity == null) {
|
||||
agentEntity = agents.get(0);
|
||||
}
|
||||
AppMpAgentResp appMpAgentResp = AppAgentConvert.INSTANCE.entityToResp(agentEntity);
|
||||
Boolean isContactPerson = Objects.nonNull(agentEntity.getContactUserId()) && agentEntity.getContactUserId().equals(userId);
|
||||
appMpAgentResp.setIsContactPerson(isContactPerson);
|
||||
appMpAgentResp.setIsContactPerson(hasContactPerson);
|
||||
appMpAgentResp.setHasMultipleAgents(agents.size() > 1);
|
||||
return appMpAgentResp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getAgentIdByUserId(Integer userId) {
|
||||
MpAgentEmployeeRelationEntity mpAgentEmployeeRelationEntity = mpAgentEmployeeRelationService.getOneByUserId(userId);
|
||||
if (mpAgentEmployeeRelationEntity == null) {
|
||||
return null;
|
||||
public List<Integer> getAgentIdListByUserId(Integer userId) {
|
||||
List<MpAgentEmployeeRelationEntity> mpAgentEmployeeRelations = mpAgentEmployeeRelationService.getListByUserId(userId);
|
||||
if (CollectionUtil.isEmpty(mpAgentEmployeeRelations)) {
|
||||
List<MpAgentEntity> mpAgentEntities = mpAgentService.lambdaQuery().eq(MpAgentEntity::getContactUserId, userId).list();
|
||||
if (CollectionUtil.isEmpty(mpAgentEntities)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return mpAgentEntities.stream().map(MpAgentEntity::getId).collect(Collectors.toList());
|
||||
}
|
||||
return mpAgentEmployeeRelationEntity.getAgentId();
|
||||
return mpAgentEmployeeRelations.stream().map(MpAgentEmployeeRelationEntity::getAgentId).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@ -38,5 +38,5 @@ public interface IMpAgentActivityParticipantService extends IService<MpAgentActi
|
||||
* @param activityId 活动ID
|
||||
* @return 参与记录列表
|
||||
*/
|
||||
List<MpAgentActivityParticipantEntity> getOneByActivityId(Integer activityId);
|
||||
List<MpAgentActivityParticipantEntity> getListByActivityId(Integer activityId);
|
||||
}
|
||||
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代理商员工关联表 服务类
|
||||
@ -62,5 +64,5 @@ public interface IMpAgentEmployeeRelationService extends IService<MpAgentEmploye
|
||||
* @param userId 用户ID
|
||||
* @return 代理商员工关联
|
||||
*/
|
||||
MpAgentEmployeeRelationEntity getOneByUserId(Integer userId);
|
||||
List<MpAgentEmployeeRelationEntity> getListByUserId(Integer userId);
|
||||
}
|
||||
@ -48,4 +48,11 @@ public interface IMpAgentService extends IService<MpAgentEntity> {
|
||||
* @return 代理商数量
|
||||
*/
|
||||
long getCountByPhone(String phone);
|
||||
|
||||
/**
|
||||
* 根据用户ID获取代理商列表
|
||||
* @param userId 用户ID
|
||||
* @return 代理商列表
|
||||
*/
|
||||
List<MpAgentEntity> getListByUserId(Integer userId);
|
||||
}
|
||||
@ -44,7 +44,7 @@ public class MpAgentActivityParticipantServiceImpl extends ServiceImpl<MpAgentAc
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MpAgentActivityParticipantEntity> getOneByActivityId(Integer activityId) {
|
||||
public List<MpAgentActivityParticipantEntity> getListByActivityId(Integer activityId) {
|
||||
return super.list(new LambdaQueryWrapper<MpAgentActivityParticipantEntity>().eq(MpAgentActivityParticipantEntity::getActivityId, activityId));
|
||||
}
|
||||
}
|
||||
@ -95,7 +95,8 @@ public class MpAgentEmployeeRelationServiceImpl extends ServiceImpl<MpAgentEmplo
|
||||
}
|
||||
|
||||
@Override
|
||||
public MpAgentEmployeeRelationEntity getOneByUserId(Integer userId) {
|
||||
return super.getOne(new LambdaQueryWrapper<>(MpAgentEmployeeRelationEntity.class).eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, userId));
|
||||
public List<MpAgentEmployeeRelationEntity> getListByUserId(Integer userId) {
|
||||
return super.list(new LambdaQueryWrapper<MpAgentEmployeeRelationEntity>()
|
||||
.eq(MpAgentEmployeeRelationEntity::getEmployeeUserId, userId));
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,12 @@
|
||||
package com.seer.teach.mp.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.seer.teach.common.enums.RoleEnum;
|
||||
import com.seer.teach.mp.entity.MpAgentEmployeeRelationEntity;
|
||||
import com.seer.teach.mp.entity.MpAgentEntity;
|
||||
import com.seer.teach.mp.mapper.MpAgentMapper;
|
||||
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;
|
||||
@ -13,6 +16,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 代理商服务实现类
|
||||
@ -23,6 +28,7 @@ import java.util.List;
|
||||
public class MpAgentServiceImpl extends ServiceImpl<MpAgentMapper, MpAgentEntity> implements IMpAgentService {
|
||||
|
||||
private final UserInfoServiceApi userInfoServiceApi;
|
||||
private final IMpAgentEmployeeRelationService mpAgentEmployeeRelationService;
|
||||
|
||||
@Override
|
||||
public MpAgentEntity getAgentById(Integer id) {
|
||||
@ -69,4 +75,18 @@ public class MpAgentServiceImpl extends ServiceImpl<MpAgentMapper, MpAgentEntity
|
||||
public long getCountByPhone(String phone) {
|
||||
return this.lambdaQuery().eq(MpAgentEntity::getContactPhone, phone).count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MpAgentEntity> getListByUserId(Integer userId) {
|
||||
List<MpAgentEntity> list = this.lambdaQuery().eq(MpAgentEntity::getContactUserId, userId).list();
|
||||
if(CollectionUtil.isEmpty(list)){
|
||||
List<MpAgentEmployeeRelationEntity> relationEntities = mpAgentEmployeeRelationService.getListByUserId(userId);
|
||||
if(CollectionUtil.isNotEmpty(relationEntities)){
|
||||
Set<Integer> agentIds = relationEntities.stream().map(MpAgentEmployeeRelationEntity::getAgentId).collect(Collectors.toSet());
|
||||
return this.lambdaQuery().in(MpAgentEntity::getId, agentIds).list();
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user