diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java index 07f8d0139..65879a3de 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java @@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient -@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"}) +@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.payservice.rpc"}) public class ManagementWebApplication { public static void main(String[] args) { diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/client/pay/transaction/PayTransactionClient.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/client/pay/transaction/PayTransactionClient.java index 70fa05444..81831a472 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/client/pay/transaction/PayTransactionClient.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/client/pay/transaction/PayTransactionClient.java @@ -2,20 +2,20 @@ package cn.iocoder.mall.managementweb.client.pay.transaction; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.payservice.rpc.transaction.PayTransactionRpc; +import cn.iocoder.mall.payservice.rpc.transaction.PayTransactionFeign; import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionPageReqDTO; import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionRespDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class PayTransactionClient { - @DubboReference(version = "${dubbo.consumer.PayTransactionRpc.version}") - private PayTransactionRpc payTransactionRpc; + @Autowired + private PayTransactionFeign payTransactionFeign; public PageResult pagePayTransaction(PayTransactionPageReqDTO pageReqDTO) { - CommonResult> pagePayTransactionResult = payTransactionRpc.pagePayTransaction(pageReqDTO); + CommonResult> pagePayTransactionResult = payTransactionFeign.pagePayTransaction(pageReqDTO); pagePayTransactionResult.checkError(); return pagePayTransactionResult.getData(); } diff --git a/pay-service-project/pay-service-api/pom.xml b/pay-service-project/pay-service-api/pom.xml index a5a5213a0..2a8412977 100644 --- a/pay-service-project/pay-service-api/pom.xml +++ b/pay-service-project/pay-service-api/pom.xml @@ -31,5 +31,9 @@ org.projectlombok lombok + + org.springframework.cloud + spring-cloud-openfeign-core + diff --git a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionFeign.java b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionFeign.java new file mode 100644 index 000000000..48dd9d09b --- /dev/null +++ b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionFeign.java @@ -0,0 +1,63 @@ +package cn.iocoder.mall.payservice.rpc.transaction; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.payservice.rpc.transaction.dto.*; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@FeignClient(value = "pay-service") +public interface PayTransactionFeign { + /** + * 创建支付交易单 + * + * @param createReqDTO 创建信息 + * @return 支付交易单号 + */ + @PostMapping("/pay/transaction/createPayTransaction") + CommonResult createPayTransaction(@RequestBody PayTransactionCreateReqDTO createReqDTO); + + /** + * 提交支付交易单 + * + * @param submitReqDTO 提交信息 + * @return 提交响应,包含三方支付的响应 + */ + @PostMapping("/pay/transaction/submitPayTransaction") + CommonResult submitPayTransaction(@RequestBody PayTransactionSubmitReqDTO submitReqDTO); + + /** + * 获得当支付交易单 + * + * @param getReqDTO 获得条件 + * @return 支付交易单 + */ + @PostMapping("/pay/transaction/getPayTransaction") + CommonResult getPayTransaction(@RequestBody PayTransactionGetReqDTO getReqDTO); + + /** + * 更新交易支付成功 + * + * @param successReqDTO 支付成功信息 + * @return 是否成功 + */ + @PostMapping("/pay/transaction/updatePayTransactionSuccess") + CommonResult updatePayTransactionSuccess(@RequestBody PayTransactionSuccessReqDTO successReqDTO); + + /** + * 获得交易支付单分页 + * + * @param pageReqDTO 分页条件 + * @return 交易支付单分页 + */ + @PostMapping("/pay/transaction/pagePayTransaction") + CommonResult> pagePayTransaction(@RequestBody PayTransactionPageReqDTO pageReqDTO); +} diff --git a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpc.java b/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpc.java deleted file mode 100644 index 11f0bba6b..000000000 --- a/pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpc.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.iocoder.mall.payservice.rpc.transaction; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.payservice.rpc.transaction.dto.*; - -/** - * 支付交易单 RPC 接口 - */ -public interface PayTransactionRpc { - - /** - * 创建支付交易单 - * - * @param createReqDTO 创建信息 - * @return 支付交易单号 - */ - CommonResult createPayTransaction(PayTransactionCreateReqDTO createReqDTO); - - /** - * 提交支付交易单 - * - * @param submitReqDTO 提交信息 - * @return 提交响应,包含三方支付的响应 - */ - CommonResult submitPayTransaction(PayTransactionSubmitReqDTO submitReqDTO); - - /** - * 获得当支付交易单 - * - * @param getReqDTO 获得条件 - * @return 支付交易单 - */ - CommonResult getPayTransaction(PayTransactionGetReqDTO getReqDTO); - - /** - * 更新交易支付成功 - * - * @param successReqDTO 支付成功信息 - * @return 是否成功 - */ - CommonResult updatePayTransactionSuccess(PayTransactionSuccessReqDTO successReqDTO); - - /** - * 获得交易支付单分页 - * - * @param pageReqDTO 分页条件 - * @return 交易支付单分页 - */ - CommonResult> pagePayTransaction(PayTransactionPageReqDTO pageReqDTO); - -} diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/PayServiceApplication.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/PayServiceApplication.java index 35ff693b5..67d3e4171 100644 --- a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/PayServiceApplication.java +++ b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/PayServiceApplication.java @@ -2,8 +2,12 @@ package cn.iocoder.mall.payservice; 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 public class PayServiceApplication { public static void main(String[] args) { diff --git a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpcImpl.java b/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpcImpl.java deleted file mode 100644 index c50e0c3b3..000000000 --- a/pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/rpc/transaction/PayTransactionRpcImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package cn.iocoder.mall.payservice.rpc.transaction; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.payservice.rpc.transaction.dto.*; -import cn.iocoder.mall.payservice.service.transaction.PayTransactionService; -import org.apache.dubbo.config.annotation.DubboService; -import org.springframework.beans.factory.annotation.Autowired; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -@DubboService -public class PayTransactionRpcImpl implements PayTransactionRpc { - - @Autowired - private PayTransactionService payTransactionService; - - @Override - public CommonResult createPayTransaction(PayTransactionCreateReqDTO createReqDTO) { - return success(payTransactionService.createPayTransaction(createReqDTO)); - } - - @Override - public CommonResult submitPayTransaction(PayTransactionSubmitReqDTO submitReqDTO) { - return success(payTransactionService.submitPayTransaction(submitReqDTO)); - } - - @Override - public CommonResult getPayTransaction(PayTransactionGetReqDTO getReqDTO) { - return success(payTransactionService.getPayTransaction(getReqDTO)); - } - - @Override - public CommonResult updatePayTransactionSuccess(PayTransactionSuccessReqDTO successReqDTO) { - return success(payTransactionService.updateTransactionPaySuccess(successReqDTO.getPayChannel(), - successReqDTO.getParams())); - } - - @Override - public CommonResult> pagePayTransaction(PayTransactionPageReqDTO pageReqDTO) { - return success(payTransactionService.pagePayTransaction(pageReqDTO)); - } - -} diff --git a/pay-service-project/pay-service-app/src/main/java/controller/PayTransactionController.java b/pay-service-project/pay-service-app/src/main/java/controller/PayTransactionController.java new file mode 100644 index 000000000..cdba02531 --- /dev/null +++ b/pay-service-project/pay-service-app/src/main/java/controller/PayTransactionController.java @@ -0,0 +1,81 @@ +package controller; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.payservice.rpc.transaction.dto.*; +import cn.iocoder.mall.payservice.service.transaction.PayTransactionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** + * Title: + * Description: + * + * @author zhuyang + * @version 1.0 2021/10/9 + */ +@RestController +@RequestMapping("/pay/transaction") +public class PayTransactionController { + @Autowired + private PayTransactionService payTransactionService; + + /** + * 创建支付交易单 + * + * @param createReqDTO 创建信息 + * @return 支付交易单号 + */ + @PostMapping("createPayTransaction") + CommonResult createPayTransaction(@RequestBody PayTransactionCreateReqDTO createReqDTO){ + return success(payTransactionService.createPayTransaction(createReqDTO)); + } + + /** + * 提交支付交易单 + * + * @param submitReqDTO 提交信息 + * @return 提交响应,包含三方支付的响应 + */ + @PostMapping("submitPayTransaction") + CommonResult submitPayTransaction(@RequestBody PayTransactionSubmitReqDTO submitReqDTO){ + return success(payTransactionService.submitPayTransaction(submitReqDTO)); + } + + /** + * 获得当支付交易单 + * + * @param getReqDTO 获得条件 + * @return 支付交易单 + */ + @PostMapping("getPayTransaction") + CommonResult getPayTransaction(@RequestBody PayTransactionGetReqDTO getReqDTO){ + return success(payTransactionService.getPayTransaction(getReqDTO));} + + /** + * 更新交易支付成功 + * + * @param successReqDTO 支付成功信息 + * @return 是否成功 + */ + @PostMapping("updatePayTransactionSuccess") + CommonResult updatePayTransactionSuccess(@RequestBody PayTransactionSuccessReqDTO successReqDTO){ + return success(payTransactionService.updateTransactionPaySuccess(successReqDTO.getPayChannel(), + successReqDTO.getParams()));} + + /** + * 获得交易支付单分页 + * + * @param pageReqDTO 分页条件 + * @return 交易支付单分页 + */ + @PostMapping("pagePayTransaction") + CommonResult> pagePayTransaction(@RequestBody PayTransactionPageReqDTO pageReqDTO){ + return success(payTransactionService.pagePayTransaction(pageReqDTO));} + +} 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 788af718e..944a3326c 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 @@ -8,7 +8,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.searchservice.rpc", - "cn.iocoder.mall.tradeservice.rpc"}) + "cn.iocoder.mall.tradeservice.rpc","cn.iocoder.mall.payservice.rpc"}) public class ShopWebApplication { public static void main(String[] args) { diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/pay/PayTransactionClient.java b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/pay/PayTransactionClient.java index 48c54a428..c24aadffc 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/pay/PayTransactionClient.java +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/client/pay/PayTransactionClient.java @@ -1,9 +1,9 @@ package cn.iocoder.mall.shopweb.client.pay; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.payservice.rpc.transaction.PayTransactionRpc; +import cn.iocoder.mall.payservice.rpc.transaction.PayTransactionFeign; import cn.iocoder.mall.payservice.rpc.transaction.dto.*; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Objects; @@ -11,11 +11,12 @@ import java.util.Objects; @Service public class PayTransactionClient { - @DubboReference(version = "${dubbo.consumer.PayTransactionRpc.version}") - private PayTransactionRpc payTransactionRpc; + + @Autowired + private PayTransactionFeign payTransactionFeign; public PayTransactionRespDTO getPayTransaction(Integer userId, String appId, String orderId) { - CommonResult getPayTransactionResult = payTransactionRpc.getPayTransaction(new PayTransactionGetReqDTO() + CommonResult getPayTransactionResult = payTransactionFeign.getPayTransaction(new PayTransactionGetReqDTO() .setAppId(appId).setOrderId(orderId)); getPayTransactionResult.checkError(); if (getPayTransactionResult.getData() == null) { @@ -27,13 +28,13 @@ public class PayTransactionClient { } public PayTransactionSubmitRespDTO submitPayTransaction(PayTransactionSubmitReqDTO submitReqDTO) { - CommonResult submitPayTransactionResult = payTransactionRpc.submitPayTransaction(submitReqDTO); + CommonResult submitPayTransactionResult = payTransactionFeign.submitPayTransaction(submitReqDTO); submitPayTransactionResult.checkError(); return submitPayTransactionResult.getData(); } public void updatePayTransactionSuccess(Integer payChannel, String params) { - CommonResult updatePayTransactionSuccessResult = payTransactionRpc.updatePayTransactionSuccess( + CommonResult updatePayTransactionSuccessResult = payTransactionFeign.updatePayTransactionSuccess( new PayTransactionSuccessReqDTO().setPayChannel(payChannel).setParams(params)); updatePayTransactionSuccessResult.checkError(); } 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 index f4d45500b..e3b3e816e 100644 --- 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 @@ -25,7 +25,7 @@ public interface CartFeign { * @param addReqDTO 添加商品信息 * @return 成功 */ - @PostMapping("addCartItem") + @PostMapping("/trade/cart/addCartItem") CommonResult addCartItem(@RequestBody CartItemAddReqDTO addReqDTO); /** @@ -34,7 +34,7 @@ public interface CartFeign { * @param updateQuantityReqDTO 更新商品数量 DTO * @return 成功 */ - @PostMapping("updateCartItemQuantity") + @PostMapping("/trade/cart/updateCartItemQuantity") CommonResult updateCartItemQuantity(@RequestBody CartItemUpdateQuantityReqDTO updateQuantityReqDTO); /** @@ -43,7 +43,7 @@ public interface CartFeign { * @param updateSelectedReqDTO 更新商品是否选中 DTO * @return 成功 */ - @PostMapping("updateCartItemSelected") + @PostMapping("/trade/cart/updateCartItemSelected") CommonResult updateCartItemSelected(@RequestBody CartItemUpdateSelectedReqDTO updateSelectedReqDTO); /** @@ -52,10 +52,10 @@ public interface CartFeign { * @param deleteListReqDTO 删除商品列表 DTO * @return 成功 */ - @PostMapping("deleteCartItems") + @PostMapping("/trade/cart/deleteCartItems") CommonResult deleteCartItems(@RequestBody CartItemDeleteListReqDTO deleteListReqDTO); @GetMapping("/sumCartItemQuantity") public CommonResult sumCartItemQuantity(@RequestParam("userId") Integer userId) ; - @PostMapping("/listCartItems") + @PostMapping("/trade/cart/listCartItems") public CommonResult> listCartItems(@RequestBody CartItemListReqDTO listReqDTO) ; } diff --git a/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderFeign.java b/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderFeign.java index 682698fb6..82405ff58 100644 --- a/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderFeign.java +++ b/trade-service-project/trade-service-api/src/main/java/cn/iocoder/mall/tradeservice/rpc/order/TradeOrderFeign.java @@ -29,7 +29,7 @@ public interface TradeOrderFeign { * @param createReqDTO 订单信息 * @return 订单编号 */ - @PostMapping("createTradeOrder") + @PostMapping("/trade/order/createTradeOrder") CommonResult createTradeOrder(@RequestBody TradeOrderCreateReqDTO createReqDTO); /** @@ -39,7 +39,7 @@ public interface TradeOrderFeign { * @param fields 额外返回字段,可见 {@link cn.iocoder.mall.tradeservice.enums.order.TradeOrderDetailFieldEnum} * @return 订单交易 */ - @GetMapping("getTradeOrder") + @GetMapping("/trade/order/getTradeOrder") CommonResult getTradeOrder(@RequestParam("tradeOrderId")Integer tradeOrderId, @RequestParam("fields") Collection fields); /** * 获得交易订单分页 @@ -47,7 +47,7 @@ public interface TradeOrderFeign { * @param pageDTO 订单交易分页查询 * @return 订单交易分页结果 */ - @PostMapping("pageTradeOrder") + @PostMapping("/trade/order/pageTradeOrder") CommonResult> pageTradeOrder(@RequestBody TradeOrderPageReqDTO pageDTO); // TODO 芋艿:需要重构成入参是 DTO,方便后续升级;返回是 CommonResult,用于返回失败的原因 @@ -60,6 +60,6 @@ public interface TradeOrderFeign { * @param payAmount 支付金额 * @return 成功 */ - @PostMapping("updateTradeOrderPaySuccess") + @PostMapping("/trade/order/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/client/pay/PayTransactionClient.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/pay/PayTransactionClient.java index f74b06783..a739c22d8 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/pay/PayTransactionClient.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/client/pay/PayTransactionClient.java @@ -1,19 +1,19 @@ package cn.iocoder.mall.tradeservice.client.pay; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.payservice.rpc.transaction.PayTransactionRpc; +import cn.iocoder.mall.payservice.rpc.transaction.PayTransactionFeign; import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO; -import org.apache.dubbo.config.annotation.DubboReference; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class PayTransactionClient { - @DubboReference(version = "${dubbo.consumer.PayTransactionRpc.version}") - private PayTransactionRpc payTransactionRpc; + @Autowired + private PayTransactionFeign payTransactionFeign; public Integer createPayTransaction(PayTransactionCreateReqDTO createReqDTO) { - CommonResult createPayTransactionResult = payTransactionRpc.createPayTransaction(createReqDTO); + CommonResult createPayTransactionResult = payTransactionFeign.createPayTransaction(createReqDTO); createPayTransactionResult.checkError(); return createPayTransactionResult.getData(); }