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 | 47 +++++++++++++++++++++++------------------------ 1 files changed, 23 insertions(+), 24 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 04feab8..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; @@ -18,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; @@ -45,6 +51,10 @@ private VipGoodClient vipGoodClient; @Resource private GoodsClient goodsClient; + @Resource + private AppUserService appUserService; + @Resource + private UserClickLogService userClickLogService; @GetMapping("getVipLevelList") @@ -83,6 +93,7 @@ vipSettingList.forEach(vipSetting -> { Level level = new Level(); + level.setName(vipSetting.getVipName()); BeanUtils.copyBeanProp(level, vipSetting); level.setVipDesc(baseSetting.getContent()); @@ -94,12 +105,7 @@ if (vipGoodList != null && !vipGoodList.isEmpty()) { List<String> goodsNames = new ArrayList<>(); vipGoodList.forEach(vipGood -> { - Integer goodId = vipGood.getGoodId(); - R<Goods> goodsR = goodsClient.getGoodsById(goodId); - if (R.isError(goodsR)) { - throw new ServiceException("商品信息获取失败"); - } - Goods goods = goodsR.getData(); + Goods goods = JSON.parseObject(vipGood.getGood_json(), Goods.class); goodsNames.add(goods.getName()); }); level.setGoodsNames(goodsNames); @@ -109,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); @@ -126,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) { @@ -145,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