bd 邀请代理功能完成
This commit is contained in:
parent
1dde8a11af
commit
7eff5facf4
@ -20,11 +20,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -184,6 +180,14 @@ public class TeamBdRestController extends BaseController {
|
|||||||
teamBdService.inviteAgent(cmd);
|
teamBdService.inviteAgent(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bd 邀请代理-撤销
|
||||||
|
*/
|
||||||
|
@PostMapping("/invite-agent-cancel/{id}")
|
||||||
|
public void inviteAgentCancel(@PathVariable("id") String id) {
|
||||||
|
teamBdService.inviteAgentCancel(id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取被Bd邀请消息-邀请代理.
|
* 获取被Bd邀请消息-邀请代理.
|
||||||
*
|
*
|
||||||
@ -198,6 +202,15 @@ public class TeamBdRestController extends BaseController {
|
|||||||
return teamBdService.listBdInviteMessage(cmd);
|
return teamBdService.listBdInviteMessage(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取邀请消息记录-邀请代理.
|
||||||
|
*/
|
||||||
|
@GetMapping("/invite-message-own")
|
||||||
|
public List<BdInviteMessageCO> listBdInviteMessageOwn(BdInviteQryCmd cmd) {
|
||||||
|
cmd.setGroup(MessageInviteGroup.BD_INVITE_TEAM.name());
|
||||||
|
return teamBdService.listBdInviteMessageOwn(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理邀请-邀请代理.
|
* 处理邀请-邀请代理.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -103,6 +103,18 @@ public class BdAgentInviteExe {
|
|||||||
sendMessage(cmd);
|
sendMessage(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cancel(String id) {
|
||||||
|
BdInviteAgentMessage agentMessage = bdInviteAgentMessageService.getById(id);
|
||||||
|
if (agentMessage == null) {
|
||||||
|
throw new RuntimeException("message not found");
|
||||||
|
}
|
||||||
|
if (agentMessage.getStatus() != 0) {
|
||||||
|
throw new RuntimeException("This message cannot be canceled ");
|
||||||
|
}
|
||||||
|
|
||||||
|
bdInviteAgentMessageService.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
private void checkInvite(DbInviteAgentCmd cmd) {
|
private void checkInvite(DbInviteAgentCmd cmd) {
|
||||||
|
|
||||||
// 验证BD区域(如BD是代理则按照代理的区域来否则用BD本身指定的区域)与被邀请人区域是不是一致,
|
// 验证BD区域(如BD是代理则按照代理的区域来否则用BD本身指定的区域)与被邀请人区域是不是一致,
|
||||||
|
|||||||
@ -56,4 +56,32 @@ public class BdInviteMessageQryExe {
|
|||||||
).collect(Collectors.toList());
|
).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<BdInviteMessageCO> inviteMessageOwn(BdInviteQryCmd cmd) {
|
||||||
|
List<BdInviteAgentMessage> messages = bdInviteAgentMessageService.listInviteMessageOwn(cmd.requiredReqUserId(), cmd.getGroup(), 50);
|
||||||
|
if (CollectionUtils.isEmpty(messages)) {
|
||||||
|
return CollectionUtils.newArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO(
|
||||||
|
userProfileGateway.mapByUserIds(
|
||||||
|
messages.stream().map(BdInviteAgentMessage::getUserId).collect(Collectors.toSet())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return messages.stream().map(msg -> new BdInviteMessageCO()
|
||||||
|
.setId(msg.getId())
|
||||||
|
.setUserProfile(Optional.ofNullable(userProfileMap.get(msg.getUserId()))
|
||||||
|
.map(userProfile -> {
|
||||||
|
userProfile.setAccount(userProfile.actualAccount());
|
||||||
|
return userProfile;
|
||||||
|
})
|
||||||
|
.orElse(null))
|
||||||
|
.setMessage(msg.getMessage())
|
||||||
|
.setStatus(msg.getStatus())
|
||||||
|
.setGroup(msg.getGroup())
|
||||||
|
.setCreateTime(msg.getCreateTime())
|
||||||
|
.setExpiredTime(msg.getExpiredTime())
|
||||||
|
).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,11 @@ public class TeamBdServiceImpl implements TeamBdService {
|
|||||||
return bdInviteMessageQryExe.execute(cmd);
|
return bdInviteMessageQryExe.execute(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BdInviteMessageCO> listBdInviteMessageOwn(BdInviteQryCmd cmd) {
|
||||||
|
return bdInviteMessageQryExe.inviteMessageOwn(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inviteBd(DbLeaderInviteBdCmd cmd) {
|
public void inviteBd(DbLeaderInviteBdCmd cmd) {
|
||||||
bdLeaderInviteBdCmdExe.execute(cmd);
|
bdLeaderInviteBdCmdExe.execute(cmd);
|
||||||
@ -100,6 +105,11 @@ public class TeamBdServiceImpl implements TeamBdService {
|
|||||||
bdAgentInviteCmdExe.execute(cmd);
|
bdAgentInviteCmdExe.execute(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inviteAgentCancel(String id) {
|
||||||
|
bdAgentInviteCmdExe.cancel(id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processBdInviteMessage(DbInviteMessageProcessCmd cmd) {
|
public void processBdInviteMessage(DbInviteMessageProcessCmd cmd) {
|
||||||
bdInviteMessageProcessCmdExe.execute(cmd);
|
bdInviteMessageProcessCmdExe.execute(cmd);
|
||||||
|
|||||||
@ -61,6 +61,11 @@ public interface TeamBdService {
|
|||||||
*/
|
*/
|
||||||
List<BdInviteMessageCO> listBdInviteMessage(BdInviteQryCmd cmd);
|
List<BdInviteMessageCO> listBdInviteMessage(BdInviteQryCmd cmd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请消息列表-bd邀请信息.
|
||||||
|
*/
|
||||||
|
List<BdInviteMessageCO> listBdInviteMessageOwn(BdInviteQryCmd cmd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邀请成为BD-邀请BD.
|
* 邀请成为BD-邀请BD.
|
||||||
*/
|
*/
|
||||||
@ -85,4 +90,10 @@ public interface TeamBdService {
|
|||||||
* bd列表
|
* bd列表
|
||||||
*/
|
*/
|
||||||
PageResult<BdPageCO> bdPage(BdTeamPageQryCmd qryCmd);
|
PageResult<BdPageCO> bdPage(BdTeamPageQryCmd qryCmd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 撤销邀请
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void inviteAgentCancel(String id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,17 @@ public interface BdInviteAgentMessageService {
|
|||||||
*/
|
*/
|
||||||
List<BdInviteAgentMessage> listInviteMessage(Long inviteUserId, String group, Integer size);
|
List<BdInviteAgentMessage> listInviteMessage(Long inviteUserId, String group, Integer size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 撤销邀请
|
||||||
|
* @param messageId
|
||||||
|
*/
|
||||||
|
void remove(String messageId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取发起邀请的信息.
|
||||||
|
*/
|
||||||
|
List<BdInviteAgentMessage> listInviteMessageOwn(Long userId, String group, Integer size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否存在等待消息.
|
* 是否存在等待消息.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -38,6 +38,21 @@ public class BdInviteAgentMessageServiceImpl implements BdInviteAgentMessageServ
|
|||||||
BdInviteAgentMessage.class);
|
BdInviteAgentMessage.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BdInviteAgentMessage> listInviteMessageOwn(Long userId, String group,
|
||||||
|
Integer size) {
|
||||||
|
return mongoTemplate.find(
|
||||||
|
Query.query(Criteria.where("userId").is(userId).and("group").is(group))
|
||||||
|
.with(Sort.by(Sort.Order.desc("createTime")))
|
||||||
|
.limit(size),
|
||||||
|
BdInviteAgentMessage.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(String messageId) {
|
||||||
|
mongoTemplate.remove(Query.query(Criteria.where("id").is(messageId)), BdInviteAgentMessage.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean existsWaitMessage(Long userId, Long inviteUserId, String group) {
|
public boolean existsWaitMessage(Long userId, Long inviteUserId, String group) {
|
||||||
return mongoTemplate.exists(
|
return mongoTemplate.exists(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user