luodangjia
2025-01-14 cb4e092579de93dae99b39bd104410b7e58040d4
12.18
1个文件已修改
35 ■■■■■ 已修改文件
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AgentApplicationController.java
@@ -14,7 +14,9 @@
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;
@@ -37,6 +39,8 @@
    private AgentApplicationService agentApplicationService;
    @Resource
    private AppUserService appUserService;
    @Resource
    private BaseSettingClient baseSettingClient;
    @PostMapping("/apply")
    @ApiOperation(value = "会员申请", tags = {"会员中心-小程序"})
@@ -95,9 +99,40 @@
        //变更会员等级
        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);
                }
            }
        }
    }
}