From fe55cdb0c754e1a5e6b342dbc79c791b6172e4d4 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 3 Dec 2025 17:48:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E9=82=80=E8=AF=B7=E5=85=85=E5=80=BC=E4=BB=A3=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/message/OfficialNoticeTypeEnum.java | 15 +++ .../inner/asserts/team/TeamErrorCode.java | 15 +++ .../app/team/TeamBdRestController.java | 65 ++++++++++++ .../team/AdminInviteRechargeAgentExe.java | 98 +++++++++++++++++++ .../AdminInviteRechargeAgentProcessExe.java | 76 ++++++++++++++ .../app/service/team/TeamBdServiceImpl.java | 32 ++++++ .../other/app/service/team/TeamBdService.java | 25 +++++ .../entity/team/bd/MessageInviteGroup.java | 7 +- .../team/AdminRechargeAgentRelationDAO.java | 13 +++ .../team/AdminRechargeAgentRelation.java | 57 +++++++++++ .../AdminRechargeAgentRelationService.java | 36 +++++++ ...AdminRechargeAgentRelationServiceImpl.java | 38 +++++++ 12 files changed, 476 insertions(+), 1 deletion(-) create mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AdminInviteRechargeAgentExe.java create mode 100644 rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AdminInviteRechargeAgentProcessExe.java create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/team/AdminRechargeAgentRelationDAO.java create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/team/AdminRechargeAgentRelation.java create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/AdminRechargeAgentRelationService.java create mode 100644 rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/impl/AdminRechargeAgentRelationServiceImpl.java diff --git a/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java b/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java index b28eb701..b42da498 100644 --- a/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java +++ b/rc-service/rc-inner-api/external-inner/external-inner-model/src/main/java/com/red/circle/external/inner/model/enums/message/OfficialNoticeTypeEnum.java @@ -222,6 +222,21 @@ public enum OfficialNoticeTypeEnum { */ VIOLATION_ADJUST, + /** + * 管理员邀请充值代理. + */ + ADMIN_INVITE_RECHARGE_AGENT, + + /** + * 用户同意管理员成为充值代理邀请. + */ + AGREE_ADMIN_INVITE_RECHARGE_AGENT, + + /** + * 用户拒绝管理员成为充值代理邀请. + */ + REFUSE_ADMIN_INVITE_RECHARGE_AGENT, + ; diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/team/TeamErrorCode.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/team/TeamErrorCode.java index 04f7bcb6..bfd99c87 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/team/TeamErrorCode.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/team/TeamErrorCode.java @@ -247,6 +247,21 @@ public enum TeamErrorCode implements IResponseErrorCode { * 用户是管理员 */ USER_IS_A_ADMIN(6055, "This user is a administrator."), + + /** + * 用户不是充值代理. + */ + USER_IS_NOT_RECHARGE_AGENT(6056, "User is not a recharge agent"), + + /** + * 用户已经是充值代理. + */ + USER_IS_ALREADY_A_RECHARGE_AGENT(6057, "User is already a recharge agent"), + + /** + * 用户不是管理员. + */ + USER_IS_NOT_ADMIN(6058, "User is not an administrator"), ; private final Integer code; diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java index d7b11c86..d982bf25 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java @@ -181,6 +181,71 @@ public class TeamBdRestController extends BaseController { teamBdService.inviteAgentCancel(id); } + /** + * 管理员邀请充值代理. + * + * @eo.name 管理员邀请充值代理. + * @eo.url /invite-recharge-agent + * @eo.method post + * @eo.request-type json + */ + @PostMapping("/invite-recharge-agent") + public void inviteRechargeAgent(@RequestBody @Validated DbLeaderInviteBdCmd cmd) { + teamBdService.inviteRechargeAgent(cmd); + } + + /** + * 获取被管理员邀请消息-邀请充值代理. + * + * @eo.name 获取被管理员邀请消息-邀请充值代理. + * @eo.url /invite-recharge-agent-message + * @eo.method get + * @eo.request-type formdata + */ + @GetMapping("/invite-recharge-agent-message") + public List listInviteRechargeAgentMessage(BdInviteQryCmd cmd) { + return teamBdService.listInviteRechargeAgentMessage(cmd); + } + + /** + * 获取邀请充值代理的消息-邀请充值代理. + * + * @eo.name 获取邀请充值代理的消息-邀请充值代理. + * @eo.url /invite-recharge-agent-message-own + * @eo.method get + * @eo.request-type formdata + */ + @GetMapping("/invite-recharge-agent-message-own") + public List listInviteRechargeAgentMessageOwn(BdInviteQryCmd cmd) { + return teamBdService.listInviteRechargeAgentMessageOwn(cmd); + } + + /** + * 邀请充值代理-撤销. + * + * @eo.name 邀请充值代理-撤销. + * @eo.url /invite-recharge-agent-cancel/{id} + * @eo.method post + * @eo.request-type formdata + */ + @PostMapping("/invite-recharge-agent-cancel/{id}") + public void inviteRechargeAgentCancel(@PathVariable("id") String id) { + teamBdService.inviteRechargeAgentCancel(id); + } + + /** + * 处理邀请-邀请充值代理. + * + * @eo.name 处理邀请-邀请充值代理. + * @eo.url /invite-recharge-agent-message-process + * @eo.method post + * @eo.request-type json + */ + @PostMapping("/invite-recharge-agent-message-process") + public void processInviteRechargeAgentMessage(@RequestBody @Validated DbInviteMessageProcessCmd cmd) { + teamBdService.processAdminInviteRechargeAgentMessage(cmd); + } + /** * 处理邀请-邀请BD. diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AdminInviteRechargeAgentExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AdminInviteRechargeAgentExe.java new file mode 100644 index 00000000..6caad342 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AdminInviteRechargeAgentExe.java @@ -0,0 +1,98 @@ +package com.red.circle.other.app.command.team; + +import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient; +import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd; +import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum; +import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; +import com.red.circle.other.app.dto.cmd.team.DbLeaderInviteBdCmd; +import com.red.circle.other.app.util.OfficialNoticeUtils; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; +import com.red.circle.other.infra.database.mongo.entity.team.bd.BdInviteAgentMessage; +import com.red.circle.other.infra.database.mongo.entity.team.bd.MessageInviteGroup; +import com.red.circle.other.infra.database.mongo.service.team.bd.BdInviteAgentMessageService; +import com.red.circle.other.infra.database.rds.service.sys.AdministratorService; +import com.red.circle.other.infra.database.rds.service.team.AdminRechargeAgentRelationService; +import com.red.circle.other.inner.asserts.team.TeamErrorCode; +import com.red.circle.other.inner.model.dto.user.UserProfileDTO; +import com.red.circle.tool.core.date.TimestampUtils; +import com.red.circle.tool.core.sequence.IdWorkerUtils; +import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 管理员邀请充值代理. + * + * @author tf + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class AdminInviteRechargeAgentExe { + + private final AdministratorService administratorService; + private final UserProfileGateway userProfileGateway; + private final OfficialNoticeClient officialNoticeClient; + private final UserProfileAppConvertor userProfileAppConvertor; + private final BdInviteAgentMessageService bdInviteAgentMessageService; + private final AdminRechargeAgentRelationService adminRechargeAgentRelationService; + private final FreightGoldClient freightGoldClient; + private final UserRegionGateway userRegionGateway; + + public void execute(DbLeaderInviteBdCmd cmd) { + + // 权限验证:必须是管理员 + ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION, + administratorService.existsAdmin(cmd.requiredReqUserId())); + + // 被邀请用户必须是充值代理 + ResponseAssert.isTrue(TeamErrorCode.USER_IS_NOT_RECHARGE_AGENT, + ResponseAssert.requiredSuccess(freightGoldClient.checkFreightAgent(cmd.getInviteUserId()))); + + // 该用户已经被邀请过了 + ResponseAssert.isFalse(TeamErrorCode.USER_IS_ALREADY_A_RECHARGE_AGENT, + adminRechargeAgentRelationService.checkRechargeAgent(cmd.getInviteUserId())); + + // 验证区域是否一致 + Boolean eqRegion = userRegionGateway.checkEqRegion(cmd.requiredReqUserId(), + cmd.getInviteUserId()); + ResponseAssert.isTrue(TeamErrorCode.NOT_INVITE_USER_ERROR, eqRegion); + + // 消息已发送 + ResponseAssert.isFalse(TeamErrorCode.MESSAGE_PROCESSED, + bdInviteAgentMessageService.existsWaitMessage(cmd.requiredReqUserId(), + cmd.getInviteUserId(), MessageInviteGroup.ADMIN_INVITE_RECHARGE_AGENT.name())); + + String messageId = IdWorkerUtils.getIdStr(); + bdInviteAgentMessageService.add(new BdInviteAgentMessage() + .setId(messageId) + .setSysOrigin(cmd.requireReqSysOrigin()) + .setUserId(cmd.requiredReqUserId()) + .setInviteUserId(cmd.getInviteUserId()) + .setMessage(cmd.getMessage()) + .setGroup(MessageInviteGroup.ADMIN_INVITE_RECHARGE_AGENT.name()) + .setCreateTime(TimestampUtils.now()) + .setUpdateTime(TimestampUtils.now()) + .setStatus(0) + .setExpiredTime(TimestampUtils.nowPlusDays(2)) + ); + + UserProfileDTO userProfile = userProfileAppConvertor.toUserProfileDTO( + userProfileGateway.getByUserId(cmd.requiredReqUserId()) + ); + + officialNoticeClient.send(NoticeExtTemplateTypeCmd.builder() + .toAccount(cmd.getInviteUserId()) + .noticeType(OfficialNoticeTypeEnum.ADMIN_INVITE_RECHARGE_AGENT) + .templateParam(OfficialNoticeUtils.buildUserProfile(userProfile)) + .expand(messageId) + .build() + ); + + } + +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AdminInviteRechargeAgentProcessExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AdminInviteRechargeAgentProcessExe.java new file mode 100644 index 00000000..02580a50 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/AdminInviteRechargeAgentProcessExe.java @@ -0,0 +1,76 @@ +package com.red.circle.other.app.command.team; + +import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.framework.core.response.ResponseErrorCode; +import com.red.circle.other.app.dto.cmd.team.DbInviteMessageProcessCmd; +import com.red.circle.other.infra.database.mongo.entity.team.bd.BdInviteAgentMessage; +import com.red.circle.other.infra.database.mongo.entity.team.bd.MessageInviteGroup; +import com.red.circle.other.infra.database.mongo.service.team.bd.BdInviteAgentMessageService; +import com.red.circle.other.infra.database.rds.entity.team.AdminRechargeAgentRelation; +import com.red.circle.other.infra.database.rds.service.sys.AdministratorService; +import com.red.circle.other.infra.database.rds.service.team.AdminRechargeAgentRelationService; +import com.red.circle.other.inner.asserts.team.TeamErrorCode; +import com.red.circle.tool.core.sequence.IdWorkerUtils; +import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient; +import java.util.Objects; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 处理管理员邀请充值代理消息. + * + * @author tf + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class AdminInviteRechargeAgentProcessExe { + + private final AdministratorService administratorService; + private final BdInviteAgentMessageService bdInviteAgentMessageService; + private final AdminRechargeAgentRelationService adminRechargeAgentRelationService; + private final FreightGoldClient freightGoldClient; + + public void execute(DbInviteMessageProcessCmd cmd) { + ResponseAssert.isTrue(ResponseErrorCode.REQUEST_PARAMETER_ERROR, cmd.getStatus() > 0); + BdInviteAgentMessage message = bdInviteAgentMessageService.getById(cmd.getId()); + ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_RECORD_INFO, message); + + ResponseAssert.isTrue(CommonErrorCode.NOT_FOUND_RECORD_INFO, + Objects.equals(message.getGroup(), MessageInviteGroup.ADMIN_INVITE_RECHARGE_AGENT.name())); + + // 被邀请用户必须是充值代理 + ResponseAssert.isTrue(TeamErrorCode.USER_IS_NOT_RECHARGE_AGENT, + ResponseAssert.requiredSuccess(freightGoldClient.checkFreightAgent(cmd.requiredReqUserId()))); + + // 该用户已经被邀请过了 + ResponseAssert.isFalse(TeamErrorCode.USER_IS_ALREADY_A_RECHARGE_AGENT, + adminRechargeAgentRelationService.checkRechargeAgent(cmd.requiredReqUserId())); + + ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION, + Objects.equals(message.getInviteUserId(), cmd.requiredReqUserId())); + ResponseAssert.isTrue(TeamErrorCode.MESSAGE_PROCESSED, Objects.equals(message.getStatus(), 0)); + + // 验证发起邀请的用户是否是管理员 + ResponseAssert.isTrue(TeamErrorCode.USER_IS_NOT_ADMIN, + administratorService.existsAdmin(message.getUserId())); + + ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE, bdInviteAgentMessageService. + updateStatus(cmd.getId(), message.getStatus(), cmd.getStatus(), + MessageInviteGroup.ADMIN_INVITE_RECHARGE_AGENT.name())); + + if (Objects.equals(cmd.getStatus(), 1)) { + + // 创建管理员与充值代理关系 + adminRechargeAgentRelationService.add(new AdminRechargeAgentRelation() + .setId(IdWorkerUtils.getId()) + .setSysOrigin(cmd.requireReqSysOrigin()) + .setAdminUserId(message.getUserId()) + .setUserId(cmd.requiredReqUserId()) + ); + } + } + +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/team/TeamBdServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/team/TeamBdServiceImpl.java index 890f810c..d71a7ba7 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/team/TeamBdServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/team/TeamBdServiceImpl.java @@ -6,6 +6,8 @@ import com.red.circle.framework.dto.PageResult; import com.red.circle.other.app.command.team.query.*; import com.red.circle.other.app.command.team.BdAgentInviteExe; import com.red.circle.other.app.command.team.BdEnterSysExe; +import com.red.circle.other.app.command.team.AdminInviteRechargeAgentExe; +import com.red.circle.other.app.command.team.AdminInviteRechargeAgentProcessExe; import com.red.circle.other.app.command.team.BdInviteMessageProcessExe; import com.red.circle.other.app.command.team.BdLeaderInviteBdExe; import com.red.circle.other.app.command.team.BdLeaderInviteMessageProcessExe; @@ -14,6 +16,7 @@ import com.red.circle.other.app.dto.cmd.team.BdInviteQryCmd; import com.red.circle.other.app.dto.cmd.team.DbInviteAgentCmd; import com.red.circle.other.app.dto.cmd.team.DbInviteMessageProcessCmd; import com.red.circle.other.app.dto.cmd.team.DbLeaderInviteBdCmd; +import com.red.circle.other.infra.database.mongo.entity.team.bd.MessageInviteGroup; import java.util.List; import com.red.circle.other.inner.endpoint.team.bd.api.BdTeamInfoClientApi; @@ -44,6 +47,8 @@ public class TeamBdServiceImpl implements TeamBdService { private final BdInviteMessageProcessExe bdInviteMessageProcessCmdExe; private final BdLeaderInviteMessageProcessExe bdLeaderInviteMessageProcessCmdExe; private final BdListQryExe bdListQryExe; + private final AdminInviteRechargeAgentExe adminInviteRechargeAgentExe; + private final AdminInviteRechargeAgentProcessExe adminInviteRechargeAgentProcessExe; @Override public String getBdRole(AppExtCommand cmd) { @@ -129,4 +134,31 @@ public class TeamBdServiceImpl implements TeamBdService { public PageResult bdPage(BdTeamPageQryCmd qryCmd) { return bdListQryExe.pageResult(qryCmd); } + + @Override + public void inviteRechargeAgent(DbLeaderInviteBdCmd cmd) { + adminInviteRechargeAgentExe.execute(cmd); + } + + @Override + public List listInviteRechargeAgentMessage(BdInviteQryCmd cmd) { + cmd.setGroup(MessageInviteGroup.ADMIN_INVITE_RECHARGE_AGENT.name()); + return bdInviteMessageQryExe.execute(cmd); + } + + @Override + public List listInviteRechargeAgentMessageOwn(BdInviteQryCmd cmd) { + cmd.setGroup(MessageInviteGroup.ADMIN_INVITE_RECHARGE_AGENT.name()); + return bdInviteMessageQryExe.inviteMessageOwn(cmd); + } + + @Override + public void inviteRechargeAgentCancel(String id) { + bdAgentInviteCmdExe.cancel(id); + } + + @Override + public void processAdminInviteRechargeAgentMessage(DbInviteMessageProcessCmd cmd) { + adminInviteRechargeAgentProcessExe.execute(cmd); + } } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/team/TeamBdService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/team/TeamBdService.java index 971cfd5d..7060f78b 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/team/TeamBdService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/team/TeamBdService.java @@ -106,4 +106,29 @@ public interface TeamBdService { * @param id */ void inviteAgentCancel(String id); + + /** + * 管理员邀请充值代理. + */ + void inviteRechargeAgent(DbLeaderInviteBdCmd cmd); + + /** + * 获取被管理员邀请消息-邀请充值代理. + */ + List listInviteRechargeAgentMessage(BdInviteQryCmd cmd); + + /** + * 获取邀请充值代理的消息-邀请充值代理. + */ + List listInviteRechargeAgentMessageOwn(BdInviteQryCmd cmd); + + /** + * 邀请充值代理-撤销. + */ + void inviteRechargeAgentCancel(String id); + + /** + * 处理邀请-邀请充值代理. + */ + void processAdminInviteRechargeAgentMessage(DbInviteMessageProcessCmd cmd); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/entity/team/bd/MessageInviteGroup.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/entity/team/bd/MessageInviteGroup.java index 58ec6673..622dea53 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/entity/team/bd/MessageInviteGroup.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/entity/team/bd/MessageInviteGroup.java @@ -25,6 +25,11 @@ public enum MessageInviteGroup { /** * agent 邀请主播 */ - AGENT_INVITE_HOST + AGENT_INVITE_HOST, + + /** + * 管理员邀请充值代理. + */ + ADMIN_INVITE_RECHARGE_AGENT } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/team/AdminRechargeAgentRelationDAO.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/team/AdminRechargeAgentRelationDAO.java new file mode 100644 index 00000000..6a3239b5 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/dao/team/AdminRechargeAgentRelationDAO.java @@ -0,0 +1,13 @@ +package com.red.circle.other.infra.database.rds.dao.team; + +import com.red.circle.framework.mybatis.dao.BaseDAO; +import com.red.circle.other.infra.database.rds.entity.team.AdminRechargeAgentRelation; + +/** + * 管理员充值代理关系DAO. + * + * @author tf + */ +public interface AdminRechargeAgentRelationDAO extends BaseDAO { + +} diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/team/AdminRechargeAgentRelation.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/team/AdminRechargeAgentRelation.java new file mode 100644 index 00000000..43f58aee --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/team/AdminRechargeAgentRelation.java @@ -0,0 +1,57 @@ +package com.red.circle.other.infra.database.rds.entity.team; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.time.LocalDateTime; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 管理员充值代理关系表. + * + * @author tf + */ +@Data +@Accessors(chain = true) +@TableName("admin_recharge_agent_relation") +public class AdminRechargeAgentRelation { + + /** + * 主键标识. + */ + @TableId("id") + private Long id; + + /** + * 来源app. + */ + @TableField("sys_origin") + private String sysOrigin; + + /** + * 管理员用户ID. + */ + @TableField("admin_user_id") + private Long adminUserId; + + /** + * 充值代理用户ID. + */ + @TableField("user_id") + private Long userId; + + /** + * 创建时间. + */ + @TableField(value = "create_time", fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 修改时间. + */ + @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; + +} diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/AdminRechargeAgentRelationService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/AdminRechargeAgentRelationService.java new file mode 100644 index 00000000..f95d0938 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/AdminRechargeAgentRelationService.java @@ -0,0 +1,36 @@ +package com.red.circle.other.infra.database.rds.service.team; + +import com.red.circle.framework.mybatis.service.BaseService; +import com.red.circle.other.infra.database.rds.entity.team.AdminRechargeAgentRelation; + +/** + * 管理员充值代理关系Service. + * + * @author tf + */ +public interface AdminRechargeAgentRelationService extends BaseService { + + /** + * 根据用户ID查询关系. + * + * @param userId 充值代理用户ID + * @return 关系实体 + */ + AdminRechargeAgentRelation getByUserId(Long userId); + + /** + * 检查用户是否是充值代理. + * + * @param userId 用户ID + * @return true-是充值代理, false-不是 + */ + boolean checkRechargeAgent(Long userId); + + /** + * 添加关系. + * + * @param relation 关系实体 + */ + void add(AdminRechargeAgentRelation relation); + +} diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/impl/AdminRechargeAgentRelationServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/impl/AdminRechargeAgentRelationServiceImpl.java new file mode 100644 index 00000000..2cf05360 --- /dev/null +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/impl/AdminRechargeAgentRelationServiceImpl.java @@ -0,0 +1,38 @@ +package com.red.circle.other.infra.database.rds.service.team.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl; +import com.red.circle.other.infra.database.rds.dao.team.AdminRechargeAgentRelationDAO; +import com.red.circle.other.infra.database.rds.entity.team.AdminRechargeAgentRelation; +import com.red.circle.other.infra.database.rds.service.team.AdminRechargeAgentRelationService; +import org.springframework.stereotype.Service; + +/** + * 管理员充值代理关系Service实现. + * + * @author tf + */ +@Service +public class AdminRechargeAgentRelationServiceImpl extends + BaseServiceImpl implements + AdminRechargeAgentRelationService { + + @Override + public AdminRechargeAgentRelation getByUserId(Long userId) { + return getOne(new LambdaQueryWrapper() + .eq(AdminRechargeAgentRelation::getUserId, userId) + .last("LIMIT 1")); + } + + @Override + public boolean checkRechargeAgent(Long userId) { + return count(new LambdaQueryWrapper() + .eq(AdminRechargeAgentRelation::getUserId, userId)) > 0; + } + + @Override + public void add(AdminRechargeAgentRelation relation) { + save(relation); + } + +}