From e81d5ff655e0c5efc85d2e4b3803bc604baf59f1 Mon Sep 17 00:00:00 2001 From: phpcjl <phpcjl@gmail.com> Date: 星期四, 28 十一月 2024 09:57:15 +0800 Subject: [PATCH] 1.完成部分接口开发 --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 50 insertions(+), 2 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java index 829c037..78e33d9 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java @@ -2,12 +2,20 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.AppUser; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.mapper.ShoppingCartMapper; import com.ruoyi.order.service.ShoppingCartService; import com.ruoyi.order.vo.MyShoppingCartVo; import com.ruoyi.other.api.domain.Goods; +import com.ruoyi.other.api.domain.GoodsArea; +import com.ruoyi.other.api.domain.GoodsShop; +import com.ruoyi.other.api.domain.GoodsVip; +import com.ruoyi.other.api.feignClient.GoodsAreaClient; import com.ruoyi.other.api.feignClient.GoodsClient; +import com.ruoyi.other.api.feignClient.GoodsShopClient; +import com.ruoyi.other.api.feignClient.GoodsVipClient; import model.ShoppingCart; import org.springframework.stereotype.Service; @@ -25,6 +33,17 @@ @Resource private GoodsClient goodsClient; + @Resource + private GoodsShopClient goodsShopClient; + + @Resource + private AppUserClient appUserClient; + + @Resource + private GoodsAreaClient goodsAreaClient; + + @Resource + private GoodsVipClient goodsVipClient; @@ -40,6 +59,7 @@ @Override public List<MyShoppingCartVo> getMyShoppingCart(Integer type, Integer shopId) { Long userid = tokenService.getLoginUserApplet().getUserid(); + AppUser appUser = appUserClient.getAppUserById(userid); //获取对应类型的商品数据 List<Goods> data = goodsClient.getGoodsByType(type).getData(); if(null == data){ @@ -51,13 +71,41 @@ List<MyShoppingCartVo> page = new ArrayList<>(); //构建返回数据 for (ShoppingCart shoppingCart : list) { + Goods goods = data.stream().filter(s -> s.getId().equals(shoppingCart.getGoodsId())).findFirst().get(); MyShoppingCartVo vo = new MyShoppingCartVo(); + vo.setId(shoppingCart.getId()); + vo.setHomePicture(goods.getHomePagePicture()); + vo.setName(goods.getName()); + + GoodsArea area = new GoodsArea(); + area.setDistrictsCode(appUser.getDistrictCode()); + area.setCityCode(appUser.getCityCode()); + area.setProvinceCode(appUser.getProvinceCode()); + area.setVip(appUser.getVipId()); + GoodsArea goodsArea = goodsAreaClient.getGoodsArea(area).getData(); + if(null == goodsArea){ + GoodsVip goodsVip = goodsVipClient.getGoodsVip(appUser.getVipId()).getData(); + } - - + vo.setSellingPrice(goods); + vo.setOriginalPrice(goods.getOriginalPrice().toString()); + vo.setNumber(shoppingCart.getNumber()); + vo.setEndTime(); + GoodsShop goodsShop = new GoodsShop(); + goodsShop.setGoodsId(shoppingCart.getGoodsId()); + goodsShop.setShopId(shopId); + GoodsShop goodsShop1 = goodsShopClient.getGoodsShop(goodsShop).getData(); + vo.setVerifiable(null == goodsShop1 ? false : true); page.add(vo); } return page; } + + @Override + public void addGoods(ShoppingCart shoppingCart) { + Long userid = tokenService.getLoginUserApplet().getUserid(); + shoppingCart.setAppUserId(userid); + this.save(shoppingCart); + } } -- Gitblit v1.7.1