From 2bc35df79fca920ad584a82b5ea7b35b6ca7b8a0 Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期三, 15 一月 2025 10:12:57 +0800 Subject: [PATCH] 12.18 --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 55 insertions(+), 5 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 dac6a7d..553522d 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 @@ -3,17 +3,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.account.api.model.AgentApplication; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserChangeLog; import com.ruoyi.account.dto.AgentQuery; +import com.ruoyi.account.api.model.VipSettingDto; import com.ruoyi.account.service.AgentApplicationService; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserChangeLogService; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.other.api.domain.BaseSetting; import com.ruoyi.other.api.domain.VipSetting; +import com.ruoyi.other.api.feignClient.BaseSettingClient; +import com.ruoyi.other.api.feignClient.VipSettingClient; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.web.bind.annotation.*; @@ -35,6 +39,8 @@ private AgentApplicationService agentApplicationService; @Resource private AppUserService appUserService; + @Resource + private BaseSettingClient baseSettingClient; @PostMapping("/apply") @ApiOperation(value = "会员申请", tags = {"会员中心-小程序"}) @@ -46,14 +52,26 @@ @PostMapping("/page") @ApiOperation(value = "会员申请列表", tags = {"后台"}) public R<IPage<AgentApplication>> page(@RequestBody AgentQuery agentQuery) { - - return R.ok(agentApplicationService.pageList(agentQuery)); + IPage<AgentApplication> agentApplicationIPage = agentApplicationService.pageList(agentQuery); + for (AgentApplication record : agentApplicationIPage.getRecords()) { + AppUser byId = appUserService.getById(record.getAppUserId()); + if (byId!=null){ + record.setVipId(byId.getVipId()); + } + } + return R.ok(agentApplicationIPage); } + @Resource + private VipSettingClient vipSettingClient; @GetMapping("/detail") @ApiOperation(value = "会员申请详情", tags = {"会员中心-小程序"}) public R<AgentApplication> detail(@RequestParam Long id) { - - return R.ok(agentApplicationService.getById(id)); + AgentApplication agentApplication = agentApplicationService.getById(id); + R<VipSetting> vipSetting = vipSettingClient.getVipSetting(agentApplication.getApplicationVipId()); + VipSettingDto vipSettingDto = new VipSettingDto(); + BeanUtils.copyProperties(vipSetting.getData(),vipSettingDto); + agentApplication.setVipSettingDto(vipSettingDto); + return R.ok(agentApplication); } @Resource private UserChangeLogService userChangeLogService; @@ -80,9 +98,41 @@ userChangeLogService.save(userChangeLog); //变更会员等级 byId1.setVipId(byId.getApplicationVipId()); + appUserService.updateById(byId1); + + // 当用户为合伙人时,计算合伙人积分和培育积分 + Integer vipId = byId1.getVipId(); + if (vipId == 7){ + // 当前用户计算合伙人积分 + R<VipSetting> vipSetting = vipSettingClient.getVipSetting(vipId); + setPoint(vipSetting, byId1, byId1.getShopPoint(), byId1.getSharePoint()); + // 上级计算培育积分 + Long inviteUserId = byId1.getInviteUserId(); + AppUser byId2 = appUserService.getById(inviteUserId); + if (byId2 != null){ + setPoint(vipSetting, byId2, byId1.getShopPoint(), byId1.getSharePoint()); + } + } return R.ok(byId); } + private void setPoint(R<VipSetting> vipSetting, AppUser appUser, Integer shopPoint, Integer sharePoint) { + VipSetting vipSettingData = vipSetting.getData(); + Integer vipLevelUpShopRole = vipSettingData.getVipLevelUpShopRole(); + 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); + } + } + } + } + } -- Gitblit v1.7.1