puzhibing
2024-12-11 ff2ef0cfdaf6c2217c728d4c7cd91ea47e1f3ac9
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenterController.java
@@ -1,7 +1,6 @@
package com.ruoyi.account.controller;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.account.service.AppUserService;
import com.ruoyi.account.service.VipCenterService;
import com.ruoyi.account.service.VipSettingService;
import com.ruoyi.account.vo.vip.Level;
@@ -14,15 +13,11 @@
import com.ruoyi.other.api.feignClient.GoodsVipClient;
import com.ruoyi.other.api.feignClient.RemoteVipSettingClient;
import com.ruoyi.other.api.feignClient.VipGoodClient;
import com.ruoyi.system.api.model.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
@@ -47,11 +42,9 @@
    @Resource
    private TokenService tokenService;
    @Resource
    private VipGoodClient vipGoodClient;
    @Resource
    private AppUserService appUserService;
    @Resource
    private VipCenterService vipCenterService;
    @Resource
    private VipGoodClient vipGoodClient;
    @GetMapping("getVipLevelList")
@@ -59,7 +52,7 @@
    public R<VipLevel> vipLevelList() {
        try {
            R<List<VipSetting>> r = remoteVipSettingClient.list();
            if (checkSuccess(r)) {
            if (R.isError(r)) {
                return R.fail("会员等级获取失败");
            }
            List<VipSetting> vipSettingList = r.getData();
@@ -68,7 +61,7 @@
            }
            R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(3);
            if (checkSuccess(baseSettingR)) {
            if (R.isError(baseSettingR)) {
                log.error("【会员设置说明】获取失败:{}", baseSettingR.getMsg());
                return R.fail("会员等级获取失败");
            }
@@ -130,30 +123,12 @@
    @GetMapping("/check")
    @ApiOperation(value = "会员申请检查", tags = {"会员中心-小程序"})
    public R<Boolean> check(@ApiParam("4:准代理,5:代理,6:总代理,7:合伙人") @RequestParam Integer type) {
        LoginUser loginUser = tokenService.getLoginUser();
        Long userid = loginUser.getUserid();
        if (type == 4){
            return R.ok(vipCenterService.checkReadyToBeProxy(userid));
        }else if (type == 5){
            return R.ok(vipCenterService.checkReadyToBeAgent(userid));
        }else if (type == 6){
            return R.ok(vipCenterService.checkReadyToBeTotalAgent(userid));
        }else if (type == 7){
            return R.ok(vipCenterService.checkReadyToBePartner(userid));
        }else {
            return R.fail("参数错误");
        }
        return R.ok(vipCenterService.check(type));
    }
    private boolean checkSuccess(R<?> r) {
        if (!R.isSuccess(r)) {
            log.error("请求失败: " + r.getMsg());
        }
        return R.isSuccess(r);
    }
    private Map<Integer, R<GoodsVip>> getGoodsVips(List<Integer> vipIds) {
        Map<Integer, R<GoodsVip>> result = new HashMap<>();
@@ -167,8 +142,8 @@
    private Map<Integer, R<List<VipGood>>> getVipGoods(List<Integer> vipIds) {
        Map<Integer, R<List<VipGood>>> result = new HashMap<>();
        for (Integer vipId : vipIds) {
//            R<List<VipGood>> vipGoodR = vipGoodClient.getVipGoodsByVipId(vipId);
//            result.put(vipId, vipGoodR);
            R<List<VipGood>> vipGoodR = vipGoodClient.getVipGoodsByVipId(vipId);
            result.put(vipId, vipGoodR);
        }
        return result;
    }