Commit 3bd524e9b347253f343213b07e29f0713b3172ab
1 parent
dfffe8a7
rtsmart payment result api
Showing
2 changed files
with
45 additions
and
0 deletions
cashier-boss/src/main/java/com/diligrp/cashier/boss/controller/CashierDeskController.java
| ... | ... | @@ -2,10 +2,13 @@ package com.diligrp.cashier.boss.controller; |
| 2 | 2 | |
| 3 | 3 | import com.diligrp.cashier.boss.domain.CashierOrderDTO; |
| 4 | 4 | import com.diligrp.cashier.boss.domain.CashierPaymentUrl; |
| 5 | +import com.diligrp.cashier.boss.domain.ZrPaymentResult; | |
| 5 | 6 | import com.diligrp.cashier.boss.service.ICashierDeskService; |
| 6 | 7 | import com.diligrp.cashier.boss.service.IMerchantService; |
| 7 | 8 | import com.diligrp.cashier.boss.util.CashierOrderConverter; |
| 9 | +import com.diligrp.cashier.mall.service.biz.PayNotifyService; | |
| 8 | 10 | import com.diligrp.cashier.pipeline.domain.OnlinePaymentStatus; |
| 11 | +import com.diligrp.cashier.pipeline.type.PaymentState; | |
| 9 | 12 | import com.diligrp.cashier.shared.domain.Message; |
| 10 | 13 | import com.diligrp.cashier.shared.util.AssertUtils; |
| 11 | 14 | import com.diligrp.cashier.trade.domain.*; |
| ... | ... | @@ -25,6 +28,9 @@ public class CashierDeskController { |
| 25 | 28 | @Resource |
| 26 | 29 | private ICashierDeskService cashierDeskService; |
| 27 | 30 | |
| 31 | + @Resource | |
| 32 | + private PayNotifyService payNotifyService; | |
| 33 | + | |
| 28 | 34 | @RequestMapping("/submitOrder") |
| 29 | 35 | public Message<?> submitOrder(@RequestBody CashierOrderDTO request) { |
| 30 | 36 | // 基本参数校验 |
| ... | ... | @@ -71,6 +77,22 @@ public class CashierDeskController { |
| 71 | 77 | return Message.success(response); |
| 72 | 78 | } |
| 73 | 79 | |
| 80 | + /** | |
| 81 | + * 中瑞对接大润发查支付状态接口 | |
| 82 | + * 大润发支付成功页面验签功能会限制有效期3分钟, 只能在查询状态时返回大润发成功页面(生成签名), 否则有超时风险 | |
| 83 | + * 为了保证收银台后端的统一性, 新增单独接口查询状态 | |
| 84 | + */ | |
| 85 | + @RequestMapping(value = "/zrPaymentState") | |
| 86 | + public Message<?> zrPaymentState(@RequestParam("paymentId") String paymentId, | |
| 87 | + @RequestParam(name = "mode", required = false) String mode) { | |
| 88 | + | |
| 89 | + OnlinePaymentResult response = cashierDeskService.queryPaymentState(paymentId, mode); | |
| 90 | + String redirectUrl = PaymentState.SUCCESS.equalTo(response.getState()) ? | |
| 91 | + payNotifyService.redirectUrl(response.getTradeId()) : null; | |
| 92 | + | |
| 93 | + return Message.success(new ZrPaymentResult(response, redirectUrl)); | |
| 94 | + } | |
| 95 | + | |
| 74 | 96 | @RequestMapping(value = "/orderRefund") |
| 75 | 97 | public Message<?> requestRefund(@RequestBody OnlineRefundDTO request) { |
| 76 | 98 | AssertUtils.notEmpty(request.getTradeId(), "tradeId missed"); | ... | ... |
cashier-boss/src/main/java/com/diligrp/cashier/boss/domain/ZrPaymentResult.java
0 → 100644
| 1 | +package com.diligrp.cashier.boss.domain; | |
| 2 | + | |
| 3 | +import com.diligrp.cashier.trade.domain.OnlinePaymentResult; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 中瑞对接大润发查支付状态领域模型 | |
| 7 | + * 大润发支付成功页面验签功能会限制有效期3分钟, 只能在查询状态时返回大润发成功页面(生成签名), 否则有超时风险 | |
| 8 | + * 为了保证收银台后端的统一性, 新增单独接口查询状态 | |
| 9 | + */ | |
| 10 | +public class ZrPaymentResult extends OnlinePaymentResult { | |
| 11 | + // 大润发支付成功页面地址 | |
| 12 | + private final String redirectUrl; | |
| 13 | + | |
| 14 | + public ZrPaymentResult(OnlinePaymentResult result, String redirectUrl) { | |
| 15 | + super(result.getTradeId(), result.getPaymentId(), result.getState(), result.getOutTradeNo(), | |
| 16 | + result.getOutPayType(), result.getPayerId(), result.getWhen(), result.getMessage()); | |
| 17 | + this.redirectUrl = redirectUrl; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public String getRedirectUrl() { | |
| 21 | + return redirectUrl; | |
| 22 | + } | |
| 23 | +} | ... | ... |