Commit 479f2c35dc5f7b0cbc7160fb91c0a3f78e35ce1e
1 parent
95109117
refund result issue fixed
Showing
3 changed files
with
14 additions
and
6 deletions
cashier-trade/src/main/java/com/diligrp/cashier/trade/manager/PaymentResultManager.java
| ... | ... | @@ -76,6 +76,7 @@ public class PaymentResultManager { |
| 76 | 76 | * 通知业务系统退款处理结果 |
| 77 | 77 | */ |
| 78 | 78 | public void notifyRefundResult(String uri, OnlineRefundResult refundResult) { |
| 79 | + LOG.info("Notifying online payment result: {}, {}", refundResult.getTradeId(), refundResult.getRefundId()); | |
| 79 | 80 | ThreadPoolService.getIoThreadPoll().submit(() -> { |
| 80 | 81 | List<IPaymentEventListener> lifeCycles = eventListeners.stream().toList(); |
| 81 | 82 | if (!lifeCycles.isEmpty()) { | ... | ... |
cashier-trade/src/main/java/com/diligrp/cashier/trade/manager/TaskMessageSender.java
| ... | ... | @@ -47,10 +47,10 @@ public class TaskMessageSender { |
| 47 | 47 | properties.setHeader("x-delay", String.valueOf(delayInMillis)); |
| 48 | 48 | String payload = JsonUtils.toJsonString(task); |
| 49 | 49 | Message message = new Message(payload.getBytes(StandardCharsets.UTF_8), properties); |
| 50 | - LOG.info("Sending async delay task message for {}", task.getPayload()); | |
| 50 | + LOG.info("Sending async delay task message: {}", task.getPayload()); | |
| 51 | 51 | rabbitTemplate.send(Constants.PAYMENT_DELAY_EXCHANGE, Constants.PAYMENT_DELAY_KEY, message); |
| 52 | 52 | } catch (Exception ex) { |
| 53 | - LOG.error("Failed to send async delay task message for {}", task.getPayload(), ex); | |
| 53 | + LOG.error("Failed to send async delay task message: {}", task.getPayload(), ex); | |
| 54 | 54 | } |
| 55 | 55 | }); |
| 56 | 56 | } | ... | ... |
cashier-trade/src/main/java/com/diligrp/cashier/trade/service/impl/CashierPaymentServiceImpl.java
| ... | ... | @@ -14,6 +14,7 @@ import com.diligrp.cashier.pipeline.type.OutPaymentType; |
| 14 | 14 | import com.diligrp.cashier.pipeline.type.PaymentState; |
| 15 | 15 | import com.diligrp.cashier.pipeline.type.PaymentType; |
| 16 | 16 | import com.diligrp.cashier.shared.ErrorCode; |
| 17 | +import com.diligrp.cashier.shared.util.DateUtils; | |
| 17 | 18 | import com.diligrp.cashier.trade.Constants; |
| 18 | 19 | import com.diligrp.cashier.trade.dao.IOnlinePaymentDao; |
| 19 | 20 | import com.diligrp.cashier.trade.dao.ITradeOrderDao; |
| ... | ... | @@ -137,13 +138,19 @@ public class CashierPaymentServiceImpl implements ICashierPaymentService { |
| 137 | 138 | if (pipeline instanceof OnlinePipeline<?> onlinePipeline) { // 在线支付通道 |
| 138 | 139 | // 在线支付通道: 不同的收银台类型使用不同的支付方式(目前只支持小程序收银台) |
| 139 | 140 | // 小程序收银台将使用在线支付通道的小程序支付 |
| 140 | - MiniProPrepayRequest request = new MiniProPaymentConverter(trade, paymentId, now).convert(cashierPayment); | |
| 141 | - MiniProPrepayResponse response = onlinePipeline.sendMiniProPrepayRequest(request); | |
| 141 | +// MiniProPrepayRequest request = new MiniProPaymentConverter(trade, paymentId, now).convert(cashierPayment); | |
| 142 | +// MiniProPrepayResponse response = onlinePipeline.sendMiniProPrepayRequest(request); | |
| 143 | + long seconds = DateUtils.secondsDiff(trade.getCreatedTime(), now); | |
| 144 | + long timeout = Math.max(trade.getTimeout() - seconds, com.diligrp.cashier.pipeline.Constants.MIN_PIPELINE_TIMEOUT); | |
| 145 | + NativePrepayRequest request = new NativePrepayRequest(paymentId, trade.getMaxAmount(), trade.getGoods(), | |
| 146 | + trade.getDescription(), now, timeout); | |
| 147 | + NativePrepayResponse response = onlinePipeline.sendNativePrepayRequest(request); | |
| 148 | + | |
| 142 | 149 | String outMchId = request.getString(com.diligrp.cashier.pipeline.Constants.PARAM_MCH_ID); |
| 143 | 150 | OnlinePayment payment = OnlinePayment.builder().outMchId(outMchId).tradeId(trade.getTradeId()) |
| 144 | 151 | .type(TradeType.TRADE).paymentId(paymentId).channelId(onlinePipeline.supportedChannel()) |
| 145 | 152 | .payType(PaymentType.MINI_PRO).pipelineId(onlinePipeline.pipelineId()).goods(trade.getGoods()) |
| 146 | - .amount(trade.getAmount()).payerId(request.getOpenId()).outTradeNo(response.getOutTradeNo()) | |
| 153 | + .amount(trade.getAmount()).payerId(null).outTradeNo(response.getOutTradeNo()) | |
| 147 | 154 | .outPayType(OutPaymentType.NOP).finishTime(null).state(response.getState()) |
| 148 | 155 | .notifyUrl(trade.getNotifyUrl()).description(null).version(0).createdTime(now).modifiedTime(now).build(); |
| 149 | 156 | onlinePaymentDao.insertOnlinePayment(payment); |
| ... | ... | @@ -357,7 +364,7 @@ public class CashierPaymentServiceImpl implements ICashierPaymentService { |
| 357 | 364 | } else if (!PaymentState.isFinished(response.getState())) { |
| 358 | 365 | // 固定周期后,查询退款状态,根据状态完成退款订单 |
| 359 | 366 | TaskMessage message = new TaskMessage(TaskMessage.TYPE_CASHIER_REFUND_SCAN, refundId, "1"); |
| 360 | - taskMessageSender.sendDelayTaskMessage(message, trade.getTimeout()); | |
| 367 | + taskMessageSender.sendDelayTaskMessage(message, trade.getTimeout() * 1000); | |
| 361 | 368 | } |
| 362 | 369 | |
| 363 | 370 | return new OnlineRefundResult(refundId, payment.getPaymentId(), response.getState(), response.getWhen(), response.getMessage()); | ... | ... |