|  |  | 
 |  |  | import cc.mrbird.febs.mall.YesOrNoEnum; | 
 |  |  | import cc.mrbird.febs.mall.dto.AdminSystemPayDto; | 
 |  |  | import cc.mrbird.febs.mall.entity.*; | 
 |  |  | import cc.mrbird.febs.mall.mapper.ChatAmountFlowMapper; | 
 |  |  | import cc.mrbird.febs.mall.mapper.ChatGroupMapper; | 
 |  |  | import cc.mrbird.febs.mall.mapper.ChatUserMapper; | 
 |  |  | import cc.mrbird.febs.mall.mapper.DataDictionaryMapper; | 
 |  |  | import cc.mrbird.febs.mall.mapper.*; | 
 |  |  | import cc.mrbird.febs.mall.service.IAdminChatService; | 
 |  |  | import cc.mrbird.febs.mall.vo.*; | 
 |  |  | import cc.mrbird.febs.rabbit.producter.AgentProducer; | 
 |  |  | import cn.hutool.core.collection.CollUtil; | 
 |  |  | import cn.hutool.core.date.DateUtil; | 
 |  |  | import cn.hutool.core.util.ObjectUtil; | 
 |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
 |  |  | 
 |  |  | import org.springframework.util.StringUtils; | 
 |  |  |  | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | @Slf4j | 
 |  |  | @Service | 
 |  |  | 
 |  |  |     private final ChatAmountFlowMapper chatAmountFlowMapper; | 
 |  |  |     private final DataDictionaryMapper dataDictionaryMapper; | 
 |  |  |     private final ChatGroupMapper chatGroupMapper; | 
 |  |  |     private final ChatVersionMapper chatVersionMapper; | 
 |  |  |     private final AgentProducer agentProducer; | 
 |  |  |     private final RedisUtils redisUtils; | 
 |  |  |  | 
 |  |  | 
 |  |  |         Page<AdminChatUserVo> page = new Page<>(request.getPageNum(), request.getPageSize()); | 
 |  |  |         IPage<AdminChatUserVo> chatUserIPage = this.baseMapper.selectUserListInPage(page, chatUser); | 
 |  |  |         return chatUserIPage; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public IPage<AdminChatUserPerkVo> getUserPerkList(ChatUser chatUser, QueryRequest request) { | 
 |  |  |         Page<AdminChatUserPerkVo> page = new Page<>(request.getPageNum(), request.getPageSize()); | 
 |  |  |         log.info(String.valueOf(chatUser.getIsRobot())); | 
 |  |  |         IPage<AdminChatUserPerkVo> chatUserPerkVoIPage = this.baseMapper.selectUserPerkListInPage(page, chatUser); | 
 |  |  |         List<AdminChatUserPerkVo> records = chatUserPerkVoIPage.getRecords(); | 
 |  |  |         if(CollUtil.isNotEmpty(records)){ | 
 |  |  |             for(AdminChatUserPerkVo adminChatUserPerkVo : records){ | 
 |  |  |                 Long userId = adminChatUserPerkVo.getUserId(); | 
 |  |  |                 List<AdminChatRedBagVo> group = this.baseMapper.selectListByMsgType(userId,"GROUP", null); | 
 |  |  | //                adminChatUserPerkVo.setGroupRedBagNum(CollUtil.isEmpty(group) ? 0 : group.size()); | 
 |  |  |                 BigDecimal redBagTotalAmount = group.stream().map(AdminChatRedBagVo::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); | 
 |  |  |                 adminChatUserPerkVo.setRedBagTotalAmount(redBagTotalAmount); | 
 |  |  |                 BigDecimal redBagAvaAmount = group.stream().map(AdminChatRedBagVo::getAmountAva).reduce(BigDecimal.ZERO, BigDecimal::add); | 
 |  |  |                 adminChatUserPerkVo.setRedBagAvaAmount(redBagAvaAmount); | 
 |  |  |                 BigDecimal getRedbagAmount = this.baseMapper.selectTotalTypeByUserId(userId,12, null, null); | 
 |  |  |                 adminChatUserPerkVo.setGetRedbagAmount(getRedbagAmount); | 
 |  |  |                 BigDecimal boomToAmount = this.baseMapper.selectTotalTypeByUserId(userId,10, null, null); | 
 |  |  |                 adminChatUserPerkVo.setBoomToAmount(boomToAmount); | 
 |  |  | //                BigDecimal boomFromAmount = this.baseMapper.selectTotalTypeByUserId(userId,9, null, null); | 
 |  |  | //                BigDecimal teamPerkAmount = this.baseMapper.selectTotalTypeByUserId(userId,7, null, null); | 
 |  |  | //                adminChatUserPerkVo.setTeamPerkAmount(teamPerkAmount.add(boomFromAmount)); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return chatUserPerkVoIPage; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public IPage<AdminVersionVo> getVersionList(ChatUser chatUser, QueryRequest request) { | 
 |  |  |         Page<AdminVersionVo> page = new Page<>(request.getPageNum(), request.getPageSize()); | 
 |  |  |         return this.baseMapper.selectVersionListInPage(page, chatUser); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public FebsResponse closeSwitchUseRobot(String id) { | 
 |  |  |         this.baseMapper.updateIsRobotByGroupId(id,0); | 
 |  |  |         return new FebsResponse().success(); | 
 |  |  | 
 |  |  |         chatGroup.setRedBagCnt(adminGroupInfoVo.getRedBagCnt()); | 
 |  |  |         chatGroup.setModelType(adminGroupInfoVo.getModelType()); | 
 |  |  |         chatGroupMapper.updateById(chatGroup); | 
 |  |  |         return new FebsResponse().success(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public FebsResponse updateVersionInfo(AdminVersionVo adminVersionVo) { | 
 |  |  |         ChatVersion chatVersion = chatVersionMapper.selectById(adminVersionVo.getId()); | 
 |  |  |         if(ObjectUtil.isEmpty(chatVersion)) { | 
 |  |  |             return new FebsResponse().fail().message("信息不存在"); | 
 |  |  |         } | 
 |  |  |         chatVersion.setVersion(adminVersionVo.getVersion()); | 
 |  |  |         chatVersion.setContent(adminVersionVo.getContent()); | 
 |  |  |         chatVersion.setUrl(adminVersionVo.getUrl()); | 
 |  |  |         chatVersion.setDescr(adminVersionVo.getDescr()); | 
 |  |  |         chatVersionMapper.updateById(chatVersion); | 
 |  |  |         return new FebsResponse().success(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         this.baseMapper.updateCreateGroupByUserId(userId,0); | 
 |  |  |         return new FebsResponse().success(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public FebsResponse openSwitchGetBoom(String userId) { | 
 |  |  |         ChatUser chatUser = this.baseMapper.selectByUserId(userId); | 
 |  |  |         if(ObjectUtil.isEmpty(chatUser)) { | 
 |  |  |             return new FebsResponse().fail().message("会员信息不存在"); | 
 |  |  |         } | 
 |  |  |         this.baseMapper.updateGetBoomByUserId(userId,1); | 
 |  |  |         return new FebsResponse().success(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public FebsResponse closeSwitchGetBoom(String userId) { | 
 |  |  |         ChatUser chatUser = this.baseMapper.selectByUserId(userId); | 
 |  |  |         if(ObjectUtil.isEmpty(chatUser)) { | 
 |  |  |             return new FebsResponse().fail().message("会员信息不存在"); | 
 |  |  |         } | 
 |  |  |         this.baseMapper.updateGetBoomByUserId(userId,0); | 
 |  |  |         return new FebsResponse().success(); | 
 |  |  |     } | 
 |  |  | } |