ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/RemoteOrderGoodsFallbackFactory.java
@@ -25,6 +25,11 @@ log.error("获取订单列表失败:{}", cause.getMessage()); throw new RuntimeException("获取订单列表失败"); } @Override public R<List<Order>> getOrderListByUserIdAndGoodsId(Long userId, Integer goodsId) { return R.fail("获取订单列表失败"); } }; } ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/RemoteOrderGoodsClient.java
@@ -7,8 +7,10 @@ import com.ruoyi.order.model.Order; import com.ruoyi.order.model.OrderGood; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -30,6 +32,6 @@ /** * 根据用户id和商品id查找订单列表 */ @PostMapping("/order/getOrderListByUserIdAndGoodsId") public R<List<Order>> getOrderListByUserIdAndGoodsId(@RequestBody OrderGood orderGood); @GetMapping("/order/getOrderListByUserIdAndGoodsId") public R<List<Order>> getOrderListByUserIdAndGoodsId(@RequestParam("userId") Long userId, @RequestParam("goodsId") Integer goodsId); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/VipCenterController.java
@@ -1,9 +1,8 @@ package com.ruoyi.account.controller; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.service.AppUserService; 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; @@ -18,9 +17,11 @@ import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; @@ -49,6 +50,8 @@ private VipGoodClient vipGoodClient; @Resource private AppUserService appUserService; @Resource private VipCenterService vipCenterService; @GetMapping("getVipLevelList") @@ -56,7 +59,7 @@ public R<VipLevel> vipLevelList() { try { R<List<VipSetting>> r = remoteVipSettingClient.list(); if (!checkSuccess(r)) { if (checkSuccess(r)) { return R.fail("会员等级获取失败"); } List<VipSetting> vipSettingList = r.getData(); @@ -65,7 +68,7 @@ } R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(3); if (!checkSuccess(baseSettingR)) { if (checkSuccess(baseSettingR)) { log.error("【会员设置说明】获取失败:{}", baseSettingR.getMsg()); return R.fail("会员等级获取失败"); } @@ -124,17 +127,22 @@ } public R<Void> test() { LoginUser loginUserApplet = tokenService.getLoginUserApplet(); AppUser appUser = appUserService.getById(loginUserApplet.getUserid()); if (appUser.getShopPoint() >= 500){ return R.ok(); @GetMapping("/check") @ApiOperation(value = "会员申请检查", tags = {"会员中心-小程序"}) public R<Boolean> check(@ApiParam("4:准代理,5:代理,6:总代理,7:合伙人") @RequestParam Integer type) { LoginUser loginUser = tokenService.getLoginUser(); Long userid = loginUser.getUserid(); if (type == 4){ return R.ok(vipCenterService.checkReadyToBeProxy(userid)); }else if (type == 5){ return R.ok(vipCenterService.checkReadyToBeAgent(userid)); }else if (type == 6){ return R.ok(vipCenterService.checkReadyToBeTotalAgent(userid)); }else if (type == 7){ return R.ok(vipCenterService.checkReadyToBePartner(userid)); }else { return R.fail("参数错误"); } if (appUser.getSharePoint() >= 400){ return R.ok(); } return R.fail(); } ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/VipCenterServiceImpl.java
@@ -1,19 +1,33 @@ package com.ruoyi.account.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.VipCenterService; import com.ruoyi.common.core.domain.R; import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; import com.ruoyi.order.model.Order; import com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.api.domain.VipGood; import com.ruoyi.other.api.feignClient.VipGoodClient; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; import java.util.stream.Collectors; @Service @RequiredArgsConstructor public class VipCenterServiceImpl implements VipCenterService { private final AppUserService appUserService; @Resource private AppUserService appUserService; @Resource private RemoteOrderGoodsClient remoteOrderGoodsClient; @Resource private VipGoodClient vipGoodClient; @Override public Boolean checkReadyToBeProxy(Long userId) { AppUser appUser = appUserService.getById(userId); @@ -32,6 +46,27 @@ return true; } // 是否购买指定商品 R<List<VipGood>> vipGoodsByVipId = vipGoodClient.getVipGoodsByVipId(4); if (R.isError(vipGoodsByVipId)){ throw new RuntimeException("根据会员id获取会员购买商品失败:" + vipGoodsByVipId.getMsg()); } List<VipGood> vipGoodList = vipGoodsByVipId.getData(); if (CollectionUtil.isNotEmpty(vipGoodList)){ List<String> goodJsonList = vipGoodList.stream().map(VipGood::getGoodJson).collect(Collectors.toList()); for (String goodJson : goodJsonList) { Goods goods = JSONObject.parseObject(goodJson, Goods.class); R<List<Order>> orderR = remoteOrderGoodsClient.getOrderListByUserIdAndGoodsId(userId, goods.getId()); if (R.isError(orderR)){ throw new RuntimeException("根据用户id和商品id获取订单失败:" + orderR.getMsg()); } if (CollectionUtil.isEmpty(orderR.getData())){ return false; } } return true; } return false; } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderGoodController.java
@@ -37,7 +37,7 @@ } @GetMapping("/getOrderListByUserIdAndGoodsId") public R<List<OrderGood>> getOrderListByUserIdAndGoodsId(Long userId, Long goodsId){ public R<List<OrderGood>> getOrderListByUserIdAndGoodsId(Long userId, Integer goodsId){ return R.ok(orderGoodService.getOrderListByUserIdAndGoodsId(userId, goodsId)); } } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderGoodMapper.java
@@ -15,6 +15,6 @@ * @since 2024-11-21 */ public interface OrderGoodMapper extends BaseMapper<OrderGood> { public List<OrderGood> getOrderListByUserIdAndGoodsId(@Param("userId") Long userId,@Param("goodsId") Long goodsId); public List<OrderGood> getOrderListByUserIdAndGoodsId(@Param("userId") Long userId,@Param("goodsId") Integer goodsId); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderGoodService.java
@@ -15,6 +15,6 @@ */ public interface OrderGoodService extends IService<OrderGood> { public List<OrderGood> getOrderListByUserIdAndGoodsId(Long userId, Long goodsId); public List<OrderGood> getOrderListByUserIdAndGoodsId(Long userId, Integer goodsId); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderGoodServiceImpl.java
@@ -24,7 +24,7 @@ private final OrderGoodMapper orderGoodMapper; @Override public List<OrderGood> getOrderListByUserIdAndGoodsId(Long userId, Long goodsId) { public List<OrderGood> getOrderListByUserIdAndGoodsId(Long userId, Integer goodsId) { return orderGoodMapper.getOrderListByUserIdAndGoodsId(userId, goodsId); } }