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/VipCenterController.java |   56 +++++++++++++++++++++++++++-----------------------------
 1 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenterController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenterController.java
index ec1bce2..1be9a3f 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenterController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenterController.java
@@ -1,6 +1,11 @@
 package com.ruoyi.account.controller;
 
+import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.account.api.model.AppUser;
+import com.ruoyi.account.api.model.UserClickLog;
+import com.ruoyi.account.service.AppUserService;
+import com.ruoyi.account.service.UserClickLogService;
 import com.ruoyi.account.service.VipCenterService;
 import com.ruoyi.account.service.VipSettingService;
 import com.ruoyi.account.vo.vip.Level;
@@ -10,10 +15,7 @@
 import com.ruoyi.common.core.utils.bean.BeanUtils;
 import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.other.api.domain.*;
-import com.ruoyi.other.api.feignClient.BaseSettingClient;
-import com.ruoyi.other.api.feignClient.GoodsVipClient;
-import com.ruoyi.other.api.feignClient.RemoteVipSettingClient;
-import com.ruoyi.other.api.feignClient.VipGoodClient;
+import com.ruoyi.other.api.feignClient.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -21,6 +23,7 @@
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -46,6 +49,12 @@
     private VipCenterService vipCenterService;
     @Resource
     private VipGoodClient vipGoodClient;
+    @Resource
+    private GoodsClient goodsClient;
+    @Resource
+    private AppUserService appUserService;
+    @Resource
+    private UserClickLogService userClickLogService;
 
 
     @GetMapping("getVipLevelList")
@@ -84,6 +93,7 @@
 
             vipSettingList.forEach(vipSetting -> {
                 Level level = new Level();
+                level.setName(vipSetting.getVipName());
                 BeanUtils.copyBeanProp(level, vipSetting);
                 level.setVipDesc(baseSetting.getContent());
 
@@ -95,13 +105,8 @@
                 if (vipGoodList != null && !vipGoodList.isEmpty()) {
                     List<String> goodsNames = new ArrayList<>();
                     vipGoodList.forEach(vipGood -> {
-                        String goodJson = vipGood.getGoodJson();
-                        if (isValidJson(goodJson)) {
-                            Goods goods = JSONObject.parseObject(goodJson, Goods.class);
-                            goodsNames.add(goods.getName());
-                        } else {
-                            log.warn("JSON无效: " + goodJson);
-                        }
+                        Goods goods = JSON.parseObject(vipGood.getGood_json(), Goods.class);
+                        goodsNames.add(goods.getName());
                     });
                     level.setGoodsNames(goodsNames);
                 }
@@ -110,6 +115,16 @@
 
             vipLevel.setLevelList(levelList);
             vipLevel.setCurrentLevel(loginUserVipSetting.getId());
+
+            //添加操作记录
+            AppUser appUser = appUserService.getById(userid);
+            UserClickLog userClickLog = new UserClickLog();
+            userClickLog.setDelFlag(0);
+            userClickLog.setCreateTime(LocalDateTime.now());
+            userClickLog.setAppUserId(userid);
+            userClickLog.setVipId(appUser.getVipId());
+            userClickLogService.save(userClickLog);
+
             return R.ok(vipLevel);
         } catch (Exception e) {
             log.error("会员等级获取失败", e);
@@ -127,16 +142,6 @@
 
 
 
-
-    private Map<Integer, R<GoodsVip>> getGoodsVips(List<Integer> vipIds) {
-        Map<Integer, R<GoodsVip>> result = new HashMap<>();
-        for (Integer vipId : vipIds) {
-            R<GoodsVip> goodsVipR = goodsVipClient.getGoodsVip(vipId);
-            result.put(vipId, goodsVipR);
-        }
-        return result;
-    }
-
     private Map<Integer, R<List<VipGood>>> getVipGoods(List<Integer> vipIds) {
         Map<Integer, R<List<VipGood>>> result = new HashMap<>();
         for (Integer vipId : vipIds) {
@@ -146,13 +151,6 @@
         return result;
     }
 
-    private boolean isValidJson(String json) {
-        try {
-            JSONObject.parseObject(json);
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
-    }
+
 
 }

--
Gitblit v1.7.1