Commit 26798a881698a30f2b7e9f534c9b4bd6c8a88db4
1 parent
87d8b55b
修改code review
Showing
7 changed files
with
23 additions
and
22 deletions
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/pay/service/order/impl/PayOrderCoreServiceImpl.java
| @@ -159,7 +159,7 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService { | @@ -159,7 +159,7 @@ public class PayOrderCoreServiceImpl implements PayOrderCoreService { | ||
| 159 | * @return | 159 | * @return |
| 160 | */ | 160 | */ |
| 161 | private String genChannelReturnUrl(PayChannelDO channel) { | 161 | private String genChannelReturnUrl(PayChannelDO channel) { |
| 162 | - return payProperties.getReturnUrl() + "/" + StrUtil.replace(channel.getCode(), "_", "-") | 162 | + return payProperties.getPayReturnUrl() + "/" + StrUtil.replace(channel.getCode(), "_", "-") |
| 163 | + "/" + channel.getId(); | 163 | + "/" + channel.getId(); |
| 164 | } | 164 | } |
| 165 | 165 |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/config/PayProperties.java
| @@ -23,15 +23,16 @@ public class PayProperties { | @@ -23,15 +23,16 @@ public class PayProperties { | ||
| 23 | * 退款回调地址 | 23 | * 退款回调地址 |
| 24 | * 注意点,同 {@link #payNotifyUrl} 属性 | 24 | * 注意点,同 {@link #payNotifyUrl} 属性 |
| 25 | */ | 25 | */ |
| 26 | - @NotEmpty(message = "短信发送频率不能为空") | 26 | + @NotEmpty(message = "退款回调地址不能为空") |
| 27 | @URL(message = "退款回调地址的格式必须是 URL") | 27 | @URL(message = "退款回调地址的格式必须是 URL") |
| 28 | private String refundNotifyUrl; | 28 | private String refundNotifyUrl; |
| 29 | 29 | ||
| 30 | - // TODO @jason:改成 payReturnUrl 。另外,可以加个 @NotEmpty,避免未填写 | 30 | + |
| 31 | /** | 31 | /** |
| 32 | * 支付完成的返回地址 | 32 | * 支付完成的返回地址 |
| 33 | */ | 33 | */ |
| 34 | @URL(message = "支付返回的地址的格式必须是 URL") | 34 | @URL(message = "支付返回的地址的格式必须是 URL") |
| 35 | - private String returnUrl; | 35 | + @NotEmpty(message = "支付返回的地址不能为空") |
| 36 | + private String payReturnUrl; | ||
| 36 | 37 | ||
| 37 | } | 38 | } |
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 { | @@ -19,7 +19,7 @@ public class AlipayPayCodeMapping extends AbstractPayCodeMapping { | ||
| 19 | return GlobalErrorCodeConstants.SUCCESS; | 19 | return GlobalErrorCodeConstants.SUCCESS; |
| 20 | } | 20 | } |
| 21 | // alipay wap api code 返回为null, 暂时定为-9999 | 21 | // alipay wap api code 返回为null, 暂时定为-9999 |
| 22 | - if(Objects.equals(apiCode, "-9999")){ // TODO @jason:空格要注意哈。if () { | 22 | + if (Objects.equals(apiCode, "-9999")) { |
| 23 | return GlobalErrorCodeConstants.SUCCESS; | 23 | return GlobalErrorCodeConstants.SUCCESS; |
| 24 | } | 24 | } |
| 25 | return null; | 25 | return null; |
yudao-framework/yudao-spring-boot-starter-biz-pay/src/main/java/cn/iocoder/yudao/framework/pay/core/client/impl/alipay/AlipayWapPayClient.java
| @@ -51,7 +51,8 @@ public class AlipayWapPayClient extends AbstractPayClient<AlipayPayClientConfig> | @@ -51,7 +51,8 @@ public class AlipayWapPayClient extends AbstractPayClient<AlipayPayClientConfig> | ||
| 51 | model.setTotalAmount(calculateAmount(reqDTO.getAmount()).toString()); | 51 | model.setTotalAmount(calculateAmount(reqDTO.getAmount()).toString()); |
| 52 | model.setProductCode("QUICK_WAP_PAY"); // TODO 芋艿:这里咋整 | 52 | model.setProductCode("QUICK_WAP_PAY"); // TODO 芋艿:这里咋整 |
| 53 | //TODO 芋艿:这里咋整 jason @芋艿 可以去掉吧, | 53 | //TODO 芋艿:这里咋整 jason @芋艿 可以去掉吧, |
| 54 | - // TODO @jason: 这个支付方式,需要有 sellerId 么? | 54 | + // TODO 芋艿 似乎这里不用传sellerId |
| 55 | + // https://opendocs.alipay.com/apis/api_1/alipay.trade.wap.pay | ||
| 55 | //model.setSellerId("2088102147948060"); | 56 | //model.setSellerId("2088102147948060"); |
| 56 | model.setTimeExpire(DateUtil.format(reqDTO.getExpireTime(),"yyyy-MM-dd HH:mm:ss")); | 57 | model.setTimeExpire(DateUtil.format(reqDTO.getExpireTime(),"yyyy-MM-dd HH:mm:ss")); |
| 57 | // TODO 芋艿:userIp | 58 | // TODO 芋艿:userIp |
| @@ -77,12 +78,13 @@ public class AlipayWapPayClient extends AbstractPayClient<AlipayPayClientConfig> | @@ -77,12 +78,13 @@ public class AlipayWapPayClient extends AbstractPayClient<AlipayPayClientConfig> | ||
| 77 | } | 78 | } |
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | - // TODO @jason: 注释记得补下哈 | 81 | + |
| 81 | /** | 82 | /** |
| 83 | + * 从支付宝通知返回参数中解析 PayOrderNotifyRespDTO, 通知具体参数参考 | ||
| 82 | * //https://opendocs.alipay.com/open/203/105286 | 84 | * //https://opendocs.alipay.com/open/203/105286 |
| 83 | * @param data 通知结果 | 85 | * @param data 通知结果 |
| 84 | - * @return | ||
| 85 | - * @throws Exception | 86 | + * @return 解析结果 PayOrderNotifyRespDTO |
| 87 | + * @throws Exception 解析失败,抛出异常 | ||
| 86 | */ | 88 | */ |
| 87 | @Override | 89 | @Override |
| 88 | public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws Exception { | 90 | public PayOrderNotifyRespDTO parseOrderNotify(PayNotifyDataDTO data) throws Exception { |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/pay/controller/order/PayOrderController.java
| @@ -84,22 +84,21 @@ public class PayOrderController { | @@ -84,22 +84,21 @@ public class PayOrderController { | ||
| 84 | public String notifyAliPayWapPayOrder(@PathVariable("channelId") Long channelId, | 84 | public String notifyAliPayWapPayOrder(@PathVariable("channelId") Long channelId, |
| 85 | @RequestParam Map<String, String> params, | 85 | @RequestParam Map<String, String> params, |
| 86 | @RequestBody String originData) throws Exception { | 86 | @RequestBody String originData) throws Exception { |
| 87 | - //TODO @jason 校验 是否支付宝调用。 使用 支付宝publickey payclient 或许加一个校验方法 | 87 | + //TODO @jason 校验 是否支付宝调用。 payclient 中加一个校验方法 |
| 88 | payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), PayNotifyDataDTO.builder().params(params).body(originData).build()); | 88 | payOrderCoreService.notifyPayOrder(channelId, PayChannelEnum.ALIPAY_WAP.getCode(), PayNotifyDataDTO.builder().params(params).body(originData).build()); |
| 89 | return "success"; | 89 | return "success"; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | - // TODO @jason 如果有些字段不注释,可以删除哈。不然 IDEA 会报警 | 92 | + |
| 93 | /** | 93 | /** |
| 94 | * 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 | 94 | * 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 |
| 95 | - * @param channelId | ||
| 96 | - * @return | ||
| 97 | - * @throws Exception | 95 | + * @param channelId 渠道id |
| 96 | + * @return 返回跳转页面 | ||
| 98 | */ | 97 | */ |
| 99 | @GetMapping(value = "/return/alipay-wap/{channelId}") | 98 | @GetMapping(value = "/return/alipay-wap/{channelId}") |
| 100 | @ApiOperation("支付宝wap页面回跳") | 99 | @ApiOperation("支付宝wap页面回跳") |
| 101 | public String returnAliPayWapPayOrder(@PathVariable("channelId") Long channelId){ | 100 | public String returnAliPayWapPayOrder(@PathVariable("channelId") Long channelId){ |
| 102 | - //TODO @jason 校验 是否支付宝调用。 支付宝publickey 可以根据 appId 跳转不同的页面 | 101 | + //TODO 校验 是否支付宝调用。 可以根据 appId 跳转不同的页面 |
| 103 | return "支付成功"; | 102 | return "支付成功"; |
| 104 | } | 103 | } |
| 105 | 104 |
yudao-user-server/src/main/resources/application-local.yaml
| @@ -155,4 +155,4 @@ yudao: | @@ -155,4 +155,4 @@ yudao: | ||
| 155 | pay: | 155 | pay: |
| 156 | pay-notify-url: http://jg6rde.natappfree.cc/api/pay/order/notify | 156 | pay-notify-url: http://jg6rde.natappfree.cc/api/pay/order/notify |
| 157 | refund-notify-url: http://jg6rde.natappfree.cc/api/pay/refund/notify | 157 | refund-notify-url: http://jg6rde.natappfree.cc/api/pay/refund/notify |
| 158 | - return-url: http://jg6rde.natappfree.cc/api/pay/order/return | 158 | + pay-return-url: http://jg6rde.natappfree.cc/api/pay/order/return |
yudao-user-server/src/main/resources/static/pay_alipay_wap.html
| @@ -9,18 +9,17 @@ | @@ -9,18 +9,17 @@ | ||
| 9 | <body> | 9 | <body> |
| 10 | <div>点击如下按钮,发起支付的测试</div> | 10 | <div>点击如下按钮,发起支付的测试</div> |
| 11 | <div> | 11 | <div> |
| 12 | - <button id="alipay_wap">支付宝h5</button> | 12 | + <button id="alipay_wap">支付宝手机网站支付</button> |
| 13 | </div> | 13 | </div> |
| 14 | <div id="dynamic_form"></div> | 14 | <div id="dynamic_form"></div> |
| 15 | </body> | 15 | </body> |
| 16 | <script> | 16 | <script> |
| 17 | - // TODO @jason:copy 过来后,有些注释要改过来哈 | 17 | + |
| 18 | let shopOrderId = undefined; | 18 | let shopOrderId = undefined; |
| 19 | let payOrderId = undefined; | 19 | let payOrderId = undefined; |
| 20 | let server = 'http://127.0.0.1:28080'; | 20 | let server = 'http://127.0.0.1:28080'; |
| 21 | //let server = 'http://niubi.natapp1.cc'; | 21 | //let server = 'http://niubi.natapp1.cc'; |
| 22 | - // TODO openid | ||
| 23 | - //let openid = "ockUAwIZ-0OeMZl9ogcZ4ILrGba0"; | 22 | + |
| 24 | $(function() { | 23 | $(function() { |
| 25 | // 自动发起商城订单编号 | 24 | // 自动发起商城订单编号 |
| 26 | $.ajax({ | 25 | $.ajax({ |
| @@ -38,7 +37,7 @@ | @@ -38,7 +37,7 @@ | ||
| 38 | } | 37 | } |
| 39 | }) | 38 | }) |
| 40 | }); | 39 | }); |
| 41 | - // 微信公众号 | 40 | + |
| 42 | $( "#alipay_wap").on( "click", function() { | 41 | $( "#alipay_wap").on( "click", function() { |
| 43 | // 提交支付 | 42 | // 提交支付 |
| 44 | $.ajax({ | 43 | $.ajax({ |
| @@ -56,7 +55,7 @@ | @@ -56,7 +55,7 @@ | ||
| 56 | return; | 55 | return; |
| 57 | } | 56 | } |
| 58 | alert('点击确定,开始支付'); | 57 | alert('点击确定,开始支付'); |
| 59 | - // 开始调用微信支付 | 58 | + //支付宝 手机WAP 返回表单,自动跳到支付宝支付页面 |
| 60 | let data = result.data.invokeResponse; | 59 | let data = result.data.invokeResponse; |
| 61 | $("#dynamic_form").html(data.body); | 60 | $("#dynamic_form").html(data.body); |
| 62 | } | 61 | } |