From 53a33e4999dfc14921882a72ebc70c0441652a23 Mon Sep 17 00:00:00 2001 From: zhuyang <1qazxsw2> Date: Thu, 7 Oct 2021 23:55:34 +0800 Subject: [PATCH] =?UTF-8?q?ProductSku=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rpc/sku/ProductSkuFeign.java | 27 +++++++++++ .../productservice/rpc/sku/ProductSkuRpc.java | 30 ------------ .../controller/ProductSkuController.java | 47 +++++++++++++++++++ .../rpc/sku/ProductSkuRpcImpl.java | 33 ------------- .../manager/price/PriceManager.java | 9 ++-- .../manager/product/SearchProductManager.java | 9 ++-- .../product/ProductSkuController.http | 2 +- .../shopweb/service/trade/CartManager.java | 14 +++--- .../service/trade/TradeOrderService.java | 9 ++-- .../tradeservice/TradeServiceApplication.java | 4 ++ .../client/product/ProductSkuClient.java | 11 ++--- .../service/cart/CartManager.java | 12 ++--- 12 files changed, 110 insertions(+), 97 deletions(-) create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuFeign.java delete mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSkuController.java delete mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuFeign.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuFeign.java new file mode 100644 index 000000000..94b077eac --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuFeign.java @@ -0,0 +1,27 @@ +package cn.iocoder.mall.productservice.rpc.sku; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; +import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; +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; + +@FeignClient(value = "product-service") +public interface ProductSkuFeign { + @GetMapping("/product/sku/getProductSku") + CommonResult getProductSku(@RequestParam("productSkuId") Integer productSkuId); + + /** + * 获得商品 SKU 列表 + * + * @param queryReqDTO 商品 SKU 列表的查询请求 DTO + * @return 商品 SKU 列表 + */ + @PostMapping("/product/sku/listProductSkus") + CommonResult> listProductSkus(@RequestBody ProductSkuListQueryReqDTO queryReqDTO); +} diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java deleted file mode 100644 index 89b20d488..000000000 --- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpc.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.mall.productservice.rpc.sku; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; -import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; - -import java.util.List; - -/** - * 商品 SKU Rpc 接口 - */ -public interface ProductSkuRpc { - - /** - * 获得商品 SKU - * - * @param productSkuId 商品 SKU 编号 - * @return 商品 SKU - */ - CommonResult getProductSku(Integer productSkuId); - - /** - * 获得商品 SKU 列表 - * - * @param queryReqDTO 商品 SKU 列表的查询请求 DTO - * @return 商品 SKU 列表 - */ - CommonResult> listProductSkus(ProductSkuListQueryReqDTO queryReqDTO); - -} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSkuController.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSkuController.java new file mode 100644 index 000000000..5e3e83782 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSkuController.java @@ -0,0 +1,47 @@ +package cn.iocoder.mall.productservice.controller; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.productservice.manager.attr.ProductAttrManager; +import cn.iocoder.mall.productservice.manager.sku.ProductSkuManager; +import cn.iocoder.mall.productservice.rpc.attr.dto.*; +import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; +import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +@RestController +@RequestMapping("/product/sku") +@Api("商品sku") +public class ProductSkuController { + @Autowired + private ProductSkuManager productSkuManager; + /** + * 获得商品 SKU + * + * @param productSkuId 商品 SKU 编号 + * @return 商品 SKU + */ + @GetMapping("getProductSku") + CommonResult getProductSku(@RequestParam("productSkuId") Integer productSkuId){ + return success(productSkuManager.getProductSku(productSkuId)); + } + + /** + * 获得商品 SKU 列表 + * + * @param queryReqDTO 商品 SKU 列表的查询请求 DTO + * @return 商品 SKU 列表 + */ + @PostMapping("listProductSkus") + CommonResult> listProductSkus(@RequestBody ProductSkuListQueryReqDTO queryReqDTO){ + return success(productSkuManager.listProductSkus(queryReqDTO)); + } + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java deleted file mode 100644 index 0528b5d63..000000000 --- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/sku/ProductSkuRpcImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.mall.productservice.rpc.sku; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.productservice.manager.sku.ProductSkuManager; -import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; -import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; -import org.apache.dubbo.config.annotation.DubboService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.List; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -/** - * 商品 SKU Rpc 实现类 - */ -@DubboService -public class ProductSkuRpcImpl implements ProductSkuRpc { - - @Autowired - private ProductSkuManager productSkuManager; - - @Override - public CommonResult getProductSku(Integer productSkuId) { - return success(productSkuManager.getProductSku(productSkuId)); - } - - @Override - public CommonResult> listProductSkus(ProductSkuListQueryReqDTO queryReqDTO) { - return success(productSkuManager.listProductSkus(queryReqDTO)); - } - -} diff --git a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java index 142851957..00b259777 100644 --- a/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java +++ b/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java @@ -3,7 +3,7 @@ package cn.iocoder.mall.promotionservice.manager.price; import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.CollectionUtils; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc; +import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign; @@ -21,7 +21,6 @@ import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.promotionservice.service.activity.PromotionActivityService; import cn.iocoder.mall.promotionservice.service.coupon.CouponCardService; import cn.iocoder.mall.promotionservice.service.coupon.CouponTemplateService; -import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.Assert; @@ -36,8 +35,8 @@ import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.*; @Validated public class PriceManager { - @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}") - private ProductSkuRpc productSkuRpc; + @Autowired + private ProductSkuFeign productSkuFeign; @Autowired private ProductSpuFeign productSpuFeign; @@ -53,7 +52,7 @@ public class PriceManager { // 校验商品都存在 Map calcProductItemDTOMap = CollectionUtils.convertMap( calcReqDTO.getItems(), PriceProductCalcReqDTO.Item::getSkuId); - CommonResult> listProductSkusResult = productSkuRpc.listProductSkus( + CommonResult> listProductSkusResult = productSkuFeign.listProductSkus( new ProductSkuListQueryReqDTO().setProductSkuIds(calcProductItemDTOMap.keySet())); listProductSkusResult.checkError(); if (calcReqDTO.getItems().size() != listProductSkusResult.getData().size()) { diff --git a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java index cc7ee0799..ec7e2461a 100644 --- a/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java +++ b/search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java @@ -5,7 +5,7 @@ import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.productservice.rpc.category.ProductCategoryFeign; import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO; -import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc; +import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign; @@ -20,7 +20,6 @@ import cn.iocoder.mall.searchservice.service.product.bo.SearchProductBO; import cn.iocoder.mall.searchservice.service.product.bo.SearchProductConditionBO; import cn.iocoder.mall.searchservice.service.product.bo.SearchProductSaveBO; import lombok.extern.slf4j.Slf4j; -import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -33,9 +32,9 @@ public class SearchProductManager { private static final Integer REBUILD_FETCH_PER_SIZE = 100; - @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}") - private ProductSkuRpc productSkuRpc; + @Autowired + private ProductSkuFeign productSkuFeign; @Autowired private ProductCategoryFeign productCategoryFeign; @Autowired @@ -102,7 +101,7 @@ public class SearchProductManager { } // 获得商品 SKU CommonResult> listProductSkusResult = - productSkuRpc.listProductSkus(new ProductSkuListQueryReqDTO().setProductSpuId(id)); + productSkuFeign.listProductSkus(new ProductSkuListQueryReqDTO().setProductSpuId(id)); listProductSkusResult.checkError(); if (CollectionUtils.isEmpty(listProductSkusResult.getData())) { log.error("[saveProduct][商品 SPU({}) 的 SKU 不存在]", id); diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSkuController.http b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSkuController.http index 32329b3ac..d304b6911 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSkuController.http +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSkuController.http @@ -1,5 +1,5 @@ ### /product-spu/page 计算商品 SKU 价格 -GET {{shop-api-base-url}}/product-sku/cal-price?id=33 +GET http://127.0.0.1:18084/shop-api/product-sku/cal-price?id=33 Content-Type: application/x-www-form-urlencoded ### diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/CartManager.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/CartManager.java index fb5836f46..74eb228c0 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/CartManager.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/CartManager.java @@ -2,10 +2,8 @@ package cn.iocoder.mall.shopweb.service.trade; import cn.iocoder.common.framework.util.CollectionUtils; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.tradeservice.rpc.cart.CartRpc; -import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum; -import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc; +import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; @@ -16,7 +14,10 @@ import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; import cn.iocoder.mall.shopweb.controller.trade.vo.cart.CartDetailVO; import cn.iocoder.mall.shopweb.convert.trade.CartConvert; +import cn.iocoder.mall.tradeservice.rpc.cart.CartRpc; +import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; @@ -34,8 +35,9 @@ public class CartManager { private PriceRpc priceRpc; @DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}") private PromotionActivityRpc promotionActivityRpc; - @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}") - private ProductSkuRpc productSkuRpc; + + @Autowired + private ProductSkuFeign productSkuFeign; /** * 添加商品到购物车 @@ -158,7 +160,7 @@ public class CartManager { } private Map getProductSkuMap(List itemRespDTOs) { - CommonResult> listProductSkusResult = productSkuRpc.listProductSkus(new ProductSkuListQueryReqDTO() + CommonResult> listProductSkusResult = productSkuFeign.listProductSkus(new ProductSkuListQueryReqDTO() .setProductSkuIds(CollectionUtils.convertSet(itemRespDTOs, CartItemRespDTO::getSkuId)) .setFields(Arrays.asList(ProductSkuDetailFieldEnum.SPU.getField(), ProductSkuDetailFieldEnum.ATTR.getField()))); listProductSkusResult.checkError(); diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/TradeOrderService.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/TradeOrderService.java index e0c6d2fe5..42fadd4bd 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/TradeOrderService.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/trade/TradeOrderService.java @@ -6,7 +6,7 @@ import cn.iocoder.common.framework.util.CollectionUtils; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum; -import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc; +import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityRpc; @@ -55,10 +55,11 @@ public class TradeOrderService { private PromotionActivityRpc promotionActivityRpc; @DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}") private CartRpc cartRpc; - @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}") - private ProductSkuRpc productSkuRpc; @DubboReference(version = "${dubbo.consumer.CouponCardRpc.version}") private CouponCardRpc couponCardRpc; + + @Autowired + private ProductSkuFeign productSkuFeign; @Autowired private TradeOrderClient tradeOrderClient; @@ -128,7 +129,7 @@ public class TradeOrderService { private Map checkProductSkus(Map skuMap) { // 获得商品 SKU 列表 - CommonResult> listProductSkusResult = productSkuRpc.listProductSkus(new ProductSkuListQueryReqDTO() + CommonResult> listProductSkusResult = productSkuFeign.listProductSkus(new ProductSkuListQueryReqDTO() .setProductSkuIds(skuMap.keySet()) .setFields(Arrays.asList(ProductSkuDetailFieldEnum.SPU.getField(), ProductSkuDetailFieldEnum.ATTR.getField()))); listProductSkusResult.checkError(); diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java index 8dc4f8733..c1fcbdbf7 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/TradeServiceApplication.java @@ -2,8 +2,12 @@ package cn.iocoder.mall.tradeservice; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"}) public class TradeServiceApplication { public static void main(String[] args) { diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/product/ProductSkuClient.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/product/ProductSkuClient.java index 88b2c9fe3..1645f365b 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/product/ProductSkuClient.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/product/ProductSkuClient.java @@ -2,10 +2,10 @@ package cn.iocoder.mall.tradeservice.client.product; import cn.iocoder.common.framework.util.CollectionUtils; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc; +import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO; import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Arrays; @@ -15,15 +15,14 @@ import java.util.List; @Service public class ProductSkuClient { - - @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}") - private ProductSkuRpc productSkuRpc; + @Autowired + private ProductSkuFeign productSkuFeign; public List listProductSkus(Collection productSkuIds, String... fields) { if (CollectionUtils.isEmpty(productSkuIds)) { return Collections.emptyList(); } - CommonResult> listProductSkusResult = productSkuRpc.listProductSkus( + CommonResult> listProductSkusResult = productSkuFeign.listProductSkus( new ProductSkuListQueryReqDTO().setProductSkuIds(productSkuIds).setFields(Arrays.asList(fields))); listProductSkusResult.checkError(); return listProductSkusResult.getData(); diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/service/cart/CartManager.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/service/cart/CartManager.java index 5fd12bebc..2543d51ac 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/service/cart/CartManager.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/service/cart/CartManager.java @@ -3,13 +3,11 @@ package cn.iocoder.mall.tradeservice.service.cart; import cn.iocoder.common.framework.enums.CommonStatusEnum; import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.productservice.rpc.sku.ProductSkuFeign; +import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; import cn.iocoder.mall.tradeservice.convert.cart.CartConvert; import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; -import cn.iocoder.mall.tradeservice.service.cart.CartService; import cn.iocoder.mall.tradeservice.service.cart.bo.CartItemBO; -import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc; -import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -23,8 +21,8 @@ import static cn.iocoder.mall.tradeservice.enums.OrderErrorCodeConstants.CARD_IT @Service public class CartManager { - @DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}") - private ProductSkuRpc productSkuRpc; + @Autowired + private ProductSkuFeign productSkuFeign; @Autowired private CartService cartService; @@ -104,7 +102,7 @@ public class CartManager { * @return 商品 SKU 信息 */ private ProductSkuRespDTO checkProductSku(Integer skuId) { - CommonResult getProductSkuResult = productSkuRpc.getProductSku(skuId); + CommonResult getProductSkuResult = productSkuFeign.getProductSku(skuId); getProductSkuResult.checkError(); ProductSkuRespDTO skuDTO = getProductSkuResult.getData(); if (skuDTO == null || CommonStatusEnum.DISABLE.getValue().equals(skuDTO.getStatus())) {