|
@@ -100,68 +100,79 @@ public class PushMsgStrategyServiceImpl extends ServiceImpl<PushMsgStrategyMappe
|
|
|
}
|
|
|
|
|
|
private boolean strategyCheck(PushMsgStrategy pushMsgStrategy, PushMsgParam param, UserDTO userDTO) {
|
|
|
- //渠道限制不为空, 且不是全渠道
|
|
|
- if (pushMsgStrategy.getAgentType() != null
|
|
|
- && !Objects.equals(pushMsgStrategy.getAgentType(), PushMsgAgentTypeEnum.PUSH_MSG_AGENT_ALL.getValue())) {
|
|
|
- //只允许自然量
|
|
|
- if (Objects.equals(pushMsgStrategy.getAgentType(), PushMsgAgentTypeEnum.PUSH_MSG_AGENT_DEFAULT.getValue())
|
|
|
- && !Objects.equals(userDTO.getAgentId(), Agent.DEFAULT_AGENT)) {
|
|
|
- return Boolean.FALSE;
|
|
|
+ try {
|
|
|
+ //渠道限制不为空, 且不是全渠道
|
|
|
+ if (pushMsgStrategy.getAgentType() != null
|
|
|
+ && !Objects.equals(pushMsgStrategy.getAgentType(), PushMsgAgentTypeEnum.PUSH_MSG_AGENT_ALL.getValue())) {
|
|
|
+ //只允许自然量
|
|
|
+ if (Objects.equals(pushMsgStrategy.getAgentType(), PushMsgAgentTypeEnum.PUSH_MSG_AGENT_DEFAULT.getValue())
|
|
|
+ && !Objects.equals(userDTO.getAgentId(), Agent.DEFAULT_AGENT)) {
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+ //只允许非自然量
|
|
|
+ if (Objects.equals(pushMsgStrategy.getAgentType(), PushMsgAgentTypeEnum.PUSH_MSG_AGENT_UN_DEFAULT.getValue())
|
|
|
+ && Objects.equals(userDTO.getAgentId(), Agent.DEFAULT_AGENT)) {
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
}
|
|
|
- //只允许非自然量
|
|
|
- if (Objects.equals(pushMsgStrategy.getAgentType(), PushMsgAgentTypeEnum.PUSH_MSG_AGENT_UN_DEFAULT.getValue())
|
|
|
- && Objects.equals(userDTO.getAgentId(), Agent.DEFAULT_AGENT)) {
|
|
|
+ log.error("1. 渠道判断结束");
|
|
|
+ //判断注册时间, 是否在最大限制之内
|
|
|
+ if (pushMsgStrategy.getRegDayMax() != null
|
|
|
+ && userDTO.getCreateTime().plusDays(pushMsgStrategy.getRegDayMax()).isBefore(LocalDateTime.now())) {
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
- }
|
|
|
- //判断注册时间, 是否在最大限制之内
|
|
|
- if (pushMsgStrategy.getRegDayMax() != null
|
|
|
- && userDTO.getCreateTime().plusDays(pushMsgStrategy.getRegDayMax()).isBefore(LocalDateTime.now())) {
|
|
|
- return Boolean.FALSE;
|
|
|
- }
|
|
|
- //首个角色限制
|
|
|
- if (Objects.equals(pushMsgStrategy.getFirstRoleSwitch(), Boolean.TRUE)) {
|
|
|
- GameUserRole gameUserRole = gameUserRoleService.getOne(new LambdaQueryWrapper<GameUserRole>()
|
|
|
- .eq(GameUserRole::getUserId, param.getUserId())
|
|
|
- .eq(GameUserRole::getGameId, param.getGameId())
|
|
|
- .orderByAsc(GameUserRole::getCreateTime)
|
|
|
- .last("limit 1"));
|
|
|
- if (gameUserRole == null || !Objects.equals(gameUserRole.getRoleId(), param.getRoleId())) {
|
|
|
- return Boolean.FALSE;
|
|
|
+ log.error("2. 判断注册时间结束");
|
|
|
+ //首个角色限制
|
|
|
+ if (Objects.equals(pushMsgStrategy.getFirstRoleSwitch(), Boolean.TRUE)) {
|
|
|
+ GameUserRole gameUserRole = gameUserRoleService.getOne(new LambdaQueryWrapper<GameUserRole>()
|
|
|
+ .eq(GameUserRole::getUserId, param.getUserId())
|
|
|
+ .eq(GameUserRole::getGameId, param.getGameId())
|
|
|
+ .orderByAsc(GameUserRole::getCreateTime)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (gameUserRole == null || !Objects.equals(gameUserRole.getRoleId(), param.getRoleId())) {
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //判断最小充值金额
|
|
|
- if (pushMsgStrategy.getRechargeMoneyMin() != null) {
|
|
|
- GameUserRole gameUserRole = gameUserRoleService.getOne(new LambdaQueryWrapper<GameUserRole>()
|
|
|
- .eq(GameUserRole::getUserId, param.getUserId())
|
|
|
- .eq(GameUserRole::getGameId, param.getGameId())
|
|
|
- .eq(GameUserRole::getRoleId, param.getRoleId()));
|
|
|
- if (gameUserRole.getRechargeMoney() == null
|
|
|
- || gameUserRole.getRechargeMoney().longValue() < pushMsgStrategy.getRechargeMoneyMin()) {
|
|
|
- return Boolean.FALSE;
|
|
|
+ log.error("3. 首个角色限制结束");
|
|
|
+ //判断最小充值金额
|
|
|
+ if (pushMsgStrategy.getRechargeMoneyMin() != null) {
|
|
|
+ GameUserRole gameUserRole = gameUserRoleService.getOne(new LambdaQueryWrapper<GameUserRole>()
|
|
|
+ .eq(GameUserRole::getUserId, param.getUserId())
|
|
|
+ .eq(GameUserRole::getGameId, param.getGameId())
|
|
|
+ .eq(GameUserRole::getRoleId, param.getRoleId()));
|
|
|
+ if (gameUserRole.getRechargeMoney() == null
|
|
|
+ || gameUserRole.getRechargeMoney().longValue() < pushMsgStrategy.getRechargeMoneyMin()) {
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //判断是否已加企微
|
|
|
- if (Objects.equals(pushMsgStrategy.getExcludeAddWechat(), Boolean.TRUE)) {
|
|
|
- RoleOperate roleOperate = roleOperateService.getOne(new LambdaQueryWrapper<RoleOperate>()
|
|
|
- .eq(RoleOperate::getUserId, param.getUserId())
|
|
|
- .eq(RoleOperate::getGameId, param.getGameId())
|
|
|
- .eq(RoleOperate::getServerId, param.getServerId())
|
|
|
- .eq(RoleOperate::getRoleId, param.getRoleId()));
|
|
|
- if (Objects.equals(roleOperate.getIsAddCorpWechat(), 1)) {
|
|
|
+ log.error("4. 首个角色限制结束");
|
|
|
+ //判断是否已加企微
|
|
|
+ if (Objects.equals(pushMsgStrategy.getExcludeAddWechat(), Boolean.TRUE)) {
|
|
|
+ RoleOperate roleOperate = roleOperateService.getOne(new LambdaQueryWrapper<RoleOperate>()
|
|
|
+ .eq(RoleOperate::getUserId, param.getUserId())
|
|
|
+ .eq(RoleOperate::getGameId, param.getGameId())
|
|
|
+ .eq(RoleOperate::getServerId, param.getServerId())
|
|
|
+ .eq(RoleOperate::getRoleId, param.getRoleId()));
|
|
|
+ if (Objects.equals(roleOperate.getIsAddCorpWechat(), 1)) {
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.error("5. 首个角色限制结束");
|
|
|
+ //单策略推送次数
|
|
|
+ if (pushMsgStrategy.getSendCountMax() != null && pushMsgSendResultService.count(new LambdaQueryWrapper<PushMsgSendResult>()
|
|
|
+ .eq(PushMsgSendResult::getGameId, param.getGameId())
|
|
|
+ .eq(PushMsgSendResult::getStrategyId, pushMsgStrategy.getId())
|
|
|
+ .eq(PushMsgSendResult::getServerId, param.getServerId())
|
|
|
+ .eq(PushMsgSendResult::getRoleId, param.getRoleId())
|
|
|
+ .eq(PushMsgSendResult::getSendStatus, CpSendRoleResultEnum.CP_SEND_ROLE_RESULT_SUCCESS.getValue())
|
|
|
+ ) >= pushMsgStrategy.getSendCountMax()) {
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
+ log.error("6. 单策略推送次数结束");
|
|
|
+ return Boolean.TRUE;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("123, e : {}", e.getMessage(), e);
|
|
|
+ throw new RuntimeException("策略判断出现异常" + e.getMessage());
|
|
|
}
|
|
|
- //单策略推送次数
|
|
|
- if (pushMsgStrategy.getSendCountMax() != null && pushMsgSendResultService.count(new LambdaQueryWrapper<PushMsgSendResult>()
|
|
|
- .eq(PushMsgSendResult::getGameId, param.getGameId())
|
|
|
- .eq(PushMsgSendResult::getStrategyId, pushMsgStrategy.getId())
|
|
|
- .eq(PushMsgSendResult::getServerId, param.getServerId())
|
|
|
- .eq(PushMsgSendResult::getRoleId, param.getRoleId())
|
|
|
- .eq(PushMsgSendResult::getSendStatus, CpSendRoleResultEnum.CP_SEND_ROLE_RESULT_SUCCESS.getValue())
|
|
|
- ) >= pushMsgStrategy.getSendCountMax()) {
|
|
|
- return Boolean.FALSE;
|
|
|
- }
|
|
|
- return Boolean.TRUE;
|
|
|
}
|
|
|
}
|