| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | 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.security.service.TokenService; |
| | | 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.RemoteVipSettingClient; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("/vipCenter") |
| | | @Api(tags = "小程序-会员中心") |
| | | @Log4j2 |
| | | public class VipCenter { |
| | | @Resource |
| | | private RemoteVipSettingClient remoteVipSettingClient; |
| | | @Resource |
| | | private BaseSettingClient baseSettingClient; |
| | | @Resource |
| | | private VipSettingService vipSettingService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | |
| | | @GetMapping("getVipLevelList") |
| | | @ApiOperation(value = "会员等级列表", tags = {"会员中心-小程序"}) |
| | | public R<VipLevel> vipLevelList() { |
| | | R<List<VipSetting>> r = remoteVipSettingClient.list(); |
| | | if (!R.isSuccess(r)){ |
| | | return R.fail("会员等级获取失败"); |
| | | } |
| | | List<VipSetting> vipSettingList = r.getData(); |
| | | if (vipSettingList == null || vipSettingList.isEmpty()){ |
| | | return R.fail("会员等级获取失败"); |
| | | } |
| | | R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(3); |
| | | if (!R.isSuccess(baseSettingR)){ |
| | | log.error("【会员设置说明】获取失败"); |
| | | return R.fail("会员等级获取失败"); |
| | | } |
| | | BaseSetting baseSetting = baseSettingR.getData(); |
| | | if (baseSetting == null){ |
| | | log.error("【会员设置说明】未设置"); |
| | | return R.fail("会员等级获取失败"); |
| | | } |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | VipSetting loginUserVipSetting = vipSettingService.getVipSettingByUserId(userid); |
| | | |
| | | VipLevel vipLevel = new VipLevel(); |
| | | List<Level> levelList = new ArrayList<>(); |
| | | vipSettingList.forEach(vipSetting -> { |
| | | Level level = new Level(); |
| | | level.setId(vipSetting.getId()); |
| | | level.setName(vipSetting.getVipName()); |
| | | level.setVipInfo(vipSetting.getVipInfo()); |
| | | level.setVipDesc(baseSetting.getContent()); |
| | | level.setVipLevelUpShop(vipSetting.getVipLevelUpShop()); |
| | | level.setVipLevelUpShare(vipSetting.getVipLevelUpShare()); |
| | | level.setKeepBuyDay(vipSetting.getKeepBuyDay()); |
| | | level.setKeepBuyPoint(vipSetting.getKeepBuyPoint()); |
| | | level.setKeepShareDay(vipSetting.getKeepShareDay()); |
| | | level.setKeepSharePoint(vipSetting.getKeepSharePoint()); |
| | | level.setKeepShopDay(vipSetting.getKeepShopDay()); |
| | | level.setKeepShopPoint(vipSetting.getKeepShopPoint()); |
| | | levelList.add(level); |
| | | }); |
| | | vipLevel.setLevelList(levelList); |
| | | vipLevel.setCurrentLevel(loginUserVipSetting.getId()); |
| | | return R.ok(vipLevel); |
| | | } |
| | | |
| | | } |