From 6cadafb3f10c5605d50b939eab7248f9bf03e63a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 4 Nov 2021 08:47:41 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=20=E6=94=AF=E4=BB=98=E5=AE=9D=20w?= =?UTF-8?q?ap=20=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/framework/pay/config/PayProperties.java | 6 ++---- .../framework/pay/core/client/dto/NotifyDataDTO.java | 3 +++ .../pay/core/client/dto/PayOrderUnifiedReqDTO.java | 10 ++++++---- .../core/client/impl/alipay/AlipayPayCodeMapping.java | 2 +- .../core/client/impl/alipay/AlipayWapPayClient.java | 4 +++- .../pay/controller/order/PayOrderController.java | 5 +++-- .../src/main/resources/static/pay_alipay_wap.html | 1 + .../resources/static/{pay.html => pay_wx_pub.html} | 0 8 files changed, 19 insertions(+), 12 deletions(-) rename yudao-user-server/src/main/resources/static/{pay.html => pay_wx_pub.html} (100%) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/PayProperties.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/PayProperties.java index 35accba3e..525ec876d 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/PayProperties.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/PayProperties.java @@ -6,8 +6,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.time.Duration; @ConfigurationProperties(prefix = "yudao.pay") @Validated @@ -25,11 +23,11 @@ public class PayProperties { * 退款回调地址 * 注意点,同 {@link #payNotifyUrl} 属性 */ - @NotNull(message = "短信发送频率不能为空") + @NotEmpty(message = "短信发送频率不能为空") @URL(message = "退款回调地址的格式必须是 URL") private String refundNotifyUrl; - + // TODO @jason:改成 payReturnUrl 。另外,可以加个 @NotEmpty,避免未填写 /** * 支付完成的返回地址 */ diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/NotifyDataDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/NotifyDataDTO.java index 6860edbc3..c081c4168 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/NotifyDataDTO.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/NotifyDataDTO.java @@ -6,12 +6,15 @@ import lombok.ToString; import java.util.Map; +// TODO @jason:NotifyDataDTO=》PayNotifyDataDTO。另外注释记得加起来哈 @Data @ToString @Builder public class NotifyDataDTO { + // TODO @jason:这个字段,改成 body private String origData; + // TODO @jason:这个字段如果暂时没用,可以去掉。 //1:xml 2:form private int format; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/PayOrderUnifiedReqDTO.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/PayOrderUnifiedReqDTO.java index d3fbf3cf9..6f99bb80d 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/PayOrderUnifiedReqDTO.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/dto/PayOrderUnifiedReqDTO.java @@ -44,13 +44,15 @@ public class PayOrderUnifiedReqDTO { @Length(max = 128, message = "商品描述信息长度不能超过128") private String body; /** - * 支付结果的回调地址 + * 支付结果的 notify 回调地址 */ @NotEmpty(message = "支付结果的回调地址不能为空") - @URL(message = "支付结果的回调地址必须是 URL 格式") + @URL(message = "支付结果的 notify 回调地址必须是 URL 格式") private String notifyUrl; - - @URL(message = "支付结果的return 必须是 URL 格式") + /** + * 支付结果的 return 回调地址 + */ + @URL(message = "支付结果的 return 回调地址必须是 URL 格式") private String returnUrl; // ========== 订单相关字段 ========== diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayCodeMapping.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayCodeMapping.java index a259ad436..b44dcb6aa 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayCodeMapping.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayPayCodeMapping.java @@ -19,7 +19,7 @@ public class AlipayPayCodeMapping extends AbstractPayCodeMapping { return GlobalErrorCodeConstants.SUCCESS; } // alipay wap api code 返回为null, 暂时定为-9999 - if(Objects.equals(apiCode, "-9999")){ + if(Objects.equals(apiCode, "-9999")){ // TODO @jason:空格要注意哈。if () { return GlobalErrorCodeConstants.SUCCESS; } return null; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java index de32a7239..a67e2a317 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java @@ -51,6 +51,7 @@ public class AlipayWapPayClient extends AbstractPayClient model.setTotalAmount(calculateAmount(reqDTO.getAmount()).toString()); model.setProductCode("QUICK_WAP_PAY"); // TODO 芋艿:这里咋整 //TODO 芋艿:这里咋整 jason @芋艿 可以去掉吧, + // TODO @jason: 这个支付方式,需要有 sellerId 么? //model.setSellerId("2088102147948060"); model.setTimeExpire(DateUtil.format(reqDTO.getExpireTime(),"yyyy-MM-dd HH:mm:ss")); // TODO 芋艿:userIp @@ -76,7 +77,7 @@ public class AlipayWapPayClient extends AbstractPayClient } } - + // TODO @jason: 注释记得补下哈 /** * //https://opendocs.alipay.com/open/203/105286 * @param data 通知结果 @@ -92,4 +93,5 @@ public class AlipayWapPayClient extends AbstractPayClient .successTime(DateUtil.parse(params.get("notify_time"), "yyyy-MM-dd HH:mm:ss")) .data(data.getOrigData()).build(); } + } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java index 6ec43d332..cb882752a 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java @@ -79,13 +79,14 @@ public class PayOrderController { @PostMapping(value = "/notify/alipay-wap/{channelId}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @ApiOperation("支付宝wap页面回调") public String notifyAliPayWapPayOrder(@PathVariable("channelId") Long channelId, - @RequestParam Map params, - @RequestBody String originData) throws Exception { + @RequestParam Map params, + @RequestBody String originData) throws Exception { //TODO @jason 校验 是否支付宝调用。 使用 支付宝publickey payclient 或许加一个校验方法 payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), NotifyDataDTO.builder().params(params).origData(originData).build()); return "success"; } + // TODO @jason 如果有些字段不注释,可以删除哈。不然 IDEA 会报警 /** * https://opendocs.alipay.com/open/203/105285#%E5%89%8D%E5%8F%B0%E5%9B%9E%E8%B7%B3%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E * @param channelId diff --git a/yudao-user-server/src/main/resources/static/pay_alipay_wap.html b/yudao-user-server/src/main/resources/static/pay_alipay_wap.html index 512a4112e..5f48dfce4 100644 --- a/yudao-user-server/src/main/resources/static/pay_alipay_wap.html +++ b/yudao-user-server/src/main/resources/static/pay_alipay_wap.html @@ -14,6 +14,7 @@