| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.account.service.VipCenterService; |
| | | import com.ruoyi.account.service.VipSettingService; |
| | | import com.ruoyi.account.vo.vip.Level; |
| | | import com.ruoyi.account.vo.vip.VipLevel; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | 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; |
| | |
| | | private VipCenterService vipCenterService; |
| | | @Resource |
| | | private VipGoodClient vipGoodClient; |
| | | @Resource |
| | | private GoodsClient goodsClient; |
| | | |
| | | |
| | | @GetMapping("getVipLevelList") |
| | |
| | | level.setVipDesc(baseSetting.getContent()); |
| | | |
| | | R<List<VipGood>> vipGoodR = vipGoodsMap.get(vipSetting.getId()); |
| | | if (R.isSuccess(vipGoodR)) { |
| | | List<VipGood> vipGoodList = vipGoodR.getData(); |
| | | 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); |
| | | } |
| | | }); |
| | | level.setGoodsNames(goodsNames); |
| | | } |
| | | if (R.isError(vipGoodR)) { |
| | | throw new ServiceException("会员商品获取失败"); |
| | | } |
| | | List<VipGood> vipGoodList = vipGoodR.getData(); |
| | | if (vipGoodList != null && !vipGoodList.isEmpty()) { |
| | | List<String> goodsNames = new ArrayList<>(); |
| | | vipGoodList.forEach(vipGood -> { |
| | | Goods goods = JSON.parseObject(vipGood.getGood_json(), Goods.class); |
| | | goodsNames.add(goods.getName()); |
| | | }); |
| | | level.setGoodsNames(goodsNames); |
| | | } |
| | | levelList.add(level); |
| | | }); |
| | |
| | | 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); |
| | | R<GoodsVip> goodsVipR = goodsVipClient.getGoodsVip(null, vipId); |
| | | result.put(vipId, goodsVipR); |
| | | } |
| | | return result; |