From 3c923d976c45df37ea752153e12107a3a29437e1 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 16 一月 2025 17:54:22 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/qijisheng --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java | 71 ++++++++++++++++++++++++++++------- 1 files changed, 57 insertions(+), 14 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java index 553522d..f50b3e3 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java @@ -1,7 +1,11 @@ package com.ruoyi.account.controller; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.api.model.AppUser; @@ -11,6 +15,7 @@ import com.ruoyi.account.service.AgentApplicationService; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserChangeLogService; +import com.ruoyi.account.service.VipCenterService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.core.web.controller.BaseController; @@ -20,6 +25,7 @@ import com.ruoyi.other.api.feignClient.VipSettingClient; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -41,6 +47,8 @@ private AppUserService appUserService; @Resource private BaseSettingClient baseSettingClient; + @Resource + private VipCenterService vipCenterService; @PostMapping("/apply") @ApiOperation(value = "会员申请", tags = {"会员中心-小程序"}) @@ -67,11 +75,35 @@ @ApiOperation(value = "会员申请详情", tags = {"会员中心-小程序"}) public R<AgentApplication> detail(@RequestParam Long id) { AgentApplication agentApplication = agentApplicationService.getById(id); + AppUser appUser = appUserService.getById(agentApplication.getAppUserId()); + agentApplication.setShopPoint(appUser.getShopPoint()); + agentApplication.setSharePoint(appUser.getSharePoint()); R<VipSetting> vipSetting = vipSettingClient.getVipSetting(agentApplication.getApplicationVipId()); VipSettingDto vipSettingDto = new VipSettingDto(); BeanUtils.copyProperties(vipSetting.getData(),vipSettingDto); agentApplication.setVipSettingDto(vipSettingDto); +// List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() +// .ne(AppUser::getStatus, 3) +// .eq(AppUser::getDelFlag, 0)); +// ArrayList<Long> userIds = new ArrayList<>(); +// userIds.add(appUser.getId()); +// getUserAncestorList(appUser,userIds,new ArrayList<>(),appUserList); + agentApplication.setVipId(agentApplication.getApplicationVipId()); return R.ok(agentApplication); + } + public void getUserAncestorList(AppUser user,List<Long> userIds, List<AppUser> children,List<AppUser> list) { + children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(children)){ + user.setCount1((user.getCount1() == null ? 0L : user.getCount1()) + children.stream().filter(e->e.getVipId() == 1).count()); + user.setCount2((user.getCount2() == null ? 0L : user.getCount2()) + children.stream().filter(e->e.getVipId() == 2).count()); + user.setCount3((user.getCount3() == null ? 0L : user.getCount3()) + children.stream().filter(e->e.getVipId() == 3).count()); + user.setCount4((user.getCount4() == null ? 0L : user.getCount4()) + children.stream().filter(e->e.getVipId() == 4).count()); + user.setCount5((user.getCount5() == null ? 0L : user.getCount5()) + children.stream().filter(e->e.getVipId() == 5).count()); + user.setCount6((user.getCount6() == null ? 0L : user.getCount6()) + children.stream().filter(e->e.getVipId() == 6).count()); + user.setCount7((user.getCount7() == null ? 0L : user.getCount7()) + children.stream().filter(e->e.getVipId() == 7).count()); + List<Long> userIdList = children.stream().map(AppUser::getId).collect(Collectors.toList()); + getUserAncestorList(user,userIdList, children,list); + } } @Resource private UserChangeLogService userChangeLogService; @@ -98,39 +130,50 @@ userChangeLogService.save(userChangeLog); //变更会员等级 byId1.setVipId(byId.getApplicationVipId()); - appUserService.updateById(byId1); // 当用户为合伙人时,计算合伙人积分和培育积分 Integer vipId = byId1.getVipId(); if (vipId == 7){ + R<BaseSetting> baseSetting = baseSettingClient.getBaseSetting(1); + BaseSetting data = baseSetting.getData(); + int basePoint = Integer.parseInt(data.getContent()); // 当前用户计算合伙人积分 R<VipSetting> vipSetting = vipSettingClient.getVipSetting(vipId); - setPoint(vipSetting, byId1, byId1.getShopPoint(), byId1.getSharePoint()); + Integer point = getPoint(vipSetting, byId1, basePoint); + byId1.setPartPoint(point); // 上级计算培育积分 + R<BaseSetting> baseSetting2 = baseSettingClient.getBaseSetting(1); + BaseSetting data2 = baseSetting2.getData(); + int basePoint2 = Integer.parseInt(data2.getContent()); Long inviteUserId = byId1.getInviteUserId(); AppUser byId2 = appUserService.getById(inviteUserId); if (byId2 != null){ - setPoint(vipSetting, byId2, byId1.getShopPoint(), byId1.getSharePoint()); + Integer point1 = getPoint(vipSetting, byId2, basePoint2); + byId2.setPartGrowPoint(point1); } } + + appUserService.updateById(byId1); return R.ok(byId); } - private void setPoint(R<VipSetting> vipSetting, AppUser appUser, Integer shopPoint, Integer sharePoint) { + private Integer getPoint(R<VipSetting> vipSetting, AppUser appUser, Integer basePoint) { VipSetting vipSettingData = vipSetting.getData(); Integer vipLevelUpShopRole = vipSettingData.getVipLevelUpShopRole(); + int i = 1; if (vipLevelUpShopRole == 1){ - Integer vipLevelUpShop = vipSettingData.getVipLevelUpShop(); - Integer vipLevelUpShare = vipSettingData.getVipLevelUpShare(); - if (shopPoint >=vipLevelUpShop && sharePoint >= vipLevelUpShare) { - R<BaseSetting> baseSetting = baseSettingClient.getBaseSetting(1); - BaseSetting data = baseSetting.getData(); - if (data != null){ - appUser.setPartPoint(Integer.parseInt(data.getContent())); - appUserService.updateById(appUser); - } - } + i += 1; } + Integer vipLevelUpNumRole = vipSettingData.getVipLevelUpNumRole(); + if (vipLevelUpNumRole == 1){ + i += 1; + } + + + if (vipCenterService.checkReadyToBePartner(appUser.getId())){ + return basePoint * i; + } + return 0; } -- Gitblit v1.7.1