From b18cd457c8b4b9c9fb00927d73d88e088fcdf49c Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 21 Nov 2021 12:24:08 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=20=E6=94=AF=E4=BB=98=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E4=BB=A3=E7=A0=81=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/pay/core/client/dto/PayNotifyDataDTO.java | 1 + .../framework/pay/core/client/impl/AbstractPayClient.java | 5 ++--- .../yudao/framework/pay/core/enums/PayChannelRespEnum.java | 1 + .../alipay/AlipayQrPayClientTest.java | 7 +++++-- .../modules/pay/controller/order/vo/PayRefundReqVO.java | 1 - .../modules/pay/convert/order/PayRefundConvert.java | 2 +- .../modules/shop/controller/ShopOrderController.java | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/PayNotifyDataDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/PayNotifyDataDTO.java index 7b0672460..060a6bfd6 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/PayNotifyDataDTO.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/PayNotifyDataDTO.java @@ -15,6 +15,7 @@ import java.util.Map; @Builder public class PayNotifyDataDTO { + // TODO @jason:使用 /** */ 的形式注释哈 //返回的所有参数 private String body; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java index 8f5678b8b..bcffa71a8 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/AbstractPayClient.java @@ -105,12 +105,11 @@ public abstract class AbstractPayClient implemen @Override public PayRefundUnifiedRespDTO unifiedRefund(PayRefundUnifiedReqDTO reqDTO) { - PayRefundUnifiedRespDTO resp; try { resp = doUnifiedRefund(reqDTO); - }catch (SocketTimeoutException ex){ - //网络 read time out 异常 + } catch (SocketTimeoutException ex){ + // 网络 read time out 异常 log.error("[unifiedRefund][request({}) 发起退款失败,网络读超时,退款状态未知]", toJsonString(reqDTO), ex); return PayRefundUnifiedRespDTO.builder() .exceptionMsg(ex.getMessage()) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelRespEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelRespEnum.java index e9d29a9f3..44c0a4955 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelRespEnum.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/enums/PayChannelRespEnum.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.framework.pay.core.enums; +// TODO @芋艿:感觉情况有点多,得讨论下 /** * 统一的渠道返回结果 * @author jason diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn.iocoder.yudao.framework.pay.core.client.impl/alipay/AlipayQrPayClientTest.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn.iocoder.yudao.framework.pay.core.client.impl/alipay/AlipayQrPayClientTest.java index 37336fecf..e511095dc 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn.iocoder.yudao.framework.pay.core.client.impl/alipay/AlipayQrPayClientTest.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/test/java/cn.iocoder.yudao.framework.pay.core.client.impl/alipay/AlipayQrPayClientTest.java @@ -25,6 +25,7 @@ public class AlipayQrPayClientTest extends BaseMockitoUnitTest { .setAppId("2021000118634035") .setServerUrl(AlipayPayClientConfig.SERVER_URL_SANDBOX) .setSignType(AlipayPayClientConfig.SIGN_TYPE_DEFAULT) + // TODO @tina:key 可以随机就好,简洁一点哈。 .setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCHsEV1cDupwJ" + "v890x84qbppUtRIfhaKSwSVN0thCcsDCaAsGR5MZslDkO8NCT9V4r2SVXjyY7eJUZlZd1M0C8T" + "01Tg4UOx5LUbic0O3A1uJMy6V1n9IyYwbAW3AEZhBd5bSbPgrqvmv3NeWSTQT6Anxnllf+2iDH" + @@ -50,8 +51,8 @@ public class AlipayQrPayClientTest extends BaseMockitoUnitTest { "gnZFv2gK51HExF8v/BaP7P979PhFMgWTqmOOI+Dtno5s+yD09XTY1WkshbLk6i4g2Xlr8fyW9ODnkU88RI2w9UdPhQU4cPPwBN" + "lrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZ" + "ikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); - // 创建客户端 + // TODO @tina:= 前后要有空格哈 @InjectMocks AlipayQrPayClient client=new AlipayQrPayClient(10L,config); @@ -66,7 +67,8 @@ public class AlipayQrPayClientTest extends BaseMockitoUnitTest { } @Test public void create() throws AlipayApiException { - + // TODO @tina:参数可以尽量随机一点,使用随机方法。这样的好处是,避免对固定参数的依赖,导致可能仅仅满足固定参数的结果 + // 这里,设置可以直接随机整个对象。 Long shopOrderId = System.currentTimeMillis(); PayOrderUnifiedReqDTO reqDTO=new PayOrderUnifiedReqDTO(); reqDTO.setMerchantOrderId(String.valueOf(System.currentTimeMillis())); @@ -88,6 +90,7 @@ public class AlipayQrPayClientTest extends BaseMockitoUnitTest { // 断言 assertEquals(response.getCode(), result.getApiCode()); assertEquals(response.getMsg(), result.getApiMsg()); + // TODO @tina:这个断言木有过? assertEquals(GlobalErrorCodeConstants.SUCCESS.getCode(), result.getCode()); assertEquals(GlobalErrorCodeConstants.SUCCESS.getMsg(), result.getMsg()); diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/vo/PayRefundReqVO.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/vo/PayRefundReqVO.java index c9d73fdf9..dce32f7c7 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/vo/PayRefundReqVO.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/vo/PayRefundReqVO.java @@ -22,7 +22,6 @@ public class PayRefundReqVO { @NotEmpty(message = "退款金额") private Long amount; - @ApiModelProperty(value = "退款原因", required = true, example = "不喜欢") @NotEmpty(message = "退款原因") private String reason; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/convert/order/PayRefundConvert.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/convert/order/PayRefundConvert.java index 9d5c479b3..0a3ae4674 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/convert/order/PayRefundConvert.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/convert/order/PayRefundConvert.java @@ -8,7 +8,7 @@ import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; /** - * 支付退款 Convert + * 支付退款 Convert // TODO @jason:类注释,和下面,有一个空行哈 * @author jason */ @Mapper diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/ShopOrderController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/ShopOrderController.java index 6dc0a3032..f9d9a7660 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/ShopOrderController.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/shop/controller/ShopOrderController.java @@ -58,7 +58,7 @@ public class ShopOrderController { } - + // TODO @jason:方法之间,空一行即可哈 @PostMapping("/pay-notify") @ApiOperation("支付回调") public CommonResult payNotify(@RequestBody @Valid PayNotifyOrderReqVO reqVO) {