| | |
| | | |
| | | 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; |
| | | |
| | |
| | | @Resource |
| | | private GoodsClient goodsClient; |
| | | |
| | | @Resource |
| | | private GoodsShopClient goodsShopClient; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private GoodsAreaClient goodsAreaClient; |
| | | |
| | | @Resource |
| | | private GoodsVipClient goodsVipClient; |
| | | |
| | | |
| | | |
| | |
| | | @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){ |
| | |
| | | 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); |
| | | } |
| | | } |