From f0acb97e91f456c9b402977416e73951b708a157 Mon Sep 17 00:00:00 2001 From: jiangqs <343695869@qq.com> Date: 星期一, 19 六月 2023 23:23:23 +0800 Subject: [PATCH] 营销统计 --- ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java | 192 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 176 insertions(+), 16 deletions(-) diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java index 1af5cf0..15affd3 100644 --- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java +++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java @@ -25,17 +25,13 @@ import com.ruoyi.member.util.HttpUtils; import com.ruoyi.system.api.constant.AppErrorConstant; import com.ruoyi.system.api.constant.SecurityConstant; -import com.ruoyi.system.api.domain.dto.AppEditUserDto; -import com.ruoyi.system.api.domain.dto.AppMemberBindingDto; -import com.ruoyi.system.api.domain.dto.AppMemberGoodsTypeDto; -import com.ruoyi.system.api.domain.dto.AppMiniRegisterDto; +import com.ruoyi.system.api.domain.dto.*; import com.ruoyi.system.api.domain.poji.config.Activeness; import com.ruoyi.system.api.domain.poji.config.SysTag; import com.ruoyi.system.api.domain.poji.member.Member; import com.ruoyi.system.api.domain.poji.shop.Shop; import com.ruoyi.system.api.domain.poji.sys.SysUser; -import com.ruoyi.system.api.domain.vo.AppMiniRegisterVo; -import com.ruoyi.system.api.domain.vo.AppOrderTotalVo; +import com.ruoyi.system.api.domain.vo.*; import com.ruoyi.system.api.model.AppMiniLoginDto; import com.ruoyi.system.api.model.AppMiniLoginVo; import com.ruoyi.system.api.service.RemoteConfigService; @@ -106,6 +102,7 @@ @Resource private MemberArchiveService memberArchiveService; + /** * @description: TODO @@ -645,7 +642,7 @@ * @return */ private String createMemberNo(){ - int memberTotal = memberMapper.selectCount(new LambdaQueryWrapper<Member>().eq(Member::getDelFlag, 0)); + int memberTotal = memberMapper.selectCount(new LambdaQueryWrapper<Member>()); String memberNo = CodeFactoryUtil.getMemberNo(Long.valueOf(memberTotal+1)); return memberNo; } @@ -661,14 +658,20 @@ public List<MgtMemberPageVo> pageMgtMember(Page page,MgtMemberPageDto merMemberPageDto){ List<Activeness> activenessList = remoteConfigService.listActiveness().getData(); Date nowDay = new Date(); - //处理活跃度筛选 - activenessList.stream() - .filter(activeness -> activeness.getActivenessId().equals(merMemberPageDto.getActivenessId())) - .findFirst() - .ifPresent(activeness -> { - merMemberPageDto.setActStartDate(DateUtils.addDays(nowDay, activeness.getEndDay())); - merMemberPageDto.setActEndDate(DateUtils.addDays(nowDay, activeness.getStartDay())); - }); + if(merMemberPageDto.getActivenessId()!=null){ + //处理活跃度筛选 + activenessList.stream() + .filter(activeness -> activeness.getActivenessId().equals(merMemberPageDto.getActivenessId())) + .findFirst() + .ifPresent(activeness -> { + merMemberPageDto.setActStartDate(DateUtils.parseDateToStr("yyyy-MM-dd",DateUtils.addDays(nowDay, activeness.getEndDay()))); + merMemberPageDto.setActEndDate(DateUtils.parseDateToStr("yyyy-MM-dd",DateUtils.addDays(nowDay, activeness.getStartDay()))); + }); + } + //处理标签为正则表达 + if(StringUtils.isNotBlank(merMemberPageDto.getMemberTags())){ + merMemberPageDto.setMemberTags(merMemberPageDto.getMemberTags().replace(",","|")); + } //查询获取结果列表 List<MgtMemberPageVo> memberPageVoList = memberMapper.pageMgtMember(page, merMemberPageDto); //处理活跃度返回 @@ -738,7 +741,7 @@ String memberUserIds = mgtMemberRelDelDto.getMemberUserIds(); String[] memberUserIdArr = memberUserIds.split(","); for(String str : memberUserIdArr) { - Member member = this.getById(Long.valueOf(str)); + Member member = this.getByUserId(Long.valueOf(str)); member.setBindingFlag(0); member.setUpdateTime(new Date()); member.setUpdateUserId(mgtMemberRelDelDto.getUserId()); @@ -883,5 +886,162 @@ memberMapper.deleteMemberTag(memberTag); } + /** + * @description 通过发送类型获取userId + * @author jqs + * @date 2023/6/13 17:53 + * @param sendType + * @return List<Long> + */ + @Override + public List<Long> listIdBySendType(Integer sendType){ + //1.手动领取2.全部用户3.会员用户4非会员用户5自定义 + return memberMapper.listIdBySendType(sendType); + } + /** + * @description 通过ids获取用户简易返回 + * @author jqs + * @date 2023/6/16 11:06 + * @param userIds + * @return List<MgtSimpleMemberVo> + */ + @Override + public List<MgtSimpleMemberVo> listSimpleVoByIds(String userIds){ + return memberMapper.listSimpleVoByIds(userIds); + } + + /** + * @description + * @author jqs + * @date 2023/6/16 12:41 + * @param mgtUserIdByKeywordDto + * @return MgtUserIdByKeywordVo + */ + @Override + public MgtUserIdByKeywordVo getUserIdByKeyword(MgtUserIdByKeywordDto mgtUserIdByKeywordDto){ + MgtUserIdByKeywordVo mgtUserIdByKeywordVo = new MgtUserIdByKeywordVo(); + List<Long> userIdList = memberMapper.getUserIdByKeyword(mgtUserIdByKeywordDto); + if(userIdList!=null&&!userIdList.isEmpty()){ + String userIdStr = userIdList.stream() + .map(Object::toString) + .collect(Collectors.joining(",")); + mgtUserIdByKeywordVo.setUserIds(userIdStr); + } + return mgtUserIdByKeywordVo; + } + + /** + * @description boardMemberTotal + * @param + * @return MgtBulletinBoardVo + * @author jqs34 + * @date 2023/6/18 16:45 + */ + @Override + public MgtBulletinBoardVo boardMemberTotal(){ + MgtBulletinBoardVo mgtBulletinBoardVo = new MgtBulletinBoardVo(); + mgtBulletinBoardVo.setMemberTotal(memberMapper.memberTotal()); + mgtBulletinBoardVo.setMemberToday(memberMapper.memberToday()); + return mgtBulletinBoardVo; + } + + /** + * @description 会员人数统计 + * @author jqs + * @date 2023/6/19 15:26 + * @param + * @return MgtTotalMemberTotalVo + */ + @Override + public MgtTotalMemberTotalVo getTotalMemberTotal(MgtBaseShopDto mgtBaseShopDto){ + Date nowDay = DateUtils.getNowDate(); + // 获取店铺ID + Long shopId = mgtBaseShopDto.getShopId(); + // 获取总会员数和不同年龄段的会员数 + MgtTotalMemberTotalVo mgtTotalMemberTotalVo = memberMapper.getTotalMemberTotal(mgtBaseShopDto); + MgtAgeTotalVo mgtAgeTotalVo = memberMapper.getTotalMemberTotalAge(mgtBaseShopDto); + // 年龄段数组 + String[] ageKey = {"<20", "21-30", "31-40", "41-50", ">50"}; + // 不同年龄段的会员数数组 + Integer[] ageValue = {mgtAgeTotalVo.getTenAge(), mgtAgeTotalVo.getTwentyAge(), mgtAgeTotalVo.getThirtyAge(), mgtAgeTotalVo.getFortyAge(), mgtAgeTotalVo.getFiftyAge()}; + // 设置年龄段数组和不同年龄段的会员数数组 + mgtTotalMemberTotalVo.setAgeKey(ageKey); + mgtTotalMemberTotalVo.setAgeValue(ageValue); + // 获取不同护理类型的会员数 + List<MgtMapTotalVo> nurseTotalVos = memberMapper.getTotalMemberTotalNurse(mgtBaseShopDto); + if (nurseTotalVos != null && nurseTotalVos.size() > 0) { + String[] nurseKey = new String[nurseTotalVos.size()]; + Integer[] nurseValue = new Integer[nurseTotalVos.size()]; + // 遍历不同护理类型的会员数列表,设置护理类型数组和对应的会员数数组 + for (int i = 0; i < nurseTotalVos.size(); i++) { + nurseKey[i] = nurseTotalVos.get(i).getMapKey(); + nurseValue[i] = nurseTotalVos.get(i).getMapValue(); + } + mgtTotalMemberTotalVo.setNurseKey(nurseKey); + mgtTotalMemberTotalVo.setNurseValue(nurseValue); + } + // 获取不同商品类型的会员数 + List<MgtMapTotalVo> goodsTypeTotalVos = memberMapper.getTotalMemberTotalGoodsType(mgtBaseShopDto); + if (goodsTypeTotalVos != null && goodsTypeTotalVos.size() > 0) { + String[] goodsTypeKey = new String[goodsTypeTotalVos.size()]; + Integer[] goodsTypeValue = new Integer[goodsTypeTotalVos.size()]; + // 遍历不同商品类型的会员数列表,设置商品类型数组和对应的会员数数组 + for (int i = 0; i < goodsTypeTotalVos.size(); i++) { + goodsTypeKey[i] = goodsTypeTotalVos.get(i).getMapKey(); + goodsTypeValue[i] = goodsTypeTotalVos.get(i).getMapValue(); + } + mgtTotalMemberTotalVo.setGoodsTypeKey(goodsTypeKey); + mgtTotalMemberTotalVo.setGoodsTypeValue(goodsTypeValue); + } + // 获取不同活跃度的会员数 + List<Activeness> activenessList = remoteConfigService.listActiveness().getData(); + if (activenessList != null && !activenessList.isEmpty()) { + String[] activenessKey = new String[activenessList.size()]; + Integer[] activenessValue = new Integer[activenessList.size()]; + Activeness activeness; + String actStartDate; + String actEndDate; + Integer count; + // 遍历不同活跃度列表,设置活跃度数组和对应的会员数数组 + for (int i = 0; i < activenessList.size(); i++) { + activeness = activenessList.get(i); + actStartDate = DateUtils.parseDateToStr("yyyy-MM-dd", DateUtils.addDays(nowDay, activeness.getEndDay())); + actEndDate = DateUtils.parseDateToStr("yyyy-MM-dd", DateUtils.addDays(nowDay, activeness.getStartDay())); + count = memberMapper.getTotalMemberTotalActiveness(shopId, actStartDate, actEndDate); + activenessKey[i] = activeness.getActivenessName(); + activenessValue[i] = count; + } + mgtTotalMemberTotalVo.setActivenessKey(activenessKey); + mgtTotalMemberTotalVo.setActivenessValue(activenessValue); + } + //获取会员消费排名 + List<MgtMapTotalVo> memberPayList = memberMapper.getTotalMemberRankPay(mgtBaseShopDto); + if (memberPayList != null && memberPayList.size() > 0) { + String[] memberPayKey = new String[memberPayList.size()]; + Integer[] memberPayValue = new Integer[memberPayList.size()]; + // 遍历不同商品类型的会员数列表,设置商品类型数组和对应的会员数数组 + for (int i = 0; i < memberPayList.size(); i++) { + memberPayKey[i] = memberPayList.get(i).getMapKey(); + memberPayValue[i] = memberPayList.get(i).getMapValue(); + } + mgtTotalMemberTotalVo.setOrderRankKey(memberPayKey); + mgtTotalMemberTotalVo.setOrderRankValue(memberPayValue); + } + //获取来源渠道排名 + List<MgtMapTotalVo> customerSourceList = memberMapper.getTotalMemberRankCustomerSource(mgtBaseShopDto); + if (customerSourceList != null && customerSourceList.size() > 0) { + String[] customerSourceKey = new String[customerSourceList.size()]; + Integer[] customerSourceValue = new Integer[customerSourceList.size()]; + // 遍历不同商品类型的会员数列表,设置商品类型数组和对应的会员数数组 + for (int i = 0; i < customerSourceList.size(); i++) { + customerSourceKey[i] = customerSourceList.get(i).getMapKey(); + customerSourceValue[i] = customerSourceList.get(i).getMapValue(); + } + mgtTotalMemberTotalVo.setCustomerSourceKey(customerSourceKey); + mgtTotalMemberTotalVo.setCustomerSourceValue(customerSourceValue); + } + // 返回总会员数和不同类型会员数的统计结果 + return mgtTotalMemberTotalVo; + } } -- Gitblit v1.7.1