| | |
| | | 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); |
| | |
| | | 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; |
| | | } |
| | | |