diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java index b72ad2964..788af718e 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java @@ -7,7 +7,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient -@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.searchservice.rpc"}) +@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.searchservice.rpc", + "cn.iocoder.mall.tradeservice.rpc"}) public class ShopWebApplication { public static void main(String[] args) { diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/trade/TradeOrderClient.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/trade/TradeOrderClient.java index 445a3035b..1029f1fa6 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/trade/TradeOrderClient.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/trade/TradeOrderClient.java @@ -2,11 +2,11 @@ package cn.iocoder.mall.shopweb.client.trade; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.tradeservice.rpc.order.TradeOrderRpc; +import cn.iocoder.mall.tradeservice.rpc.order.TradeOrderFeign; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Arrays; @@ -14,23 +14,23 @@ import java.util.Arrays; @Service public class TradeOrderClient { - @DubboReference(version = "${dubbo.consumer.TradeOrderRpc.version}") - private TradeOrderRpc tradeOrderRpc; + @Autowired + private TradeOrderFeign tradeOrderFeign; public Integer createTradeOrder(TradeOrderCreateReqDTO createReqDTO) { - CommonResult createTradeOrderResult = tradeOrderRpc.createTradeOrder(createReqDTO); + CommonResult createTradeOrderResult = tradeOrderFeign.createTradeOrder(createReqDTO); createTradeOrderResult.checkError(); return createTradeOrderResult.getData(); } public PageResult pageTradeOrder(TradeOrderPageReqDTO pageReqDTO) { - CommonResult> pageTradeOrderResult = tradeOrderRpc.pageTradeOrder(pageReqDTO); + CommonResult> pageTradeOrderResult = tradeOrderFeign.pageTradeOrder(pageReqDTO); pageTradeOrderResult.checkError(); return pageTradeOrderResult.getData(); } public TradeOrderRespDTO getTradeOrder(Integer tradeOrderId, String... fields) { - CommonResult getTradeOrderResult = tradeOrderRpc.getTradeOrder(tradeOrderId, Arrays.asList(fields)); + CommonResult getTradeOrderResult = tradeOrderFeign.getTradeOrder(tradeOrderId, Arrays.asList(fields)); getTradeOrderResult.checkError(); return getTradeOrderResult.getData(); } 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 74eb228c0..b220106f8 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 @@ -14,7 +14,7 @@ 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.CartFeign; import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Autowired; @@ -29,8 +29,8 @@ import java.util.stream.Collectors; @Service public class CartManager { - @DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}") - private CartRpc cartRpc; + @Autowired + private CartFeign cartFeign; @DubboReference(version = "${dubbo.consumer.PriceRpc.version}") private PriceRpc priceRpc; @DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}") @@ -47,7 +47,7 @@ public class CartManager { * @param quantity 增加数量 */ public void addCartItem(Integer userId, Integer skuId, Integer quantity) { - CommonResult addCartItemResult = cartRpc.addCartItem(new CartItemAddReqDTO().setUserId(userId) + CommonResult addCartItemResult = cartFeign.addCartItem(new CartItemAddReqDTO().setUserId(userId) .setSkuId(skuId).setQuantity(quantity)); addCartItemResult.checkError(); } @@ -59,7 +59,7 @@ public class CartManager { * @return 商品数量 */ public Integer sumCartItemQuantity(Integer userId) { - CommonResult sumCartItemQuantityResult = cartRpc.sumCartItemQuantity(userId); + CommonResult sumCartItemQuantityResult = cartFeign.sumCartItemQuantity(userId); sumCartItemQuantityResult.checkError(); return sumCartItemQuantityResult.getData(); } @@ -72,7 +72,7 @@ public class CartManager { * @param quantity 数量 */ public void updateCartItemQuantity(Integer userId, Integer skuId, Integer quantity) { - CommonResult updateCartItemQuantityResult = cartRpc.updateCartItemQuantity(new CartItemUpdateQuantityReqDTO() + CommonResult updateCartItemQuantityResult = cartFeign.updateCartItemQuantity(new CartItemUpdateQuantityReqDTO() .setUserId(userId).setSkuId(skuId).setQuantity(quantity)); updateCartItemQuantityResult.checkError(); } @@ -85,7 +85,7 @@ public class CartManager { * @param selected 是否选中 */ public void updateCartItemSelected(Integer userId, Set skuIds, Boolean selected) { - CommonResult updateCartItemSelectedResult = cartRpc.updateCartItemSelected(new CartItemUpdateSelectedReqDTO() + CommonResult updateCartItemSelectedResult = cartFeign.updateCartItemSelected(new CartItemUpdateSelectedReqDTO() .setUserId(userId).setSkuIds(skuIds).setSelected(selected)); updateCartItemSelectedResult.checkError(); } @@ -97,7 +97,7 @@ public class CartManager { */ public CartDetailVO getCartDetail(Integer userId) { // 获得购物车的商品 - CommonResult> listCartItemsResult = cartRpc.listCartItems(new CartItemListReqDTO().setUserId(userId)); + CommonResult> listCartItemsResult = cartFeign.listCartItems(new CartItemListReqDTO().setUserId(userId)); listCartItemsResult.checkError(); // 购物车为空时,构造空的 UsersOrderConfirmCreateVO 返回 if (CollectionUtils.isEmpty(listCartItemsResult.getData())) { 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 42fadd4bd..de4105e94 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 @@ -26,7 +26,7 @@ import cn.iocoder.mall.shopweb.controller.trade.vo.order.TradeOrderRespVO; import cn.iocoder.mall.shopweb.convert.trade.CartConvert; import cn.iocoder.mall.shopweb.convert.trade.TradeOrderConvert; import cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum; -import cn.iocoder.mall.tradeservice.rpc.cart.CartRpc; +import cn.iocoder.mall.tradeservice.rpc.cart.CartFeign; import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemListReqDTO; import cn.iocoder.mall.tradeservice.rpc.cart.dto.CartItemRespDTO; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO; @@ -53,9 +53,9 @@ public class TradeOrderService { private PriceRpc priceRpc; @DubboReference(version = "${dubbo.consumer.PromotionActivityRpc.version}") private PromotionActivityRpc promotionActivityRpc; - @DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}") - private CartRpc cartRpc; - @DubboReference(version = "${dubbo.consumer.CouponCardRpc.version}") + + @Autowired + private CartFeign cartFeign; private CouponCardRpc couponCardRpc; @Autowired @@ -72,7 +72,7 @@ public class TradeOrderService { public TradeOrderConfirmCreateInfoRespVO getOrderConfirmCreateInfoFromCart(Integer userId, Integer couponCardId) { // 获得购物车的商品 - CommonResult> listCartItemsResult = cartRpc.listCartItems( + CommonResult> listCartItemsResult = cartFeign.listCartItems( new CartItemListReqDTO().setUserId(userId).setSelected(true)); listCartItemsResult.checkError(); // 购物车为空时,构造空的 OrderConfirmCreateInfoRespVO 返回 diff --git a/trade-service-project/trade-service-api/pom.xml b/trade-service-project/trade-service-api/pom.xml index 3b0e8d04c..6b261f641 100644 --- a/trade-service-project/trade-service-api/pom.xml +++ b/trade-service-project/trade-service-api/pom.xml @@ -26,6 +26,10 @@ org.projectlombok lombok + + org.springframework.cloud + spring-cloud-openfeign-core + diff --git a/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/cart/CartFeign.java b/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/cart/CartFeign.java new file mode 100644 index 000000000..f4d45500b --- /dev/null +++ b/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/cart/CartFeign.java @@ -0,0 +1,61 @@ +package cn.iocoder.mall.tradeservice.rpc.cart; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; +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; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@FeignClient(value = "trade-service") +public interface CartFeign { + /** + * 添加商品到购物车 + * + * @param addReqDTO 添加商品信息 + * @return 成功 + */ + @PostMapping("addCartItem") + CommonResult addCartItem(@RequestBody CartItemAddReqDTO addReqDTO); + + /** + * 更新购物车商品数量 + * + * @param updateQuantityReqDTO 更新商品数量 DTO + * @return 成功 + */ + @PostMapping("updateCartItemQuantity") + CommonResult updateCartItemQuantity(@RequestBody CartItemUpdateQuantityReqDTO updateQuantityReqDTO); + + /** + * 更新购物车商品是否选中 + * + * @param updateSelectedReqDTO 更新商品是否选中 DTO + * @return 成功 + */ + @PostMapping("updateCartItemSelected") + CommonResult updateCartItemSelected(@RequestBody CartItemUpdateSelectedReqDTO updateSelectedReqDTO); + + /** + * 删除购物车商品列表 + * + * @param deleteListReqDTO 删除商品列表 DTO + * @return 成功 + */ + @PostMapping("deleteCartItems") + CommonResult deleteCartItems(@RequestBody CartItemDeleteListReqDTO deleteListReqDTO); + @GetMapping("/sumCartItemQuantity") + public CommonResult sumCartItemQuantity(@RequestParam("userId") Integer userId) ; + @PostMapping("/listCartItems") + public CommonResult> listCartItems(@RequestBody CartItemListReqDTO listReqDTO) ; +} diff --git a/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/cart/CartRpc.java b/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/cart/CartRpc.java deleted file mode 100644 index 66f46af8a..000000000 --- a/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/cart/CartRpc.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.mall.tradeservice.rpc.cart; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; - -import java.util.List; - -/** - * 购物车 Rpc 接口 - */ -public interface CartRpc { - - /** - * 添加商品到购物车 - * - * @param addReqDTO 添加商品信息 - * @return 成功 - */ - CommonResult addCartItem(CartItemAddReqDTO addReqDTO); - - /** - * 更新购物车商品数量 - * - * @param updateQuantityReqDTO 更新商品数量 DTO - * @return 成功 - */ - CommonResult updateCartItemQuantity(CartItemUpdateQuantityReqDTO updateQuantityReqDTO); - - /** - * 更新购物车商品是否选中 - * - * @param updateSelectedReqDTO 更新商品是否选中 DTO - * @return 成功 - */ - CommonResult updateCartItemSelected(CartItemUpdateSelectedReqDTO updateSelectedReqDTO); - - /** - * 删除购物车商品列表 - * - * @param deleteListReqDTO 删除商品列表 DTO - * @return 成功 - */ - CommonResult deleteCartItems(CartItemDeleteListReqDTO deleteListReqDTO); - - /** - * 查询用户在购物车中的商品数量 - * - * @param userId 用户编号 - * @return 商品数量 - */ - CommonResult sumCartItemQuantity(Integer userId); - - /** - * 查询用户在购物车种的商品列表 - * - * @param listReqDTO 查询条件 DTO - * @return 购物车中商品列表信息 - */ - CommonResult> listCartItems(CartItemListReqDTO listReqDTO); - -} diff --git a/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderRpc.java b/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderFeign.java similarity index 54% rename from trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderRpc.java rename to trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderFeign.java index fddd76fdf..682698fb6 100644 --- a/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderRpc.java +++ b/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderFeign.java @@ -5,13 +5,23 @@ import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO; import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO; +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.Collection; /** - * 交易订单 Rpc 接口 + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 */ -public interface TradeOrderRpc { +@FeignClient(value = "trade-service") +public interface TradeOrderFeign { /** * 创建交易订单 @@ -19,7 +29,8 @@ public interface TradeOrderRpc { * @param createReqDTO 订单信息 * @return 订单编号 */ - CommonResult createTradeOrder(TradeOrderCreateReqDTO createReqDTO); + @PostMapping("createTradeOrder") + CommonResult createTradeOrder(@RequestBody TradeOrderCreateReqDTO createReqDTO); /** * 获得订单交易 @@ -28,16 +39,16 @@ public interface TradeOrderRpc { * @param fields 额外返回字段,可见 {@link cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum} * @return 订单交易 */ - CommonResult getTradeOrder(Integer tradeOrderId, Collection fields); - + @GetMapping("getTradeOrder") + CommonResult getTradeOrder(@RequestParam("tradeOrderId")Integer tradeOrderId, @RequestParam("fields") Collection fields); /** * 获得交易订单分页 * * @param pageDTO 订单交易分页查询 * @return 订单交易分页结果 */ - CommonResult> pageTradeOrder(TradeOrderPageReqDTO pageDTO); - + @PostMapping("pageTradeOrder") + CommonResult> pageTradeOrder(@RequestBody TradeOrderPageReqDTO pageDTO); // TODO 芋艿:需要重构成入参是 DTO,方便后续升级;返回是 CommonResult,用于返回失败的原因 /** @@ -49,6 +60,6 @@ public interface TradeOrderRpc { * @param payAmount 支付金额 * @return 成功 */ - CommonResult updateTradeOrderPaySuccess(String tradeOrderId, Integer payAmount); - + @PostMapping("updateTradeOrderPaySuccess") + CommonResult updateTradeOrderPaySuccess(@RequestParam("tradeOrderId") String tradeOrderId, @RequestParam("payAmount")Integer payAmount); } diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/CartController.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/CartController.java new file mode 100644 index 000000000..fa6067bef --- /dev/null +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/CartController.java @@ -0,0 +1,74 @@ +package cn.iocoder.mall.tradeservice.controller; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; +import cn.iocoder.mall.tradeservice.service.cart.CartManager; +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("/trade/cart") +public class CartController { + @Autowired + private CartManager cartManager; + + /** + * 添加商品到购物车 + * + * @param addReqDTO 添加商品信息 + * @return 成功 + */ + @PostMapping("addCartItem") + CommonResult addCartItem(@RequestBody CartItemAddReqDTO addReqDTO){ + cartManager.addCartItem(addReqDTO); + return success(true); + } + + /** + * 更新购物车商品数量 + * + * @param updateQuantityReqDTO 更新商品数量 DTO + * @return 成功 + */ + @PostMapping("updateCartItemQuantity") + CommonResult updateCartItemQuantity(@RequestBody CartItemUpdateQuantityReqDTO updateQuantityReqDTO){ + cartManager.updateCartItemSelected(updateQuantityReqDTO); + return success(true); + } + + /** + * 更新购物车商品是否选中 + * + * @param updateSelectedReqDTO 更新商品是否选中 DTO + * @return 成功 + */ + @PostMapping("updateCartItemSelected") + CommonResult updateCartItemSelected(@RequestBody CartItemUpdateSelectedReqDTO updateSelectedReqDTO){ + cartManager.updateCartItemSelected(updateSelectedReqDTO); + return success(true); + } + + /** + * 删除购物车商品列表 + * + * @param deleteListReqDTO 删除商品列表 DTO + * @return 成功 + */ + @PostMapping("deleteCartItems") + CommonResult deleteCartItems(@RequestBody CartItemDeleteListReqDTO deleteListReqDTO){ + cartManager.deleteCartItems(deleteListReqDTO); + return success(true); + } + @GetMapping("/sumCartItemQuantity") + public CommonResult sumCartItemQuantity(@RequestParam("userId") Integer userId) { + return success(cartManager.sumCartItemQuantity(userId)); + } + @PostMapping("/listCartItems") + public CommonResult> listCartItems(@RequestBody CartItemListReqDTO listReqDTO) { + return success(cartManager.listCartItems(listReqDTO)); + } +} diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/TradeOrderController.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/TradeOrderController.java new file mode 100644 index 000000000..f27e4d35e --- /dev/null +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/controller/TradeOrderController.java @@ -0,0 +1,78 @@ +package cn.iocoder.mall.tradeservice.controller; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO; +import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO; +import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO; +import cn.iocoder.mall.tradeservice.service.order.TradeOrderService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Collection; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@RestController +@RequestMapping("/trade/order") +public class TradeOrderController { + @Autowired + private TradeOrderService tradeOrderService; + /** + * 创建交易订单 + * + * @param createReqDTO 订单信息 + * @return 订单编号 + */ + @PostMapping("createTradeOrder") + CommonResult createTradeOrder(@RequestBody TradeOrderCreateReqDTO createReqDTO){ + return success(tradeOrderService.createTradeOrder(createReqDTO)); + } + + /** + * 获得订单交易 + * + * @param tradeOrderId 订单交易编号 + * @param fields 额外返回字段,可见 {@link cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum} + * @return 订单交易 + */ + @GetMapping("getTradeOrder") + CommonResult getTradeOrder( @RequestParam("tradeOrderId")Integer tradeOrderId, @RequestParam("fields") Collection fields){ + return success(tradeOrderService.getTradeOrder(tradeOrderId, fields)); + } + + /** + * 获得交易订单分页 + * + * @param pageDTO 订单交易分页查询 + * @return 订单交易分页结果 + */ + @PostMapping("pageTradeOrder") + CommonResult> pageTradeOrder(@RequestBody TradeOrderPageReqDTO pageDTO){ + return success(tradeOrderService.pageTradeOrder(pageDTO)); + } + + // TODO 芋艿:需要重构成入参是 DTO,方便后续升级;返回是 CommonResult,用于返回失败的原因 + + /** + * 更新交易订单支付成功 + * + * 目前用于对接 pay-service 支付服务,回调该交易订单在三方支付平台,支付成功 + * + * @param tradeOrderId 交易订单编号 + * @param payAmount 支付金额 + * @return 成功 + */ + @PostMapping("updateTradeOrderPaySuccess") + CommonResult updateTradeOrderPaySuccess(@RequestParam("tradeOrderId") String tradeOrderId, @RequestParam("payAmount")Integer payAmount){ + tradeOrderService.updateTradeOrderPaySuccess(Integer.valueOf(tradeOrderId), payAmount); + return success(true); + } +} diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/rpc/cart/CartRpcImpl.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/rpc/cart/CartRpcImpl.java deleted file mode 100644 index 917a982bf..000000000 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/rpc/cart/CartRpcImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.mall.tradeservice.rpc.cart; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.tradeservice.service.cart.CartManager; -import cn.iocoder.mall.tradeservice.rpc.cart.dto.*; -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; - -/** - * 购物车 Rpc 实现 - */ -@DubboService -public class CartRpcImpl implements CartRpc { - - @Autowired - private CartManager cartManager; - - @Override - public CommonResult addCartItem(CartItemAddReqDTO addItemReqDTO) { - cartManager.addCartItem(addItemReqDTO); - return success(true); - } - - @Override - public CommonResult updateCartItemQuantity(CartItemUpdateQuantityReqDTO updateQuantityReqDTO) { - cartManager.updateCartItemSelected(updateQuantityReqDTO); - return success(true); - } - - @Override - public CommonResult updateCartItemSelected(CartItemUpdateSelectedReqDTO updateSelectedReqDTO) { - cartManager.updateCartItemSelected(updateSelectedReqDTO); - return success(true); - } - - @Override - public CommonResult deleteCartItems(CartItemDeleteListReqDTO deleteListReqDTO) { - cartManager.deleteCartItems(deleteListReqDTO); - return success(true); - } - - @Override - public CommonResult sumCartItemQuantity(Integer userId) { - return success(cartManager.sumCartItemQuantity(userId)); - } - - @Override - public CommonResult> listCartItems(CartItemListReqDTO listReqDTO) { - return success(cartManager.listCartItems(listReqDTO)); - } - -} diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderRpcImpl.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderRpcImpl.java deleted file mode 100644 index f9b3a9e30..000000000 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderRpcImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.mall.tradeservice.rpc.order; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO; -import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO; -import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO; -import cn.iocoder.mall.tradeservice.service.order.TradeOrderService; -import org.apache.dubbo.config.annotation.DubboService; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Collection; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -/** - * 交易订单 Rpc 实现 - */ -@DubboService -public class TradeOrderRpcImpl implements TradeOrderRpc { - - @Autowired - private TradeOrderService tradeOrderService; - - @Override - public CommonResult createTradeOrder(TradeOrderCreateReqDTO createReqDTO) { - return success(tradeOrderService.createTradeOrder(createReqDTO)); - } - - @Override - public CommonResult getTradeOrder(Integer tradeOrderId, Collection fields) { - return success(tradeOrderService.getTradeOrder(tradeOrderId, fields)); - } - - @Override - public CommonResult> pageTradeOrder(TradeOrderPageReqDTO pageDTO) { - return success(tradeOrderService.pageTradeOrder(pageDTO)); - } - - @Override - public CommonResult updateTradeOrderPaySuccess(String tradeOrderId, Integer payAmount) { - tradeOrderService.updateTradeOrderPaySuccess(Integer.valueOf(tradeOrderId), payAmount); - return success(true); - } - -}