| | |
| | | package com.ruoyi.account.controller; |
| | | import java.time.LocalDateTime; |
| | | 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; |
| | |
| | | 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; |
| | |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private BaseSettingClient baseSettingClient; |
| | | @Resource |
| | | private VipCenterService vipCenterService; |
| | | |
| | | @PostMapping("/apply") |
| | | @ApiOperation(value = "会员申请", tags = {"会员中心-小程序"}) |
| | |
| | | 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; |
| | | } |
| | | |
| | | |