From bd8574be2b262a901865dd5fea9cc35da8e2d229 Mon Sep 17 00:00:00 2001 From: phpcjl <phpcjl@gmail.com> Date: 星期四, 05 十二月 2024 17:51:40 +0800 Subject: [PATCH] 1. --- /dev/null | 10 --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java | 71 +++++++++++++++++++++++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java | 5 - ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java | 49 ++++++++++++++++ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/VipLevel.java | 20 ++++++ ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java | 5 + ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java | 7 ++ 7 files changed, 154 insertions(+), 13 deletions(-) diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java index 6bd559c..1fd7d1f 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/RemoteVipSettingFallbackFactory.java @@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.openfeign.FallbackFactory; +import java.util.List; + @Slf4j public class RemoteVipSettingFallbackFactory implements FallbackFactory<RemoteVipSettingClient> { @Override @@ -17,6 +19,11 @@ log.error("获取会员设置信息失败:{}", cause.getMessage()); throw new ServiceException("获取会员设置信息失败"); } + + @Override + public R<List<VipSetting>> list() { + return R.fail("获取会员设置信息失败"); + } }; } } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java index d99075a..647e84e 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java @@ -8,9 +8,14 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; + @FeignClient(contextId = "RemoteVipSettingClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = RemoteVipSettingFallbackFactory.class) public interface RemoteVipSettingClient { @GetMapping("/vip-setting/getVipSettingById") R<VipSetting> getVipSettingById(@RequestParam(value = "id",required = true) Integer id); + + @GetMapping("/vip-setting/list") + R<List<VipSetting>> list(); } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java index 4dce832..d964ef6 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenter.java @@ -1,14 +1,85 @@ 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); + } } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Describe.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Describe.java deleted file mode 100644 index d2ee8ac..0000000 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Describe.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.ruoyi.account.vo.vip; - -import com.baomidou.mybatisplus.annotation.TableField; -import io.swagger.annotations.ApiModelProperty; - -public class Describe { - - @ApiModelProperty(value = "会员专属权益") - private String vipInfo; -} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java index cfe2841..855de5c 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/Level.java @@ -1,11 +1,60 @@ package com.ruoyi.account.vo.vip; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data public class Level { + + @ApiModelProperty(value = "会员等级id") + private Integer id; /** * 会员名称 */ + @ApiModelProperty(value = "会员名称") private String name; + @ApiModelProperty(value = "会员专属权益") + private String vipInfo; + + @ApiModelProperty(value = "会员说明") + private String vipDesc; + + @ApiModelProperty(value = "消费达到积分 后升级") + private BigDecimal vipLevelUpShop; + + @ApiModelProperty(value = "返佣达到积分 后升级") + private BigDecimal vipLevelUpShare; + + @ApiModelProperty(value = "升级会员的直推用户人数要求") + private Integer vipDirectNum; + @ApiModelProperty(value = "升级会员的团队数要求") + private Integer vipTeamNum; + + @ApiModelProperty(value = "保级:消费x天") + private Integer keepBuyDay; + + @ApiModelProperty(value = "保级:消费x分") + private BigDecimal keepBuyPoint; + + @ApiModelProperty(value = "保级:返佣x天") + private Integer keepShareDay; + + @ApiModelProperty(value = "保级:返佣x分") + private BigDecimal keepSharePoint; + + @ApiModelProperty(value = "保级:门店x天") + private Integer keepShopDay; + + @ApiModelProperty(value = "保级:门店x分") + private BigDecimal keepShopPoint; + + + } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/VipLevel.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/VipLevel.java new file mode 100644 index 0000000..a1282ea --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/vip/VipLevel.java @@ -0,0 +1,20 @@ +package com.ruoyi.account.vo.vip; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Api(tags = "会员等级") +@Data +public class VipLevel { + /** + * 当前等级 + */ + @ApiModelProperty(value = "当前等级") + private Integer currentLevel; + + @ApiModelProperty(value = "会员等级列表") + private List<Level> levelList; +} diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java index 4af566f..8f73394 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java @@ -36,9 +36,8 @@ @Resource private VipGoodService vipGoodService; - @GetMapping("/info") - @ApiOperation(value = "获取各级会员信息", tags = {"小程序-个人中心首页", "小程序-会员中心"}) - public R<List<VipSetting>> info() { + @GetMapping("/list") + public R<List<VipSetting>> list() { List<VipSetting> list = vipSettingService.list(); return R.ok(list); } -- Gitblit v1.7.1